question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make it easier to debug functions in IDEs

See original GitHub issue

Currently, it is super hard to configure the local debug of the functions in PyCharm, moreover, I found it impossible without hacking the cli.py.

Here is a way to do it in PyCharm now:

  1. Add main function to the cli.py:
    if __name__ == '__main__':
        cli(sys.argv[1:])
    
  2. Create PyCharm Python config and choose functions_framework\cli.py as a script.
  3. Pass required params as Parameters in the configuration, e.g. --port 8088 --signature-type http, etc.
  4. Make sure to set the working directory to the project root (so that the functions framework is able to load the entry point function).
  5. Run the created configurations and use PyCharm debugger.

What we can to make life easier:

  1. Create __main__.py in the functions_framework module and allow running the module as the CLI. Or, add the main function to the cli.py itself, maybe worth having both.
  2. Create well-structured documentation about debugging functions locally with popular IDEs (PyCharm, VSCode, others?)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
yan-hiccommented, Jun 9, 2020

nvm - found it: image

1reaction
dicommented, Apr 8, 2020

Hi @yuri-sergiichuk, can you try this branch and let me know if it works for you?

You should be able to install it with:

pip install git+https://github.com/googlecloudplatform/functions-framework-python.git@add-main
Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging in IDEs
Eclipse includes a debugging interface that makes many debugging tasks simple. Example 2: Try This: Eclipse Debugger. Launch the Eclipse IDE ...
Read more >
How does the debug function for IDEs work?
Typically one runs one's program in debug mode, which executes it but attaches to the process with the debugger. Then one can set...
Read more >
Why is debugging better in an IDE? [closed]
My general opinion is that IDE debuggers are absolutely, amazingly wonderful for managed languages like Java or C#, are fairly useful for C++, ......
Read more >
How to Debug Java Code Faster with Eclipse
1. A breakpoint is a point in code where the program execution pauses during debugging. This allows the programmer to inspect code and...
Read more >
Code completion - IDEs & Debugging - milliams.com
They're not magic and can't write the code for you but they will make it easier to remember the names of functions and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found