TaskManager
- class arcgis.gis.tasks.TaskManager(url: str, user: User, gis: GIS)
Bases:
object
Provides the functions to create, update, delete and view
task
objects.Note
Available starting with ArcGIS Enterprise release 10.8.1, and ArcGIS Online.
Objects are not meant to be initialized directly, but instead are accessed using the
tasks
property on aUser
object:>>> from arcgis.gis import GIS >>> gis = GIS(profile="your_online_profile") >>> task_mgr = gis.users.me.tasks >>> type(task_mgr) <class 'arcgis.gis.tasks._schedule.TaskManager'>
Parameter
Description
url
Required string. The URL to the REST endpoint.
user
Required User. The user to perform the Task management on.
gis
Required GIS. The GIS object.
- property all: list
returns all the current user’s tasks
- Returns:
List of
Task
objects
- property count: int
Returns the number of tasks belonging to the
User
.- Returns:
Int
- create(item: Item, cron: str, task_type: str, occurences: int = 10, start_date: datetime | None = None, end_date: datetime | None = None, title: str | None = None, parameters: dict | None = None, task_url: str | None = None) Task
Creates a new scheduled task.
Parameter
Description
item
Required
Item
. The item to schedule a task on.cron
Required String. The CRON statement. This should be in the following format:
<minute> <hour> <day of month> <month> <day of week>`
Example to run a task weekly, use: 0 0 * * 0.
Note
See cron for details on valid values and meanings for symbols.
task_type
Required String. The type of task that will be executed against the specified _item_.
Values:
ExecuteNotebook
UpdateInsightsWorkbook
ExecuteSceneCook
ExecuteWorkflowManager
ExecuteReport,
GPService
RunDataPipeline
occurences
Optional Integer. The maximum number of times the task will run.
start_date
Optional Datetime. The begin date for the task to run.
end_date
Optional Datetime. The end date for the task to run.
title
Optional String. The title of the scheduled task.
parameters
Optional Dict. Optional collection of Key/Value pairs that will be inserted into the task run at time of request.
Note
Required when task_type argument is ExecuteSceneCook
# Usage Example: For a scene service >>> task_mgr = gis.users.me.tasks >>> task_output = task_mgr.create( ... parameters = { "service_url": <scene service URL>, "num_of_caching_service_instances": 2, #(2 instances are required) "layer": "{<list of scene layers to cook>}", #The default is all layers "update_mode": "PARTIAL_UPDATE_NODES" }, ... )
task_url
Optional String. The URL of the task of an asynchronous geoprocessing service on any of the federated servers of your portal.
Note
Required when task_type argument is GPService
- Returns:
Task
object
# Usage Example: Schedule a notebook to run every 15 minutes for 5 runs # starting March 8, 2025 at 1pm Pacific >>> import datetime as dt >>> import pytz >>> from arcgis.gis import GIS >>> gis = GIS(profile="your_online_profile") >>> nb_item = gis.content.search("air_quality_regular_updates", "notebook")[0] >>> dt = dt.datetime(2025, 3, 8, 13, 0, 0) >>> pdt_tz = pytz.timezone("US/Pacific") >>> dt_pdt = pdt_tz.localize(dt) >>> tsk_mgr = gis.users.me.tasks >>> tsk_mgr.create( >>> item=nb_item, >>> cron= "*/15 * ? * 1,2,3,4,5,6,7", >>> task_type="ExecuteNotebook", >>> occurences=5, >>> start_date= dt_pdt, >>> title="data_index_update" >>> )
- search(item: Item | None = None, active: bool | None = None, types: str | None = None) list[Task]
This property allows users to search for tasks based on criteria.
Parameter
Description
item
Optional
Item
. The item to query tasks about.active
Optional Bool. Queries tasks based on active status.
types
Optional String. The type of notebook execution for the item. Can be one of:
ExecuteNotebook
UpdateInsightsWorkbook
ExecuteSceneCook
ExecuteWorkflowManager
ExecuteReport
GPService
- Returns:
List of
Task
objects
Task
- class arcgis.gis.tasks.Task(url: str, gis: GIS)
Bases:
BaseTask
Represents a scheduled
task
. These objects are not meant to be intialized directly, but instead are returned by theall
property orsearch()
method on theTaskManager
object.# Usage example: Returning task objects for an item >>> from arcgis.gis import GIS >>> gis = GIS(profile="your_organization_profile") >>> task_mgr = gis.users.me.tasks >>> user_item = gis.content.get(<item_id>) >>> task_list = task_mgr.search(item=user_item) >>> task_list [<Task @ 3259ac1...afc154f>, <Task @ 10f7a74...3afa7de>, <Task @ 0e6dc28...32ac65b>] >>> t0 = task_list[0] >>> t0 <Task @ 3259ac1...afc154f>
Parameter
Description
url
Required string. The URL to the REST endpoint.
gis
Required GIS. The GIS object.
- enable(enabled: bool) bool
The enable method allows administrators to enable or disable the scheduled task..
Parameter
Description
enabled
Required Boolean. If True, the status of the task is set to active. If False, the task is set active to False.
- Returns:
Boolean
- property properties
A dictionary-like object listing various properties of the
task
object.# Usage Example: Listing keys of the properties object for a task: >>> from arcgis.gis import GIS >>> gis = GIS(profile="your_organization_profile") >>> task_mgr = gis.users.me.tasks >>> tsk = task_mgr.search(item=my_item)[0] >>> list(tsk.properties.keys()) ['id', 'itemId', 'type', 'title', 'userId', 'cronSchedule', 'runIntervalSeconds', 'nextStart', 'maxOccurrences', 'created', 'updated', 'startDate', 'active', 'taskState']
- Returns:
Dictionary-like object of task properties.
- property runs: list
Returns all runs for the task. The maximum number of runs returned is 30>
- Returns:
List of
Run
objects.
- update(item: Item | None = None, cron: str | None = None, task_type: str | None = None, occurences: int = 10, start_date: datetime | None = None, end_date: datetime | None = None, title: str | None = None, parameters: dict | None = None, task_url: str | None = None, is_active: bool | None = None) bool
Updates the current Task
Parameter
Description
item
Optional Item. The item to update the schedule for.
cron
Optional String. The executution time syntax.
task_type
Required String. The type of task, either executing a notebook or updating an Insights workbook, that will be executed against the specified item. For notebook server tasks use
ExecuteNotebook
, for Insights notebook use:UpdateInsightsWorkbook
. UseExecuteSceneCook
to cook scene tiles. UseExecuteWorkflowManager
to run workflow manager tasks. Values: ExecuteNotebook, UpdateInsightsWorkbook, ExecuteSceneCook, ExecuteWorkflowManager, ExecuteReport, or GPService`ns are ``ExecuteNotebook` orUpdateInsightsWorkbook
occurences
Optional Integer. The maximum number of occurrences this task should execute.
start_date
Optional Datetime. The date/time when the task will begin executing.
end_date
Optional Datetime. The date/time when the task will stop executing.
title
Optional String. The name of the task.
parameters
Optional Dict. Additional key/value pairs for execution of notebooks.
task_url
Optional String. A response URL with a set of results.
is_active
Optional Bool. Determines if the tasks is currently running.
- Returns:
Boolean or Dict on error.
Run
- class arcgis.gis.tasks.Run(url: str, gis: GIS)
Bases:
BaseTask
Represents a run of a scheduled
task
. The objects are not meant to be initialized directly, but instead a list of runs are returned by theruns
property oftask
objects.Parameter
Description
url
Required string. The URL to the REST endpoint.
gis
Required GIS. The GIS object.
- property properties
A dictionary-like object listing various properties of the
run
object.
- update(status: str | None = None, description: str | None = None) bool
Updates the Run’s Status Message and Result Message.
Parameter
Description
status
Optional String. The status of the run. The allowed values are: scheduled, executing, succeeded, failed, or skipped.
description
Optional String. Updates the descriptive message associated with the current Run.
- Returns:
Boolean