I have a geoprocessing script written in Python that includes a main file, several .py files, and a config.json file. I want to publish it as a geoprocessing service in ArcGIS Enterprise 10.9.1.
In ArcGIS Pro, I set up a new script in the default toolbox, ran it, and published it as a geoprocessing service. However, when I tried to use it, I noticed that while the .py files were uploaded to the server's service directory, the config.json file was not included.
Is there any way to ensure the config.json file is uploaded so the service can access it without having to manually copy and paste it?
Hi Edgar,
Did you find a solution to this? I current have the same problem in that I want to include a config.ini file when I publish the geoprocessing service. It feels like we can't be the first people to have wanted to do something like this.
After a great deal of head scratching and frustration I found a workaround:
I created a config.py that contained a single line and placed it in the same location as my script tool (.pyt file):
config_file = "config.ini"
then in my script tool, I imported the config.py and declared an unused variable referencing config_file attribute in the config.py:
import config as config
script_dir = os.path.dirname(os.path.abspath(__file__))
f_config_path = os.path.join(script_dir, mappingini.config_filepath)
this was enough for to force the geoprocessing creation service in ArcGIS Pro to include my config.ini in the same folder as the script tool on the server. Then I could use it as intended later in the script tool:
config = configparser.RawConfigParser()
config.read(pathlib.Path(__file__).parent / "config.ini")