-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests and canonicalization for ConfigWorkflow #89
Changes from 2 commits
954869b
81c8979
f5669f1
63d6801
bec3583
05ed3aa
d3c0621
65c84b7
2e3bcf5
21302d1
dbe4597
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from sirocco import pretty_print | ||
from sirocco.core import workflow | ||
from sirocco.parsing import _yaml_data_models as models | ||
|
||
|
||
def test_minimal_workflow(): | ||
minimal_config = models.ConfigWorkflow( | ||
cycles=[], | ||
tasks=[{"some_task": {"plugin": "shell"}}], | ||
data=models.ConfigData( | ||
available=[models.ConfigAvailableData(foo={})], | ||
generated=[models.ConfigGeneratedData(bar={})], | ||
), | ||
) | ||
|
||
testee = workflow.Workflow(minimal_config) | ||
|
||
pretty_print.PrettyPrinter().format(testee) | ||
|
||
assert testee.name is None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: What does it mean to have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realistically this can not happen in normal usage, (as tested in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we need to check if they are not None in the core.Workflow right? Should we make an issue to keep in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eventually, for core objects, the
So if you create a canonical class:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will adapt this in #90 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will need to think about how to adapt the canonicalize function to allow passing in additional information though, because the additional information will be different per class if any (not sure if singledispatch is still the right match then). |
||
assert len(list(testee.tasks)) == 0 | ||
assert len(list(testee.cycles)) == 0 | ||
assert testee.data[("foo", {})].available |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import textwrap | ||
|
||
from sirocco.parsing import _yaml_data_models as models | ||
|
||
|
||
def test_workflow_test_internal_dicts(): | ||
testee = models.ConfigWorkflow( | ||
cycles=[], | ||
tasks=[{"some_task": {"plugin": "shell"}}], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: is it a problem, that we can not currently (for testing purposes) pass actual There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think yes. As you pointed out in the last meeting, we need to decouple the components for effective testing so we need to test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of the drafted solution in #90, splitting into a "canonical" and a "yaml-parsed" class? Note that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. made a comment there about the canonical workflow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with the creation of |
||
data=models.ConfigData( | ||
available=[models.ConfigAvailableData(foo={})], | ||
generated=[models.ConfigGeneratedData(bar={})], | ||
), | ||
) | ||
assert testee.data_dict["foo"].name == "foo" | ||
assert testee.data_dict["bar"].name == "bar" | ||
assert testee.task_dict["some_task"].name == "some_task" | ||
|
||
|
||
def test_load_workflow_config(tmp_path): | ||
minimal_config = textwrap.dedent( | ||
""" | ||
cycles: | ||
- minimal: | ||
tasks: | ||
- a: | ||
tasks: | ||
- b: | ||
plugin: shell | ||
data: | ||
available: | ||
- c: | ||
generated: | ||
- d: | ||
""" | ||
) | ||
minimal = tmp_path / "minimal.yml" | ||
minimal.write_text(minimal_config) | ||
testee = models.load_workflow_config(str(minimal)) | ||
assert testee.name == "minimal" | ||
assert testee.rootdir == tmp_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: are we ok with this yaml snippet parsing without validation errors?
If so, should it fail with a clear message down the line or should it create a viable WorkGraph, which runs nothing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we agreed in the meeting to produce an error, maybe it is easier for merging to do this in a subsequent PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once I merge #90 into this, the error would be raised during canonicalization