arcgis.notebook module

create_snapshot

arcgis.notebook.create_snapshot(item, name, *, description=None, notebook_json=None, access=False, server_index=None)

Creates a Snapshot of a Given Item.

Parameter

Description

item

Required Item. The ‘Notebook’ typed item to create a snapshot for.

name

Required String. The name of the snapshot. This is the identifier used to identify the snapshot.

description

Optional String. An piece of text that describes the snapshot.

notebook_json

Optional Dict. If you want to store different JSON text other than what is in the current notebook provide it here.

access

Optional Bool. When false, the snapshot will not be publicly available.

server_index

Optional Int. The ArcGIS Notebook server to use to run the notebook. This only applies to ArcGIS Enterprise.

Returns

Snapshot | dict (on error)

execute_notebook

arcgis.notebook.execute_notebook(item, *, timeout=50, update_portal_item=True, parameters=None, save_parameters=False, server_index=0, gis=None, future=False)

The Execute Notebook operation allows administrators and users with the Create and Edit Notebooks privilege to remotely run a notebook that they own. The notebook specified in the operation will be run with all cells in order.

Using this operation, you can schedule the execution of a notebook, either once or with a regular occurrence. This allows you to automate repeating tasks such as data collection and cleaning, content updates, and portal administration. On Linux machines, use a cron job to schedule the executeNotebook operation; on Windows machines, you can use the Task Scheduler app.

Note

To run this operation in ArcGIS Enterprise, you must log in with an Enterprise account. You cannot execute notebooks using the ArcGIS Notebook Server primary site administrator account.

Note

ArcGIS Online has additional parameters, as noted in the parameter table below.

You can specify parameters to be used in the notebook at execution time. If you’ve specified one or more parameters, they’ll be inserted into the notebook as a new cell. This cell will be placed at the beginning of the notebook, unless you have added the tag parameters to a cell.

Parameter

Description

item

Required Item. Opens an existing portal item.

update_portal_item

Optional Boolean. Specifies whether you want to update the notebook’s portal item after execution. The default is true. You may want to specify true when the notebook you’re executing contains information that needs to be updated, such as a workflow that collects the most recent version of a dataset. It may not be important to update the portal item if the notebook won’t store any new information after executing, such as an administrative notebook that emails reminders to inactive users.

parameters

Optional List. An optional array of parameters to add to the notebook for this execution. The parameters will be inserted as a new cell directly after the cell you have tagged parameters. Separate parameters with a comma. Use the format “x”:1 when defining parameters with numbers, and “y”:”text” when defining parameters with text strings.

save_parameters

Optional Boolean. Specifies whether the notebook parameters cell should be saved in the notebook for future use. The default is false.

timeout

Optional Int. The number of minutes to run the instance before timeout. This is only available on ArcGIS Online.

future

Optional boolean. If True, a Job object will be returned and the process will not wait for the task to complete. The default is False, which means wait for results.

Returns

Dict else If future = True, then the result is a concurrent.futures.Future object. Call result() to get the response

#Usage example

>>> from arcgis.gis import GIS
>>> from arcgis.notebook import execute_notebook

>>> gis = GIS(profile="your_org_profile")

>>> nb_item = gis.content.get("ac7b7792913b4b3c9b22da4e2c42f986")
>>> execute_notebook(nb_item)

list_runtimes

arcgis.notebook.list_runtimes(gis=None)

Returns a list of avaialable runtimes.

Returns

list[dict[str:str]]

list_snapshots

arcgis.notebook.list_snapshots(item)

Returns all snapshots associated with a given item.

Returns

list

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.