Skip to content

Commit

Permalink
[FIX] Remove working directory in PipelineRunner instead of `BasePi…
Browse files Browse the repository at this point in the history
…pelineWorkflow` (nipoppy#288)

* test for model field names

* add `pipeline_starttime` column to bagel

* do not remove working directory in tracker
  • Loading branch information
michellewang authored Jul 15, 2024
1 parent 28ed729 commit 72e841a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
6 changes: 0 additions & 6 deletions nipoppy_cli/nipoppy/workflows/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,6 @@ def run_main(self, **kwargs):
f": {exception}"
)

def run_cleanup(self, **kwargs):
"""Run pipeline cleanup."""
if self.dpath_pipeline_work.exists():
self.rm(self.dpath_pipeline_work)
return super().run_cleanup(**kwargs)

@abstractmethod
def get_participants_sessions_to_run(
self, participant_id: Optional[str], session_id: Optional[str]
Expand Down
5 changes: 3 additions & 2 deletions nipoppy_cli/nipoppy/workflows/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def run_single(self, participant_id: str, session_id: str):

def run_cleanup(self, **kwargs):
"""Run pipeline runner cleanup."""
if self.dpath_pipeline_bids_db.exists():
self.rm(self.dpath_pipeline_bids_db)
for dpath in [self.dpath_pipeline_bids_db, self.dpath_pipeline_work]:
if dpath.exists():
self.rm(dpath)
return super().run_cleanup(**kwargs)
17 changes: 17 additions & 0 deletions nipoppy_cli/tests/test_workflow_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ def test_run_setup(config: Config, tmp_path: Path):
assert runner.dpath_pipeline_work.exists()


def test_run_cleanup(tmp_path: Path):
runner = PipelineRunner(
dpath_root=tmp_path / "my_dataset",
pipeline_name="dummy_pipeline",
pipeline_version="1.0.0",
)
dpaths = [
runner.dpath_pipeline_bids_db,
runner.dpath_pipeline_work,
]
for dpath in dpaths:
dpath.mkdir(parents=True)
runner.run_cleanup()
for dpath in dpaths:
assert not dpath.exists()


@pytest.mark.parametrize("simulate", [True, False])
def test_launch_boutiques_run(simulate, config: Config, tmp_path: Path):
runner = PipelineRunner(
Expand Down
11 changes: 11 additions & 0 deletions nipoppy_cli/tests/test_workflow_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,14 @@ def test_run_cleanup(tracker: PipelineTracker, bagel: Bagel):

assert tracker.layout.fpath_imaging_bagel.exists()
assert Bagel.load(tracker.layout.fpath_imaging_bagel).equals(bagel)


def test_run_no_create_work_directory(tracker: PipelineTracker):
tracker.run()
assert not tracker.dpath_pipeline_work.exists()


def test_run_no_rm_work_directory(tracker: PipelineTracker):
tracker.dpath_pipeline_work.mkdir(parents=True)
tracker.run()
assert tracker.dpath_pipeline_work.exists()

0 comments on commit 72e841a

Please sign in to comment.