-
Notifications
You must be signed in to change notification settings - Fork 467
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
Improve step and pipeline interface #175
Conversation
…n parameter conversion to string
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.
Nice! Loads of improvements to the error messages, plus all sorts of niceties like docstring improvements and of course a ton of tests to ensure it's doing what we think.
same artifact.""" | ||
if isinstance(other, ArtifactView): | ||
return self._id == other._id and self._uri == other._uri | ||
return NotImplemented |
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.
Is it normal/standard to return NotImplemented
in this way?
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.
Yes I think so, if I remember correctly returning NotImplemented
in __eq__
is the best practice if you can't do the comparison yourself.
For example if someone decides to subclass ArtifactView (and doesn't do any major changes, let's say just add a small method to it), an object of that class might still be 'equal' to an ArtifactView object. But we can't check for that here in __eq__
as we don't know of the subclass.
If we return NotImplemented
, python will as a next step try calling __eq__
on the other object (the subclass in our example, which might handle comparing to ArtifactView) and if that returns NotImplemented
as well it will fallback to comparing if it's the same object in memory.
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.
Ok thank you. I didn't know that.
tests/steps/test_base_step.py
Outdated
int_step_output, step_with_two_int_inputs | ||
): | ||
"""Test that a step can be called with a mix of args and kwargs.""" | ||
step_with_two_int_inputs()(int_step_output, input_2=int_step_output) |
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.
No assertion in these tests. Not sure if that's best practice with pytest. I have a feeling these kinds of tests give a false feeling of security.
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.
No idea either, do you have any suggestions how we could improve it? Is there some pytest.no_raise or something similar?
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.
I've used the second style / syntax before in tests that I wrote:
https://stackoverflow.com/a/20275035/6649687
It's a bit wordier, but I find it a bit clearer and works better when it actually does fail.
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.
There is also this, but I think that's beyond what we need here.
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.
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.
Ok yes I like that better too.
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.
I added it for all step and pipeline tests
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.
I like it too
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.
Wow solid PR. Really like all the tests and could not think of more (Y)
Pre-requisites
Please ensure you have done the following:
Types of changes
Describe changes