Execute Notebooks hosted in ArcGIS Online using ArcGIS API for Python

2126
7
05-04-2022 02:38 AM
ConradSchaefer__DOIT_
New Contributor III

We have notebooks in AGOL that we would like to trigger remotely using the API for Python. It appears to be a possibility if you have your own Notebook Server but it doesn't look like the functionality exists for AGOL. See the arcgis.gis.nb.NotebookManager execute_notebook() function which says "The Execute Notebook operation allows administrators to remotely run a notebook in their ArcGIS Notebook Server site"

The times we want to run our notebooks are not on a regular schedule so the task functionality in AGOL is not appropriate. The run events are customer driven and on an unpredictable schedule, and turning the notebook over to them would not be appropriate. We would like to be able to be able to run a local python script that uses the API to trigger the Notebook to execute in AGOL.

 

@SusanHmel__DOIT_ 

7 Comments
jcarlson

What is the output / end result of the notebook? Have you considered just having a Python script that you can run on demand? Notebooks are great for situations when you need to see the output or explain things with markup, but if you're not even opening the notebook, you'd probably be better off with a Python script instead.

ConradSchaefer__DOIT_

jcarlson, We currently have administrative notebooks that have very little value visually that are running via a task in AGOL. Noone examines the outputs as long as the runs were successful. We do have successful runs notify AGOL members and include select print output content on the task run.

Our new use case is another action process. The notebook is not an inspection of data with visualizations. It's akin to an administrative process like account management etc. We would like to be able to access it with the API and execute it.

Note: I compartmentalized this idea to remote trigger. Once remote is possible then we would want to be able to pass a parameter to the notebook. 

jcarlson

The API is accessible anywhere, though. You can install the arcgis Python module on any machine and run all the same commands. For instance, I have a number of administrative tasks that I run from a Linux machine. Many of these are custom functions that take parameters, too, so it's very simple to remotely initiate a process.

We also have certain common tasks that we share through a private GitHub repository, allowing other administrators to run these administrative tasks from literally any machine with an internet connection.

ConradSchaefer__DOIT_

jcarlson,

ESRI has given us Notebooks in AGOL. We pay for this functionality. These notebooks are currently able to be executed on a schedule in AGOL, just not on demand.

It's worthwhile emphasizing Notebook Server allows execution of notebooks through the API, as stated above. We are requesting the same functionality for AGOL.

We are aware of how to use the ArcGIS API for Python module in a script on a local server with internet. We have many processes in place already that leverage the API. We now want to be able to execute a Notebook in AGOL through that API. 

 

jcarlson

I agree that triggering a notebook is a function that would be nice to have in either place, so I still think this is a good idea.

I'm just not sure why, in this particular use case, it needs to be a notebook at all if it's not actually leveraging the particular capabilities of the notebook environment.

AndrewChapkowski
Status changed to: Under Consideration
 
AndrewChapkowski
Status changed to: Implemented

This functionality will be in the 2.1.0 release.