-
Notifications
You must be signed in to change notification settings - Fork 3k
Support deploying to Google Cloud using gradio deploy --provider gcloud
#11776
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
Conversation
🪼 branch checks and previews
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> |
🦄 change detectedThis Pull Request includes changes to the following packages.
|
gradio deploy --provider gcloud
@@ -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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added for #6470
gradio/cli/commands/deploy_space.py
Outdated
|
||
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...") |
There was a problem hiding this comment.
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
gradio/cli/commands/deploy_space.py
Outdated
) | ||
return | ||
|
||
if not os.path.exists("app.py"): |
There was a problem hiding this comment.
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.
There was a problem hiding this 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(): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
Thanks for the reviews @steren and @freddyaboulton! Excited to have this as part of the I've addressed all of the comments and will merge in after CI is green |
Closes: #11727