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
pipeline: generic interface for pipeline items #378
Conversation
@@ -34,6 +32,12 @@ def test_load_skypy_yaml(): | |||
load_skypy_yaml(filename) | |||
|
|||
|
|||
def test_empty_ref(): | |||
filename = get_pkg_data_filename('data/test_empty_ref.yml') | |||
with pytest.raises(ValueError, match='empty reference'): |
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.
Looking at the yml file for this test, is this still an empty reference? Or a broken one?
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.
My thinking here was that at the config (i.e. YAML) level we can only catch empty strings being passed when the !ref
tag is used without argument. We could also let it go to the pipeline level and check there, but then we lose the information about where the error happened.
Which now makes me think that the next iteration of this should be adding 'file', 'line' and 'column' information to Item
on construction so that the pipeline can do all of the checking and give great error messages.
Provide a generic base class
Item
for pipeline items, and two concretisationsRef
(reference to another variable) andCall
(function call). The pipeline items have three methods:infer
to infer additional properties from context (e.g. thecosmology
argument inCall
),depend
to return the dependencies of the item, andevaluate
to return the computed value of the item.This removes special cases from the
Pipeline
class and makes it easily extendable to other types of items.