Hi @PhilLarkin1 , I found a workaround that seems fast. Create a new version then create a temporary connection file avoiding the slog of trying to change the version.
try:
# Check if version name already exists - use existing one if found or create a new one
arcpy.SetProgressorLabel("Processing EGDB requirements")
version_list = [sde_version.name for sde_version in arcpy.da.ListVersions(sde_path)]
if full_version_name not in version_list:
arcpy.AddMessage("Creating new version of sde.default")
arcpy.CreateVersion_management(sde_path, parent_version, version_name, "PUBLIC")
else:
arcpy.AddMessage("Version already exists - writing to existing version")
arcpy.AddMessage("Creating temporary connection file")
# Check if temp username folder exists, if not create in the staging area.
# The temp user folder is used to store the temp connection file.
staging_user_folder_path = os.path.join(staging_folder, get_current_user())
if not os.path.exists(staging_user_folder_path):
os.mkdir(staging_user_folder_path)
# Create temporary connection file in the user folder that connects to the version
arcpy.CreateDatabaseConnection_management(
staging_user_folder_path, f"{version_name}.sde", "ORACLE",
f"{os.path.basename(sde_path_split[0])}/{os.path.basename(sde_path_split[0])}", "OPERATING_SYSTEM_AUTH",
None, None, None, None, None, "TRANSACTIONAL", full_version_name)
temp_sde_path = os.path.join(staging_user_folder_path, f"{version_name}.sde")
temp_sde_fc_path = os.path.join(temp_sde_path, sde_fs_fc_name)
except arcpy.ExecuteError:
exec_error()
except:
traceback_error()