Skip To Content

CreateGPSDDraft

Summary

The function converts Result objects and result files (.rlt) into Service Definition Draft (.sddraft) files.

Note:

A draft service definition does not contain data. A draft service alone cannot be used to publish a service.

Discussion

CreateGPSDDraft is the first step to automating the publishing of a geoprocessing result to a GIS Server using ArcPy. The output created from CreateGPSDDraft is a Service Definition Draft (.sddraft) file. A Service Definition Draft is the combination of a result file or Result object, information about the server, and a set of service properties. A Result object can be created in a Python script by setting a variable to a tool execution. For example, the following buffer result is saved to a variable called result.

import arcpy
result = arcpy.Buffer_analysis("inPts", "output.shp", "100 Meters")

Information about the server includes the server connection, server type being published to, type of service being published, metadata for the service (Item info), and data references (whether or not data is being copied to the server).

The function returns a dictionary containing errors, warnings, and messages that you should address prior to creating your Service Definition file.

The Service Definition Draft needs to be converted to a fully consolidated Service Definition (.sd) file using the Stage Service tool. Staging compiles all the necessary information needed to successfully publish the GIS resource. If your data is not registered with the server, the data will be added when the Service Definition Draft is staged. Finally, the Service Definition file can be uploaded and published as a GIS service to a specified GIS server using the Upload Service Definition tool. This step takes the Service Definition file, copies it onto the server, extracts required information, and publishes the GIS resource. For more information, see An overview of the Publishing toolset.

Syntax

CreateGPSDDraft (result, out_sddraft, service_name, {server_type}, {connection_file_path}, {copy_data_to_server}, {folder_name}, {summary}, {tags}, {executionType}, {resultMapServer}, {showMessages}, {maximumRecords}, {minInstances}, {maxInstances}, {maxUsageTime}, {maxWaitTime}, {maxIdleTime}, {capabilities}, {constantValues})
ParameterExplanationData Type
result
[result,...]

A reference to one or multiple Result objects or result files (.rlt) on disk. Multiple results must be supplied in a list format. The following example demonstrates multiple results as input to the CreateGPSDDraft function.

import arcpy
result1 = arcpy.Buffer_analysis("inPts", "output.shp", "100 Meters")
result2 = arcpy.GetCount_management("FireStations")
arcpy.CreateGPSDDraft([result1, result2], "output.sddraft", "myservice")
Result
out_sddraft

A string that represents the path and file name for the output Service Definition Draft (.sddraft) file.

String
service_name

A string that represents the name of the service. This is the name people will see and use to identify the service. The name can only contain alphanumeric characters and underscores. No spaces or special characters are allowed. The name cannot be more than 120 characters in length.

String
server_type

A string representing the server type. If a connection_file_path parameter is not supplied, a server_type must be provided. If a connection_file_path parameter is supplied, the server_type is taken from the connection file. In this case, you can choose FROM_CONNECTION_FILE or skip the parameter entirely.

Note:

MY_HOSTED_SERVICES is only available when creating .sddraft files from ArcGIS Pro.

  • ARCGIS_SERVERArcGIS Server server type.
  • FROM_CONNECTION_FILEGets the server_type as specified in the connection_file_path parameter.
  • MY_HOSTED_SERVICESCreates an .sddraft file to be published to the current portal.

(The default value is ARCGIS_SERVER)

String
connection_file_path

A string that represents the path and file name to the ArcGIS Server connection file (.ags).

String
copy_data_to_server

A Boolean that indicates whether or not the data referenced in the result will be copied to the server. The copy_data_to_server parameter is only used if the server_type is ARCGIS_SERVER and the connection_file_path isn't specified. If the connection_file_path is specified, the server's registered data stores are used. For example, if the data in the result is registered with the server, copy_data_to_server will always be False. Conversely, if the data in the result is not registered with the server, copy_data_to_server will always be True.

(The default value is False)

Boolean
folder_name

