Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Esri Developer

ArcGIS API for PythonAPI Reference

arcgis.gis.tasks module

TaskManager

classarcgis.gis.tasks.TaskManager(url:str,user:User,gis:GIS)

Bases:object

Provides the functions to create, update, delete and viewtask 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 accessedusing thetasks property on aUserobject:

>>>fromarcgis.gisimportGIS>>>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.

propertyall:list

returns all the current user’s tasks

Returns:

List ofTask objects

propertycount:int

Returns the number of tasks belonging to theUser.

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

RequiredItem. The item to schedule a task on.

cron

Required String. The CRON statement. This should be in the followingformat:

<minute> <hour> <day of month> <month> <day of week>`

Example to run a task weekly, use:0 0 * * 0.

Note

Seecron fordetails on valid values and meanings for symbols.

task_type

Required String. The type of task that will be executed against thespecified _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 beinserted into the task run at time of request.

Note

Required whentask_type argument isExecuteSceneCook

# Usage Example: For a scene service>>>task_mgr=gis.users.me.tasks>>>task_output=task_mgr.create(...parameters={"service_url":<sceneserviceURL>,"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 asynchronousgeoprocessing service on any of the federated servers of your portal.

Note

Required whentask_type argument isGPService

Returns:

Task object

# Usage Example: Schedule a notebook to run every 15 minutes for 5 runs#                starting March 8, 2025 at 1pm Pacific>>>importdatetimeasdt>>>importpytz>>>fromarcgis.gisimportGIS>>>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

OptionalItem. 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 ofTask objects

Task

classarcgis.gis.tasks.Task(url:str,gis:GIS)

Bases:BaseTask

Represents a scheduledtask. These objectsare not meant to be intialized directly, but instead are returnedby theall property orsearch() method on theTaskManager object.

# Usage example:  Returning task objects for an item>>>fromarcgis.gisimportGIS>>>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.

delete()bool

Removes the Task from the System.

Returns:

Boolean

enable(enabled:bool)bool

Theenable 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

propertyproperties

A dictionary-like object listing various properties of thetask object.

# Usage Example: Listing keys of the properties object for a task:>>>fromarcgis.gisimportGIS>>>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 oftask properties.

propertyruns:list

Returns allruns for thetask. The maximum number of runsreturned is 30>

Returns:

List ofRun objects.

start()bool

Starts a task if it is actively running.

Returns:

Boolean

stop()bool

Stops a task if it is actively running.

Returns:

Boolean

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 orupdating an Insights workbook, that will be executed against thespecified item. For notebook server tasks useExecuteNotebook,for Insights notebook use:UpdateInsightsWorkbook. UseExecuteSceneCook to cook scene tiles. UseExecuteWorkflowManagerto run workflow manager tasks.Values:ExecuteNotebook,UpdateInsightsWorkbook,ExecuteSceneCook,ExecuteWorkflowManager,ExecuteReport, orGPService`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

classarcgis.gis.tasks.Run(url:str,gis:GIS)

Bases:BaseTask

Represents a run of a scheduledtask. Theobjects are not meant to be initialized directly, but instead a list ofruns are returned by theruns propertyoftask objects.

Parameter

Description

url

Required string. The URL to the REST endpoint.

gis

Required GIS. The GIS object.

delete()bool

Removes the Task from the System.

Returns:

Boolean

propertyproperties

A dictionary-like object listing various properties of therun 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, orskipped.

description

Optional String. Updates the descriptive message associated with thecurrentRun.

Returns:

Boolean

Your browser is no longer supported. Please upgrade your browser for the best experience. See ourbrowser deprecation post for more details.


[8]ページ先頭

©2009-2025 Movatter.jp