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

User-friendly exception when LightningWork.run() method is missing #14759

Merged
merged 5 commits into from
Sep 17, 2022

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Sep 16, 2022

What does this PR do?

Fixes #14677

The LightningWork no longer is an abstract class, and the run() method is no longer abstract.
When you try to instantiate a work without a run method overridden, you will get an error message saying:

The work name of the class is missing the run() method. This is required. Implement it first and then call it in your Flow.

Does your PR introduce any breaking changes? If yes, please list them.

No.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

I made sure I had fun coding 🙃

cc @Borda

@github-actions github-actions bot added the app (removed) Generic label for Lightning App package label Sep 16, 2022
@awaelchli awaelchli added the feature Is an improvement or enhancement label Sep 16, 2022
@awaelchli awaelchli added this to the app:0.7 milestone Sep 16, 2022
@awaelchli awaelchli self-assigned this Sep 16, 2022
@awaelchli awaelchli marked this pull request as ready for review September 16, 2022 21:43
@codecov
Copy link

codecov bot commented Sep 16, 2022

Codecov Report

Merging #14759 (c0bc164) into master (8f14184) will increase coverage by 1%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master   #14759     +/-   ##
=========================================
+ Coverage      84%      85%     +1%     
=========================================
  Files         395      328     -67     
  Lines       28817    25784   -3033     
=========================================
- Hits        24105    21871   -2234     
+ Misses       4712     3913    -799     

Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

@mergify mergify bot added ready PRs ready to be merged has conflicts and removed ready PRs ready to be merged labels Sep 17, 2022
@awaelchli awaelchli enabled auto-merge (squash) September 17, 2022 10:37
@mergify mergify bot added ready PRs ready to be merged and removed has conflicts ready PRs ready to be merged labels Sep 17, 2022
@awaelchli awaelchli merged commit e872b27 into master Sep 17, 2022
@awaelchli awaelchli deleted the feature/run-method-validation branch September 17, 2022 19:45
Copy link
Contributor

@krshrimali krshrimali left a comment

Choose a reason for hiding this comment

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

Thank you @awaelchli - I'm a bit late to the party, sorry for that. I left a comment but great work on getting this PR in, let's get it in the next release. 🚀

I changed the milestone to app:0.6.x, is that okay? Please feel free to move it back to 0.7 if desired.

Comment on lines +575 to +576
f"The work `{self.__class__.__name__}` is missing the `run()` method. This is required. Implement it"
" first and then call it in your Flow."
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you so much @awaelchli for picking this up.

I really liked the message here: https://github.com/Lightning-AI/lightning/pull/14760/files#diff-7fc1f959c169d77f9190069631cd8e51de55be8cc19214c92440cee6cb42f171R129-R130, with a minor "Please", and also "work" -> "Work" (just like Flow is used instead of flow). I know this is very minor, but this is just one of those errors that is going to reach to the user a lot of times.

Probably:

f"The Work `{self.__class__.__name__}` is missing the `run()` method. This is required. Please implement it"
                " first and then call it in your Flow. You can refer to the docs here: https://lightning.ai/lightning-docs/basics.html?highlight=lightningwork on some basics around `LightningWork`"

(I'm not sure if including the docs link is a good idea here, but just pointing them to the place where they can learn how to implement the run method will help)

Nothing major, and will have to be done in another PR, but I'm just nit-picking here. (please don't mind) ❤️

cc: @Felonious-Spellfire on his opinion as well! I'm not a native English speaker, so I'm sorry if I'm wrong :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feel free to open a PR with your ideas. Adding the doc link to the message is risky business. We haven't considered that so far as there is an open problem of how to guarantee valid links over time, so not sure if we are ready to do that just yet.

@krshrimali krshrimali removed this from the app:0.7 milestone Sep 18, 2022
@krshrimali krshrimali added this to the app:0.6.x milestone Sep 18, 2022
Borda pushed a commit that referenced this pull request Sep 20, 2022
lexierule pushed a commit that referenced this pull request Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app (removed) Generic label for Lightning App package feature Is an improvement or enhancement ready PRs ready to be merged
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

App: Raise a better error when run method not defined for the LightningWork
4 participants