yt-project / libyt

In-situ analysis with yt
https://libyt.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

Reloading script automatically #76

Closed hyschive closed 5 months ago

hyschive commented 1 year ago

Major

When running batch instead of interactive jobs (i.e., qsub job_script instead of qsub -I), it will be great if a simulation code can reload a yt script automatically. IIRC, LIBYT_STOP only works for interactive jobs. This feature is especially important for production scientific simulations since they usually use batch instead of interactive jobs.

One possible approach is to add another file LIBYT_RELOAD, put all the Python statements therein, and execute it directly without activating a Python prompt. For example, we can put the following codes in LIBYT_RELOAD.

%libyt load filename
%libyt idle func1
a = 1
def func2(*args):
%libyt run func2 a 2 "3"

Further, the GAMER PR gamer-project/gamer#193 can be used together with LIBYT_RELOAD to reload a libyt script in the following procedure.

  1. A user realizes something in the original libyt script needs to be revised.
  2. Create the file PAUSE_GAMER_PAUSE to pause a run.
  3. Revise the libyt script.
  4. Create the file LIBYT_RELOAD.
  5. Delete PAUSE_GAMER_PAUSE to resume a simulation, which will then reload the revised libyt script when detecting LIBYT_RELOAD.

Minor

Why not include libyt_interactive_mode.h in libyt.h so that simulation codes only need to include libyt.h even when enabling INTERACTIVE_MODE?

cindytsai commented 1 year ago

@hyschive I have made libyt_interactive_mode.h inside libyt.h, along with many other small updates. I'll PR again to gamer.

cindytsai commented 5 months ago

@hyschive do you expect to get feedbacks from the script?

hyschive commented 5 months ago

@cindytsai What kind of feedback are you referring to? Could you give an example?

cindytsai commented 5 months ago

Like output messages and results.

hyschive commented 5 months ago

I'm afraid that I'll need more information. I don't think libyt supports passing the analysis results (e.g., the density profile data) back to a simulation code, right? As for outputting log messages, what's the difference between the original and reloaded scripts?

cindytsai commented 5 months ago

The original and the reloaded script are the same, except that they need to filter through the log file to get the results. Ex: What you get in prompt:

>>> array
[1, 2, 3]

Now you would only get this in the log file.

[1, 2, 3]
cindytsai commented 5 months ago

@hyschive this is what I'm thinking, about the procedure:

libyt-dev-0 1 - page 77

hyschive commented 5 months ago

@cindytsai I'll test it and provide more feedback once you have a prototype