<?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: Hardcoded path and registered folder as datastore in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/hardcoded-path-and-registered-folder-as-datastore/m-p/1293980#M26893</link>
    <description>&lt;P&gt;Thank you for your answer &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/17963"&gt;@DEWright_CA&lt;/a&gt; .&lt;/P&gt;&lt;P&gt;So I changed my code for&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def execute(self, parameters, messages):
    """The source code of the tool."""

    dem_dir = r"\\files\D\1_DATA\8_Raster\MNT\MNT_2021\Assemblage"
    dem_name = "MNT_2021_CD17_EPSG3857.tif"
    dem = os.path.join(dem_dir, dem_name)
    #dem = r"\\files\D\1_DATA\8_Raster\MNT\MNT_2021\Assemblage\MNT_2021_CD17_EPSG3857.tif"
    
    feat_dir = r"\\files\D\1_DATA\8_Raster\MNT\MNT_2021\Assemblage\interpolation.gdb"
    feat_name = "line"
    feat = os.path.join(feat_dir, feat_name)
    #feat = r"\\files\D\1_DATA\8_Raster\MNT\MNT_2021\Assemblage\interpolation.gdb\line"
    
    interp_line = r"memory\interpouttmp"
    
    arcpy.sa.InterpolateShape(in_surface=dem,
                                 in_feature_class=feat,
                                 out_feature_class=interp_line,
                                 vertices_only="VERTICES_ONLY")
    
    arcpy.SetParameter(0, interp_line)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I changed registered Datastore from&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Publisher Folder Path: K:\8_Raster&lt;/LI&gt;&lt;LI&gt;Publisher Folder Hostname: agserver&lt;/LI&gt;&lt;LI&gt;Server Folder Path: /home/adminsig/datastore_rasters/&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;to&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Publisher Folder Path: \\files\D\1_DATA\8_Raster&lt;/LI&gt;&lt;LI&gt;Server Folder Path: /home/adminsig/datastore_rasters/&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Is that what you suggested &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/17963"&gt;@DEWright_CA&lt;/a&gt; ?&lt;/P&gt;&lt;P&gt;I'm not sure because the issue remains. Publisher folder path is not converted to Server folder path in the published python script.&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2023 14:35:27 GMT</pubDate>
    <dc:creator>OlivierLefevre</dc:creator>
    <dc:date>2023-05-31T14:35:27Z</dc:date>
    <item>
      <title>Hardcoded path and registered folder as datastore</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/hardcoded-path-and-registered-folder-as-datastore/m-p/1293513#M26888</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've been trying to author a geoprocessing service that uses data stored in a folder of the ArcGIS Server machine.&lt;/P&gt;&lt;P&gt;Below is the code of the Python Toolbox I run before publishing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "PythonToolbox"
        self.alias = "mypythontoolbox"

        # List of tool classes associated with this toolbox
        self.tools = [PyToolInterpolation]


