Per the documentation, create replica can be called using
manager.create(title,ids,layer_queries=export_params, return_attachments=True, attachments_sync_direction = None, sync_direction=None, data_format='filegdb',asynchronous=True)
The response from this call is a job URL
How do you manage this process of monitoring the job for completion and then downloading the result?
I could use urllib3 requests but looking for a cleaner method
Not sure I correctly understand what you mean 'a cleaner method'.
It seems to me you have to check the status manually to make sure the creation of the replica is completed before you can use it.
The status are quite specific to replica creation in ArcGIS:
"status": "<Pending | InProgress | Completed | Failed | ImportChanges | ExportChanges | ExportingData | ExportingSnapshot | ExportAttachments | ImportAttachments | ProvisioningReplica | UnRegisteringReplica | CompletedWithErrors>"
It's similar to submitting an asynchronous Geoprocessing request, so you can use the following code to get a jump start if you like.
import urllib, json, time
# the response of an asynchronous request is an url, now start checking the status
submitJson = json.loads(submitResponse.read())
if 'jobId' in submitJson:
jobID = submitJson['jobId']
status = submitJson['jobStatus']
jobUrl = taskUrl + "/jobs/" + jobID
while status == "esriJobSubmitted" or status == "esriJobExecuting":
print "checking to see if job is completed..."
time.sleep(1)
jobResponse = urllib.urlopen(jobUrl, "f=json")
jobJson = json.loads(jobResponse.read())
if 'jobStatus' in jobJson:
status = jobJson['jobStatus']
if status == "esriJobSucceeded":
if 'results' in jobJson:
resultsUrl = jobUrl + "/results/"
resultsJson = jobJson['results']
for paramName in resultsJson.keys():
resultUrl = resultsUrl + paramName
resultResponse = urllib.urlopen(resultUrl, "f=json")
resultJson = json.loads(resultResponse.read())
print resultJson
if status == "esriJobFailed":
if 'messages' in jobJson:
print jobJson['messages']
else:
print "no jobId found in the response"
Note: The above code snippet is from ESRI help:
Using a geoprocessing service in Python scripts—Documentation | ArcGIS Enterprise
Hope this is helpful
Thanks for the reply. I am using requests to do the same thing.
However, it would be nice if the ArcGIS API had something for this.
By "Cleaner" I mean a concise ArcGIS API method for this instead of using urllib and json.
Not to mention you have to throw a token call form gis._conf.token.
Seems like an omission to have a very clean method to call the create Replica but no way for the API to download it.
Maybe manager.job.status?
or manager.job.download?