creating and using web tools and geoprocessing services€¦ · •software -arcgis pro 1.4 and...
TRANSCRIPT
Shing LinSimon Suo
Creating and Using Web Tools and Geoprocessing Services
1. Introduction2. Design and Author 3. Run and Publish
• Demo 1 Publish Web Tool• Demo 2 Publish GP Service
4. Consume • Demo 3 Consume Web Tool and GP Service
5. Advanced Considerations6. Resources and New Features
Overview
Concept, Requirements, and WorkflowIntroduction
Web Tool vs Geoprocessing Service
• Web Tool - Publish from ArcMap or Pro to ArcGIS Enterprise
• Geoprocessing Service - Publish from ArcMap or Pro to Stand-Alone Server
Requirements• Software
- ArcGIS Pro 1.4 and above for web tool- ArcGIS Pro 2.3.1 and above for gp service - Enterprise 10.6 and above
• Login account- Web tool
- Must have Admin or Publisher permissions to publish- For Publisher, you need to create a Customized Publisher role in Portal and turn on Publish
Web Tools option in the Administrative Privileges. - GP service
- A server connection (.ags file) with Admin account
Data Preparations and Pre-Publishing Considerations
Design and Author - Script Tool and Pre-publishing Script
Preparation – Data in Script Tool
• Avoid “hard coding” all data paths and dependencies- Favor input parameters which a user can customize- my_param = arcpy.GetParameterAsText() or “P” in Model Builder
• If you have to use a “hard coded” data path, build it dynamically- Utilize os.path.join(“root directory”, “file_name”) so the tool works on any OS- Use sys.path.append(“server’s path to the module”) if needed
• Write intermediate/temporary output data to memory- Keep everything running fast, and lighten the load on your Data Store- Use os.path.join(“in_memory”, “your output name”) or Intermediate Data
Pre-publishing considerations 1 - Input mode • The way the users provide input in web tool
• User Defined Value: allows the end user to interactively add data• Use non-layer object as input
• Choice list: allows the end user to select from a list of layers on the server• Use layer object for each input
• Constant value: hard codes the parameter, user cannot see it• Provide the tool and parameter name and set the value in constant list
parameter of
arcpy.CreateGPSDDraft (……, constantValues = [toolName.parameterName, ..])
Pre-publishing Considerations 2 – Data Reference and Validation • For all the project data or input data as layer or constant
- If data source is not registered on Server Data Store, data is recursively found in any directory, then consolidated and copied to server
- If data source is registered on Server Data Store, data is referenced from the server, not consolidated
- If the data is large, try reference
• Tool Validation script will be published, and executed by SubmitJob()
- The validation occurs server-side, and should act the same, but test it!
Functions and Demos for publishing Web Tool and GP ServicePublishing Functions
• Run tool to get result file in python
• Login from ArcGIS Pro or arcpy.SigninToPortal (PortalURL, Username, Password) function
• Use arcpy.CreateGPSDDraft (result, out_sddraft, service_name, server_type (user MY_HOSTED_SERVICES here)) to obtain a service definition draft
• Use arcpy.StageService_server (sddraft, sd) to create a service definition file
• Use arcpy.UploadServiceDefinition_server (sd, ServerURL) to upload the service definition file to server
Publishing Functions for Web Tool
Demo 1Publish Web Tool
• Run Desktop tool to get result object in python • Use arcpy.CreateGPSDDraft (result, out_sddraft, service_name,
server_type (use ARCGIS_SERVER here)) to obtain a service definition draft.
• Use arcpy.StageService_server (sddraft, sd) to create a service definition file.
• Use arcpy.UploadServiceDefinition_server (sd, Server Connection File) to upload the service definition file to server.
Publishing Functions for GP Service
Demo 2Publish GP Service
Functions and Demo for consuming Web Tool and GP ServiceConsuming Functions
Consuming a Web Tool and GP Service
• Use ArcPy Functions - Call ImportToolbox or AddToolbox function
arcpy.ImportToolbox ( “Https://ServerName/WebAdaptorName/Services; Web tool or Service name; Username; Password”)
- Run like Desktop tool arcpy.WebToolName.TaskName(<Parameters>)
- If consuming a web tool, you can write the output to a feature service by setting the service name for the output parameter esri_out_feature_service_name
• Use REST API for automation and testinng‒Use "requests" and "json“ modules
Demo 3Consume Web Tool and GP Service
3rd-party Libraries, Sharing from ArcMap and Notebook, Frequent Publishing
Advanced Considerations
1. Login Server Machine command prompt as an Admin2. Clone the server's default Python environment with a new
environment name, such as newenvname, using Condaclone command
3. Activate the Clone Environment by running proswapnewenvname
4. Install the third-party Python packages by running condainstall
5. Restart the ArcGIS Server service on the Windows Task Manager
Third Party Libraries Deployment
• Sharing from ArcMap- Publish with the same way as stand-alone server from Pro
• Publishing and consuming from NoteBook- Use Python API. Can only publish using service definition file.
• If you publish the same service frequently in Pro- Save the service definition file and publish from
arcpy.UploadServiceDefinition_server directly
ArcMap, Notebook and Frequent Publishing Considerations
New Features and Doc linksNew Features and Resources
• ArcGIS Pro 2.3 2.4 and Enterprise 10.7 , 10.7.1- Output feature service- Publish to stand-alone server Using script (Pro 2.3.1), from GUI (Pro 2.4)- Deploy custom python packages for services published from Pro- Deploy R for ArcGIS- Support new data types – Filters, Field- Move jobs directory to Azure
• ArcGIS Pro 2.5 and Enterprise 10.8- Specify Environmental Variables from the client- Provide image service URL for raster input
Major Web Tool New Features
Useful Links• Session scripts, models, and data http://bit.ly/2Wqdjys• Sharing web tool with python https://bit.ly/3ausYRm• Quick tour of sharing web tool https://bit.ly/2wrfHdw• Quick tour of sharing GP service https://bit.ly/32Ocq48• Deploy 3rd party python packages https://bit.ly/38o1Rpt• Accessing web tool from Notebook https://bit.ly/2vG1fy7• Sign in Portal https://bit.ly/38lAbBx• CreateGPSDDraft https://bit.ly/39viDVi• Stage https://bit.ly/3axcfwv• Upload Service Definition https://bit.ly/3au5Oua