arcgis.gis.tasks module

TaskManager

class arcgis.gis.tasks.TaskManager(url, user, gis)

Bases: object

Provides the functions to create, update and delete scheduled tasks.

This operation is for Enterprise configuration 10.8.1+.

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

returns all the current user’s tasks

Returns

List of Task objects

property count

Returns the number of tasks a user has

Returns

Int

create(item, cron, task_type, occurences=10, start_date=None, end_date=None, title=None, parameters=None, task_url=None)

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 from of:

<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 added to the task run request.

Note

Required when task_type argument is ExecuteSceneCook

>>> 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

search(item=None, active=None, types=None)

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. This can be ‘’ExecuteNotebook’’, ‘’UpdateInsightsWorkbook’’, ‘’ExecuteSceneCook’’, ‘’ExecuteWorkflowManager’’. ‘’ExecuteReport’’, or ‘’GPService’’.

Returns

List of Task objects

Task

class arcgis.gis.tasks.Task(url, gis)

Bases: arcgis.gis.tasks._schedule.BaseTask

Represents a scheduled task that can be modified for a user.

Parameter

Description

url

Required string. The URL to the REST endpoint.

gis

Required GIS. The GIS object.

delete()

Removes the Task from the System.

Returns

Boolean

enable(enabled)

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 runs

Returns the Runs for the Task. The maximum number of runs returned is 30

Returns

List

start()

Starts a task if it is actively running.

Returns

Boolean

stop()

Stops a task if it is actively running.

Returns

Boolean

update(item=None, cron=None, task_type=None, occurences=10, start_date=None, end_date=None, title=None, parameters=None, task_url=None, is_active=None)

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. Use ExecuteSceneCook to cook scene tiles. Use ExecuteWorkflowManager to run workflow manager tasks. Values: ExecuteNotebook, UpdateInsightsWorkbook, ExecuteSceneCook, ExecuteWorkflowManager, ExecuteReport, or GPService`ns are ``ExecuteNotebook` or UpdateInsightsWorkbook

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, gis)

Bases: arcgis.gis.tasks._schedule.BaseTask

Represents a single run of a scheduled task.

Parameter

Description

url

Required string. The URL to the REST endpoint.

gis

Required GIS. The GIS object.

delete()

Removes the Task from the System.

Returns

Boolean

update(status=None, description=None)

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