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

colossal-room-15708

05/16/2019, 8:35 PM
Will we soon get a better experience writing pulumi in python? At the moment I prefer nodejs over python because intellisense works much better and drilling into resources for examples actually works.
w

white-balloon-205

05/16/2019, 8:38 PM
What are your top requests for Pulumi in Python?
c

colossal-room-15708

05/17/2019, 2:01 AM
Intellisense mainly, unless it only doesn't work on my machine?! In nodejs I can also ctrl+click a resource to see the implementation including examples. I don't have that in python.
i

incalculable-sundown-82514

05/17/2019, 11:26 PM
what IDE are you using?
c

colossal-room-15708

05/17/2019, 11:56 PM
vs code on ubuntu
l

little-river-49422

05/18/2019, 7:13 AM
vs code does intellisense for me
c

colossal-room-15708

05/18/2019, 8:04 AM
the things I do get seem far away from what I get in nodejs though, especially `ctrl`+`click` on a resourcetype and going straight to an implementation example
l

little-river-49422

05/18/2019, 8:55 AM
i have no idea what intellisense for nodejs looks like
ctrl+click works for me, no idea why you would need that, but it works
it shows the source code for the function
like it normally does
c

colossal-room-15708

05/18/2019, 11:32 AM
in nodejs I can then go and check out the actual
.js
and see example usage. I don't seem to get that in python. This has already been quite useful more than once.
g

glamorous-printer-66548

05/18/2019, 8:46 PM
@colossal-room-15708 I’m also primarily a TS user but just tried out pulumi python and I can navigate to the class implementation just like with TS. The only catch is that you have to navigate first to the import statement and then click in the import statement again to get to the implementation
have you created a local virtuelenv and set VS code to correctly use that virtualenv as interpreter?
you can do this via the
Python: Select Interpreter
action in vs code
@white-balloon-205 that code navigation aside. I noticed that most pulumi python resources have very incomplete type information compared to TS equivalent. I.e. the k8s Deployment resource in TS has full type information for the
Spec
and one gets really rich code completion whereas in the python equivalent there seems to be no type information (python 3.6+ type annotations) at all for the Spec.
l

little-river-49422

05/18/2019, 8:54 PM
The only catch is that you have to navigate first to the import statement and then click in the import statement again to get to the implementation
- thats not true, you dont have to click the import statement
g

glamorous-printer-66548

05/18/2019, 8:57 PM
@little-river-49422 really? In my example:
Copy code
from pulumi_kubernetes.apps.v1 import Deployment

deployment = Deployment()
when I click on
Deployment()
it navigates first to the import statement and then I have to click again to go to the implementation. How does that work on your side?
l

little-river-49422

05/18/2019, 8:57 PM
it takes me to the code, not the import statement
ah, i think for k8s it does that, not for azure
here's what i get when I click on the clusterrolebinding resource
but that code is part of pulumi module, not my code
g

glamorous-printer-66548

05/18/2019, 9:00 PM
I think it’s because you’re doing * imports
whereas my code imports individual pieces
l

little-river-49422

05/18/2019, 9:01 PM
like i said, its not my code. i'm not doing * imports
g

glamorous-printer-66548

05/18/2019, 9:02 PM
just tried. When I write this:
Copy code
from pulumi_kubernetes.apps.v1.Deployment import *

Deployment()
and click
Deployment()
it takes me directly to the implementation
how do you import then @little-river-49422 . Do you have an example?
l

little-river-49422

05/18/2019, 9:04 PM
👍 1
c

colossal-room-15708

05/19/2019, 2:27 AM
Looks like I completely skipped the virtualenv setup 😞 I'm now getting "better" intellisense, although vs code sorts everything alphabetically, where in nodejs vs code shows me properties for the resource first, then the generic stuff. Probably a vs code thing though.
alright, that said, here is something I observed comparing the two (nodejs v python)
nodejs
python
nodejs referencing other resources' properties
python referencing other resources' properties (doesn't work?)
nodejs showing me what values I can specify for resource properties
python not showing me anything
I'm happy to be called an idiot here by the way and told that I'm doing it wrong (like the virtualenv above)
Oh, I can btw `ctrl`+`click` on
Profile
in python and then get here, but for example on
monitor_configs
it says "supports the fields documented below", but then nothing is "documented below".
I eventually got here to a working example, but I needed to have another pulumi workspace open which had a JS stack in it where I rewrote JS to python, plus the terraform docs. Feels like I'm context switching a lot in order to get to my python stack
l

little-river-49422

05/19/2019, 7:29 AM
personally i dont trust all these tools and only use api reference