<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CreateVersion &amp;amp; DeleteVersion both fail on workspace errors in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098550#M45620</link>
    <description>&lt;P&gt;What is the value of&amp;nbsp; full_conn_path for you compared to other users?&amp;nbsp; Maybe add a print statement to your code to see if this value is applicable to all users or just you for your current code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Sep 2021 16:46:42 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2021-09-15T16:46:42Z</dc:date>
    <item>
      <title>CreateVersion &amp; DeleteVersion both fail on workspace errors</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098507#M45616</link>
      <description>&lt;P&gt;I have a workflow in which I need to iteratively delete and re-create versions for automated edits. When I run the script, I do not get any errors and everything works fine; however, as soon as someone else runs the script, they cannot get past the version management steps. Here's the relevant code:&lt;/P&gt;&lt;PRE&gt;from arcpy import (ClearWorkspaceCache_management,
                   CreateDatabaseConnection_management,
                   CreateVersion_management, DeleteVersion_management)&lt;/PRE&gt;&lt;PRE&gt;def clear_cache(func):
    """Clears the workspace cache.

    Used as a decorator on any function that deals with version management.&lt;BR /&gt;
    Parameters
    ----------
    func : function
        The decorated function
    """
    def wrapper(*args, **kwargs):
        log.debug("Clearing workspace cache...")
        ClearWorkspaceCache_management()
        value = func(*args, **kwargs)
        return value
    return wrapper&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;@clear_cache
def versioned_connection(parent: str, version_name: str):
    """Create a version and associated versioned database connection.

    Parameters
    ----------
    parent : str
        The parent of the edit version to be created
    version_name : str
        The name of the version to be created

    Returns
    -------
    str
        A file path to the proper connection file
    """

    conn_file = os.path.join(".\\.esri", f"{version_name}.sde")
    full_conn_path = os.path.realpath(conn_file)

    if os.path.exists(conn_file):
        log.debug(f"{version_name} has already been created...")
    else:
        version_owner = "GISSCR"
        full_version_name = f"{version_owner}.{version_name}"

        # Create the version
        log.debug((f"Creating a version called {version_name} owned by "
                   f"{version_owner}..."))
        version = {"in_workspace": config.edit,
                   "parent_version": parent,
                   "version_name": version_name,
                   "access_permission": "PRIVATE"}
        CreateVersion_management(**version)

        # Create the database connection file
        log.debug(f"Creating a versioned db connection at {conn_file}...")
        connect = {"out_folder_path": ".\\.esri",
                   "out_name": f"{version_name}.sde",
                   "version": full_version_name,
                   "password": "password",&lt;BR /&gt;                   "database_platform": "SQL_SERVER",
                   "instance": "GISData",
                   "database": "gisprod3",
                   "account_authentication": "DATABASE_AUTH",
                   "username": "gisscr",
                   "version_type": "TRANSACTIONAL"}&lt;BR /&gt;        CreateDatabaseConnection_management(**connect)&lt;BR /&gt;   &lt;BR /&gt;    return full_conn_path&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;@clear_cache def&lt;BR /&gt;delete_versions(connection: str) -&amp;gt; None: &lt;BR /&gt;    """Deletes versions created for editing Facility IDs &lt;BR /&gt;&lt;BR /&gt;    Parameters&lt;BR /&gt;    ---------- &lt;BR /&gt;    connection : str &lt;BR /&gt;        location of the sde connection file """ &lt;BR /&gt;&lt;BR /&gt;    del_versions = [v for v in ListVersions(connection) if "FACILITYID" in v.upper()]&lt;BR /&gt;    for d in del_versions:&lt;BR /&gt;        DeleteVersion_management(connection, d)&lt;/PRE&gt;&lt;PRE&gt;if name == "__main__":&lt;BR /&gt;    # Step 1: Delete all existing Facility ID versions&lt;BR /&gt;    log.info("Deleting old Facility ID versions...")&lt;BR /&gt;    edit = "path\to\edit\connection"&lt;BR /&gt;    delete_versions(edit)&lt;BR /&gt; &lt;BR /&gt;    # Step 2: Re-create FacilityID versions&lt;BR /&gt;    log.info("Creating new Facility ID versions...")&lt;BR /&gt;    parent = "SDE.DEFAULT"&lt;BR /&gt;    v_name = "FacilityID_Edits"&lt;BR /&gt;    conn_file = versioned_connection(parent, v_name)&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;These version management steps always fail for other people, even though I've written a function that clears the workspace cache before every version management step (as suggested &lt;A href="https://community.esri.com/t5/geoprocessing-questions/createversion-tool-doesn-t-like-my-workspace/m-p/733989#M24189" target="_blank" rel="noopener"&gt;here&lt;/A&gt;). It never fails for me, though (even on different machines!!) This is the traceback when it fails:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;09/14/2021 16:21:36.316 : __main__ : ERROR : Something prevented the script from running&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "S:\PW\PWShare\GIS\SharedScripts\facilityid\facilityid\__main__.py", line 10, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.main()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "S:\PW\PWShare\GIS\SharedScripts\facilityid\facilityid\app.py", line 52, in main&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; conn_file = mgmt.versioned_connection(parent, v_name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "S:\PW\PWShare\GIS\SharedScripts\facilityid\facilityid\utils\management.py", line 152, in versioned_connection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CreateVersion_management(**version)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 22237, in CreateVersion&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 22234, in CreateVersion&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; retval = convertArcObjectToPythonObject(gp.CreateVersion_management(*gp_fixargs((in_workspace, parent_version, version_name, access_permission), True)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 511, in &amp;lt;lambda&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return lambda *args: val(*gp_fixargs(args, True))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000837: The workspace is not the correct workspace type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WARNING 000379: The value may not be valid because of empty domain or does not exist in the domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CreateVersion).&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;I'm at my wit's end. Plz help!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 15:31:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098507#M45616</guid>
      <dc:creator>Jesse</dc:creator>
      <dc:date>2021-09-15T15:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: CreateVersion &amp; DeleteVersion both fail on workspace errors</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098550#M45620</link>
      <description>&lt;P&gt;What is the value of&amp;nbsp; full_conn_path for you compared to other users?&amp;nbsp; Maybe add a print statement to your code to see if this value is applicable to all users or just you for your current code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 16:46:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098550#M45620</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-09-15T16:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: CreateVersion &amp; DeleteVersion both fail on workspace errors</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098559#M45622</link>
      <description>&lt;P&gt;Good suggestion, I'll give it a whirl and see if it leads me anywhere.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 17:00:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098559#M45622</guid>
      <dc:creator>Jesse</dc:creator>
      <dc:date>2021-09-15T17:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: CreateVersion &amp; DeleteVersion both fail on workspace errors</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098655#M45626</link>
      <description>&lt;P&gt;The paths are identical across all folks running the script, me included.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 20:19:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/createversion-amp-deleteversion-both-fail-on/m-p/1098655#M45626</guid>
      <dc:creator>Jesse</dc:creator>
      <dc:date>2021-09-15T20:19:28Z</dc:date>
    </item>
  </channel>
</rss>

