Deploy a Python Visualization Panel App to Google Cloud Run

Sophia Yang · Intermediate ·☁️ DevOps & Cloud ·4y ago

Key Takeaways

Deploy a Python Visualization Panel App to Google Cloud Run using Google Cloud SDK, Cloud Build, and Terraform.

Full Transcript

hello everyone today i would like to talk about how to deploy a python app or dashboard to google cloud run with three simple scripts and also how to automate your google cloud setup through cloud build and terraform first let's set up our google cloud account the google cloud run documentation mentioned the following steps you need to do to enable running a project so first let's go to the project select selector you will need to create a new project here i created one called panel cloud run so i'm just gonna use this project for now i like to keep my project id the same as my project name so that i can keep track of my project um and then second you want to go to this link to confirm that billing is enabled and also then install the cloud sdk following this link so i have done all that so once we have uh downloaded the google cloud sdk you should be able to do gcloud in it to initialize the google cloud sdk on your local machine you can also do cloud config set project panel cloud run to set your current project to the project id you want it to be okay so that's it for the setup in terms of creating the app there are three scripts we need to create a panel app and then deploy it the first one app.pi this is the python file that creates the panel app to run this app locally you can simply do conda install panel edge replot and run panel serve app.pi second we have the requirements.txt which lists all the package dependencies of our panel app so for our panel app we only need panel bokeh and h3plot the third file we need is the docker file installs python and its project's dependencies and then run the commands panel serve app.pi to run our panel app okay with everything ready i have um so i have this repo in my local machine so i can just direct um myself into this folder this is the same thing and then to deploy my app i can simply run cloud run deploy we need to define the service folder and then let it run so after a few minutes you should see the service url showing up and then let's go to this url and take a look cool it seems working and then if we go to our dashboard and then go to the cloud rom uh so this is the information of the app we just deployed we can delete this one if we don't want this anymore and then this page should give us a 404. okay so the next thing i would like to talk about is to deploy app to google cloud run using terraform so when we did the gcloud run deploy we have to define the region of the project we also need to enable a bunch of services apis if we're running it the first time terraform can help us capture all those decisions in code so that can we have a place to see how the infrastructure is exactly doing and how it is set up to use terraform with google cloud round there are two parts part one is to use cloudbuild.yaml file to build a container image to execute your app with this cloudbuild.yml file we could simply do cloud builds submit to submit a build using google cloud build okay so here's the docker images we have under our project so right now we see there's no pro no docker image here but after a few minutes after this command finished running we should see a darker image now this finished running let's see if anything showed up so yeah so here we see a docker image uploaded to our container registry under the current project so that is part one part two part two is to use terraform so we have a file called main.pdf this is a terraform configuration file it does the following things first it creates a variable project for us so we we can define what project we want in the command line it enables the crowd the cloud round service it specifies the crowd run services for example we use the image that we just uploaded from from the cloud build in the cloud run service here we also set the service public and then we return our service url so this defines everything we need to be able to create and run a cloud run service okay so in order to run terraform first of all we need to if you're running it locally like i do you need to do con install conda forge terraform i already did that so let's see conda list terraform you can see i have terraform installed in my environment already and then we can do terraform in it to initialize terraform next we can do a terraform plan variable project equals your project name here i have piano crowd cloud run this gives us a chance to review your execution plan so you can see this is the things we're gonna do with our google cloud project and after we confirm everything looks good we can do terraform apply to the project we want so now we got another service url let's take a look cool now we have this app served again using terraform if you would like to remove the cloud run service you can also do terraform destroy or you can simply go to the project list and delete your project that's probably the safest way to to delete an app so that's it for today's video thank you so much for watching bye bye

Original Description

