Skip to content

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Aug 26, 2025

Closes: #11727

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Aug 26, 2025

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
🦄 Changes detecting...

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/05502183dfbada678248f1b5930b4e7575f04315/gradio-5.44.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@05502183dfbada678248f1b5930b4e7575f04315#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/05502183dfbada678248f1b5930b4e7575f04315/gradio-client-1.17.1.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/05502183dfbada678248f1b5930b4e7575f04315/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Aug 26, 2025

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio minor

  • Support deploying to Google Cloud using gradio deploy --provider gcloud

‼️ Changeset not approved by maintainers. Ensure the version bump is appropriate for all packages before approving.

  • Maintainers can approve the changeset by selecting this checkbox.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs abidlabs changed the title Support deploying to Google Cloud using Support deploying to Google Cloud using gradio deploy --provider gcloud Aug 26, 2025
@@ -48,7 +48,7 @@ If you'd like to have a permanent link to your Gradio demo on the internet, use

After you have [created a free Hugging Face account](https://huggingface.co/join), you have two methods to deploy your Gradio app to Hugging Face Spaces:

1. From terminal: run `gradio deploy` in your app directory. The CLI will gather some basic metadata and then launch your app. To update your space, you can re-run this command or enable the Github Actions option to automatically update the Spaces on `git push`.
1. From terminal: run `gradio deploy` in your app directory. The CLI will gather some basic metadata, upload all the files in the current directory (respecting any `.gitignore` file that may be present in the root of the directory), and then launch your app on Spaces. To update your Space, you can re-run this command or enable the Github Actions option in the CLI to automatically update the Spaces on `git push`.
Copy link
Member Author

Choose a reason for hiding this comment

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

Added for #6470

@abidlabs abidlabs marked this pull request as ready for review August 28, 2025 21:12

if not project_result.stdout.strip():
print("[bold yellow]No Google Cloud project is selected.[/bold yellow]")
print("Running 'gcloud init' to select a project...")
Copy link

Choose a reason for hiding this comment

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

If no project is available, I suggest instead prompting for a project ID, instead of doing a full gcloud init.

Once we have the project ID from the user, we can pass it as --project argument to the gcloud run deploy command

)
return

if not os.path.exists("app.py"):
Copy link

Choose a reason for hiding this comment

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

We also look for main.py and take it if present. I suggest checking for either of these two files.

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Thanks for the pr @abidlabs ! Very slick. Huge kudos to the google cloud run team. Just two nits below

@@ -117,15 +119,141 @@ def format_title(title: str):
return title


def check_gcloud_auth():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just let the gcloud cli handle this?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you run gcloud deploy and you are not logged in, the error messaging is quite verbose and requires you to run several commands independently. I added this to a provide, imho, a better DX

return

requirements_file = "requirements.txt"
if not os.path.exists(requirements_file):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think if the requirements.txt file doesn't exist at all we might as well create it for them otherwise the deployment would fail

Copy link
Member Author

@abidlabs abidlabs Aug 28, 2025

Choose a reason for hiding this comment

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

I hesitate to create a file without user input. But you're right, it'll fail without it so I as part of de033a3, I make that clear now in the message and terminate deployment if a user says n.

@abidlabs
Copy link
Member Author

abidlabs commented Aug 28, 2025

Thanks for the reviews @steren and @freddyaboulton! Excited to have this as part of the gradio deploy workflow

I've addressed all of the comments and will merge in after CI is green

@abidlabs abidlabs merged commit 3393b70 into main Aug 28, 2025
23 of 25 checks passed
@abidlabs abidlabs deleted the gcloud-dep branch August 28, 2025 23:27
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.

Allow deploying to Google Cloud via gradio deploy
4 participants