-
Notifications
You must be signed in to change notification settings - Fork 235
Remove stash, unstash and monitor keys from default CalcJob builder inputs #7143
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7143 +/- ##
==========================================
+ Coverage 79.61% 79.61% +0.01%
==========================================
Files 566 566
Lines 43572 43575 +3
==========================================
+ Hits 34684 34687 +3
Misses 8888 8888 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This PR removes stash, unstash, and monitors keys from empty CalcJob builders to reduce interface clutter and user confusion. The implementation uses the populate_defaults=False parameter to enable lazy namespace creation.
Key changes:
- Added
populate_defaults=Falseto themonitorsinput namespace in CalcJob definitions - Modified ProcessBuilderNamespace to respect
populate_defaultsby deferring namespace creation until first access - Added comprehensive tests for lazy namespace behavior and CalcJob builder output
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/aiida/engine/processes/calcjobs/calcjob.py |
Added populate_defaults=False to monitors namespace, matching existing stash/unstash configuration |
src/aiida/engine/processes/builder.py |
Implemented lazy namespace creation - namespaces with populate_defaults=False are only created on first access |
tests/engine/processes/test_builder.py |
Added test class and comprehensive tests verifying lazy namespace behavior and CalcJob builder cleanliness |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@mbercx , actually worked 😄 🚀 from aiida.calculations.arithmetic.add import ArithmeticAddCalculation
>>> ArithmeticAddCalculation.get_builder()
{'metadata': {'options': {}}} |
khsrali
left a comment
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.
How come you added populate_defaults=False, only to monitor and somehow it also disappeared from the results of stash and unstash as well. (I mean, what you did is a good solution I just want you to explain it)
| def define(cls, spec): | ||
| super().define(spec) | ||
| spec.input_namespace('optional_ns', non_db=True, required=False, populate_defaults=False) | ||
| spec.input('optional_ns.value', valid_type=str, non_db=True, required=False) |
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.
why do you have this line?
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 line adds a child input (value) to the optional_ns namespace to make it a realistic test case. Without any child ports, the namespace would just be empty and not useful for testing the lazy creation and value-setting functionality.
| def test_calcjob_builder_no_stash_unstash_monitors(): | ||
| """Test that CalcJob builders don't include stash, unstash, and monitors in empty builder.""" | ||
| ArithmeticAddCalculation = CalculationFactory('core.arithmetic.add') | ||
| builder = ArithmeticAddCalculation.get_builder() | ||
|
|
||
| # Verify that stash, unstash, and monitors are not in the builder | ||
| assert 'stash' not in dict(builder.metadata.options) | ||
| assert 'unstash' not in dict(builder.metadata.options) | ||
| assert 'monitors' not in dict(builder) | ||
|
|
||
| # But they should be accessible and settable | ||
| builder.metadata.options.stash.target_base = '/tmp/test' | ||
| builder.metadata.options.stash.source_list = ['file1'] | ||
| builder.metadata.options.stash.stash_mode = 'copy' | ||
| assert 'stash' in dict(builder.metadata.options) | ||
| assert builder.metadata.options.stash.target_base == '/tmp/test' | ||
|
|
||
|
|
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.
Although the original issue specifically was targeting stash, unstash, and monitors; Do this a bit more general. I don't want to have super single use tests in the code base.
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.
Removed the specific test in 7d97fb5. The general test_builder_populate_defaults_false test using PopulateDefaultsProcess now covers the behavior without being tied to specific CalcJob namespaces.
The change to |
|
@mbercx IMO, this solution is already good enough. let me know what do you think, cheers! |
…uilder Co-authored-by: khsrali <[email protected]>
…of general populate_defaults test Co-authored-by: khsrali <[email protected]>
9786997 to
2ea7e99
Compare
stash,unstash, andmonitorskeys appear in empty builderspopulate_defaults=Falseto themonitorsinput namespace incalcjob.pyProcessBuilderNamespace.__init__inbuilder.pyto respectpopulate_defaultsattributeSummary
This PR removes the
stash,unstash, andmonitorskeys from appearing in empty CalcJob builders.Before:
After:
Changes Made
src/aiida/engine/processes/calcjobs/calcjob.py: Addedpopulate_defaults=Falseto themonitorsinput namespace (already set forstash/unstash).src/aiida/engine/processes/builder.py: ModifiedProcessBuilderNamespace.__init__to respect thepopulate_defaultsattribute. Namespaces withpopulate_defaults=Falseare now lazily created only when accessed.Tests: Added general test for
populate_defaults=Falsebehavior using a dedicated test process class.Original prompt
stash,unstashandmonitorkeys from the default inputs #6994💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.