class PyToolInterpolation(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "PyToolInterpolation"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""
        param0 = arcpy.Parameter(
            displayName="Resultat",
            name="result",
            datatype="GPFeatureLayer",
            parameterType="Derived",
            direction="Output")
        params = [param0]
        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""
        return
        
    def execute(self, parameters, messages):
        """The source code of the tool."""

        dem_dir = r"K:\8_Raster\MNT\MNT_2021\Assemblage"
        dem_name = "MNT_2021_CD17_EPSG3857.tif"
        dem = os.path.join(dem_dir, dem_name)
        #dem = r"K:\8_Raster\MNT\MNT_2021\Assemblage\MNT_2021_CD17_EPSG3857.tif"
        
        feat_dir = r"K:\8_Raster\MNT\MNT_2021\Assemblage\interpolation.gdb"
        feat_name = "line"
        feat = os.path.join(feat_dir, feat_name)
        #feat = r"K:\8_Raster\MNT\MNT_2021\Assemblage\interpolation.gdb\line"
        
        interp_line = r"memory\interpouttmp"
        
        arcpy.sa.InterpolateShape(in_surface=dem,
                                     in_feature_class=feat,
                                     out_feature_class=interp_line,
                                     vertices_only="VERTICES_ONLY")
        
        arcpy.SetParameter(0, interp_line)

    def postExecute(self, parameters):
        """This method takes place after outputs are processed and
        added to the display."""
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In ArcGIS Server Manager's Data Stores tab I registered the folder that contains data before publication.&lt;BR /&gt;So the publisher folder path is mapped with the server folder path where the data is duplicated.&lt;BR /&gt;This way data are not copied when publishing.&lt;/P&gt;&lt;P&gt;I don't understand why the Python script on server-side keeps using publisher pathes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Esri start of added imports
import sys, os, arcpy
# Esri end of added imports

# Esri start of added variables
g_ESRI_variable_1 = 'K:\\8_Raster\\MNT\\MNT_2021\\Assemblage'
g_ESRI_variable_2 = 'K:\\8_Raster\\MNT\\MNT_2021\\Assemblage\\interpolation.gdb'
g_ESRI_variable_3 = 'memory\\interpouttmp'
# Esri end of added variables

import os
import arcpy

class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "PythonToolbox"
        self.alias = "mypythontoolbox"

        # List of tool classes associated with this toolbox
        self.tools = [PyToolInterpolation]


class PyToolInterpolation(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "PyToolInterpolation"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""
        param0 = arcpy.Parameter(
            displayName="Resultat",
            name="result",
            datatype="GPFeatureLayer",
            parameterType="Derived",
            direction="Output")
        params = [param0]
        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""
        return
        
    def execute(self, parameters, messages):
        """The source code of the tool."""

        dem_dir = g_ESRI_variable_1
        dem_name = "MNT_2021_CD17_EPSG3857.tif"
        dem = os.path.join(dem_dir, dem_name)
        #dem = r"K:\8_Raster\MNT\MNT_2021\Assemblage\MNT_2021_CD17_EPSG3857.tif"
        
        feat_dir = g_ESRI_variable_2
        feat_name = "line"
        feat = os.path.join(feat_dir, feat_name)
        #feat = r"K:\8_Raster\MNT\MNT_2021\Assemblage\interpolation.gdb\line"
        
        interp_line = g_ESRI_variable_3

        arcpy.sa.InterpolateShape(in_surface=dem,
                                     in_feature_class=feat,
                                     out_feature_class=interp_line,
                                     vertices_only="VERTICES_ONLY")
        
        arcpy.SetParameter(0, interp_line)

    def postExecute(self, parameters):
        """This method takes place after outputs are processed and
        added to the display."""
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think it should be using pathes like&amp;nbsp;'/home/adminsig/datastore_rasters/MNT/MNT_2021/Assemblage/' and&amp;nbsp;'/home/adminsig/datastore_rasters/MNT/MNT_2021/Assemblage/interpolation.gdb'&lt;/P&gt;&lt;P&gt;The geoprocessing task works if I update the server-side Python script with those pathes.&lt;/P&gt;&lt;P&gt;Is there a way to author this geoprocessing without doing this script modification ?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 14:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/hardcoded-path-and-registered-folder-as-datastore/m-p/1293513#M26888</guid>
      <dc:creator>OlivierLefevre</dc:creator>
      <dc:date>2023-05-31T14:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoded path and registered folder as datastore</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/hardcoded-path-and-registered-folder-as-datastore/m-p/1293521#M26889</link>
      <description>&lt;P&gt;I have found that actually pathing my scripts to use a UNC\SMB script; then having that published to my DataStore alleviates this issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 16:34:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/hardcoded-path-and-registered-folder-as-datastore/m-p/1293521#M26889</guid>
      <dc:creator>DEWright_CA</dc:creator>
      <dc:date>2023-05-26T16:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Hardcoded path and registered folder as datastore</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/hardcoded-path-and-registered-folder-as-datastore/m-p/1293980#M26893</link>
      <description>&lt;P&gt;Thank you for your answer &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/17963"&gt;@DEWright_CA&lt;/a&gt; .&lt;/P&gt;&lt;P&gt;So I changed my code for&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def execute(self, parameters, messages):
    """The source code of the tool."""

    dem_dir = r"\\files\D\1_DATA\8_Raster\MNT\MNT_2021\Assemblage"
    dem_name = "MNT_2021_CD17_EPSG3857.tif"
    dem = os.path.join(dem_dir, dem_name)
    #dem = r"\\files\D\1_DATA\8_Raster\MNT\MNT_2021\Assemblage\MNT_2021_CD17_EPSG3857.tif"
    
    feat_dir = r"\\files\D\1_DATA\8_Raster\MNT\MNT_2021\Assemblage\interpolation.gdb"
    feat_name = "line"
    feat = os.path.join(feat_dir, feat_name)
    #feat = r"\\files\D\1_DATA\8_Raster\MNT\MNT_2021\Assemblage\interpolation.gdb\line"
    
    interp_line = r"memory\interpouttmp"
    
    arcpy.sa.InterpolateShape(in_surface=dem,
                                 in_feature_class=feat,
                                 out_feature_class=interp_line,
                                 vertices_only="VERTICES_ONLY")
    
    arcpy.SetParameter(0, interp_line)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I changed registered Datastore from&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Publisher Folder Path: K:\8_Raster&lt;/LI&gt;&lt;LI&gt;Publisher Folder Hostname: agserver&lt;/LI&gt;&lt;LI&gt;Server Folder Path: /home/adminsig/datastore_rasters/&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;to&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Publisher Folder Path: \\files\D\1_DATA\8_Raster&lt;/LI&gt;&lt;LI&gt;Server Folder Path: /home/adminsig/datastore_rasters/&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Is that what you suggested &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/17963"&gt;@DEWright_CA&lt;/a&gt; ?&lt;/P&gt;&lt;P&gt;I'm not sure because the issue remains. Publisher folder path is not converted to Server folder path in the published python script.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 14:35:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/hardcoded-path-and-registered-folder-as-datastore/m-p/1293980#M26893</guid>
      <dc:creator>OlivierLefevre</dc:creator>
      <dc:date>2023-05-31T14:35:27Z</dc:date>
    </item>
  </channel>
</rss>

