Skip to content

Commit

Permalink
update workflow meta object - raising MissingDataset when dataset s…
Browse files Browse the repository at this point in the history
…tage not found
  • Loading branch information
saurbhc committed Nov 8, 2023
1 parent 8e4d75b commit ea0ffe7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions darwin/future/meta/objects/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from darwin.dataset.upload_manager import LocalFile
from darwin.datatypes import PathLike
from darwin.future.data_objects.workflow import WFDatasetCore, WFTypeCore, WorkflowCore
from darwin.future.exceptions import MissingDataset
from darwin.future.meta.objects.base import MetaBase
from darwin.future.meta.queries.stage import Stage, StageQuery

Expand Down Expand Up @@ -55,12 +56,14 @@ def stages(self) -> StageQuery:
meta_params["dataset_name"] = self.datasets[0].name
return StageQuery(self.client, meta_params=meta_params)

def _get_dataset_stage(self) -> Stage | None:
def _get_dataset_stage(self) -> Stage:
# stages are not in right order - finding the dataset stage
for stage in self.stages:
if stage.type == "dataset":
return stage

raise MissingDataset(f"Workflow has no dataset stage")

@property
def datasets(self) -> List[WFDatasetCore]:
if self._element.dataset is None:
Expand All @@ -81,13 +84,11 @@ def push_from_dataset_stage(self, wait: bool = True) -> Workflow:
assert len(stages) > 1

ds_stage = self._get_dataset_stage()
assert ds_stage

assert ds_stage._element.type == WFTypeCore.DATASET
next_stage = ds_stage._element.edges[0].target_stage_id
assert next_stage is not None

ds_stage.move_attached_files_to_stage(next_stage, wait)

return self

def upload_files(
Expand Down

0 comments on commit ea0ffe7

Please sign in to comment.