-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix pass manager config for dynamic jobs #502
Closed
FabiPi3
wants to merge
17
commits into
materialsproject:main
from
FabiPi3:fix_manager_config_dynamic_jobs
Closed
Fix pass manager config for dynamic jobs #502
FabiPi3
wants to merge
17
commits into
materialsproject:main
from
FabiPi3:fix_manager_config_dynamic_jobs
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Maybe @utf or @gpetretto would be interested |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #502 +/- ##
==========================================
+ Coverage 99.42% 99.86% +0.44%
==========================================
Files 21 20 -1
Lines 1564 1511 -53
Branches 425 414 -11
==========================================
- Hits 1555 1509 -46
+ Misses 9 2 -7
|
Auto-update pre-commit hooks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
The easiest way to handle this is to run the following in the correct sequence on
your local machine. Start with running black on your new code. This will
automatically reformat your code to PEP8 conventions and removes most issues. Then run
pycodestyle, followed by flake8.
Run pydocstyle on your code.
type check your code.