https://pulumi.com logo
#python
Title
# python
e

enough-leather-70274

04/21/2021, 3:33 AM
Hi folks - where can I find the python reference docs for the automation library?
I can see the guides at https://www.pulumi.com/docs/guides/automation-api/ and there's a link at the bottom of the page to python pointing to https://www.pulumi.com/docs/reference/pkg/python/pulumi/#module-pulumi.automation, but that idref doesn't exist
e.g. I'm looking for the python equivalent of https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/auto#Stack
r

red-match-15116

04/21/2021, 3:39 AM
Yikes yeah something went wrong with the latest docgen, I’ll sort that out ASAP - but that documentation is generated from the source code so you should be able to get the same info from the docstring on
Stack
for now.
Is there anything specific you’re looking for?
e

enough-leather-70274

04/21/2021, 3:40 AM
I actually came to ask if there was a post-pulumi-up hook I could use to run our db migration scripts in python... and realised it's exactly what the automation lib is prob for
But wanted to look at the api ref doc in full to see what was available and how to do it.
So the docstring on Stack for python is where then?
(also another thing - your go docs still say automation is in alpha, which is why we've steered clear of it so far... but I guess that needs an update!)
r

red-match-15116

04/21/2021, 3:42 AM
I can do you one better for that specific use-case Automation examples for python: https://github.com/pulumi/automation-api-examples#python-examples For database migration specifically: https://github.com/pulumi/automation-api-examples/tree/main/python/database_migration
(also another thing - your go docs still say automation is in alpha, which is why we’ve steered clear of it so far... but I guess that needs an update!)
Thanks for the callout, yeah we need to do a sweep and update those docs
e

enough-leather-70274

04/21/2021, 3:45 AM
For database migration specifically: https://github.com/pulumi/automation-api-examples/tree/main/python/database_migration
Hah, yeah that's the type of thing, tho our db infra is totally isolated, so no way to run them from public-facing CI. Need to invoke a migration lambda via boto basically. Still, it's the bit about wrapping the logic in our current
__main__.py
and associated components that I'm interested in
I guess we'd do away with the CLI altogether then? i.e. wrap our current pulumi logic in a python program that uses the automation api then just invoke that from the command line when doing local dev?
💯 1
r

red-match-15116

04/21/2021, 3:48 AM
I’m fixing up the python docs now so we’ll get that updated soon.
Still, it’s the bit about wrapping the logic in our current 
__main__.py
  and associated components that I’m interested in
You can take a look at the local program example to see how you can deploy/invoke a pre-existing CLI-driven python pulumi program, and then add on the bit that does the migration… does that align more?
You can always set it up in a way that it can be driven by both the CLI and via automation if using it via the “local program” route
e

enough-leather-70274

04/21/2021, 3:50 AM
Got it. Yeah, this is new to us so will have a tinker. Will keep an eye on the docs too.
partypus 8bit 1
r

red-match-15116

04/21/2021, 5:13 AM
Fix for docs should be merged in the morning (PST). https://github.com/pulumi/docs/pull/5859
Docs are fixed now @enough-leather-70274 The link should take you there: https://www.pulumi.com/docs/reference/pkg/python/pulumi/#module-pulumi.automation
e

enough-leather-70274

04/21/2021, 9:45 PM
Thanks Komal - defo an improvement. FWIW, I find the go docs way easier to navigate than the unindexed single page for python. Know you're keen to show off the brand, but DX should win here I think. Can we access the native format (e.g. readthedocs) somewhere else?
Also, the formatting's a bit out of whack
r

red-match-15116

04/21/2021, 11:11 PM
…yeah I totally hear you! There’s an open issue: https://github.com/pulumi/docs/issues/4615 I’m not a fan of our python docs, just haven’t had the time to address it.
We unfortunately don’t have a readthedocs version. These are also sphinx-generated, we just do some pretty weird stuff to generate it this way. I decided not to open that can of worms at the time. But feel free to leave some comments on that issue so we can reconsider prioritizing.
3 Views