<?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: Publishing Geoprocessing Service that use Feature Service URLs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162170#M64302</link>
    <description>&lt;P&gt;Can you please post your code snippet to show how you are using defining the URL and using it to access the data store?&lt;/P&gt;</description>
    <pubDate>Thu, 07 Apr 2022 15:58:45 GMT</pubDate>
    <dc:creator>DonMorrison1</dc:creator>
    <dc:date>2022-04-07T15:58:45Z</dc:date>
    <item>
      <title>Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162149#M64301</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I've developed a script tool which I'm looking to publish as a GP service. The script leverages several feature service URLs from our Enterprise system hard-coded inputs for the script; using direct DB connections to the under lying database isn't a viable option.&lt;/P&gt;&lt;P&gt;Obviously, you cannot/do not register server URLs with your Data Store, but since the validation process cannot find these resources in the Data Store, it warns that the data source is not registered and will therefore be copied.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;inFeatures = "https://myserver.mydomain.com/server/rest/services/Folder/FeatureServiceName/FeatureServer/1"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought that maybe I could simply parameterize these URLs in the Script Tool but I'm not sure that you can make these hidden or locked.&lt;/P&gt;&lt;P&gt;Is there anyway to go about publishing this without using a direct DB connection?&lt;/P&gt;&lt;P&gt;EDIT: I'm suddenly remembering something about registering a folder that contains a valid AGS connection file...hmmm&lt;/P&gt;&lt;P&gt;UPDATE: No dice. I saved a server connection file (.ags) to a folder registered with the data store, but I've am not able to use this input in any code. For example, making a feature layer from the REST endpoint for the layer within the feature service using the .ags file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;testLayer = arcpy.management.MakeFeatureLayer("\\\\sharedLocation\\Folder\\AGSConnections\\connectionFile.ags\\serverFolder\\featureService.FeatureServer\\layer","test")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Note this is the format used if you drag the layer from ags connection file in the catalog pane to the Python window in Pro.]&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 16:52:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162149#M64301</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-04-11T16:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162170#M64302</link>
      <description>&lt;P&gt;Can you please post your code snippet to show how you are using defining the URL and using it to access the data store?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 15:58:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162170#M64302</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-04-07T15:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162181#M64303</link>
      <description>&lt;P&gt;I'm simply referencing them to the Feature Service REST endpoints like so:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;inFeatures = "https://myserver.mydomain.com/server/rest/services/Folder/FeatureServiceName/FeatureServer/1"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Apr 2022 16:19:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162181#M64303</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-04-07T16:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162367#M64307</link>
      <description>&lt;P&gt;If it is the consolidation process that is changing the string to something incorrect (I've seen this happen with directory paths but not urls), then I've been able to get around problems like that by breaking up the string literal. I'm not sure if this is relevant to your situation......&lt;/P&gt;&lt;P&gt;Here is an example of how I did it&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    # To get around a problem with consolidation we break the template directory name apart
    # to trick the consolidator so it doesn't try to change the path (for shared projects the
    # consolidator puts the files in the right place but generates the wrong path literals)
    template_rptx = os.path.dirname(__file__) + os.path.sep +  'report' + '_' + 'templates' + os.path.sep +  'CCAA_Report.rptx'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 00:02:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162367#M64307</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-04-08T00:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162368#M64308</link>
      <description>&lt;P&gt;It's not during consolidation, it's during validation because it's evaluating the URL as a data source registered with the data store or not. And since the data store does not register valid REST endpoints but only direct DB connections, this will raise an error and advise to copy the data to the server (a silly circular reference).&lt;/P&gt;&lt;P&gt;That said, the faking the string as you suggested is intriguing and I will try that to see if it sneaks by the validation.&lt;/P&gt;&lt;P&gt;It's odd that this isn't accounted for since Python web API would happily use a feature service URL even in a federated environment and you could share (and possibly publish, I've not tried) that notebook but for a script tool you cannot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously the script tool works just fine while using Pro (it's not necessary to add the layers to your session but only that Pro is logged into Portal).&lt;/P&gt;&lt;P&gt;I can flip this to direct GDB connections but it will be so so slow (remote DB in the cloud) for the initial run of the script tool just&amp;nbsp; so that I can capture the result and use that to publish the GP Service.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 00:18:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1162368#M64308</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-04-08T00:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1179085#M64687</link>
      <description>&lt;P&gt;I'm unfortunately still not having any luck with this.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 17:01:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1179085#M64687</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-06-01T17:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1188683#M64882</link>
      <description>&lt;P&gt;Is there anyone from Esri willing to answer this? We have a number of GP tools we'd like to roll out to our users that are currently working in Pro using FS within the code but cannot be successfully published.&lt;/P&gt;&lt;P&gt;Why wouldn't you want to leverage the speed of FS in your code vs direct GDB connections?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 13:19:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1188683#M64882</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-07-01T13:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1319642#M68439</link>
      <description>&lt;P&gt;Does anyone have any suggestions regarding this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone utilize Feature Services as an input to GP Tools??&lt;/P&gt;&lt;P&gt;Here's what Chat GPT 4 had to offer:&lt;/P&gt;&lt;P&gt;It sounds like you're facing an issue while trying to publish a geoprocessing tool to ArcGIS Server that uses a feature service as input. The problem arises because ArcGIS Server doesn't support registering a feature service with ArcGIS Datastore, which leads to a failure during the validation process. Here are a few steps you can consider to resolve this issue:&lt;/P&gt;&lt;P&gt;1. **Use a Geoprocessing Service**: Instead of trying to publish the geoprocessing tool with the feature service as input directly, you could create a separate geoprocessing service that takes the feature service as input and then use that geoprocessing service as a tool within the main tool you're trying to publish.&lt;/P&gt;&lt;P&gt;2. **Data Extract**: Depending on the nature of your geoprocessing task, you could use the feature service as a reference but extract the necessary data to a file geodatabase or other supported data source that can be used in the geoprocessing tool. This extracted data could then be included with your geoprocessing tool when you publish it.&lt;/P&gt;&lt;P&gt;3. **Temporary Feature Class**: If possible, you could create a temporary feature class within a supported geodatabase (like a file geodatabase) and populate it with the features from the feature service. This temporary feature class could be used as input for your geoprocessing tool.&lt;/P&gt;&lt;P&gt;4. **Data Replication**: If your workflow requires frequent updates to the feature service, you could consider setting up a data replication process where the feature service's data is periodically copied to a registered data source that is compatible with ArcGIS Server.&lt;/P&gt;&lt;P&gt;5. **Contact Esri Support**: If you're still facing issues, it might be a good idea to reach out to Esri's technical support. They can provide you with more specific guidance and troubleshoot your scenario to find the best solution.&lt;/P&gt;&lt;P&gt;Remember that the specifics of your workflow and environment can influence the best approach to take. Choose the option that aligns most closely with your requirements and available resources.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 15:29:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1319642#M68439</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2023-08-17T15:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1400460#M70155</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/194227"&gt;@ZacharyHart&lt;/a&gt;&amp;nbsp;, I know this is a late but I put my urls in a text file and read them from it. This excludes it from the tool validation.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 17:51:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1400460#M70155</guid>
      <dc:creator>cepsgis</dc:creator>
      <dc:date>2024-03-25T17:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1536160#M72796</link>
      <description>&lt;P&gt;Edit - 2/19/25&lt;/P&gt;&lt;P&gt;I've completely updated my answer. Prior answer I put them as parameter objects in the Python toolbox - this worked initially, but subsequently, I was getting new errors&lt;BR /&gt;.&lt;/P&gt;&lt;P&gt;Simpler approach:&lt;/P&gt;&lt;P&gt;I publish the Python toolbox tool from ArcGIS Pro and get a successful run in my ArcGIS Pro History.&amp;nbsp; Then prior to publishing the tool as a web tool, I comment out all the code in execute() where the URLs are located - minus a pass statement.&amp;nbsp; Then I publish the tool to Portal.&amp;nbsp; I subsequently edit the .pyt file directly where it was copied to ArcGIS Server and uncomment out the code.&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;C:\arcgisserver\directories\arcgissystem\arcgisinput\[folder]\[web tool/GP tool name].GPServer\extracted\p20\report\[my python toolbox file].pyt&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 21:59:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1536160#M72796</guid>
      <dc:creator>Ed-Conrad</dc:creator>
      <dc:date>2025-02-19T21:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1546345#M73002</link>
      <description>&lt;P&gt;Did you ever figure this out&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/194227"&gt;@ZacharyHart&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 21:58:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1546345#M73002</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2024-10-07T21:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1585579#M73744</link>
      <description>&lt;P&gt;I experienced this issue myself when trying to set up a local script as a GP service - I foolishly thought that the validation would "just know" that the hard-coded feature services were feature services and not local data and therefore would not attempt to copy the data when publishing. I attempted to publish the script with the hard-coded URLs and I ended up having to kill the publishing job as we all know it attempted to copy the data to the server despite no actual local data being referenced in the script.&lt;/P&gt;&lt;P&gt;The issue with validation flagging feature service URLs as file directories can be avoided by storing all URLs in a YAML configuration file. Instead of embedding/hard-coding the URLs directly in the script or tool, reference them dynamically by reading from the YAML file at runtime. This way, the only file that gets copied with the GP service is the small YAML file, avoiding any validation errors related to directory structures and drastically reducing the time to publish the GP service.&lt;/P&gt;&lt;P&gt;For example, you can structure the YAML file like this:&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;portal: 
   master_fs: https://yourserver.com/FeatureServer/0
feature_services:
  other_fs1: "https://yourserver.com/FeatureServer/1"
  other_fs2: "https://yourserver.com/FeatureServer/2"
  other_fs3: "https://yourserver.com/FeatureServer/3"&lt;/LI-CODE&gt;&lt;P&gt;Then, in your script, load the URLs dynamically:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import yaml

def read_config(config_path):
    with open(config_path, 'r') as file:
        return yaml.safe_load(file)

config = read_config("config.yaml")
master_feature_service = config["portal"]["master_fs"]
feature_service_urls = config["feature_services"]&lt;/LI-CODE&gt;&lt;P&gt;This approach ensures that no hardcoded paths cause validation issues and makes it easier to update URLs without modifying the script itself. You can modify the YAML file published with the GP service by going to the file directory for the GP service on your server if you need to add/remove variables.&lt;/P&gt;&lt;P&gt;Hope this helps anyone that has been struggling with this issue!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2025 17:42:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1585579#M73744</guid>
      <dc:creator>samc-gis</dc:creator>
      <dc:date>2025-02-14T17:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing Geoprocessing Service that use Feature Service URLs</title>
      <link>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1585611#M73745</link>
      <description>&lt;P&gt;Yes or regular old text file works also.&amp;nbsp; In the end now I just comment out my script totally, publish, then on the server uncomment it back.&amp;nbsp; Works way faster and then nothing gets repathed at all.&amp;nbsp; Took some convincing with IT but now I can skip all validation.&amp;nbsp; Script is much cleaner now and I can publish in like a min vs the 20 minutes it was taking to repath on me.&amp;nbsp; Then going forward I just make changes to the script on the server vs republishing.&amp;nbsp; I know its not great to change production like that but I only really do it for dev scripts.&amp;nbsp; Light years faster to troubleshoot the 500 other things that break in GP services.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2025 18:26:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-geoprocessing-service-that-use-feature/m-p/1585611#M73745</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2025-02-14T18:26:18Z</dc:date>
    </item>
  </channel>
</rss>

