Skip to content

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Nov 8, 2022

What does this PR do?

This PR enables running an app within a debugger with breakpoints with flows and works without your changing code :)

fimal.mp4

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

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 list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the 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?

Make sure you had fun coding 🙃

cc @Borda

@tchaton tchaton changed the title Enable debug mode [App] Enable debug mode Nov 8, 2022
@github-actions github-actions bot added the app (removed) Generic label for Lightning App package label Nov 8, 2022
@tchaton tchaton marked this pull request as ready for review November 8, 2022 19:12
@tchaton tchaton added the feature Is an improvement or enhancement label Nov 8, 2022
@tchaton tchaton changed the title [App] Enable debug mode [App] Enable debugger with LightningApp Nov 8, 2022
@tchaton tchaton added this to the v1.8.x milestone Nov 8, 2022
Copy link
Member

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

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

LGTM 😃

Copy link
Collaborator

@lantiga lantiga left a comment

Choose a reason for hiding this comment

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

Great! Docstring change and a comment

@mergify mergify bot added the ready PRs ready to be merged label Nov 9, 2022
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

I don't understand how this is supposed to work. I checked out the branch, set a breakpoint() in the examples/app_boring in one of the works, and it exited with an error.

Perhaps you only meant to add support for the debugger in the IDE. I verified that it works in PyCharm with the debugger, but the user will have to change their code from

    app = L.LightningApp(BoringApp())

to

    app = L.LightningApp(BoringApp())
    MultiProcessRuntime(app).dispatch()

in order to run it as a regular python program without cli.
However, we never explain to the user that this is another way of launching an app locally. Using the runtime directly like that is only meant for our testing. We would need to introduce a simpler API here to do the same if we really want to support running it like that.

@tchaton
Copy link
Contributor Author

tchaton commented Nov 9, 2022

I don't understand how this is supposed to work. I checked out the branch, set a breakpoint() in the examples/app_boring in one of the works, and it exited with an error.

Perhaps you only meant to add support for the debugger in the IDE. I verified that it works in PyCharm with the debugger, but the user will have to change their code from

    app = L.LightningApp(BoringApp())

to

    app = L.LightningApp(BoringApp())
    MultiProcessRuntime(app).dispatch()

in order to run it as a regular python program without cli. However, we never explain to the user that this is another way of launching an app locally. Using the runtime directly like that is only meant for our testing. We would need to introduce a simpler API here to do the same if we really want to support running it like that.

This is meant to work if you run your script with a debugger attached to it. This enables to debug very simply your app directly within the IDE. You don't need to change single line of code for it to work, this is the entire goal here.

in order to run it as a regular python program without cli.

This isn't what we are trying to enable. Just for users to run their app in their IDE without code modification and set breakpoints wherever they decide.

@mergify mergify bot added ready PRs ready to be merged and removed has conflicts ready PRs ready to be merged labels Nov 9, 2022
@tchaton tchaton requested a review from awaelchli November 9, 2022 14:08
@tchaton tchaton enabled auto-merge (squash) November 9, 2022 17:21
@tchaton tchaton merged commit f06de83 into master Nov 9, 2022
@tchaton tchaton deleted the enable_debug_mode branch November 9, 2022 20:46
Borda pushed a commit that referenced this pull request Nov 10, 2022
lexierule pushed a commit that referenced this pull request Nov 10, 2022
alecmerdler added a commit to Lightning-Universe/Echo that referenced this pull request Nov 18, 2022
Adds lightning==1.8.2 for the latest goodies.
- Removes 'debug.py' now that debugging is supported
  (Lightning-AI/pytorch-lightning#15590)
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
None yet
Development

Successfully merging this pull request may close these issues.

4 participants