notebook create

Create a notebook by referencing the notebook content with the required attributes (file-reference, name, project or space, and runtime or compute).

Syntax

cpd-cli notebook create \
[--compute=<saas-identifier>] \
[--context=<catalog-project-or-space-id>] \
[--cpd-config=<cpd-config-location>] \
[--description=<notebook-description>] \
--file-reference=<file-reference> \
[--jmes-query=<jmespath-query>] \
[--kernel=<notebook-kernel>] \
--name=<notebook-name> \
[--originates-from=<notebook-origin>] \
[--output=json|yaml|table] \
[--output-file=<output-file-location>] \
--profile=<cpd-profile-name> \
[--project=<cpd-project-id-for-notebook>] \
[--quiet] \
[--raw-output=true|false] \
[--runtime=<notebook-runtime>] \
[--space=<space-id>] \
[--verbose]

Arguments

The notebook create command has no arguments.

Options

Table 1: Command options
Option Description
--compute Specify the Spark-as-a-Service identifier that the notebook runs on.
Status
Optional.
Syntax
--compute=<saas-identifier>
Default value
No default.
Valid values
A valid Spark-as-a-Service identifier.
--context Specify the configuration context
 name.
Status
Optional.
Syntax
--context=<catalog-project-or-space-id>
Default value
Not applicable.
Valid values
A valid configuration context name.
--cpd-config The Cloud Pak for Data
 configuration location. For example, $HOME/.cpd-cli/config.
Status
Required.
Syntax
--cpd-config=<cpd-config-location>
Default value
$HOME/.cpd-cli/config
Valid values
A valid Cloud Pak for Data configuration location.
--description Specify a notebook
 description.
Status
Optional.
Syntax
--description=<notebook-description>
Default value
No default.
Valid values
A valid notebook description.
--file-reference Specify the reference to the file in the object storage.
Status
Required.
Syntax
--file-reference=<file-reference>
Default value
No default.
Valid values
A valid reference to a file in the object storage.

--help

-h

Display command help.
Status
Optional.
Syntax
--help
Default value
No default.
Valid values
Not applicable.
--jmes-query Provide a JMESPath query to customize the output.
Status
Optional.
Syntax
--jmes-query=<jmespath-query>
Default value
No default.
Valid values
A valid JMESPath query.
--kernel Specify the notebook kernel.
Status
Optional.
Syntax
--kernel=<notebook-kernel>
Default value
No default.
Valid values
A valid notebook kernel.
--output Specify an output format.
Status
Optional.
Syntax
--output=json|yaml|text
Default value
text
Valid values
Valid formats include JSON, YAML, or text (the default format).
--output-file Specify a file path where all output is redirected.
Status
Optional.
Syntax
--output-file=<output-file-location>
Default value
No default.
Valid values
A valid output file path location.
--profile The name of the profile that you created to store information about an instance of Cloud Pak for Data and your credentials for the instance.
Status
Required.
Syntax
--profile=<cpd-profile-name>
Default value
No default.
Valid values

The name of the profile that you created.

--project Specify a Cloud Pak for Data project instance to create the notebook on.
Status
Optional.
Syntax
--project=<cpd-project-id-for-notebook>
Default value
No default.
Valid values
Any valid project identifier.
--quiet Suppress verbose messages.
Status
Optional.
Syntax
--quiet
Default value
No default.
Valid values
Not applicable.
--raw-output When set to true, single values are not surrounded by quotation marks in
 JSON output mode.
Status
Optional.
Syntax
--raw-output=true|false
Default value
false
Valid values
false
Single values in JSON output mode are surrounded by quotation marks.
true
Single values in JSON output mode are not surrounded by quotation marks.
--runtime Specify the notebook runtime.
Status
Optional.
Syntax
--runtime=<notebook-runtime>
Default value
No default.
Valid values
A valid notebook runtime.
--space Specify the space identifier to create the notebook in.
Status
Optional.
Syntax
--space=<space-id>
Default value
No default.
Valid values
A valid space identifier.
--verbose Logs include more detailed messages.
Status
Optional.
Syntax
--verbose
Default value
No default.
Valid values
Not applicable.

Examples

Note: The following examples use environment variables. Use a script to create environment variables with the correct values for your environment. You can add the listed environment variables to the installation variables script. For more information, see Setting up installation environment variables.
Specify the environment variables in a script file.
file_name = "cpdctl-notebook.ipynb"
local_file_path = "cpdctl-notebook.ipynb"
remote_file_path = "notebook/cpdctl-notebook.ipynb"
runtime = {
    'environment': env_id
}
runtime_json = json.dumps(runtime)
originate = {
    'type': 'blank'
}
originate_json = json.dumps(originate)
Create a notebook asset.
cpd-cli notebook create \
--file-reference=${remote_file_path} \
--jmes-query="metadata.asset_id" \
--name=${file_name} \
--originates-from=${originate_json} \
--output=json \
--project=${PROJECT_CPD_INST_OPERANDS} \
--runtime=${runtime_json} \
--raw-output