-
Notifications
You must be signed in to change notification settings - Fork 344
Set default values to map task template #841
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
Changes from all commits
216f4ee
2e1636d
9b043ce
6295118
bb98e76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,13 +70,21 @@ def to_dict(self): | |
| """ | ||
| :rtype: dict[T, Text] | ||
| """ | ||
| return _json_format.MessageToDict( | ||
| _array_job.ArrayJob( | ||
| array_job = None | ||
| if self.min_successes is not None: | ||
| array_job = _array_job.ArrayJob( | ||
| parallelism=self.parallelism, | ||
| size=self.size, | ||
| min_successes=self.min_successes, | ||
| ) | ||
| ) | ||
| elif self.min_success_ratio is not None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quick thought, should this be changed to check for 1.0 instead of None? If we default to 1.0 in both flytekit and flyteplugins then there is no reason to write the custom arrayjob if it is 1.0.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
edit: if we go that route we are essentially saying that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect I don't have enough context for where this function is used. It seems to check if the provided values are different then the default to populate the array_job only if necessary. If they are the default values, then we don't write the custom array job parameters and the backend used the default. I think the 0 actually doesn't mean 0 only applies for parallelism. Though probably unlikely, having a 0.0 min_success_ratio means the map task should succeed even if all subtasks fail, which could be valid. However, a parallelism of 0, meaning no tasks can execute, doesn't make any sense. Do we need to add another check here if parallelism != 0?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This function translates the python values to protobuf, which ends up hitting the issue of default values, specifically how the default value for numeric values is 0. There's no way to set the default value to a different value in a numeric field.
The key here is exactly what you said. In other words, a parallelism of 0 makes sense as a magic value (and not as a user-input). However a min_success_ratio of 0 might make sense as a user-input and since we use a numeric field to represent this in protobuf we cannot distinguish between the two cases in the case of min_success_ratio.
IMO, to simplify usage we should allow users to set parallelism to 0 with the caveat tha this means unbounded concurrency. The scenario I'm thinking is someone generating these configurations programmatically, if we we don't allow for parallelism to be set to 0 they will have to special case that in their configuration (which is very annoying). |
||
| array_job = _array_job.ArrayJob( | ||
| parallelism=self.parallelism, | ||
| size=self.size, | ||
| min_success_ratio=self.min_success_ratio, | ||
| ) | ||
|
|
||
| return _json_format.MessageToDict(array_job) | ||
|
|
||
| @classmethod | ||
| def from_dict(cls, idl_dict): | ||
|
|
@@ -86,8 +94,15 @@ def from_dict(cls, idl_dict): | |
| """ | ||
| pb2_object = _json_format.Parse(_json.dumps(idl_dict), _array_job.ArrayJob()) | ||
|
|
||
| return cls( | ||
| parallelism=pb2_object.parallelism, | ||
| size=pb2_object.size, | ||
| min_successes=pb2_object.min_successes, | ||
| ) | ||
| if pb2_object.HasField("min_successes"): | ||
| return cls( | ||
| parallelism=pb2_object.parallelism, | ||
| size=pb2_object.size, | ||
| min_successes=pb2_object.min_successes, | ||
| ) | ||
| else: | ||
| return cls( | ||
| parallelism=pb2_object.parallelism, | ||
| size=pb2_object.size, | ||
| min_success_ratio=pb2_object.min_success_ratio, | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.