How does one specify the Environments honored by a geoprocessing tool in a Python toolbox and have them show up in the Environments tab?

3307
22
02-22-2018 06:39 AM
JacquesBeaurain
New Contributor III

Example

This is for inside ArcGIS Pro but I assume it also applies to Desktop. I assume there is some way to advertise the environments in same way as the internal tools do but could not locate a single example or mention of it in the documentaion.

Thanks

22 Replies
DanPatterson_Retired
MVP Emeritus

you can't hide anything... you can set stuff see my example of using an existing file... 

You can even set stuff in an accompanying script and 'import' it just like any other module.

XanderBakker
Esri Esteemed Contributor

As you already discovered, you cannot hide the environment settings that are not relevant to the tool. Would be nice if that would be possible. However, you can provide a description to the end user in your tool to indicate which settings are relevant. When the user decides to change other settings, they won't effect the tool, nor other processes (since they were defined at the tool run level).

See the hierarchy in defining the environment setting What is a geoprocessing environment setting?—Geoprocessing | ArcGIS Desktop :

Environment hierarchy

0 Kudos
JacquesBeaurain
New Contributor III

It would actually be better if it was a problem of note being able to hide them (as is the case with tools custom script tools created via the catalog). Once again; note I am not implementing a Custom toolbox but rather a Python toolbox. In the Python toolbox that tab is empty.

I should have probably attached the following to my original question to clear up the confusion since we seem to be caught up in discussions about custom toolboxes. Here is what my tools show:

0 Kudos
XanderBakker
Esri Esteemed Contributor

I see... What environment settings would you like to provide to the end user in your python toolbox tool?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Not sure if they show in the environments tab for python toolboxes... don't use them, so I can't test

But they can be defined ie

Setting a default value from an environment...

    http://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/defining-parameters-in-a-python-...

0 Kudos
JacquesBeaurain
New Contributor III

At this moment I want to expose the build pyramids and statistics settings, but potentially might want to add others like output coordinate system etc. I know it is possible to add an input parameter for each of the settings involved but that really bloats the input parameters unnecessarily and puts controls in the first tab (Parameters) that belong in the second (Environment).

0 Kudos
DanPatterson_Retired
MVP Emeritus

Use a regular toolbox since you really haven't specified any real need for a python toolbox unless I am missing something from your description of the tool's purpose

JacquesBeaurain
New Contributor III

There are multiple reasons for using a python toolbox outlined in:  Comparing custom and Python toolboxes.  My reasons align with the ones described there (e.g. maintainability as well as test-ability since validation logic is defined in Python code, value tables etc.) and I am also building a toolbox that will be installed on systems with a Pro SDK AddIn that utilizes them inside the arcgispro-py3 environment along with dependent Python packages etc. The toolbox need to appear for any ArcGIS Pro project without users needing to import them into each project.

DanPatterson_Retired
MVP Emeritus

I am familiar with the differences.  I just do my validation differently.  Yes, a multiuser environment can be a hastle.  As for a toolbox appearing in any new project, ...at least at the single user level, ... is readily handled under Project, Options, General, Default toolbox (use the same toolbox as the default for all projects).  BUT that won't help if you have several toolboxes to use.  

Good luck... maybe put in an ArcGIS Idea if we haven't overlooked something simple

JacquesBeaurain
New Contributor III

Thanks. I just https://community.esri.com/ideas/14621. Guess I was just holding on to the fact that I might be missing some existing way to do this. I assume the internal tools uses something of this sort.