google.cloud.gcp_colab_notebook_execution module – Creates a GCP Colab.NotebookExecution resource
Note
This module is part of the google.cloud collection (version 1.13.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install google.cloud.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: google.cloud.gcp_colab_notebook_execution.
Synopsis
‘An instance of a notebook Execution’
Requirements
The below requirements are needed on the host that executes this module.
python >= 3.8
requests >= 2.18.4
google-auth >= 2.25.1
Parameters
Parameter |
Comments |
|---|---|
The access token used to authenticate. |
|
The type of credential used. Choices:
|
|
Compute configuration to use for an execution job. |
|
‘The machine configuration of the runtime.’. |
|
The number of accelerators used by the runtime. |
|
The type of hardware accelerator used by the runtime. If specified, acceleratorCount must also be specified. |
|
The Compute Engine machine type selected for the runtime. |
|
The network configuration for the runtime. |
|
Enable public internet access for the runtime. Choices:
|
|
The name of the VPC that this runtime is in. |
|
The name of the subnetwork that this runtime is in. |
|
The configuration for the data disk of the runtime. |
|
The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. |
|
The type of the persistent disk. |
|
The Dataform Repository containing the input notebook. |
|
The commit SHA to read repository with. If unset, the file will be read at HEAD. |
|
The resource name of the Dataform Repository. |
|
The content of the input notebook in ipynb format. |
|
The base64-encoded contents of the input notebook file. |
|
The display name of the Notebook Execution. |
|
Specifies which Ansible environment you’re running this module within. This should not be set unless you know what you’re doing. This only alters the User Agent string for any API requests. |
|
Max running time of the execution job in seconds (default 86400s / 24 hrs). |
|
The user email to run the execution as. |
|
The Cloud Storage uri for the input notebook. |
|
The version of the Cloud Storage object to read. If unset, the current version of the object is read. See https://cloud.google.com/storage/docs/metadata#generation-number. |
|
The Cloud Storage uri pointing to the ipynb file. |
|
The Cloud Storage location to upload the result to. Format:`gs://bucket-name`. |
|
The location for the resource: https://cloud.google.com/colab/docs/locations. |
|
User specified ID for the Notebook Execution Job. |
|
The NotebookRuntimeTemplate to source compute configuration from. |
|
The Google Cloud Platform project to use. |
|
Array of scopes to be used. |
|
The service account to run the execution as. |
|
The contents of a Service Account JSON file, either in a dictionary or as a JSON string that represents it. |
|
An optional service account email address if machineaccount is selected and the user does not wish to use the default email. |
|
The path of a Service Account JSON file if serviceaccount is selected as type. |
|
Whether the resource should exist in GCP. Choices:
|
Notes
Note
API Reference: https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.notebookExecutionJobs
Schedule a notebook run Guide: https://cloud.google.com/colab/docs/schedule-notebook-run
For authentication, you can set auth_kind using the
GCP_AUTH_KINDenv variable.For authentication, you can set service_account_file using the
GCP_SERVICE_ACCOUNT_FILEenv variable.For authentication, you can set service_account_contents using the
GCP_SERVICE_ACCOUNT_CONTENTSenv variable.For authentication, you can set service_account_email using the
GCP_SERVICE_ACCOUNT_EMAILenv variable.For authentication, you can set access_token using the
GCP_ACCESS_TOKENenv variable.For authentication, you can set scopes using the
GCP_SCOPESenv variable.Environment variables values will only be used if the playbook values are not set.
The
service_account_email,service_account_file,service_account_fileandaccess_tokenoptions are mutually exclusive.
Examples
- name: Create Basic Notebook Execution
vars:
nb_config:
cells:
- cell_type: code
execution_count: null
metadata: {}
outputs: []
source:
- print('Hello, World!')
metadata:
kernelspec:
display_name: Python 3
language: python
name: python3
language_info:
codemirror_mode:
name: ipython
version: 3
file_extension: .py
mimetype: text/x-python
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.8.5
nbformat: 4
nbformat_minor: 4
google.cloud.gcp_colab_notebook_execution:
state: present
display_name: my-notebook-execution
location: us-central1
direct_notebook_source:
content: "{{ nb_config | to_json | b64encode }}"
notebook_runtime_template_resource_name: projects/{{ gcp_project }}/locations/us-central1/notebookRuntimeTemplates/my-runtime-template
gcs_output_uri: gs://my-bucket
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
################################################################################
- name: Create Notebook Execution With Custom Environment
vars:
nb_config:
cells:
- cell_type: code
execution_count: null
metadata: {}
outputs: []
source:
- print('Hello, World!')
metadata:
kernelspec:
display_name: Python 3
language: python
name: python3
language_info:
codemirror_mode:
name: ipython
version: 3
file_extension: .py
mimetype: text/x-python
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.8.5
nbformat: 4
nbformat_minor: 4
google.cloud.gcp_colab_notebook_execution:
state: present
display_name: my-notebook-execution
location: us-central1
direct_notebook_source:
content: "{{ nb_config | to_json | b64encode }}"
notebook_runtime_template_resource_name: projects/{{ gcp_project }}/locations/us-central1/notebookRuntimeTemplates/my-runtime-template
custom_environment_spec:
machine_spec:
machine_type: n1-standard-4
accelerator_type: NVIDIA_TESLA_T4
accelerator_count: 1
persistent_disk_spec:
disk_type: pd-standard
disk_size_gb: 100
network_spec:
enable_internet_access: true
network: "projects/{{ gcp_project }}/global/networks/my-network"
gcs_output_uri: gs://my-bucket
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
################################################################################
- name: Create Notebook Execution With Dataform Repository Source
google.cloud.gcp_colab_notebook_execution:
state: present
display_name: my-notebook-execution
location: us-central1
dataform_repository_source:
commit_sha: deadbeef
dataform_repository_resource_name: projects/{{ gcp_project }}/locations/us-central1/dataform/repositories/my-dataform-repository
notebook_runtime_template_resource_name: projects/{{ gcp_project }}/locations/us-central1/notebookRuntimeTemplates/my-runtime-template
gcs_output_uri: gs://my-bucket
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Whether the resource was changed. Returned: always |
|
The current state of the resource. Returned: always |