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

Updated python example #1361

Merged
merged 4 commits into from
Nov 1, 2023
Merged

Updated python example #1361

merged 4 commits into from
Nov 1, 2023

Conversation

j-antunes
Copy link
Contributor

I tried the python example and it is not working out of the box. The main issue that I was facing is:

google.api_core.exceptions.BadRequest: 400 GET https://storage.googleapis.com/storage/v1/b?project=test&projection=noAcl&prettyPrint=false: Invalid project number: 0. Project id: 0 is invalid or not found

I think the issue has to do with not setting the api_endpoint for the docker container.

The solution is to add

    client_options={"api_endpoint": "http://localhost:4443"},

Apart from that I added some instructions as to how to run this example.

Copy link
Owner

@fsouza fsouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instructions on how to run the example can be derived from the CI script that executes the example in GHA. Can you update the comment to reflect that and undo the client_options step? Otherwise, this breaks CI.

@j-antunes
Copy link
Contributor Author

@fsouza - I followed you suggestion and update my example.

I added this line
os.environ["STORAGE_EMULATOR_HOST"] = os.environ.get( "STORAGE_EMULATOR_HOST", "http://localhost:4443" )

That should help to make this example more clear without breaking your CI. This tries to get the value of the STORAGE_EMULATOR_HOST environment variable. If it doesn't exist, it provides a default value of "http://localhost:4443/".

When you run your CI, you set this value, so it will use localhost:8080, if running just the python script with the instructions it will set to localhost:4443

examples/python/python.py Outdated Show resolved Hide resolved
fsouza

This comment was marked as outdated.

Copy link
Owner

@fsouza fsouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

examples/python/python.py Outdated Show resolved Hide resolved
@fsouza fsouza merged commit fa4c7dc into fsouza:main Nov 1, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants