Skip to content
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

Merged
merged 16 commits into from
Nov 18, 2021

Conversation

schustmi
Copy link
Contributor

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have added tests to cover my changes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Describe changes

  • Add improved error handling when creating and calling steps
  • Add tests for step definition and calling
  • Replace SpecMaterializerRegistry with simple dictionary (it was nothing else to begin with)
  • Add equality operations for post-execution classes (failed some tests locally because of random order I think)

@github-actions github-actions bot added the internal To filter out internal PRs and issues label Nov 18, 2021
Copy link
Contributor

@alex-zenml alex-zenml left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I quite like the concept of the second link, but I would use it without the parametrize:

from contextlib import ExitStack as does_not_raise

def test_something():
    with does_not_raise():
        do_something()

What do you think about that? Maybe also @htahir1 @bcdurak

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it too

Copy link
Contributor

@htahir1 htahir1 left a 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)

@schustmi schustmi merged commit 708bbb1 into main Nov 18, 2021
@schustmi schustmi deleted the michael/ENG-83-step-and-pipeline-interface branch November 18, 2021 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal To filter out internal PRs and issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants