Skip to content

Commit

Permalink
[Tasks] Bug fix: Allow re-running combine() tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffxy committed Feb 7, 2021
1 parent 3183f4d commit 9c8b9f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/conductor/task_types/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ def execute(self, ctx: "c.Context"):
):
continue
copy_into = output_path / dep.name
shutil.copytree(task_output_dir, copy_into)
shutil.copytree(task_output_dir, copy_into, dirs_exist_ok=True)
30 changes: 19 additions & 11 deletions tests/cond_run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,28 @@ def test_cond_run_deps(tmp_path: pathlib.Path):

def test_cond_run_combine(tmp_path: pathlib.Path):
cond = ConductorRunner.from_template(tmp_path, FIXTURE_TEMPLATES["combine-test"])
result = cond.run("//:all")
assert result.returncode == 0
assert cond.output_path.exists()

combine_task_output_dir = cond.output_path / ("all" + TASK_OUTPUT_DIR_SUFFIX)
assert combine_task_output_dir.exists()
def run_assertions():
result = cond.run("//:all")
assert result.returncode == 0
assert cond.output_path.exists()

combine_task_output_dir = cond.output_path / ("all" + TASK_OUTPUT_DIR_SUFFIX)
assert combine_task_output_dir.exists()

task_dirs = [file.name for file in combine_task_output_dir.iterdir()]
assert len(task_dirs) == 2
assert "echo1" in task_dirs
assert "echo2" in task_dirs

task_dirs = [file.name for file in combine_task_output_dir.iterdir()]
assert len(task_dirs) == 2
assert "echo1" in task_dirs
assert "echo2" in task_dirs
file1 = combine_task_output_dir / "echo1" / "file1.txt"
assert file1.is_file()
assert (combine_task_output_dir / "echo2" / "file2.txt").is_file()
file1.unlink()

assert (combine_task_output_dir / "echo1" / "file1.txt").is_file()
assert (combine_task_output_dir / "echo2" / "file2.txt").is_file()
run_assertions()
# Should be able to re-run the task without any problems
run_assertions()


def test_cond_run_ordering(tmp_path: pathlib.Path):
Expand Down

0 comments on commit 9c8b9f1

Please sign in to comment.