Schedule a notebook run
This page shows you how to use the Vertex AI Workbench 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
Notebooks Viewer (roles/notebooks.viewer
)
IAM role on the project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to interact with the Vertex AI Workbench executor. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to interact with the Vertex AI Workbench executor:
-
To list executions:
notebooks.executions.list
Your administrator might also be able to give your instance's service account these permissions with custom roles or other predefined roles.
Create an 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 Instances page.
Next to your instance's name, click Open JupyterLab.
Your Vertex AI Workbench 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, enter a name for your bucket in the Cloud Storage bucket field, 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 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.
The executor opens your result in a new browser tab.
Share the execution results
In your 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 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 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.
For the schedule that you want to view, 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.
The executor opens your result in a new browser tab.
JupyterLab
In your 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.
The 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 schedule that you want to delete.
Click
Delete.
JupyterLab
In your instance's JupyterLab user interface, in the navigation menu, click the Notebook Executor button.
Click the Schedules tab.
Click the schedule name. 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 Instances page.
Select the instance that you want to delete.
Click
Delete.
Delete the project
If you used resources outside of your Vertex AI Workbench 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.