-
Notifications
You must be signed in to change notification settings - Fork 310
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
Execute launchplans declared locally and automatically adjust input params based on fixed and default values #3115
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Code Review Agent Run #58cf8aActionable Suggestions - 2
Additional Suggestions - 1
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
str( | ||
json.load( | ||
open( | ||
os.path.join( | ||
os.path.dirname(os.path.realpath(__file__)), | ||
"my_wf_input.json", | ||
), | ||
"r", | ||
) |
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.
Consider simplifying the nested function calls by using pathlib.Path
for file operations. This could make the code more readable and maintainable.
Code suggestion
Check the AI-generated fix before applying
- str(
- json.load(
- open(
- os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "my_wf_input.json",
- ),
- "r",
- )
- )
- ),
+ str(json.loads(pathlib.Path(__file__).parent.joinpath("my_wf_input.json").read_text())),
Code Review Run #58cf8a
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
final_inputs_with_defaults = loaded_entity.python_interface.inputs_with_defaults | ||
if isinstance(loaded_entity, LaunchPlan): | ||
# For LaunchPlans it is essential to handle fixed inputs and default inputs in a special way | ||
# Fixed inputs are inputs that are always passed to the launch plan and cannot be overridden | ||
# Default inputs are inputs that are optional and have a default value | ||
# The final inputs to the launch plan are a combination of the fixed inputs and the default inputs | ||
all_inputs = loaded_entity.python_interface.inputs_with_defaults | ||
default_inputs = loaded_entity.saved_inputs | ||
pmap = loaded_entity.parameters | ||
final_inputs_with_defaults = {} | ||
for name, _ in pmap.parameters.items(): | ||
_type, v = all_inputs[name] | ||
if name in default_inputs: | ||
v = default_inputs[name] | ||
final_inputs_with_defaults[name] = _type, v |
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 launch plan input handling logic could be extracted into a separate helper method to improve code readability and maintainability. Consider moving the logic for handling fixed and default inputs into a dedicated function.
Code suggestion
Check the AI-generated fix before applying
final_inputs_with_defaults = loaded_entity.python_interface.inputs_with_defaults | |
if isinstance(loaded_entity, LaunchPlan): | |
# For LaunchPlans it is essential to handle fixed inputs and default inputs in a special way | |
# Fixed inputs are inputs that are always passed to the launch plan and cannot be overridden | |
# Default inputs are inputs that are optional and have a default value | |
# The final inputs to the launch plan are a combination of the fixed inputs and the default inputs | |
all_inputs = loaded_entity.python_interface.inputs_with_defaults | |
default_inputs = loaded_entity.saved_inputs | |
pmap = loaded_entity.parameters | |
final_inputs_with_defaults = {} | |
for name, _ in pmap.parameters.items(): | |
_type, v = all_inputs[name] | |
if name in default_inputs: | |
v = default_inputs[name] | |
final_inputs_with_defaults[name] = _type, v | |
final_inputs_with_defaults = self._get_launch_plan_inputs(loaded_entity) if isinstance(loaded_entity, LaunchPlan) else loaded_entity.python_interface.inputs_with_defaults | |
def _get_launch_plan_inputs(self, launch_plan): | |
# For LaunchPlans it is essential to handle fixed inputs and default inputs in a special way | |
# Fixed inputs are inputs that are always passed to the launch plan and cannot be overridden | |
# Default inputs are inputs that are optional and have a default value | |
# The final inputs to the launch plan are a combination of the fixed inputs and the default inputs | |
all_inputs = launch_plan.python_interface.inputs_with_defaults | |
default_inputs = launch_plan.saved_inputs | |
pmap = launch_plan.parameters | |
final_inputs = {} | |
for name, _ in pmap.parameters.items(): | |
_type, v = all_inputs[name] | |
if name in default_inputs: | |
v = default_inputs[name] | |
final_inputs[name] = _type, v | |
return final_inputs |
Code Review Run #58cf8a
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3115 +/- ##
===========================================
+ Coverage 78.20% 91.08% +12.87%
===========================================
Files 292 114 -178
Lines 25401 5785 -19616
Branches 2779 0 -2779
===========================================
- Hits 19864 5269 -14595
+ Misses 4726 516 -4210
+ Partials 811 0 -811 ☔ View full report in Codecov by Sentry. |
Cc @fiedlerNr9 @eapolinario |
Today, you could execute local launchplans, but the default and fixed values were not respected. This fix solve this problem.
Consider this example
Can be invoked correctly
TODO I am observing a bug in admin for registeration where version is ignored
Summary by Bito
This PR improves LaunchPlan local execution by implementing proper handling of fixed and default input values. The changes focus on the WorkflowCommand class to ensure fixed inputs cannot be overridden while maintaining optional default inputs. The implementation includes comprehensive test coverage for various input combinations.Unit tests added: True
Estimated effort to review (1-5, lower is better): 2