0

I have a Versioned Database reading and writing information from both the Desktop Environment and Collector for ArcGIS. I have a Server for ArcGIS, running an Advanced License. I would like users with a Basic License to be able to access published Advanced Geoprocessing (GP) Services / Tools and maintain the database using a series of my own Toolboxes.

As a test of the concept I have performed a Reconcile on my Database and published it to my Server as a Geoprocessing Service. The service runs as you would expect when run off the Server. The issue that I am having is the number of Versions of the Database will change as new users logon and create edit sessions (Primarily new devices connecting via the Collector App).

Is there a way to publish a GP Service that allows for a Dynamic input?

Allowing for the input versions list to be updated as the number of versions update. Running it off an Advanced License, this is accomplished by:

versionList = arcpy.ListVersions("Connection_To_Database")

If I try and run the Service using arcpy and updating the version list, I am presented an error:

Traceback (most recent call last): File "", line 107, in execute File "https://linktomyserver ; Geoprocessing/GP_ReconcileVersions", line 93, in ReconcileVersions ExecuteError: Failed to execute. Parameters are not valid. ERROR 000800: The value is not a member of DBO.Esri_Anonymous_P_1517838606513. ERROR 000800: The value is not a member of DBO.Esri_Anonymous_P_1517838606513. Failed to execute (ReconcileVersions).

From what I can see here, the DBO.Esri_Anonymous_P_1517838606513 is a new version I created when I logged onto the Collector and created a new Offline Map. Which is a reasonable example of a real-world instance.

I have also created a Toolbox, which calls the published GP Service. My Toolbox is running the following code:

    Source = parameters[0].valueAsText

    arcpy.AddMessage(str(Source))

    Input = str(Source)
    arcpy.AddMessage(str(Input))

    read_lines = [line.rstrip('\n') for line in open(Input)]

    Conn = read_lines[1]

    InputText = Conn
    arcpy.AddMessage(Conn)
    arcpy.AddMessage("Connecting to Server Toolbox - GP Reconcile - Testing 1")
    arcpy.ImportToolbox("Link t to my server/rest/services;Geoprocessing/GP_ReconcileVersions","Reconcile Versions")
    arcpy.AddMessage("Toolbox Connection Established")
    versionList = arcpy.ListVersions(InputText)
    arcpy.AddMessage(str(versionList))
    #arcpy.ReconcileVersions_management(InputText, "ALL_VERSIONS", "sde.DEFAULT", versionList, "NO_LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION")
    #arcpy.ReconcileVersions_GPReconcileVersions(InputText, "ALL_VERSIONS", "sde.DEFAULT", versionList, "NO_LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION")

    result = arcpy.ReconcileVersions_GPReconcileVersions("ALL_VERSIONS", "sde.DEFAULT", versionList, "NO_LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION")

    while result.status < 4:
       arcpy.AddMessage(result.status)
       time.sleep(0.2)

    arcpy.AddMessage("Reconcile completed")
    return

I have a few lines of code in there which are just for my own debugging and will be removed. The code works if I am calling a "Local" reconcile tool, but fails with the error presented when I try and call the published GP Service. I used this example: ArcGIS: Using a service in python

1 Answer 1

2

Any sort of list, whether the list is static and you've created it yourself with a, b, c or a list that is dynamically created when the tool runs, like version A, version B, version C will become SET when published as a GP Service. Simply meaning, whatever is in that list becomes the only permitted values to that parameter when executing.

If you want to allow for "any" value, you need to NOT use a list, but use a basic string input (that allows for any string). You'd then move the responsibility for the list to the client application. Say a web application, you'd write the front end so the user has to select a, b, or c and pass that in.

Now for your specific case, dynamic versions, there isn't much you can do. You'd need a way to populate your client application list with all the versions (unless your users are super smart and 'just know' what version string they need to type in), the user selects a version and the client app passes that value as a basic string into the service for execution.

While not "pretty", you could have your advanced tools service that needs a version and you could have a extremely simple task in that service that just gets versions. Like 4 lines that included versionList = arcpy.ListVersions("Connection_To_Database"): when the application starts up, it sends a request to that task, gets back the list and fills out a drop down menu. The user then selects one and executes the main Reconcile task using the appropriate version.

1
  • Thank you @KHimba for the response. Through the process of reviewing your answer as well as some of your other posts, I think I have found the solution. I found a post which describes my predicament perfectly. I am testing the solution and if it works, I will post it here. Feb 6, 2018 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.