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

  1. 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.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Notebooks and Vertex AI APIs.

    Enable the APIs

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Notebooks and Vertex AI APIs.

    Enable the 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:

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

  1. Create a managed notebooks instance.

  2. Open JupyterLab.

  3. Open a new notebook file.

  4. 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())
    
  5. To make sure your notebook file is saved, select File > Save Notebook.

Schedule a run

  1. In the Google Cloud console, go to the Managed notebooks page.

    Go to Managed notebooks

  2. Next to the managed notebooks instance that you want to use, click Open JupyterLab.

    Your managed notebooks instance opens JupyterLab.

  3. In the  File Browser, double-click the example notebook file to open it.

  4. Click the  Execute button.

  5. 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.

  6. In Advanced options, select the Region where you want to run your notebook.

  7. 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.

  8. 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

  1. In JupyterLab's navigation menu, click the  Notebook Executor button.

  2. Click the Executions tab.

  3. Under the execution that you want to view, click View result.

    Executor opens your result in a new browser tab.

Share the execution results

  1. In your managed notebooks instance's JupyterLab user interface, in the navigation menu, click the  Notebook Executor button.

  2. Click the Executions tab.

  3. Next to the execution that you want to share, click the  options menu, and select Share execution result.

  4. Follow the directions in the dialog to grant users access to the execution result.

Import the executed notebook into JupyterLab

  1. In your managed notebooks instance's JupyterLab user interface, in the navigation menu, click the  Notebook Executor button.

  2. Click the Executions tab.

  3. Next to the execution that you want to import, click the  options menu, and select Import executed notebook.

  4. 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

  1. In the Google Cloud console, go to the Schedules page.

    Go to Schedules

  2. Select the Region where you want to see schedules.

  3. 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.

  4. Next to an execution name, click View result to open the executed notebook file.

    Executor opens your result in a new browser tab.

JupyterLab

  1. In your managed notebooks instance's JupyterLab user interface, in the navigation menu, click the  Notebook Executor button.

  2. Click the Schedules tab.

  3. 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

  1. In the Google Cloud console, go to the Schedules page.

    Go to Schedules

  2. Select the Region that contains the schedule that you want to delete.

  3. Select the schedule that you want to delete.

  4. Click  Delete.

JupyterLab

  1. In your managed notebooks instance's JupyterLab user interface, in the navigation menu, click the  Notebook Executor button.

  2. Click the Schedules tab.

  3. 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.

  4. 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

  1. In the Google Cloud console, go to the Managed notebooks page.

    Go to Managed notebooks

  2. Select the Region that contains your instance.

  3. Select the managed notebooks instance that you want to delete.

  4. 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.

  1. In the Google Cloud console, go to the Manage resources page.

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then click Delete.
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

What's next