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

Python code imports do not work #50

Closed
drzero42 opened this issue Jul 12, 2021 · 3 comments · Fixed by #143
Closed

Python code imports do not work #50

drzero42 opened this issue Jul 12, 2021 · 3 comments · Fixed by #143
Assignees
Labels
area/codegen Affects quality or correctness of generated code kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed

Comments

@drzero42
Copy link

Pulumi v3.6.1
Pulumi-kubernetes v3.5.0
crd2pulumi v1.0.8

I am trying to generate a Pulumi Python module for Cert-manager CRDs:

$ wget https://github.com/jetstack/cert-manager/releases/download/v1.4.0/cert-manager.crds.yaml
$ crd2pulumi --pythonPath certmanager cert-manager.crds.yaml
$ cat __main__.py
"""A Kubernetes Python Pulumi program"""

from certmanager.pulumi_crds import certmanager

$ pulumi preview

Previewing update (dev)

View Live: https://app.pulumi.com/drzero/pulumi-learn/dev/previews/da0b527b-a91f-46fc-b483-457e9e71877c

     Type                 Name              Plan       Info
 +   pulumi:pulumi:Stack  pulumi-learn-dev  create     3 errors
 
Diagnostics:
  pulumi:pulumi:Stack (pulumi-learn-dev):
    error: Program failed with an unhandled exception:
    error: Traceback (most recent call last):
      File "/home/abo/.pulumi/bin/pulumi-language-python-exec", line 92, in <module>
        loop.run_until_complete(coro)
      File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
        return future.result()
      File "/home/abo/sandbox/pulumi-learn/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 110, in run_in_stack
        await run_pulumi_func(lambda: Stack(func))
      File "/home/abo/sandbox/pulumi-learn/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 43, in run_pulumi_func
        func()
      File "/home/abo/sandbox/pulumi-learn/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 110, in <lambda>
        await run_pulumi_func(lambda: Stack(func))
      File "/home/abo/sandbox/pulumi-learn/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 133, in __init__
        func()
      File "/home/abo/.pulumi/bin/pulumi-language-python-exec", line 91, in <lambda>
        coro = pulumi.runtime.run_in_stack(lambda: runpy.run_path(args.PROGRAM, run_name='__main__'))
      File "/usr/lib/python3.8/runpy.py", line 282, in run_path
        return _run_code(code, mod_globals, init_globals,
      File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/home/abo/sandbox/pulumi-learn/./__main__.py", line 8, in <module>
        from certmanager.pulumi_crds import certmanager
      File "/home/abo/sandbox/pulumi-learn/./certmanager/pulumi_crds/__init__.py", line 9, in <module>
        from . import (
      File "/home/abo/sandbox/pulumi-learn/./certmanager/pulumi_crds/acme/__init__.py", line 7, in <module>
        from . import (
      File "/home/abo/sandbox/pulumi-learn/./certmanager/pulumi_crds/acme/v1/__init__.py", line 6, in <module>
        from .Challenge import *
      File "/home/abo/sandbox/pulumi-learn/./certmanager/pulumi_crds/acme/v1/Challenge.py", line 12, in <module>
        from pulumi_kubernetes import meta_v1 as _meta_v1
    ImportError: cannot import name 'meta_v1' from 'pulumi_kubernetes' (/home/abo/sandbox/pulumi-learn/venv/lib/python3.8/site-packages/pulumi_kubernetes/__init__.py)
    error: an unhandled error occurred: Program exited with non-zero exit code: 1

As far as I can see, there is no meta_v1 module in pulumi_kubernetes, it needs to do something like from pulumi_kubernetes.meta impart v1 as _meta_v1 instead.

@drzero42 drzero42 added the kind/bug Some behavior is incorrect or out of spec label Jul 12, 2021
@drzero42
Copy link
Author

Additional info:

Ubuntu 20.04
Python v3.8.10

@cleverguy25
Copy link

@pulumi-bot
Copy link

This issue has been addressed in PR #143 and shipped in release v1.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen Affects quality or correctness of generated code kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants