Skip to content

Commit

Permalink
Merge branch 'main' into uv-ci-test-lowest-highest-dep-resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh authored Jul 20, 2024
2 parents 3b85016 + 06a2b36 commit e509d06
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ docs = [
"myst_parser==3.0.1",
"nbsphinx==0.9.4",
"sphinx-copybutton==0.5.2",
"sphinx==7.3.7",
"sphinx==7.4.4",
]
dev = ["pre-commit>=2.12.1", "typing_extensions; python_version < '3.11'"]
tests = ["moto==4.2.13", "pytest-cov==5.0.0", "pytest==8.2.2"]
Expand All @@ -54,12 +54,12 @@ strict = [
"FireWorks==2.0.3",
"PyYAML==6.0.1",
"maggma==0.69.0",
"matplotlib==3.9.0",
"monty==2024.5.24",
"matplotlib==3.9.1",
"monty==2024.7.12",
"moto==4.2.13",
"networkx==3.2.1",
"pydantic-settings==2.3.4",
"pydantic==2.8.0",
"pydantic==2.8.2",
"pydash==8.0.1",
"pydot==2.0.0",
"python-ulid==2.7.0",
Expand Down
4 changes: 2 additions & 2 deletions src/jobflow/core/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def update_maker_kwargs(
dict_mod=dict_mod,
)

def append_name(self, append_str: str, prepend: bool = False):
def append_name(self, append_str: str, prepend: bool = False, dynamic: bool = True):
"""
Append a string to the name of the flow and all jobs contained in it.
Expand All @@ -599,7 +599,7 @@ def append_name(self, append_str: str, prepend: bool = False):
self.name += append_str

for job in self:
job.append_name(append_str, prepend=prepend)
job.append_name(append_str, prepend=prepend, dynamic=dynamic)

def update_metadata(
self,
Expand Down
12 changes: 11 additions & 1 deletion src/jobflow/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def __init__(
hosts: list[str] = None,
metadata_updates: list[dict[str, Any]] = None,
config_updates: list[dict[str, Any]] = None,
name_updates: list[dict[str, Any]] = None,
**kwargs,
):
from copy import deepcopy
Expand All @@ -352,6 +353,7 @@ def __init__(
self.config = config
self.hosts = hosts or []
self.metadata_updates = metadata_updates or []
self.name_updates = name_updates or []
self.config_updates = config_updates or []
self._kwargs = kwargs

Expand Down Expand Up @@ -621,6 +623,8 @@ def run(self, store: jobflow.JobStore, job_dir: Path = None) -> Response:
new_jobs.update_metadata(**metadata_update, dynamic=True)
for config_update in self.config_updates:
new_jobs.update_config(**config_update, dynamic=True)
for name_update in self.name_updates:
new_jobs.append_name(**name_update, dynamic=True)

if self.config.response_manager_config:
passed_config = self.config.response_manager_config
Expand Down Expand Up @@ -889,7 +893,7 @@ def update_maker_kwargs(
dict_mod=dict_mod,
)

def append_name(self, append_str: str, prepend: bool = False):
def append_name(self, append_str: str, prepend: bool = False, dynamic: bool = True):
"""
Append a string to the name of the job.
Expand All @@ -899,12 +903,18 @@ def append_name(self, append_str: str, prepend: bool = False):
A string to append.
prepend
Prepend the name rather than appending it.
dynamic
The updates will be propagated to Jobs/Flows dynamically generated at
runtime.
"""
if prepend:
self.name = append_str + self.name
else:
self.name += append_str

if dynamic:
self.name_updates.append({"append_str": append_str, "prepend": prepend})

def update_metadata(
self,
update: dict[str, Any],
Expand Down

0 comments on commit e509d06

Please sign in to comment.