-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add Aggregation Feature to Flow #336
Conversation
…rge feature/enable-aggregate-status-logic
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.
A few initial comments -- I'll do a more thorough review later, but this should be a good starting point for general style-related things to fix throughout the PR.
return [jobs] | ||
|
||
if not callable(aggregator): | ||
raise TypeError("Expected callable for aggregator, got {}" |
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.
Use f-strings, here and below.
if getattr(aggregator, '_num', False): | ||
self._is_aggregate = False if aggregator._num == 1 else True | ||
else: | ||
self._is_aggregate = True |
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 think this is equivalent - please check it.
if getattr(aggregator, '_num', False): | |
self._is_aggregate = False if aggregator._num == 1 else True | |
else: | |
self._is_aggregate = True | |
self._is_aggregate = getattr(aggregator, '_num', 0) != 1 |
"got {}".format(type(default))) | ||
|
||
def keyfunction(job): | ||
return [job.sp.get(key, default[i]) for i, key in enumerate(keys)] |
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'd rewrite this to use zip
instead of enumerate
. This might work:
return [job.sp.get(key, default[i]) for i, key in enumerate(keys)] | |
return [job.sp.get(key, default_value) for key, default_value in zip(keys, default)] |
r"""This class handles the creation of aggregates. | ||
|
||
.. note:: | ||
This class should not be instantiated by users directly. |
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 class should be private, according to this comment.
if len(jobs) == 1: | ||
return str(jobs[0]) # Return job id as it's already unique | ||
|
||
blob = ''.join((job.get_id() for job in jobs)) |
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'd prefer to separate the job ids with a comma for conceptual clarity. I know this isn't really "meaningful" since it's hashed, but I think it makes the purpose clearer.
blob = ''.join((job.get_id() for job in jobs)) | |
blob = ','.join((job.get_id() for job in jobs)) |
To be marked as ready for review after #335 gets merged |
e3c94ec
to
619f9bf
Compare
* Add the private Aggregate class having fundamental concepts * Tests for _Aggregate class added * Logic for _condition, BaseFlowOperation, FlowGroup added * Logic extended for exec command * Logic extended for next command * Logic for run command * Logic for script command added * Logic for submit and status enabled * Make tests pass, replaced by-job grouping with by-op grouping * Style Fix * Remove print statement * Suggested changes implemented with refactoring of Aggregate class and FlowGroup * Documentation Edit and implement suggested changes * Improve status fetching performance * Use get_id() instead of the id property * Remove the use of Aggregate class and refactored * Minute document change * Apply suggested changes * Deprecate eligible and complete methods of Flow{Group|Operation} * Move property method job to JobOperation only * Apply suggested changes * Apply suggested changes * Apply suggested changes * Change variable name * Insert assert statement to check len(_JobOperation._jobs) == 1 * Internally change the use to lists to tuples * Additional suggested changes from code review * Add suggested changes * Revert accidental changes * Use repr(job) instead of str(job) for __repr__ method and remove instance check * Use f-strings * Remove checks from run, submit, print_status, _generate_id methods. To be implemented in #336
619f9bf
to
5493b4b
Compare
This PR is on hold until we make improvements to |
Moved to #464 |
Description
Introducing the use of
Aggregate
class in flow.This class includes features like:
select
parameterMotivation and Context
The current PR for aggregation is too big. Now that PR will track my project and I'll be splitting the work into several small PRs.
Types of Changes
1The change breaks (or has the potential to break) existing functionality.
Checklist:
If necessary: