-
-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding functionality to Detect Running Environments for TARDIS Simulations #1650
Conversation
Before a pull request is accepted, it must meet the following criteria:
|
6042872
to
ea2c9f0
Compare
Codecov Report
@@ Coverage Diff @@
## master #1650 +/- ##
=======================================
Coverage 61.92% 61.92%
=======================================
Files 62 62
Lines 5702 5713 +11
=======================================
+ Hits 3531 3538 +7
- Misses 2171 2175 +4
Continue to review full report at Codecov.
|
1e3c281
to
a45dfa7
Compare
return True | ||
elif shell == "TerminalInteractiveShell": | ||
return False | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when does this else statement happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following needs to be considered for the conditional check:
- If we are in IPython Kernel environment, ie Jupyter Notebook, Jupyter Lab, etc, then we are in the
ZMQInteractiveShell
. Please check this. - If we are in the Terminal IPython environment, ie IPython Kernel running in Terminal, more of like a REPL, then we are in the
TerminalInteractiveShell
. Please check this. - If we are in any other environment, ie Google Colab or Normal Shell based Terminal, etc, then we are in the else condition. Hence, the main
else
condition allows us to print the values as a str in Formatting Logging Output for Simulation #1632
This Link explains exactly what I mean by these conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the |
a02c4d7
to
bad49fb
Compare
bad49fb
to
ebecc9d
Compare
I would recommend instead of getting the class name from the dunder methods (not really part of their API), you should compare the shell directly using
|
Additionally, I do feel like the name Have you tested this in something like jupyter-lab or vscode? |
Yes, Jupyter based Environments have the class name is always ZMQInteractiveShell. It is purely based on the IPython kernel being run or not. As for the screenshots above, you can see the different types of output that are returned when we run the |
Absolutely, I would change it in the logging formatting PR and hence we can make it little more clearer 😄 |
Just a small update on this import. This has been deprecated in IPython 4 version. Newer import is the following: |
This PR adds the functionality to check the environment in which the TARDIS Simulation is run.
Needs to be merged before the #1632
Description
This PR aims to add a new function
check_simulation_env()
which checks if the simulation is being run in a IPython environment or any other environment such as a Terminal, etc.This function returns
True
in the former option &False
in the latter.Motivation and context
This function is vital for the implementation of the Logging Formatting which is being done in #1632. It would allow us to control the output of the logging & would allow for better formatting for the logging output generated while running the simulation.
How has this been tested?
Examples
Check PR #1632
Type of change
Checklist