Closed FabiPi3 closed 6 months ago
Maybe @utf or @gpetretto would be interested
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.86%. Comparing base (
eda2a65
) to head (393e71d
). Report is 14 commits behind head on main.:exclamation: Current head 393e71d differs from pull request most recent head 72081f9. Consider uploading reports for the commit 72081f9 to get more accurate results
Description & Motivation
I am writing dynamic workflows, basically using the
replace
feature ofjobflow
. I have a single starting job, which adds always a new job if some criterion is not yet fulfilled (In principle following the fibonacci example at https://github.com/materialsproject/jobflow/blob/main/examples/fibonacci.py). Now I want to use a manager to execute the workflow (specifially jobflow-remote), and I have to specify somemanager_config
's. Now I want that every step in my workflow uses different configurations, so I somehow have to specify them.I know that there are ways to do that, for example set
pass_manager_config=True
when specifying configs or even use theresponse_manager_config
to specify new configs for replace jobs. But I don't know how to do it for say 5 steps in the workflow, where every step uses different configs. And I find it very implicit and around the corner to specify this all beforehand (and sometimes I don't even know before execution).What I would like to do is to set this in the job itself. I am not sure whether this breaks one of the basic design rules of jobflow. Here is a stupid example to show this:
But this does not work. The reason is, as far as I found out, the last function of
src/jobflow/core/job.py
, namelypass_manager_config()
, which ends with the following lines of code:This overwrites the
manager_config
of all new jobs with the oldmanager_config
. Here is where my suggestion comes into play, I would like to change this into:Which would instead merge the new config with the old one. Now my idea seems to work.
Tests
While running the tests of jobflow for my new changes, I found an issue in the tests. Consider the following (minimal) example of tests:
With the old version of overwriting the manager_config, everything worked fine. With my new changes, this happened: Running ONLY ONE of the two tests independently, both work. But if I execute BOTH jobs in a single pytest run, the second job fails.
The reason seems to be in the
store_inputs
job, which is a trick to make the replace with a flow working. For whatever reason I do not understand, this job has an non-empty manager_config in the second run (which of course was ignored in the first version of the code, but now it leads to an error).More in detail: looking in the function
prepare_replace
insrc/jobflow/core/job.py
line 1319 and adding a print here:should always give an empty dict back. But if I run
pytest tests/core/test_job.py -k test_job_config
I see something in the dictionary:And I have no idea why. Now the fix I propose here and what worked locally is to remove the
@job
decorator from thestore_inputs
function and convert it explicitly into aJob
using the sameJobConfig
. See the changes for that. What do you think?In any case please provide some feedback on my initial example, or suggest some improvement on how I could achieve my goal.
Checklist