Skip to content

Commit

Permalink
feat: align Hamilton cache path with workflow save path
Browse files Browse the repository at this point in the history
  • Loading branch information
kreczko committed Oct 15, 2024
1 parent 0afb1e9 commit 5d35ca2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/fasthep_flow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def execute(
cfg = init_config(config, overrides)
workflow = Workflow(config=cfg)
save_path = workflow.save(Path(save_path))
dag = workflow_to_hamilton_dag(workflow)
dag = workflow_to_hamilton_dag(workflow, save_path)
dag.visualize_execution(
final_vars=workflow.task_names,
output_file_path=Path(workflow.save_path) / "dag.png",
Expand Down
10 changes: 8 additions & 2 deletions src/fasthep_flow/orchestration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

import logging
from pathlib import Path
from typing import Any

from hamilton import driver, telemetry
Expand Down Expand Up @@ -39,10 +40,15 @@
# return client


def workflow_to_hamilton_dag(workflow: Workflow) -> Any:
def workflow_to_hamilton_dag(workflow: Workflow, output_path: str) -> Any:
"""Convert a workflow into a Hamilton flow."""
task_functions = load_tasks_module(workflow)
return driver.Builder().with_modules(task_functions).with_cache().build()
return (
driver.Builder()
.with_modules(task_functions)
.with_cache(Path(output_path) / ".hamilton_cache")
.build()
)


# def gitlab_ci_workflow(workflow: Workflow):
Expand Down

0 comments on commit 5d35ca2

Please sign in to comment.