GithubHelp home page GithubHelp logo

plot-clusters-demo's Introduction

Instructions

Run app locally

  1. Clone/upload this folder (plot-clusters-demo) to Cloud Shell, or use Cloud Shell Editor. The important files are:
  • app.py
  • requirements.txt
  • Dockerfile
  • data/clusters.csv
  1. Setup the Python virtual environment:

In Cloud Shell, execute the following commands:

python3 -m venv plot-clusters-demo-env
source plot-clusters-demo-env/bin/activate
pip install -r requirements.txt
  1. Setup environment variables:

In Cloud Shell, execute the following commands:

export GCP_PROJECT=<PROJECT_ID>
export GCP_REGION='us-central1'
  1. To run the application locally, execute the following command:

In Cloud Shell, execute the following command:

streamlit run app.py \
  --browser.serverAddress=localhost \
  --server.enableCORS=false \
  --server.enableXsrfProtection=false \
  --server.port 8080
  1. View the output at http://localhost:8080

Build/deploy the app to Cloud Run

  1. Setup environment variables:

    In Cloud Shell, execute the following commands:

    export GCP_PROJECT=<PROJECT_ID>
    export GCP_REGION='us-central1'
  2. Build the Docker image for the application and push it to Artifact Registry

    In Cloud Shell, execute the following commands:

    export AR_REPO='plot-clusters-repo'  # Dashes, no underscores
    export SERVICE_NAME='plot-clusters-demo' # Dashes, no underscores
    
    #make sure you are in the active directory for 'plot-clusters-demo'
    gcloud artifacts repositories create "$AR_REPO" --location="$GCP_REGION" --repository-format=Docker
    gcloud builds submit --tag "$GCP_REGION-docker.pkg.dev/$GCP_PROJECT/$AR_REPO/$SERVICE_NAME"
  3. Deploy the service in Cloud Run with the image that we had built and had pushed to the Artifact Registry in the previous step:

    In Cloud Shell, execute the following command:

    gcloud run deploy "$SERVICE_NAME" \
      --port=8080 \
      --image="$GCP_REGION-docker.pkg.dev/$GCP_PROJECT/$AR_REPO/$SERVICE_NAME" \
      --allow-unauthenticated \
      --region=$GCP_REGION \
      --platform=managed  \
      --project=$GCP_PROJECT \
      --set-env-vars=GCP_PROJECT=$GCP_PROJECT,GCP_REGION=$GCP_REGION
    
  4. View the output at https://plot-clusters-demo-qrscbr27oa-uc.a.run.app/

plot-clusters-demo's People

Contributors

wpok-google avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.