Skip to content

Commit

Permalink
Iterate on tags support
Browse files Browse the repository at this point in the history
- `tags` should be a set, not a list. Changes throughout.
- Add `--tags` to `click_options` so it shows up in the correct group.
- Cleanups and improvements suggested by @drewpca.
  • Loading branch information
dmcc committed Aug 26, 2024
1 parent f19353d commit 7ca1068
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/aeromancy/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _set_buildtime_properties(self, project_name: str, skip: bool):
self._skip = skip
self._project_name = project_name

def _set_runtime_properties(self, tags: list[str] | None = None):
def _set_runtime_properties(self, tags: set[str] | None = None):
"""Set properties that we won't know until ActionRunner time."""
# TODO: With some refactoring, this could be combined with
# _set_buildtime_properties
Expand Down
4 changes: 2 additions & 2 deletions src/aeromancy/action_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self, actions: list[Action]):
"""
self.actions = actions
self.job_name_filter = None
self.job_tags = []
self.job_tags = set()

@override
def load_doit_config(self):
Expand Down Expand Up @@ -228,7 +228,7 @@ def job_name_filter(job_name):
raise SystemExit

if tags:
self.job_tags = tags.split(",")
self.job_tags = set(tags.split(","))

if get_runtime_environment().dev_mode:
console.rule(
Expand Down
7 changes: 6 additions & 1 deletion src/aeromancy/click_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
"main.py": [
{
"name": "Task runner options",
"options": ["--only", "--graph", "--list-actions"],
"options": [
"--only",
"--graph",
"--list-actions",
"--tags",
],
},
{
"name": "Aeromancy runtime options",
Expand Down
5 changes: 3 additions & 2 deletions src/aeromancy/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,16 @@ def build_docker(
(
"--tag",
docker_tag,
# The version tag should be updated whenever Dockerfile changes.
# The version tag should be updated whenever ../../docker/Dockerfile
# changes.
"https://github.com/quant-aq/aeromancy.git#v0.2.2:docker",
),
)
docker_command = " ".join(docker_commmand_pieces)

console.log(f"Running {docker_command!r}", style="info")
docker_status, docker_output = subprocess.getstatusoutput( # noqa: S605
docker_command,
docker_commmand_pieces,
)
if docker_status:
console.log(f"Docker output: {docker_output}", style="error")
Expand Down
2 changes: 1 addition & 1 deletion src/aeromancy/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
self.config = config
self.job_type = job_type
self.job_group = job_group
self.tags = tags
self.tags = tags or set()

@abstractmethod
def __enter__(self):
Expand Down
5 changes: 2 additions & 3 deletions src/aeromancy/wandb_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def __init__(
# For "https://github.com/x/y.git", we'd pull out "y" as the job name
job_name = runtime_environment.git_repo_name

tags = self.tags or []
tags.insert(0, f"git/{runtime_environment.git_branch}")
self.tags.add(f"git/{runtime_environment.git_branch}")

# Run wandb init with our extra tracking data.
notes = f"{runtime_environment.git_message} (git message for {git_ref[:6]})"
Expand All @@ -61,7 +60,7 @@ def __init__(
job_type=job_type,
group=job_group,
notes=notes,
tags=tags,
tags=self.tags,
settings=wandb.Settings(
job_name=job_name,
git_commit=git_ref,
Expand Down

0 comments on commit 7ca1068

Please sign in to comment.