top of page

Python - Interactive Dash graph in Google Colaboratory

App Engine is a fully managed, serverless platform for developing and hosting web applications at scale. You can choose from several popular languages, libraries, and frameworks to develop your apps, and then let App Engine take care of provisioning servers and scaling your app instances based on demand.



1. CREATE APP


Create 2 new folders: in Mac in Finder, sarka

Create files: App, main and requirements in dash-gcp folder

Install GCP: in google-cloud-sdk folder


(base) sarkas-imac:~ sarka$ cd ~

(base) sarkas-imac:~ sarka$ python3 -m venv .venvs/dash

(base) sarkas-imac:~ sarka$ source .venvs/dash/bin/activate

(dash) (base) sarkas-imac:~ sarka$ mkdir dash-gcp && cd .

(dash) (base) sarkas-imac:~ sarka$ touch app.yaml

yaml file defines your configuration settings for your Python runtime as well as general app, network, and other resource settings.

(dash) (base) sarkas-imac:~ sarka$ touch main.py

(dash) (base) sarkas-imac:~ sarka$ pip install dash==0.36.0

(dash) (base) sarkas-imac:~ sarka$ pip install dash-core-components==0.43.0

(dash) (base) sarkas-imac:~ sarka$ pip install dash-table==3.1.11

(dash) (base) sarkas-imac:~ sarka$ pip install dash-daq==0.1.0

(dash) (base) sarkas-imac:~ sarka$ pip freeze > requirements.txt

(dash) (base) sarkas-imac:~ sarka$ ls

(dash) (base) sarkas-imac:~ sarka$ pwd

/Users/sarka

(dash) (base) sarkas-imac:~ sarka$ /Users/sarka/google-cloud-sdk/install.sh

(dash) (base) sarkas-imac:~ sarka$ /Users/sarka/google-cloud-sdk/bin/gcloud init

[4] Create a new project

Please enter numeric choice or text value (must exactly match list item): 7

$ gcloud projects create dash-1

(dash) (base) sarkas-imac:~ sarka$ pip install --upgrade dash-html-components

(dash) (base) sarkas-imac:~ sarka$ pip install --upgrade dash-core-components

(dash) (base) sarkas-imac:~ sarka$ pip install pandas

(dash) (base) sarkas-imac:~ sarka$ pip install dash

(dash) (base) sarkas-imac:~ sarka$ pip install jupyter_dash

(dash) (base) sarkas-imac:~ sarka$ pip install --upgrade dash dash-core-components dash-html-components dash-renderer


open app.yaml and save into the file: runtime: python37

open main.py and save into file: the main code



2. DEPLOY LOCAL


Run the main.py file.


(dash) (base) sarkas-imac:~ sarka$ python main.py


http://localhost:8050

http://127.0.0.1:8050/


local dashboard stays active only if i keep terminal open, press CTRL+C to abort it



3. DEPLOY TO GCP AND APP ENGINE


Set up GCP and APP engine.


(dash) (base) sarkas-imac:~ sarka$ ls /Users/sarka/google-cloud-sdk/bin/

https://console.cloud.google.com/home/dashboard?project=fluted-depth-345707&supportedpurview=project

(dash) (base) sarkas-imac:~ sarka$ /Users/sarka/google-cloud-sdk/bin/gcloud info

(dash) (base) sarkas-imac:~ sarka$ /Users/sarka/google-cloud-sdk/bin/gcloud app deploy

Please choose the region where you want your App Engine application located:

[10] europe-central2 (supports standard and flexible)

Creating App Engine application in project [python-dashboard-345707] and region [europe-central2]....done.

Services to deploy:


descriptor: [/Users/sarka/app.yaml]

source: [/Users/sarka]

target project: [python-dashboard-345707]

target service: [default]

target version: [20220330t100154]

target url: [https://python-dashboard-345707.lm.r.appspot.com]

target service account: [App Engine default service account]


(dash) (base) sarkas-imac:~ sarka$ /Users/sarka/google-cloud-sdk/bin/gcloud app browse

Opening [https://python-dashboard-345707.lm.r.appspot.com] in a new tab in your default browser.








References:


8 views0 comments

Recent Posts

See All

Python - sktime

There are various libraries created for Python Time Series. Each of them has its own style, contributors and functions. Each library has...

Comments


bottom of page