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

Create a dedicated page on debugging the code #1149

Open
nazarewk opened this issue Jul 15, 2024 · 0 comments
Open

Create a dedicated page on debugging the code #1149

nazarewk opened this issue Jul 15, 2024 · 0 comments
Labels
documentation Issues with docs/examples/docstrings.

Comments

@nazarewk
Copy link

nazarewk commented Jul 15, 2024

Is your feature request related to a problem? Please describe

As somebody with years of experience with IaC tooling (mostly Terraform, occasional Ansible) I had trouble finding any resources on how to interact with and debug the pyinfra code.

After failing to use PyCharm debugger and searching through docs I came up with this frankenstein (which nobody should use) to print out databases in MySQL:

# DO NOT USE
databases = host.get_fact(MysqlDatabases, **mysql_args)
server.shell(commands=[f"echo 'Hello World!' {databases}"])

what I later learned it could look like:

from pyinfra import logger
databases = host.get_fact(MysqlDatabases, **mysql_args)
logger.info(json.dumps(databases, indent=2, sort_keys=True))

Describe the solution you'd like

It would be great to have a debugging instructions page dedicated to new users. Some stuff it could include, which I learned after brief talk on Matrix chat/through issues:

  • make it obvious that re-running operations it currently the only sensible way to learn/reason about and debug the code.
  • point out that from pyinfra import logger can aid this model with "print driven debugging".
  • note that pyinfra doesn't really work with Jetbrains/PyCharm debugger, remove the compatibility docs saying otherwise.
  • make it obvious step by step debugging is not (currently?) available due to heavily asynchronous execution model
  • I've seen it somewhere that pyinfra execution model doesn't allow retrieving outputs from operations (only facts).
@nazarewk nazarewk changed the title Create a dedicated page for debugging ideas. Create a dedicated page on debugging the code Jul 15, 2024
@Fizzadar Fizzadar added the documentation Issues with docs/examples/docstrings. label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues with docs/examples/docstrings.
Projects
None yet
Development

No branches or pull requests

2 participants