A string that represents a folder name to which you want to publish the service definition. If the folder does not currently exist, it will be created. The default folder is the server root level.

(The default value is None)

String
summary

A string that represents the Item Description Summary.

Use this parameter to override the user interface summary or to provide a summary if one does not exist. The summary provided here will not be persisted in the map document.

(The default value is None)

String
tags

A string that represents the Item Description Tags.

Use this parameter to override the user interface tags or to provide tags if they do not exist. The tags provided here will not be persisted in the map document.

(The default value is None)

String
executionType

Asynchronous and synchronous define how the client (the application using the task) interacts with the server and gets the result from the task. When a service is set to synchronous, the client waits for the task to finish. Typically, a synchronous task executes quickly—five seconds or less. An asynchronous task typically takes longer to execute, and the client must periodically ask the server if the task has finished and, if it has finished, get the result. A web application using an asynchronous task must have logic implemented to check the status of a task and handle the result once execution is finished. ArcGIS Desktop clients handle both execution types natively.

(The default value is Asynchronous)

String
resultMapServer

When publishing a geoprocessing service, you can choose to view the result of all tasks with the service as a map (in addition to other results of your task). The map is created on the server using a Map Service for transport back to the client as an image (a .jpeg file for example). The symbology, labeling, transparency, and all other properties of the returned map are the same as the settings of your output layer. Remember, if you are creating result layers within the Python scripting environment (outside ), default symbologies will be used. To maintain control over symbology, you will need to pre-create layer files with rich symbology and use them to modify the output symbology of your task.

When you choose this option, a map service is automatically created on the server with the same name as your geoprocessing service.

(The default value is False)

Boolean
showMessages

A string setting the message level for the geoprocessing service. The following is a list of valid message levels the service will return to the client:

  • NoneNo geoprocessing messages are returned to the client except those regarding whether the execution was successful or failed.
  • ErrorOnly tool messages that produce an error are returned to the client.
  • WarningAll tool error and warning messages are returned to the client.
  • InfoAll tool messages from execution are returned to the client.

(The default value is None)

String
maximumRecords

The maximum number of results the service can return to a client. Setting this value to a large number means your GIS server can handle sending a lot of individual records or features to the client. If you don't want to return any features, set this value to 0 (zero). Typically, you set this value to zero only when you enable View result with a map service.

(The default value is 1000)

Integer
minInstances

An integer value representing the minimum number of instances a service will start and make available for use. For heavily used services, you may want to increase this value.

(The default value is 1)

Integer
maxInstances

An integer value representing the maximum number of instances a service can start and make available for use. For heavily used services, you may need to increase this value. Ensure the server has adequate hardware to support the maximum number of instances you will allow.

(The default value is 2)

Integer
maxUsageTime

The maximum time, in seconds, that a service can be used. You may need to increase the default of 600 seconds (10 minutes) for long-running geoprocessing tasks. Alternatively, you may need to reduce this time to ensure a client will not abuse your services.

(The default value is 600)

Integer
maxWaitTime

The maximum time, in seconds, that a client will wait to connect with an instance before timing out. When all instances are busy processing requests, subsequent requests are queued. If this time-out elapses before an instance becomes available, the task will fail. The default is 60 seconds (1 minute).

(The default value is 60)

Integer
maxIdleTime

The maximum time, in seconds, that an instance will continue to be active before pool shrinking occurs. Any instances above the minimum number of instances that have not been used will be shut down once the idle maximum time value has elapsed.

(The default value is 1800)

Integer
capabilities

Specifies the capabilities a service can support. Currently, only UPLOADS is supported.

(The default value is None)

String
constantValues
[constantValues,...]

A list of parameter names to be set as a constant. If multiple tools are included, parameter names must be qualified with the tool name, for example, ["toolX.parameterA", "toolY.parameterD"].

(The default value is None)

String
Return Value
Data TypeExplanation
Dictionary

Returns a dictionary of information messages, warnings, and errors.

Related topics