Deploy a Python Visualization Panel App to Google Cloud II: Google Cloud Run, Google Cloud Build, and Terraform In my last video, I talked about how to deploy a Python visualization Panel App to Google Cloud App Engine. App Engine works well, but it can be expensive because the app runs continuously whether anyone is using it or not. Luckily, there is a cheaper option called Cloud Run that only runs when receiving requests. In this video, I will walk you through how to deploy a Python app or dashboard to Google Cloud Run with three simple scripts, and also how to automate your Google Cloud setup via Cloud Build and Terraform. Article link: https://sophiamyang.medium.com/deploy-a-python-visualization-panel-app-to-google-cloud-ii-416e487b44eb?sk=aac35055957ba95641a6947bbb436410 Github link: https://github.com/sophiamyang/panel_cloud_run
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Sophia Yang · Sophia Yang · 5 of 60

1 Customer lifetime value in a discrete-time contractual setting (math and Python implementation)
Customer lifetime value in a discrete-time contractual setting (math and Python implementation)
Sophia Yang
2 Time series analysis using Prophet in Python — Math explained
Time series analysis using Prophet in Python — Math explained
Sophia Yang
3 Multiclass logistic/softmax regression from scratch
Multiclass logistic/softmax regression from scratch
Sophia Yang
4 Deploy a Python Visualization Panel App to Google Cloud App Engine
Deploy a Python Visualization Panel App to Google Cloud App Engine
Sophia Yang
Deploy a Python Visualization Panel App to Google Cloud Run
Deploy a Python Visualization Panel App to Google Cloud Run
Sophia Yang
6 [Read a paper (with code)] Beyond Accuracy: Behavioral Testing of NLP models with CheckList
[Read a paper (with code)] Beyond Accuracy: Behavioral Testing of NLP models with CheckList
Sophia Yang
7 5-step data science workflow
5-step data science workflow
Sophia Yang
8 Multi-armed bandit algorithms - ETC Explore then Commit
Multi-armed bandit algorithms - ETC Explore then Commit
Sophia Yang
9 Multi-armed bandit algorithms - Epsilon greedy algorithm
Multi-armed bandit algorithms - Epsilon greedy algorithm
Sophia Yang
10 User retention analysis framework | data science product sense
User retention analysis framework | data science product sense
Sophia Yang
11 Visualization and Interactive Dashboard in Python: My favorite Python Viz tools — HoloViz
Visualization and Interactive Dashboard in Python: My favorite Python Viz tools — HoloViz
Sophia Yang
12 Multi-armed bandit algorithms: Thompson Sampling
Multi-armed bandit algorithms: Thompson Sampling
Sophia Yang
13 The Easiest Way to Create an Interactive Dashboard in Python
The Easiest Way to Create an Interactive Dashboard in Python
Sophia Yang
14 Big Data Visualization Using Datashader in Python | How does Datashader work and why is it so fast?
Big Data Visualization Using Datashader in Python | How does Datashader work and why is it so fast?
Sophia Yang
15 Why do you want to be a data scientist? Don't be a data scientist if ...
Why do you want to be a data scientist? Don't be a data scientist if ...
Sophia Yang
16 Johnny Depp v Amber Heard Twitter Sentiment Analysis | Is Camille Vasquez the real winner | 🤗 NLP
Johnny Depp v Amber Heard Twitter Sentiment Analysis | Is Camille Vasquez the real winner | 🤗 NLP
Sophia Yang
17 How to build a product that sells itself | Product-led Growth | Book Summary | Read a book with me
How to build a product that sells itself | Product-led Growth | Book Summary | Read a book with me
Sophia Yang
18 Designing Machine Learning Systems | book summary | Read a book with me
Designing Machine Learning Systems | book summary | Read a book with me
Sophia Yang
19 Where do data scientists/analysts go next? Love and hate in data analytics (ft. Shashank Kalanithi)
Where do data scientists/analysts go next? Love and hate in data analytics (ft. Shashank Kalanithi)
Sophia Yang
20 Meet the Author: Fundamentals of Data Engineering | DS/ML book club
Meet the Author: Fundamentals of Data Engineering | DS/ML book club
Sophia Yang
21 What's new in hvPlot releases 0.8.0 & 0.8.1?
What's new in hvPlot releases 0.8.0 & 0.8.1?
Sophia Yang
22 Meet the Author: Machine Learning Design Patterns | What do ML/Research Engineers do at Google?
Meet the Author: Machine Learning Design Patterns | What do ML/Research Engineers do at Google?
Sophia Yang
23 Machine Learning Design Patterns | Google Executive | Investor | Meet the Author
Machine Learning Design Patterns | Google Executive | Investor | Meet the Author
Sophia Yang
24 How to solve data quality issues | Data Reliability | Meet the Author
How to solve data quality issues | Data Reliability | Meet the Author
Sophia Yang
25 Reliable Machine Learning author interview | DS/ML book club
Reliable Machine Learning author interview | DS/ML book club
Sophia Yang
26 Toronto VLOG | First vlog | Meet my favorite author | Toronto ML Summit conference
Toronto VLOG | First vlog | Meet my favorite author | Toronto ML Summit conference
Sophia Yang
27 TOP 6 tech news in 2022 #shorts
TOP 6 tech news in 2022 #shorts
Sophia Yang
28 How to deploy a Panel app to Hugging Face using Docker?
How to deploy a Panel app to Hugging Face using Docker?
Sophia Yang
29 Tech news this week | ChatGPT, Hacks, Snowflake, CES #shorts
Tech news this week | ChatGPT, Hacks, Snowflake, CES #shorts
Sophia Yang
30 🗞️ Tech news this week: ChatGPT, DreamerV3, Muse, VALL-E, Mineral, DoNotPay, Tesla, SBF... #shorts
🗞️ Tech news this week: ChatGPT, DreamerV3, Muse, VALL-E, Mineral, DoNotPay, Tesla, SBF... #shorts
Sophia Yang
31 Tech news this week | Boston Dynamics, Microsoft, Snowflake, Google, and more #shorts
Tech news this week | Boston Dynamics, Microsoft, Snowflake, Google, and more #shorts
Sophia Yang
32 The story of Metaflow | Effective Data Science Infrastructure | Book author interview
The story of Metaflow | Effective Data Science Infrastructure | Book author interview
Sophia Yang
33 Tech news this week #shorts
Tech news this week #shorts
Sophia Yang
34 A day in life of a data scientist | Data Day Texas | Interview 12 authors/speakers
A day in life of a data scientist | Data Day Texas | Interview 12 authors/speakers
Sophia Yang
35 Tech news this week #shorts
Tech news this week #shorts
Sophia Yang
36 Explainable AI with Shapley Values (Part 1: Game Theory)
Explainable AI with Shapley Values (Part 1: Game Theory)
Sophia Yang
37 Explainable AI with Shapley Values (Part 2: Estimate Shapley Values)
Explainable AI with Shapley Values (Part 2: Estimate Shapley Values)
Sophia Yang
38 Explainable AI with Shapley Values (Part 3: KernelSHAP)
Explainable AI with Shapley Values (Part 3: KernelSHAP)
Sophia Yang
39 Tech news this week | AI search war between Microsoft and Google #shorts
Tech news this week | AI search war between Microsoft and Google #shorts
Sophia Yang
40 The Story of ChatGPT's creator OpenAI | From Riches to Fame
The Story of ChatGPT's creator OpenAI | From Riches to Fame
Sophia Yang
41 Explainable AI for Practitioners | Must-read for XAI | author interview
Explainable AI for Practitioners | Must-read for XAI | author interview
Sophia Yang
42 Train your own language model with nanoGPT | Let’s build a songwriter
Train your own language model with nanoGPT | Let’s build a songwriter
Sophia Yang
43 The easiest way to work with large language models | Learn LangChain in 10min
The easiest way to work with large language models | Learn LangChain in 10min
Sophia Yang
44 The BEST browser? AI article summary, image generation, website insights. Microsoft Edge Copilot!
The BEST browser? AI article summary, image generation, website insights. Microsoft Edge Copilot!
Sophia Yang
45 startup scene in data | insights from 50+ data startups from Data Council
startup scene in data | insights from 50+ data startups from Data Council
Sophia Yang
46 NLP with Transformers author interview with Lewis Tunstall from Hugging Face
NLP with Transformers author interview with Lewis Tunstall from Hugging Face
Sophia Yang
47 4 ways to do question answering in LangChain | chat with long PDF docs | BEST method
4 ways to do question answering in LangChain | chat with long PDF docs | BEST method
Sophia Yang
48 5 Steps to Build a Question Answering PDF Chatbot: LangChain + OpenAI + Panel + HuggingFace.
5 Steps to Build a Question Answering PDF Chatbot: LangChain + OpenAI + Panel + HuggingFace.
Sophia Yang
49 4 Autonomous AI Agents: “Westworld” simulation, Camel, BabyAGI, AutoGPT, Camel ⭐ LangChain ⭐
4 Autonomous AI Agents: “Westworld” simulation, Camel, BabyAGI, AutoGPT, Camel ⭐ LangChain ⭐
Sophia Yang
50 MiniGPT4: image understanding & open-source!
MiniGPT4: image understanding & open-source!
Sophia Yang
51 BEST Practices in Prompt Engineering: Learnings and Thoughts from Andrew Ng's New Course
BEST Practices in Prompt Engineering: Learnings and Thoughts from Andrew Ng's New Course
Sophia Yang
52 Designing Machine Learning Systems author interview with Chip Huyen
Designing Machine Learning Systems author interview with Chip Huyen
Sophia Yang
53 Tech news this week: code interpreter, Mojo, Redpajama, MPT7b, StarCoder #shorts
Tech news this week: code interpreter, Mojo, Redpajama, MPT7b, StarCoder #shorts
Sophia Yang
54 🤗 Hugging Face Transformers Agent | LangChain comparisons
🤗 Hugging Face Transformers Agent | LangChain comparisons
Sophia Yang
55 📢 Tech news this week #shorts
📢 Tech news this week #shorts
Sophia Yang
56 📢 Tech news this week #shorts
📢 Tech news this week #shorts
Sophia Yang
57 The BEST ChatGPT Plugins | Brand NEW Bing Search | Web browsing, CODING, summarizing, and more
The BEST ChatGPT Plugins | Brand NEW Bing Search | Web browsing, CODING, summarizing, and more
Sophia Yang
58 Tech news this week #shorts #short
Tech news this week #shorts #short
Sophia Yang
59 📢 Tech news this week #shorts
📢 Tech news this week #shorts
Sophia Yang
60 Deep Learning with PyTorch Author Interview with Eli Stevens, Luca Antiga, and Thomas Viehmann
Deep Learning with PyTorch Author Interview with Eli Stevens, Luca Antiga, and Thomas Viehmann
Sophia Yang

This video teaches how to deploy a Python Visualization Panel App to Google Cloud Run using Google Cloud SDK, Cloud Build, and Terraform. It covers setting up a Google Cloud account, creating a Panel app, and automating deployment using Terraform.

Key Takeaways
  1. Create a new Google Cloud project
  2. Enable billing and install the Google Cloud SDK
  3. Create a Panel app using Python
  4. Define dependencies in requirements.txt
  5. Create a Dockerfile to containerize the app
  6. Deploy the app to Google Cloud Run using cloud run deploy
  7. Use Terraform to automate infrastructure setup
  8. Use Cloud Build to build a container image
💡 Terraform can be used to capture infrastructure decisions in code, making it easier to manage and reproduce deployments.

Related AI Lessons

Up next
Containers on Amazon ECS with Mama J
AWS Developers
Watch →