Migrating Job Template properties via Python API

279
0
02-20-2023 01:17 PM
RichardOxales
New Contributor III

I'm currently working on a script to migrate diagrams and templates from one Workflow Manager instance to another. The samples provided me a good base through the WMX_MigrateWorkflows_PythonAPI.py script, but I noticed that it wasn't migrating all properties and I can't seem to update certain properties. In particular, I'd like to be able to update the default job name in the Job Template (i.e., be able to set something like "MyJob_[index]"), but this doesn't get passed from the source Workflow Manager item and I can't seem to update it.

Is there currently a way to update these properties that aren't part of the create_job_template method of the WorkflowManager object? (link)

My script looks something like this:

import arcpy
from arcgis.gis import GIS
from arcgis.gis.workflowmnager import WorkflowManager, JobTemplate

# get sources
source_gis = GIS('https://myurl.com','user1','pass1')
dest_gis = GIS('https://myurl.com','user1','pass1')
source_wf_item = source_gis.content.get('Source_WFM_ID')
dest_wf_item = dest_gis.content.get('Dest_WFM_ID')

source_wfm = WorkflowManager(source_wf_item)
dest_wfm = WorkflowManager(dest_wf_item)

source_job_template = source_wfm.job_template('SourceTemplateID123')

# creates destination template; the source's attributes are also filled in here, only mentioning name and priority for brevity
dest_new_template_id = dest_wfm.create_job_template('MyTemplate','Low')

dest_job_template = dest_wfm.job_template(dest_new_template_id)

# sets destination job template to source's, e.g 'MyJob_[index]'
dest_job_template.default_job_name = source_job_template.default_job_name

# throws an error - 'JobTemplate' object is not subscriptable
dest_wfm.update_job_template(dest_job_template)

 

Tags (3)
0 Kudos
0 Replies