Schedule a managed notebooks run
This page shows you how to use the Vertex AI Workbench managed notebooks executor to run a Python notebook file on an hourly schedule.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Notebooks and Vertex AI APIs.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Notebooks and Vertex AI APIs.
Required roles
To ensure that your instance's service account has the necessary permissions to interact with the Vertex AI Workbench executor, ask your administrator to grant your instance's service account the following IAM roles on the project:
-
Notebooks Viewer (
roles/notebooks.viewer
) -
Vertex AI User (
roles/aiplatform.user
) -
Storage Admin (
roles/storage.admin
)
For more information about granting roles, see Manage access to projects, folders, and organizations.
Your administrator might also be able to give your instance's service account the required permissions through custom roles or other predefined roles.
Create a managed notebooks instance and example notebook file
In the first cell of the notebook file, enter the following:
# Import datetime import datetime # Get the time and print it datetime.datetime.now() print(datetime.datetime.now())
To make sure your notebook file is saved, select File > Save Notebook.
Schedule a run
In the Google Cloud console, go to the Managed notebooks page.
Next to the managed notebooks instance that you want to use, click Open JupyterLab.
Your managed notebooks instance opens JupyterLab.
In the
File Browser, double-click the example notebook file to open it.Click the Execute button.
In the Submit notebooks to Executor dialog, in the Type field, select Schedule-based recurring executions.
By default, the executor runs your notebook file every hour at the
00
minute of the hour.In Advanced options, select the Region where you want to run your notebook.
In the Cloud Storage bucket field, enter a name for your bucket, and then click Create and select. The executor stores your notebook output in the Cloud Storage bucket.
Click Submit.
Your notebook file runs automatically on the schedule that you set.
When you finish the tasks that are described in this document, you can avoid continued billing by deleting the resources that you created. For more information, see Clean up.
View, share, and import an executed notebook file
By using your managed notebooks instance's JupyterLab interface, you can view your notebook output, share the results with others, and import the executed notebook file into JupyterLab.
View the execution results
In JupyterLab's navigation menu, click the Notebook Executor button.
Click the Executions tab.
Under the execution that you want to view, click View result.
Executor opens your result in a new browser tab.
Share the execution results
In your managed notebooks instance's JupyterLab user interface, in the navigation menu, click the Notebook Executor button.
Click the Executions tab.
Next to the execution that you want to share, click the
options menu, and select Share execution result.Follow the directions in the dialog to grant users access to the execution result.
Import the executed notebook into JupyterLab
In your managed notebooks instance's JupyterLab user interface, in the navigation menu, click the Notebook Executor button.
Click the Executions tab.
Next to the execution that you want to import, click the
options menu, and select Import executed notebook.If the Select Kernel dialog appears, select the kernel that you want to open the notebook.
The executor opens the executed notebook file in JupyterLab, and stores this notebook file in the JupyterLab File Browser in a folder named imported_notebook_jobs.
View or delete a schedule
You can view and delete schedules by using either the Google Cloud console or your managed notebooks instance's JupyterLab user interface.
View a schedule
View a schedule to see the frequency settings of the schedule or to view the five most recent results of the notebook file execution.
Console
In the Google Cloud console, go to the Schedules page.
Select the Region where you want to see schedules.
For the Schedule details page that you want to open, click its schedule name.
On the Schedule details page, you can view the schedule's last five executions.
Next to an execution name, click View result to open the executed notebook file.
Executor opens your result in a new browser tab.
JupyterLab
In your managed notebooks instance's JupyterLab user interface, in the navigation menu, click the Notebook Executor button.
Click the Schedules tab.
Under the execution that you want to view, click View latest execution result.
Executor opens your result in a new browser tab.
Delete a schedule
Deleting a schedule doesn't delete the executions that were generated from that schedule.
Console
In the Google Cloud console, go to the Schedules page.
Select the Region that contains the schedule that you want to delete.
Select the schedule that you want to delete.
Click
Delete.
JupyterLab
In your managed notebooks instance's JupyterLab user interface, in the navigation menu, click the Notebook Executor button.
Click the Schedules tab.
At the end of the schedule name, click the
Open in new icon. The Schedule details page for that schedule opens in the Google Cloud console.Click
Delete.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
Delete the instance
In the Google Cloud console, go to the Managed notebooks page.
Select the Region that contains your instance.
Select the managed notebooks instance that you want to delete.
Click
Delete.
Delete the project
If you used resources outside of your managed notebooks instance, such as the Cloud Storage bucket required for creating a schedule, you might want to delete your project to avoid incurring additional charges.
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
What's next
- Learn more about creating a managed notebooks instance.