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

Document how session.run fails, and how to handle failures #533

Merged
merged 3 commits into from
Dec 26, 2021

Conversation

DiddiLeija
Copy link
Collaborator

Closes #517.

This PR added a docstring to explain how session.run fails and stop the session. Also, I documented how to handle these failures, like described in #517.

Session.run will raise an exception (a private exception), so we can use try...finally and try...except blocks with them.
@DiddiLeija
Copy link
Collaborator Author

cc @cjolowicz @ktbarrett

Copy link
Collaborator

@cjolowicz cjolowicz left a comment

Choose a reason for hiding this comment

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

Can we simplify the example? In particular, I'd be wary of using git stashas an example because it (temporarily) modifies the user's work tree.

What do you think about using something like this as an example?

try:
    session.run("coverage", "run", "-m", "pytest")
finally:
    # Display coverage report even when tests fail.
    session.run("coverage", "report")

I've found this to be a useful real-world idiom, especially when you're in the habit of writing a failing test first.

@ktbarrett
Copy link
Contributor

I agree on simplifying the example. As I've discovered it's a little more involved than just git stash pop and I don't want to screw up people's working tree who are trying the feature out.

@DiddiLeija
Copy link
Collaborator Author

Done.

@cjolowicz cjolowicz merged commit b0750af into wntrblm:main Dec 26, 2021
@DiddiLeija DiddiLeija deleted the document-run-failures branch December 26, 2021 18:13
@cjolowicz
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Document how runs cause sessions to fail
3 participants