Skip to content

Commit bd9dfa0

Browse files
bdicebpuchala
andauthored
Make bundle_prefix consistent with bundle_id (#720)
* make bundle_prefix consistent with bundle_id * Centralize bundle prefix definition. * Update changelog. * Add Brian Puchala to contributors.yaml. --------- Co-authored-by: bpuchala <[email protected]>
1 parent 00b5149 commit bd9dfa0

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

changelog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Fixed
2121
+++++
2222

2323
- Bumped ``isort`` to 5.12.0 in the pre-commit configuration file (#715).
24+
- Fixed bundle status information not being correctly read for subclasses of ``FlowProject`` (#718, #720).
2425

2526
Removed
2627
+++++++

contributors.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,9 @@ contributors:
171171
given-names: Melody
172172
orcid: "https://orcid.org/0000-0001-9788-9958"
173173
affiliation: "University of Michigan"
174+
-
175+
family-names: Puchala
176+
given-names: Brian
177+
orcid: "https://orcid.org/0000-0002-2461-6614"
178+
affiliation: "University of Michigan"
174179
...

flow/project.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,11 @@ def _fn_bundle(self, bundle_id):
21262126
"""Return the canonical name to store bundle information."""
21272127
return os.path.join(self.path, ".bundles", bundle_id)
21282128

2129+
@property
2130+
def _bundle_prefix(self):
2131+
sep = getattr(self._environment, "JOB_ID_SEPARATOR", "/")
2132+
return f"{self.__class__.__name__}{sep}bundle{sep}"
2133+
21292134
def _store_bundled(self, operations):
21302135
"""Store operation-ids as part of a bundle and return bundle id.
21312136
@@ -2148,9 +2153,8 @@ def _store_bundled(self, operations):
21482153
"""
21492154
if len(operations) == 1:
21502155
return operations[0].id
2151-
sep = getattr(self._environment, "JOB_ID_SEPARATOR", "/")
21522156
_id = sha1(".".join(op.id for op in operations).encode("utf-8")).hexdigest()
2153-
bundle_id = f"{self.__class__.__name__}{sep}bundle{sep}{_id}"
2157+
bundle_id = self._bundle_prefix + _id
21542158
fn_bundle = self._fn_bundle(bundle_id)
21552159
os.makedirs(os.path.dirname(fn_bundle), exist_ok=True)
21562160
with open(fn_bundle, "w") as file:
@@ -2160,10 +2164,9 @@ def _store_bundled(self, operations):
21602164

21612165
def _expand_bundled_jobs(self, scheduler_jobs):
21622166
"""Expand jobs which were submitted as part of a bundle."""
2163-
sep = getattr(self._environment, "JOB_ID_SEPARATOR", "/")
2164-
bundle_prefix = f"{self}{sep}bundle{sep}"
21652167
if scheduler_jobs is None:
21662168
return
2169+
bundle_prefix = self._bundle_prefix
21672170
for job in scheduler_jobs:
21682171
if job.name().startswith(bundle_prefix):
21692172
with open(self._fn_bundle(job.name())) as file:

0 commit comments

Comments
 (0)