Skip to content

Commit

Permalink
fix logic for comparing versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal-Babins committed Mar 5, 2024
1 parent 9f87818 commit 0c4c02d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions nmdc_automation/workflow_automation/sched.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def get_version(wf):
v_string = wf.version.lstrip("b").lstrip("v")
return Version.parse(v_string)

# Check for different workflow names
if wf1.name != wf2.name:
return False

Expand All @@ -52,8 +51,12 @@ def get_version(wf):
if force:
return v1 == v2

if getattr(v1, version_range) == getattr(v2, version_range):
return True
if version_range == "major":
return v1.major == v2.major
elif version_range == "minor":
return v1.major == v2.major and v1.minor == v2.minor
elif version_range == "patch":
return v1 == v2

return False

Expand Down
5 changes: 4 additions & 1 deletion tests/test_sched.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_within_range():
"Name": "TestWF",
"Version": "v1.1.5",
}

# Instantiate Workflow objects from dictionaries
wf1_major = Workflow(wf1_major_dict)
wf2_major = Workflow(wf2_major_dict)
Expand All @@ -131,6 +131,9 @@ def test_within_range():
# Test patch version range
assert within_range(wf1_patch, wf2_patch, "patch") == False
assert within_range(wf1_patch, wf1_minor, "patch") == True

assert within_range(wf1_patch, wf1_patch, "mafor", force=True) == True


def test_submit(db, mock_api):
"""
Expand Down

0 comments on commit 0c4c02d

Please sign in to comment.