Skip to content

Commit

Permalink
Cleanups and more tests for filter_ and confirm_deferred
Browse files Browse the repository at this point in the history
  • Loading branch information
tovrstra committed Jun 13, 2024
1 parent e106038 commit eb9f574
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@
# - Update some actions to more recent versions

name: release
on:
push:
branches:
# Run tests for change on the main branch ...
- main
tags-ignore:
# ... but not for tags (avoids duplicate work).
- '**'
pull_request:
# Run tests on pull requests
on: push

env:
# This is not critical
Expand Down
1 change: 0 additions & 1 deletion stepup/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ def filter_deferred(self, paths: list[str]) -> list[str]:
all_paths = []
while not (path is None or f"file:{path}" in self.nodes):
all_paths.insert(0, path)
print(all_paths)
path = myparent(path)
for path_up in all_paths:
dg = self.matching_deferred_glob(path_up)
Expand Down
47 changes: 47 additions & 0 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,3 +1650,50 @@ def test_set_pool(wfp):
plan.update_recording(wfp)
assert plan.recording.defined_pools == {"random": 2}
check_workflow_unstructure(wfp)


def test_filter_deferred1(wfp):
plan_key = "step:./plan.py"
assert wfp.defer_glob(plan_key, ["*.txt"]) == []
assert wfp.filter_deferred(["test.png", "test.txt", "other.txt", "sub/boom.txt"]) == [
"test.txt",
"other.txt",
]
assert "file:test.png" not in wfp.nodes
assert wfp.get_file("file:test.txt").get_state(wfp) == FileState.MISSING
assert wfp.get_file("file:other.txt").get_state(wfp) == FileState.MISSING
assert "file:sub/boom.txt" not in wfp.nodes


def test_filter_deferred2(wfp):
plan_key = "step:./plan.py"
assert wfp.defer_glob(plan_key, ["data/**"]) == []
assert wfp.filter_deferred(["data/test.txt", "data.txt"]) == ["data/", "data/test.txt"]
assert wfp.get_file("file:data/").get_state(wfp) == FileState.MISSING
assert wfp.get_file("file:data/test.txt").get_state(wfp) == FileState.MISSING
assert "file:data.txt" not in wfp.nodes


def test_filter_deferred3(wfp):
plan_key = "step:./plan.py"
assert wfp.defer_glob(plan_key, ["data/**/foo.txt"]) == []
with pytest.raises(GraphError):
wfp.filter_deferred(["data/test/foo.txt"])
wfp.declare_static(plan_key, ["data/", "data/other/"])
assert wfp.filter_deferred(["data/other/foo.txt"]) == ["data/other/foo.txt"]


def test_confirm_deferred(wfp):
plan_key = "step:./plan.py"
step_key = wfp.define_step(plan_key, "cat ${inp}", inp_paths=["test.txt"])
wfp.declare_static(plan_key, ["test.txt", "other.txt"], verified=False)
# static other.txt
assert wfp.get_file("file:other.txt").get_state(wfp) == FileState.MISSING
wfp.confirm_deferred(["other.txt"])
assert wfp.get_step(step_key).get_state(wfp) == StepState.PENDING
# static test.txt
assert wfp.get_file("file:test.txt").get_state(wfp) == FileState.MISSING
assert wfp.get_step(step_key).get_state(wfp) == StepState.PENDING
wfp.confirm_deferred(["test.txt"])
assert wfp.get_file("file:test.txt").get_state(wfp) == FileState.STATIC
assert wfp.get_step(step_key).get_state(wfp) == StepState.QUEUED

0 comments on commit eb9f574

Please sign in to comment.