NotebookJob
- class arcgis.notebook.NotebookJob(future, task_name, jobid=None, task_url=None, notify=False, gis=None)
represents an asynchronous job
- property elapse_time
Returns the amount of time that has passed while the
AsyncJob
ran.
create_snapshot
- arcgis.notebook.create_snapshot(item: Item, name: str, *, description: str | None = None, notebook_json: dict | None = None, access: bool = False, server_index: int | None = None) dict | SnapShot | SnapShot
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: Item, *, timeout: int = 50, update_portal_item: bool = True, parameters: list = None, save_parameters: bool = False, server_index: int = 0, gis: GIS = None, future: bool = False) dict | Future
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 Dictionary. Defines the 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 format of:
“x”:1 when defining number parameters
“y”:”text” when defining string parameters
See Prepare the Notebook for detailed explanation.
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.
Note
This is only available in ArcGIS Online.
future
Optional boolean.
If True, a Job object will be returned and the process runs asynchronously, allowing for other work to be done while processing completes.T
If False, which is the default, the process waits for results before continuing.
- Returns:
If future=False, a Python dictionary
If future = True, then the result is a concurrent.futures.Future object. Call result() on the object to get the response
#Usage example: Inserting parameters at execution time >>> from arcgis.gis import GIS >>> from arcgis.notebook import execute_notebook >>> gis = GIS( profile="your_online_admin_profile", verify_cert=False ) >>> nb_item = gis.content.search( query="air_quality_regular_updates", item_type="Notebook" )[0] # In the notebook cell tagged as parameters, the variables defined # with the below key values will be replaced by the value >>> execute_notebook( item=nb_item, parameters={ "file_path": r"/arcgis/home/aqi_data/", "num": 2, }, save_parameters=True )
list_runtimes
- arcgis.notebook.list_runtimes(gis: GIS = None) list
Returns a list of avaialable runtimes.
- Returns:
list[dict[str:str]]
list_snapshots
- arcgis.notebook.list_snapshots(item: Item) list
Returns all snapshots associated with a given item.
- Returns:
list