4

When publishing a geoprocessing service, I noticed that arcgis does not like to see:

os.path.join(os.path.dirname(__file__), 'projections')

This line seems to throw an broken project data source while analyzing the service for publishing to arcgis server.

I'm guessing its because the only the main .py file will be copied into the services directory and Esri is giving me a heads up that the data source is going to break because 'projections' folder will NOT be copied over.

In my case, I also have some unit test which reference a test_data folder and shouldn't affect the tool when running off the server. Unfortunately I still can't publish.

To publish, I:

  1. Moved my relative path references to a separate module named service_config.py
  2. imported the path constants from service_config.py
  3. Added a .pth file to Lib/site-packages to allow the services directory version of the script to still have references to the projection folder without needing it to be copied to the arcgisinput directory.

I feel like my solution is a hack. Any suggests on how to improve this tool configuration?

My code can be found here:

https://github.com/brendancol/esri-extract-data-where

1 Answer 1

1

Use full, literal path strings (eg c:\mydata\projections\hello.prj) in your scripts you plan on publishing as geoprocessing services. This way the publishing framework can find your data, consolidate it into a package, and publish it on the server. See this documentation for some hints. On 10.2, there is also a way to structure a Python package with data using distutils that will make it possible to use as a tool as well.

1
  • Cool, bit of a pain as we deploy across different environments, but at the same time, if we followed best practices setting up our environments the pathes shouldn't change. Thanks a lot for your help.
    – bcollins
    Commented Oct 18, 2013 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.