Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffxy committed Oct 7, 2023
1 parent b1402be commit 575cc78
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/cond_run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,10 @@ def test_cond_run_multiple_failures_stop_early(tmp_path: pathlib.Path):
# The top level `run_experiment_group()` task is technically not a Conductor experiment task.
sweep_out = cond.find_task_output_dir("//multiple:sweep", is_experiment=False)
assert sweep_out is None


def test_cond_run_chained(tmp_path: pathlib.Path):
cond = ConductorRunner.from_template(tmp_path, FIXTURE_TEMPLATES["experiments"])
# The task checks that chaining occurs.
result = cond.run("//sweep:chained-test", jobs=5)
assert result.returncode == 0
23 changes: 23 additions & 0 deletions tests/fixture-projects/experiments/sweep/COND
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,26 @@ run_experiment_group(
for threads in range(1, 5)
],
)

run_experiment_group(
name="chained-test",
run="./run_check_file.sh",
experiments=[
ExperimentInstance(
name="chained-test-1",
args=["chained", "1"],
parallelizable=True,
),
ExperimentInstance(
name="chained-test-2",
args=["chained", "2"],
parallelizable=True,
),
ExperimentInstance(
name="chained-test-3",
args=["chained", "3"],
parallelizable=True,
),
],
chain_experiments=True,
)
16 changes: 16 additions & 0 deletions tests/fixture-projects/experiments/sweep/run_check_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash

prefix=$1
num=$2

if [ $num -gt 1 ] && [ -z "$COND_DEPS" ]; then
exit 1
fi

if [ $num = 1 || -f "$COND_DEPS/$prefix_$num" ]; then
next_num=(($num + 1))
touch $COND_OUT/$prefix_$next_num
exit 0
else
exit 1
fi

0 comments on commit 575cc78

Please sign in to comment.