Pyinfra: Callback plugins for API usage?

Created on 15 Jun 2020  路  5Comments  路  Source: Fizzadar/pyinfra

Is your feature request related to a problem? Please describe.

I'm investigating using the pyinfra api directly from a Python application, which seems easy enough (looking at the api-deploy.py example). One thing I'd like to do is plug-in in my own progess logger, and hide the pyinfra output entirely. Is that currently possible?

Describe the solution you'd like

Ideally, there was an abstract base class I could extend which would have methods like 'task_started', 'task_finished', 'task_failed', including maybe some task details. Then I could for example display the progress in my own internal format in my application, or do some auditing on execution metrics, send notifications, etc.

API

Most helpful comment

I'm super keen on pushing API support to the same level as the CLI. Currently aiming to clear v1 which clears up a lot of old cruft, and should allow creation of a stable API that can be documented + used just like the CLI, including callbacks as described!

Time wise my aim is to get v1 out ASAP, 0.15 being the final 0.x release due in a few days.

All 5 comments

I'm super keen on pushing API support to the same level as the CLI. Currently aiming to clear v1 which clears up a lot of old cruft, and should allow creation of a stable API that can be documented + used just like the CLI, including callbacks as described!

Time wise my aim is to get v1 out ASAP, 0.15 being the final 0.x release due in a few days.

Sounds great. Thanks for this project, by the way! I think there is a lot of potential in pyinfra, it's comparatively light-weight design, and the the fact that no real dependencies are needed on targets. I've worked in this space for quite a while now, and I think pyinfra really fills a need that isn't currently covered by any other tool...

I've added host_connect and host_disconnect callback methods to the implementation and released in v1.1.dev0, as 1.1 is a little delayed! Will close this issue as I believe this resolves it - although keen to have further issues for other callback specifics that make sense to add! 1.1 should bring proper API usage :)

Thanks heaps for this. I haven't had the chance to try it out yet, but once I do I'll report any issues I encounter. I'm really excited about the API...

Was this page helpful?
0 / 5 - 0 ratings