Skip to content
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

Refactor _register_aggregates. #430

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions flow/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
default aggregator produces individual jobs.
"""
import itertools
from abc import abstractmethod
from collections.abc import Iterable, Mapping
from hashlib import md5

Expand Down Expand Up @@ -361,17 +360,6 @@ class _BaseAggregateStore(Mapping):

def __init__(self, project):
self._project = project
self._register_aggregates()

@abstractmethod
def _register_aggregates(self):
"""Register aggregates for a given project.

This is called at instantiation to generate and store aggregates.

Every aggregate is required to be a tuple of jobs.
"""
pass

def __iter__(self):
yield from self.keys()
Expand All @@ -395,12 +383,13 @@ class _AggregateStore(_BaseAggregateStore):

def __init__(self, aggregator, project):
self._aggregator = aggregator
super().__init__(project)

# We need to register the aggregates for this instance using the
# project provided. After registering, we store the aggregates
# mapped with the ids using :func:`get_aggregate_id`.
# provided project. After registering, we store the aggregates mapped
# with the ids using :func:`get_aggregate_id`.
self._aggregates_by_id = {}
super().__init__(project)
self._register_aggregates()

def __getitem__(self, id):
"""Get the aggregate corresponding to the provided id."""
Expand Down Expand Up @@ -572,14 +561,6 @@ def items(self):
for job in self._project:
yield (job.get_id(), (job,))

def _register_aggregates(self):
"""Register aggregates for a given project.

A reference to the project is stored on instantiation, and iterated
over on-the-fly.
"""
pass


def get_aggregate_id(aggregate):
"""Generate aggregate id for an aggregate of jobs.
Expand Down