Skip to content

Commit

Permalink
[Workflows] Add subpath or workdir to workflow path (#5461)
Browse files Browse the repository at this point in the history
  • Loading branch information
GiladShapira94 committed May 1, 2024
1 parent f696700 commit b0c8065
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mlrun/projects/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def get_state(run_id, project=None):
@staticmethod
def _get_handler(workflow_handler, workflow_spec, project, secrets):
if not (workflow_handler and callable(workflow_handler)):
workflow_file = workflow_spec.get_source_file(project.spec.context)
workflow_file = workflow_spec.get_source_file(project.spec.get_code_path())
workflow_handler = create_pipeline(
project,
workflow_file,
Expand Down Expand Up @@ -554,7 +554,7 @@ class _KFPRunner(_PipelineRunner):
@classmethod
def save(cls, project, workflow_spec: WorkflowSpec, target, artifact_path=None):
pipeline_context.set(project, workflow_spec)
workflow_file = workflow_spec.get_source_file(project.spec.context)
workflow_file = workflow_spec.get_source_file(project.spec.get_code_path())
functions = FunctionsDict(project)
pipeline = create_pipeline(
project,
Expand Down
23 changes: 23 additions & 0 deletions tests/projects/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,29 @@ def test_load_project_dir(project_file_name, expectation):
shutil.rmtree(project_dir)


def test_workflow_path_with_project_workdir():
project_name = "project1"

project = mlrun.new_project(project_name, save=False, context="./context")
workflow_path = "workflow.py"
workflow_spec = mlrun.projects.pipelines.WorkflowSpec(path=workflow_path)
# with_out_workdir
path = workflow_spec.get_source_file(project.spec.get_code_path())
assert path == "./context/workflow.py"

# with__subpath
project = mlrun.new_project(
project_name, save=False, context="./context", subpath="./subpath"
)
path = workflow_spec.get_source_file(project.spec.get_code_path())
assert path == "./context/./subpath/workflow.py"

# with__workdir
project.spec.workdir = "./workdir"
path = workflow_spec.get_source_file(project.spec.get_code_path())
assert path == "./context/./workdir/workflow.py"


class TestModelMonitoring:
"""Test model monitoring project methods"""

Expand Down

0 comments on commit b0c8065

Please sign in to comment.