pulumi / pulumi-ai

222 stars 15 forks source link

Using service_registries with py in ecs.Service #77

Open caffeinate opened 3 months ago

caffeinate commented 3 months ago

using ecs.Service(..)

This arg- service_registries=[ecs.ServiceServiceRegistriesArgs(registry_arn=http_namespace.arn)],

causes- AssertionError: Unexpected type. Expected 'list' got '<class 'pulumi_aws.ecs._inputs.ServiceServiceRegistriesArgs'>'

The service_registries are being supplied as a list.

Expected behavior

This code was used as a starting point- https://www.pulumi.com/ai/answers/1eTQsUEuD7z6y4iEJWxa3d/implementing-service-discovery-for-ai-workloads-on-aws-ecs

I've reduced the original plan to used exactly the same servicediscovery.HttpNamespace as in the example code.

Current behavior

Throws an exception.

Steps to reproduce

I'm using Pulumi 3.109.0 and pulumi_aws 6.25.0

  1. This commit https://github.com/Aye-Aye-Dev/Aye-Aye-Recipes/commit/c66a3dc0ff347f84aaad9c90fd3b57a10c192f60
  2. Uncomment line 193 of aws_fargate/cluster/main.py
  3. pulumi up

Context (Environment)

Make the IP addresses (ideally using PrivateDnsNamespace available to another ECS service).

Affected feature

iwahbe commented 3 months ago

Hi @caffeinate. I'm sorry you're hitting that. It's definitely confusing. The correct type for service_registries is ecs.ServiceServiceRegistriesArgs (docs):

https://github.com/pulumi/pulumi-aws/blob/b82e03002e0c3b7bdc584fae396d7de7d4c7729d/sdk/python/pulumi_aws/ecs/service.py#L42

Could you provide the line number for the assertion error? If that's coming from Pulumi code, we would like to fix the error.

AaronFriel commented 3 months ago

Hey, sorry about that - it looks like in this case we need to improve our retrieval augmented generation for Pulumi AI. I'll move this to the AI repo, though I think we won't have an immediate fix for this.

@iwahbe is correct, the right code should be service_registries=aws.ecs.ServiceServiceRegistriesArgs.

caffeinate commented 3 months ago

Just to confirm- If I use a list as per the example I get the assertion error which originates from-

     File "/Users/si/.local/share/virtualenvs/aws_fargate-vnPX2j61/lib/python3.10/site-packages/pulumi/runtime/rpc.py", line 168, in _get_list_element_type
        raise AssertionError(f"Unexpected type. Expected 'list' got '{typ}'")

If I use a single ServiceServiceRegistriesArgs I get-

**error: 1 error occurred:

The ARN is from this-

http_namespace = servicediscovery.HttpNamespace(
    "fossa_http_namespace",
    name="fossa_workloads",
    description="HTTP Namespace for Fossa",
)

Which is pretty close to the example.

Thanks for looking into this.

AaronFriel commented 3 months ago

@caffeinate We've just shipped some improvements here to the prompting for list types. Due to the search issues mentioned before, though, I'm not confident it would result in better code generation here. We're tracking an issue for improving resource retrieval and grounding results.

caffeinate commented 3 months ago

Thanks @AaronFriel , I can confirm that this hasn't yet solved it for me.