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

Support remote debugging in dev environments #1780

Merged
merged 2 commits into from
Nov 16, 2022
Merged

Conversation

adamsachs
Copy link
Contributor

@adamsachs adamsachs commented Nov 14, 2022

Closes #1779

Code Changes

  • add nox flag to spin up the fides service with some slight tweaks to enable a debugpy remote debugger to attach to it
    • this includes an additional docker-compose yml to provide some overrides to the base fides service definition - to me, this felt like the cleanest way to provide these overrides/alternatives
  • also add an entry to our launch.json to give devs an easy way to start up the remote debugger from vscode.

Steps to Confirm

  • run nox -s dev -- remote_debug to start your dev app with remote debugging enabled

  • attach a remote debugger to your server from VSCode

    • open up fides repo in a VSCode workspace
    • go to Run and Debug view
    • select Python debugger: Remote Attach Fides launch/debug config from dropdown and click the "start" arrow
      image
  • add a breakpoint to codepath that will be hit by interacting with the server, and watch it get hit

  • more info on remote debugging in VSCode: https://code.visualstudio.com/docs/python/debugging#_debugging-by-attaching-over-a-network-connection

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Documentation Updated:
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Issue Requirements are Met
  • Relevant Follow-Up Issues Created
  • Update CHANGELOG.md

Description Of Changes

  • remote_debug can now be passed as a nox flag to the dev session, and it will start up the fides service with a container that has port 5678 open to the host.
    • e.g. nox -s dev -- remote_debug ui will spin up fides alongside the admin UI, while also allowing a remote debugger to attach to that running fides container/server
    • this can also be used alongside local integration environments with additional datastore containers
    • this cannot currently be used alongside pytest unit testing. the issue description context gives some detail about how/why i couldn't get that to work. i may be missing something dumb and would appreciate any pointers!
  • from VSCode, if devs switch to the Run and Debug view, they should now have a launch/debug config Python debugger: Remote Attach Fides. If they launch that debug config after their server/app boots up with e.g. nox -s dev -- remote_debug, then they should now be ready to debug that server live!

@adamsachs adamsachs marked this pull request as ready for review November 14, 2022 18:49
@adamsachs adamsachs added the dev experience Targets the developer experience label Nov 14, 2022
@adamsachs adamsachs self-assigned this Nov 14, 2022
@adamsachs
Copy link
Contributor Author

not sure whether we'd want to update any developer documentation with this change. any thoughts @ethyca/docs-authors ?

Copy link
Contributor

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

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

Everything seems to work for me and I was able to get the debugger running. I will say I don't use VS Code so someone that does may try things I didn't.

On a quick search it looks like I can also get it working with neovim, but I haven't had time to test that yet. This also makes me think there will be a way for our IntelliJ/Pycharm users to get it working.

@conceptualshark
Copy link
Contributor

not sure whether we'd want to update any developer documentation with this change.

We do have some documentation on how to debug in intellij/pycharm, I think having a section for this couldn't hurt?

@ThomasLaPiana
Copy link
Contributor

@adamsachs might as well add this to our dev docs, this is a great feature!

@adamsachs adamsachs requested a review from a team November 16, 2022 13:47
@adamsachs
Copy link
Contributor Author

@conceptualshark i've added a quick guide on VSCode debugging in dd72026. Would you mind giving it a once-over? Thanks!

@adamsachs adamsachs merged commit fb99072 into main Nov 16, 2022
@adamsachs adamsachs deleted the 1779-remote-debugging branch November 16, 2022 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev experience Targets the developer experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support live app debugging in dev environment
4 participants