Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Interactive Python Prompt

Table of contents

Requirements

:information_source: Interactive mode only works on local machine or submit the job to HPC platforms through interactive queue like qsub -I. The reason is that the prompt is exposed through the terminal. Use Reloading Script or Jupyter Notebook Access to avoid this.

Using Interactive Python Prompt

Status Board

At the start of interactive mode, libyt prints the status board. Interactive Python prompt will list all the Python function it finds, either in imported script, or input from interactive Python prompt. These are functions we can control whether to run in next round, and to access error message if it has.

=====================================================================
  Inline Function                              Status         Run
---------------------------------------------------------------------
  * yt_inline_ProjectionPlot                   success         V
  * yt_inline_ProfilePlot                      success         V
  * yt_inline_ParticlePlot                     success         V
  * yt_derived_field_demo                      idle            V
  * test_function                              failed          V
=====================================================================
>>> 
  • Inline Function: the inline function found by libyt.
  • Status: function status.
    • success: successfully run the function.
    • failed: failed to run the function.
    • idle: the function was set to idle, so it was ignored and did nothing.
    • not run yet: the function hasn’t been run yet.
  • Run: whether the function will run automatically in next round.
    • V: this function will run automatically in the following in situ analysis.
    • X: this function will idle in next in situ analysis, even if it is called through yt_run_FunctionArguments or yt_run_Function in simulation.

Python Prompt and libyt Defined Commands

>>> 

It can run any Python statements or libyt defined commands here, including importing Python modules. This is like using normal Python prompt, except that there are functions, objects, and simulation data already defined in it. These statements run in inline script’s namespace, and will update and make changes to it.

:information_source: To make interactive prompt more smoothly, set lower YT_VERBOSE.

How does the prompt execute Python statements and libyt defined commands?
  1. MPI root process is the user interface, which takes user inputs.
  2. MPI root process broadcasts the inputs to other processes.
  3. Every other MPI process executes the same piece of input synchronously.
  4. Print feedbacks to the terminal.

:warning: Changes is kept and maintain in user’s inline script’s namespace in situ analysis in the following round.

Exit Interactive Python Prompt

Use %libyt exit to exit the prompt. Then it will return back to the simulation process.

Known Limitations

FAQs

Why Can’t I Find the Prompt >>> After I have Activated Interactive Mode?

>>> is probably immersed inside the output. We can hit enter again, which is to provide an empty statement, and it will come out.

We can make prompt more smoothly by setting YT_VERBOSE to YT_VERBOSE_INFO.

Where Can I Use Interactive Mode?

libyt interactive Python prompt only works on local machine or submit the job to HPC platforms through interactive queue like qsub -I. The reason is that the user interface is exposed in the terminal.