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

No frills Result class #612

Merged
merged 14 commits into from
Feb 1, 2019
Merged

No frills Result class #612

merged 14 commits into from
Feb 1, 2019

Conversation

cicdw
Copy link
Member

@cicdw cicdw commented Feb 1, 2019

Thanks for contributing to Prefect!

Please describe your work and make sure your PR:

  • adds new tests (if appropriate)
  • updates CHANGELOG.md (if appropriate)
  • updates docstrings for any new functions or function arguments, including docs/outline.toml for API reference docs (if appropriate)

What does this PR change?

This PR begins work on PIN 4 (and consequently, changes the status of PIN 4 to "Accepted"). Specifically, this PR introduces a new Result class and a corresponding NoResult class, along with schemas for both. Additionally, this PR makes a large breaking change that result handler methods have been renamed to read/ write for clarity / less ambiguity.

Why is this PR important?

This PR is the first step towards the PIN 4 refactor; this PR introduces the necessary classes, but doesn't use them anywhere yet.

src/prefect/engine/result.py Show resolved Hide resolved
return self


class NoResult:
Copy link

Choose a reason for hiding this comment

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

Is it supposed to be checked that this is an instance of a NoResult when used? i.e. can it be guaranteed that the read/write functions won't be called on a NoResult

Copy link
Member Author

Choose a reason for hiding this comment

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

So I'll have to see what feels right when I start using this everywhere, but the current plan is that that will just error out.

Copy link

Choose a reason for hiding this comment

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

Error out like it tries to access a function on a class that doesn't have it?

Copy link
Member

Choose a reason for hiding this comment

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

It may be worthwhile to implement read()/write() just so we can have a more informative error than missing attribute -- although depending on how you use this (in next PR, I believe) that could change. Happy to wait and see.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea if it's OK with y'all, I do agree I'll need to do something special for the situation @joshmeek brought up but I'm not 100% sure what the best way to handle it is yet

src/prefect/engine/result_handlers/gcs_result_handler.py Outdated Show resolved Hide resolved
src/prefect/engine/result_handlers/local_result_handler.py Outdated Show resolved Hide resolved
src/prefect/engine/result_handlers/local_result_handler.py Outdated Show resolved Hide resolved
joshmeek
joshmeek previously approved these changes Feb 1, 2019
Co-Authored-By: cicdw <white.cdw@gmail.com>
joshmeek
joshmeek previously approved these changes Feb 1, 2019
assert r.value == 2
assert r.handled is False

def test_result_doesnt_allow_handled_without_result_handler(self):
Copy link
Member

Choose a reason for hiding this comment

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

👍

@cicdw cicdw merged commit 5748c94 into master Feb 1, 2019
@cicdw cicdw deleted the result-class branch February 1, 2019 20:11
cicdw pushed a commit that referenced this pull request Nov 22, 2021
…the-interface

[db-abstract] more abstractions off of the interface
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants