https://pulumi.com logo
Docs
Join the conversationJoin Slack
Channels
announcements
automation-api
aws
azure
blog-posts
built-with-pulumi
cloudengineering
cloudengineering-support
content-share
contribex
contribute
docs
dotnet
finops
general
getting-started
gitlab
golang
google-cloud
hackathon-03-19-2020
hacktoberfest
install
java
jobs
kubernetes
learn-pulumi-events
linen
localstack
multi-language-hackathon
office-hours
oracle-cloud-infrastructure
plugin-framework
pulumi-cdk
pulumi-crosscode
pulumi-deployments
pulumi-kubernetes-operator
pulumi-service
pulumiverse
python
registry
status
testingtesting123
testingtesting321
typescript
welcome
workshops
yaml
Powered by Linen
python
  • s

    steep-alligator-79173

    08/28/2020, 8:21 PM
    File "./arc_repos.py", line 72
            requests.get("<https://gitlab.com>")
            ^
        SyntaxError: invalid syntax
        error: an unhandled error occurred: Program exited with non-zero exit code: 1
  • s

    steep-alligator-79173

    08/28/2020, 8:22 PM
    Just make a note that im learning python as well 🙂 in the same time
  • m

    microscopic-pilot-97530

    08/28/2020, 8:28 PM
    I don’t believe Python support multi-statement lambdas. You’ll need to define a separate function.
  • g

    green-school-95910

    08/28/2020, 8:30 PM
    I think it is possible if you butcher the language and abuse the interpreter tokenizer
  • g

    green-school-95910

    08/28/2020, 8:30 PM
    But those are some very dark and heretic thoughts
  • m

    microscopic-pilot-97530

    08/28/2020, 8:30 PM
    Yes
  • m

    microscopic-pilot-97530

    08/28/2020, 8:31 PM
    @steep-alligator-79173, you’ll need to do something like the following, per @green-school-95910:
    def function_that_receives_the_id(repo_id):
        print(f"<https://gitlab.com/api/v4/projects/{repo_id}/environments>")
        requests.get("<https://gitlab.com>")
        return repo_id
    
    repo_id = gitlab_repo.id.apply(function_that_receives_the_id)
  • g

    green-school-95910

    08/28/2020, 8:33 PM
    I think you don't need to return anything in this case. If there is something on the response of the request that is useful you might return it, but not the repo_id
  • s

    steep-alligator-79173

    08/28/2020, 8:33 PM
    repo_id = gitlab_repo.id.apply(lambda repo_id:
          <http://requests.post|requests.post>(f"<https://gitlab.com/api/v4/projects/{repo_id}/environments>",
            data={
              "name": "dev",
              "state": "available"
            },
            headers={
              "PRIVATE-TOKEN": "xxxxx"
            }
          )
        )
  • s

    steep-alligator-79173

    08/28/2020, 8:33 PM
    pulumi:pulumi:Stack (gitlab-repos-dev):
        error: Program failed with an unhandled exception:
        error: Traceback (most recent call last):
          File "/usr/local/bin/pulumi-language-python-exec", line 85, in <module>
            loop.run_until_complete(coro)
          File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
            return future.result()
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 83, in run_in_stack
            await run_pulumi_func(lambda: Stack(func))
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
            await RPC_MANAGER.rpcs.pop()
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/rpc_manager.py", line 67, in rpc_wrapper
            result = await rpc
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/resource.py", line 435, in do_register_resource_outputs
            serialized_props = await rpc.serialize_properties(outputs, {})
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/rpc.py", line 71, in serialize_properties
            result = await serialize_property(v, deps, input_transformer)
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/rpc.py", line 176, in serialize_property
            value = await serialize_property(output.future(), deps, input_transformer)
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/rpc.py", line 163, in serialize_property
            return await serialize_property(future_return, deps, input_transformer)
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/rpc.py", line 204, in serialize_property
            obj[transformed_key] = await serialize_property(v, deps, input_transformer)
          File "/Users/pawelmadon/git/qtx/arc/repos/venv/lib/python3.8/site-packages/pulumi/runtime/rpc.py", line 210, in serialize_property
            raise ValueError(f"unexpected input of type {type(value).__name__}")
        ValueError: unexpected input of type timedelta
        error: an unhandled error occurred: Program exited with non-zero exit code: 1
  • s

    steep-alligator-79173

    08/28/2020, 8:33 PM
    im getting this
  • g

    green-school-95910

    08/28/2020, 8:34 PM
    Because of the return value. The return value of the function is wrapped into a new Output, so it must be compatible
  • g

    green-school-95910

    08/28/2020, 8:34 PM
    environments = gitlab_repo.id.apply(lambda repo_id:
          <http://requests.post|requests.post>(f"<https://gitlab.com/api/v4/projects/{repo_id}/environments>",
            data={
              "name": "dev",
              "state": "available"
            },
            headers={
              "PRIVATE-TOKEN": "xxxxx"
            }
          ).json() # <= This will get the json response as a dictionary
        )
  • g

    green-school-95910

    08/28/2020, 8:35 PM
    And I changed the name of the variable to avoid confusion. The return value of apply is the Output wrapping the return of the function, so it is no longer the repo id
  • s

    steep-alligator-79173

    08/28/2020, 8:38 PM
    $ pulumi up                                                                                                                                                                                          ‹ruby-2.6.0›
    Enter your passphrase to unlock config/secrets
        (set PULUMI_CONFIG_PASSPHRASE to remember): 
    Previewing update (dev):
         Type                 Name              Plan     
         pulumi:pulumi:Stack  gitlab-repos-dev           
     
    Resources:
        37 unchanged
    
    Do you want to perform this update? yes
    Updating (dev):
       Type  Name  Status     
     
    Resources:
        37 unchanged
    
    Duration: 21s
  • s

    steep-alligator-79173

    08/28/2020, 8:38 PM
    @green-school-95910 working !
  • s

    steep-alligator-79173

    08/28/2020, 8:38 PM
    thx for the help
  • s

    steep-alligator-79173

    08/28/2020, 8:38 PM
    I’ve learned 🙂
  • s

    steep-alligator-79173

    08/28/2020, 8:41 PM
    I am grateful for your help and for your time !
  • g

    green-school-95910

    08/28/2020, 8:41 PM
    You're welcome, glad to help
  • h

    hallowed-beach-15050

    08/29/2020, 4:40 AM
    so… confused AF… using gitlab I am caching the venv and my stuff fails consistently. Remove the cache, and it works consistently…
    m
    • 2
    • 1
  • h

    hallowed-beach-15050

    08/29/2020, 4:40 AM
    is there something I am missing?
  • h

    hallowed-beach-15050

    08/29/2020, 4:41 AM
    stages:
      - Preview
      - Production Gate
      - Deploy Production
    
    Preview:
      stage: Preview
      image: &img pulumi/pulumi-python:2.9.1
      script:
        - pulumi login --cloud-url <s3://openraven-pulumi-state/internal>
        - pulumi stack select internal
        - python3 -m venv ${CI_PROJECT_DIR}/venv
        - ${CI_PROJECT_DIR}/venv/bin/python -m pip install --upgrade pip setuptools wheel
        - ${CI_PROJECT_DIR}/venv/bin/python -m pip install -r requirements.txt
        - pulumi preview --diff --non-interactive --color=never
      # Yes, I tried to cache the venv... no I don't understand why it blows up when I do...
  • h

    hallowed-beach-15050

    08/29/2020, 4:41 AM
    i was doing ``````
  • h

    hallowed-beach-15050

    08/29/2020, 4:41 AM
    cache:
        paths:
        - venv
  • h

    hallowed-beach-15050

    08/30/2020, 6:37 AM
    Ugh. this is my weekend for bugs…
  • h

    hallowed-beach-15050

    08/30/2020, 6:38 AM
    seeing an issue where a parameter that is supposed to accept a
    dict
    but instead complains that it wants a list…
  • h

    hallowed-beach-15050

    08/30/2020, 6:38 AM
    raise AssertionError(f"Unexpected type. Expected 'list' got '{typ}'")
        AssertionError: Unexpected type. Expected 'list' got '<class 'str'>'
    m
    • 2
    • 8
  • h

    hallowed-beach-15050

    08/30/2020, 6:40 AM
    in this case it is the parameters to a cloudformation stack but saw the same issue with thresholds on a datadog monitor
  • d

    damp-elephant-82829

    08/30/2020, 8:27 AM
    When using Pulumi in python, is there a naming convention for multiple files setup? Is there a file pulumi will start from?
Powered by Linen
Title
d

damp-elephant-82829

08/30/2020, 8:27 AM
When using Pulumi in python, is there a naming convention for multiple files setup? Is there a file pulumi will start from?
View count: 1