-
Notifications
You must be signed in to change notification settings - Fork 189
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
Implement method for JobCalculation to create a restart builder #1962
Implement method for JobCalculation to create a restart builder #1962
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1962 +/- ##
===========================================
- Coverage 67.56% 67.49% -0.08%
===========================================
Files 324 324
Lines 33342 33390 +48
===========================================
+ Hits 22529 22538 +9
- Misses 10813 10852 +39
Continue to review full report at Codecov.
|
Do we need a new method for this or can/should this be handled by passing a parameter of |
I could not implement this with a toggle keyword in |
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.
Can we add a test for this new function? (+ the two comments)
builder = self.get_builder() | ||
|
||
for port_name, port in self.process().spec().inputs.items(): | ||
if port_name == JobProcess.OPTIONS_INPUT_LABEL: |
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.
Does this work? This does builder.options = {...}
, can this be done directly or should we loop?
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.
I tested this manually and it works, because builder.options
is just a mapping namespace, so assigning a dictionary works. But I will write some unit tests
setattr(builder, port_name, options) | ||
elif isinstance(port, PortNamespace): | ||
namespace = port_name + '_' | ||
sub = {link.replace(namespace, ''): node for link, node in inputs.items() if link.startswith(namespace)} |
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.
I'm not sure link.replace(namespace, '')
is safe, e.g. if the sub-namespace has the same name it would remove both. Better link[len(namespace):]
or something equivalent
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.
Good point
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.
This is fixed
d8addb8
to
c1cd4f7
Compare
c1cd4f7
to
b16f593
Compare
Pull Request Test Coverage Report for Build 3839
💛 - Coveralls |
The `get_builder` method will return a "clean" builder for the given `JobProcess`, without any inputs defined. Here we implement `get_builder_restart` for the `JobCalculation` that will also return a `JobProcessBuilder` but with the inputs and options pre-set with those that were used for the original node. The builder can then immediately be resubmitted to run another instance of that calculation, while of course giving the chance to change one or more inputs. For example: calculation = load_node(<pk>) # Some completed JobCalculation node builder = calculation.get_builder_restart() results = run(builder)
b16f593
to
8a1e95d
Compare
@giovannipizzi I addressed your comments and added some unit tests, so it's ready for a second review |
Fixes #230
The
get_builder
method will return a "clean" builder for the givenJobProcess
, without any inputs defined. Here we implementget_builder_restart
for the
JobCalculation
that will also return aJobProcessBuilder
but withthe inputs and options pre-set with those that were used for the original node.
The builder can then immediately be resubmitted to run another instance of that
calculation, while of course giving the chance to change one or more inputs.
For example: