Modelbuilder workspace problem

4386
5
Jump to solution
01-24-2017 01:31 AM
MatsNyborg
New Contributor II

I am trying to run a Modelbuilder model from ArcMap catalogue (ie. not inside Modelbuilder). In the modeI I have defined workspaces for current and scratch workspaces as model parameters (not connected, but as standalone model variables). I call upon these parameters using inline variables (%xxxx%). Also, in the environment for the model I have defined the parameters for current and scratch workspaces as inline variables.

However, when I run the model from catalogue level, I get error messages in reference to paths to workspace. When opening the model in edit mode, I notice that the defined paths to workspaces has changed. It now contains my default workspace in addtion to my inline variable, as defined for ArcMap.

I need to have workspaces transparent to the ArcMap installation (the model will need to be run from other ArcMap installations  - other users), not needing to go into the model and correct the paths before each execution. I cannot accept having hard coded paths for workspace and scratch.

How do I configure my model so that my paths not will be changed by ArcMap default configuration?

I am working on ArcMap 10.3.

Best regards,

Mats

1 Solution

Accepted Solutions
ScottFierro2
Occasional Contributor III

Trying to piece a few of these items together. We use inline variables in over 100 ETL's but we do not define the current workspace or scratch as environment variables.

If all your users are going to be running this out of some flavor of Arc then because they have Arc installed you should be able to leverage ESRI's scratch space without defining anything on your own. ESRI will recognize and use the same user dependent location when you make use of %scratchWorkspace%\ or %scratchFolder%. You can read up more about it and depending on systems and data size making use of the "in_memory" call might be useful https://blogs.esri.com/esri/arcgis/2012/10/19/the-new-scratchgdb-and-scratchfolder-environments/

The user based paths will look like this C:\Users\<user_name>\AppData\Local\Temp\5\arcBC74 but the last 2 folders will vary so you may see something like C:\Users\<user_name>\AppData\Local\Temp\2\arcDT51 or C:\Users\<user_name>\AppData\Local\Temp\7\arcFG26

Hopefully that can work to resolve your scratch concerns, you can build these directly into the model without needing to define model parameters and it will work for all your users. Moving on to the current workspace need.

We essentially define our current workspaces without the use of defining a model parameter but it does mean where/when you need a workspace call that you simply connect it to the tool as an input. We assign a workspace (for us a .sde connection) as a data type = workspace and inline variable name of %TargetWorkspace%. This variable we then map into our tools that call for it.

No model level environment variables set:

Connected use of inline variable for %TargetWorkspace% (would be your current workspace) to 3 tools:

View solution in original post

5 Replies
DanPatterson_Retired
MVP Emeritus

have you set it up to use relative paths? Setting general model properties—Help | ArcGIS Desktop 

Step 11 in this... Tutorial: Creating tools with ModelBuilder—Help | ArcGIS Desktop 

They are pretty well your options relative or hardcoded

ScottFierro2
Occasional Contributor III

Trying to piece a few of these items together. We use inline variables in over 100 ETL's but we do not define the current workspace or scratch as environment variables.

If all your users are going to be running this out of some flavor of Arc then because they have Arc installed you should be able to leverage ESRI's scratch space without defining anything on your own. ESRI will recognize and use the same user dependent location when you make use of %scratchWorkspace%\ or %scratchFolder%. You can read up more about it and depending on systems and data size making use of the "in_memory" call might be useful https://blogs.esri.com/esri/arcgis/2012/10/19/the-new-scratchgdb-and-scratchfolder-environments/

The user based paths will look like this C:\Users\<user_name>\AppData\Local\Temp\5\arcBC74 but the last 2 folders will vary so you may see something like C:\Users\<user_name>\AppData\Local\Temp\2\arcDT51 or C:\Users\<user_name>\AppData\Local\Temp\7\arcFG26

Hopefully that can work to resolve your scratch concerns, you can build these directly into the model without needing to define model parameters and it will work for all your users. Moving on to the current workspace need.

We essentially define our current workspaces without the use of defining a model parameter but it does mean where/when you need a workspace call that you simply connect it to the tool as an input. We assign a workspace (for us a .sde connection) as a data type = workspace and inline variable name of %TargetWorkspace%. This variable we then map into our tools that call for it.

No model level environment variables set:

Connected use of inline variable for %TargetWorkspace% (would be your current workspace) to 3 tools:

MatsNyborg
New Contributor II

Thank very much! This was very helpful. I will try this. I might get back to you with more questions.

MatsNyborg
New Contributor II

Hi again Scott,

I have tried to follow your ideas. The model works perfectly on my machine, but there is still problems when switching to another user.

The scratch for ArcGIS is defined under Geoprocessing / Envrioments... / Workspace:

In my model I call for the scratch geodatabase by using the inline variable %scratchworkspace% or %scratchGDB%. It seems like both variants are accepted.

However, when the other user tries the same, the model writes scratch data in windows temp directory in Shape format.

 -----

ERROR 000229: Cannot open C:\windows\system32\EnskildVag_GrupperaLinjer1.dbf

Failed to execute (Dissolve).

Failed at Wed Jan 25 15:10:03 2017 (Elapsed Time: 0,01 seconds)

Failed to execute (Model323).

Failed at Wed Jan 25 15:10:03 2017 (Elapsed Time: 30,15 seconds)

-----

This causes my model to stop functioning in further processing. It seems like it does not find the geodatabase to write in, and therefore writes in Shape format in the windows directory. Why is this?

Regards,

Mats

0 Kudos
ScottFierro2
Occasional Contributor III

Ohhh ok, sorry I see so I gave you details regarding the individual model level but left out overall environment variables, etc. So below is the screen shot from our desktop environment where we leave those blank and that allows ESRI to use the default paths I had given you before for C:\<user name>

Here is a screen shot of what the published service looks like from the server and as you can see there is no physical scratch.gdb being used the way that there is an output.gdb which is by design because we run a process to zip the output.gdb and provide it through the front end interface for user downloads.