GoogleCloudPlatform / functions-framework-python

FaaS (Function as a service) framework for writing portable Python functions
https://pypi.org/p/functions-framework/
Apache License 2.0
856 stars 118 forks source link

Error when following Quickstart: Pub/Sub emulator #177

Closed leo-padron closed 2 years ago

leo-padron commented 2 years ago

I'm following the instructions exactly as described in Functions Framework for Python -Quickstart: Pub/Sub emulator

But I run these steps:

image

I get this error:

image

grant commented 2 years ago

This is not parsing the command correctly.

I think you need to write "create-push" instead of create-push for this to work properly.

grant commented 2 years ago

Part of docs: https://github.com/GoogleCloudPlatform/functions-framework-python#quickstart-pubsub-emulator

@anguillanneuf, can you triage this issue since you added these docs?

anguillanneuf commented 2 years ago

@leo-padron I wasn't able to reproduce the error you are seeing.

This is what I get:

tianzi 14:32 snippets % python subscriber.py tz-playground-bigdata create-push one yiyi http://localhost:8080          (main)
Push subscription created: name: "projects/tz-playground-bigdata/subscriptions/yiyi"
topic: "projects/tz-playground-bigdata/topics/one"
push_config {
  push_endpoint: "http://localhost:8080"
}
ack_deadline_seconds: 10
message_retention_duration {
  seconds: 604800
}
.
Endpoint for subscription is: http://localhost:8080

I suspect $TOPIC_ID and $PUSH_SUBSCRIPTION_ID aren't populated in your case. Could you check? Thanks for your patience.

BoHuang2018 commented 2 years ago

I have a question for the paragraph of using PubSub Emulator

Above the example function, def hello(event, context):, there is no decorator like @functions_framework.cloud_event.

@leo-padron Is this the reason for your error ?

grant commented 2 years ago

There is no decorator for event, just cloud_event - which is preferred.

I'm going to close this as both Tianzi and myself couldn't repro the issue and I believe there's just a user-error typo.