arcgis.notebook module
NotebookJob
- classarcgis.notebook.NotebookJob(future,task_name,jobid=None,task_url=None,notify=False,gis=None)
represents an asynchronous job
- propertyelapse_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 identifierused 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 otherthan 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 withtheCreate and Edit Notebooks privilege to remotely run a notebookthat they own. The notebook specified in the operation will be runwith 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 toautomate repeating tasks such as data collection and cleaning,content updates, and portal administration. On Linux machines, usea cron job to schedule the executeNotebook operation; on Windowsmachines, you can use the Task Scheduler app.
Note
To run this operation in ArcGIS Enterprise, you must log in withan Enterprise account. You cannot execute notebooks using theArcGIS Notebook Server primary site administrator account.
Note
ArcGIS Online has additional parameters, as noted in the parametertable below.
You can specify parameters to be used in the notebook at executiontime. If you’ve specified one or more parameters, they’ll beinserted into the notebook as a new cell. This cell will be placedat the beginning of the notebook, unless you have added the tagparameters to a cell.
Parameter
Description
item
Required
Item
. Opens an existing portal item.update_portal_item
Optional Boolean. Specifies whether you want to update thenotebook’s portal item after execution. The default is true. You maywant to specify true when the notebook you’re executing containsinformation that needs to be updated, such as a workflow thatcollects the most recent version of a dataset. It may not beimportant to update the portal item if the notebook won’t store anynew information after executing, such as an administrative notebookthat emails reminders to inactive users.
parameters
Optional Dictionary. Defines the parameters to add to thenotebook for this execution. The parameters will be inserted as anew cell directly after the cell you have taggedparameters.Separate parameters with a comma. Use format of:
“x”:1 when defining number parameters
“y”:”text” when defining string parameters
SeePrepare the Notebookfor detailed explanation.
save_parameters
Optional Boolean. Specifies whether the notebook parameters cellshould be saved in the notebook for future use. The default isFalse.
timeout
Optional Int. The number of minutes to run the instance before timeout.
Note
This is only available in ArcGIS Online.
future
Optional boolean.
IfTrue, a Job object will be returned and the process runsasynchronously, allowing for other work to be done whileprocessing completes.T
IfFalse, which is the default, the process waits for resultsbefore continuing.
- Returns:
Iffuture=False, a Python dictionary
Iffuture = True, then the result is aconcurrent.futures.Futureobject. Callresult() on the object to get the response
#Usage example: Inserting parameters at execution time>>>fromarcgis.gisimportGIS>>>fromarcgis.notebookimportexecute_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