Ritu Gahir
Ritu Gahir

Reputation: 43

Run Managed notebook with Cloud function

Is it possible to start a specific .py file within a managed notebook using cloud functions in GCP ? I was hoping that there might be some kind of request sent to Vertex AI workbench from the Cloud Function, which will have details of which Notebook to trigger and also specify which .py file within this notebook to start. Does anyone has any idea ?

Upvotes: 1

Views: 388

Answers (1)

gogasca
gogasca

Reputation: 10048

Managed Notebooks kernels under the hood are just Docker containers. Each kernel correspond to a Deep Learning container

enter image description here

IIUC you will call a Cloud Function -> CF launches a new Managed Notebook and this Managed Notebook executes a Python file.

You have few options:

  1. Use REST API and create a new Managed Notebook using Post startup script.

https://cloud.google.com/vertex-ai/docs/workbench/reference/rest/v1/projects.locations.runtimes#RuntimeSoftwareConfig

  1. Execute the Python file using a container, this container is the same as the Managed Notebooks kernels. Pick the container from the link above. In this case you dont need the Managed Notebook instance
    docker run --name=cf-agent \
      --restart always \
      --net host \
      --pid host \
      gcr.io/deeplearning-platform-release/base-cu113.py310 \
    python3 /script.py
  1. Use Notebook Executor which provides an API. This will allow you to execute a Notebook (.ipynb) programatically. You would need to convert your .py file to .ipynb. In this case you dont need the Managed Notebook instance

https://cloud.google.com/vertex-ai/docs/workbench/reference/rest/v1/projects.locations.executions

Upvotes: 0

Related Questions