-
Notifications
You must be signed in to change notification settings - Fork 182
Expose CLI Options through public API #1928
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
Conversation
Expose a public API that can retrieve the processed CLI options for the current process launched through the debugpy CLI. This enables code to be able to retrieve options like the port and adapter access token to be used for launching their own child process' that can be debugged.
| # The CLI entrypoint was not called so there are no options present. | ||
| return None | ||
|
|
||
| # We don't return the actual options object because we don't want callers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, good idea
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
I'll look at the CI failures and try and fix them up but I just wanted to float an alternative idea to see if you prefer that. Instead of exposing the CLI options like this an alternative would be to extract the debugging information at runtime from pydevd instead. That way it would also work for debugging sessions started with something like # src/debugpy/server/api.py
@dataclasses.dataclass(frozen=True)
class DebugInfo:
client: str
port: int
access_token: str | None
def get_debug_info():
ensure_logging()
log.debug("get_debug_info()")
info = pydevd.SetupHolder.setup
return DebugInfo(
client=info['client']
port=info['port']
access_token=info['access-token']
)The advantages here is that it only exposes what you want to expose from pydevd and works for both a session started from the CLI as well as through the API. The downside is you are potentially at the mercy of exposing how pydevd works. |
I think I prefer your original idea. I'd guess that somebody starting using the API would know what parameters they passed to it (so they wouldn't need this api?) And not super happy about pydevd knowledge bleeding upwards. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Thanks, looking forward to the next release! Edit: just noticed 1.8.15 was just pushed out, will have to wait for the next one. |
Expose a public API that can retrieve the processed CLI options for the current process launched through the debugpy CLI. This enables code to be able to retrieve options like the port and adapter access token to be used for launching their own child process' that can be debugged.