Cannot access FME workbenches from arcpy in ArcGIS 10 (sp1) environment

2865
2
09-18-2011 06:31 PM
HugoBouckaert
New Contributor II
I have a problem with accessing Data Interoperability (FME) workbenches version 10.0 from python (arcpy) using ArcGIS Desktop 10, service pack 1. 

The purpose is to run several FME translators as a batch script without having to open ArcCatalog, the toolbox, and in the toolbox, the Data Interoperability workbenches themselves. This is so the process of importing (and translating) data can be automated.

The way that this works (from the documentation) is that you import the ArcGIS toolbox in your arcpy environment and then run the workbenches in the toolbox. For example I have a toolbox named "SDE Loads.tbx" which contains several FME workbenches. To import in arcpy I do the following: 

arcpy.ImportToolbox("D:/FME/SDE Loads.tbx")

A toolbox has a name alias (right click on toolbox, -> properties with the name to be found in the �??Name�?� properties box). Each FME workbench in the toolbox also has an alias (right click on FME workbench, -> properties with the name to be found in the �??Name�?� properties box). The way that python then is suposed to call the FME workbench (to execute the FME translation) is with the following format:

FMEworkbenchAlias_ToolboxAlias(input parameters)

However this rarely works as most times, the workbench aliases in the toolbox cannot be found. However note that if other objects in the toolbox are created, such as models, they can always be found. This proves that both the toolbox as well as tools in the toolbox can be found, with the exception of FME workbenches.

Note that the way I check whether models, scripts or FME workbenches can be found in the toolbox is with the following code:

tools = arcpy.ListTools("*_ToolboxAlias")
for tool in tools:
        print tool
        print arcpy.Usage(tool)

Sometimes (and it is not known why) the workbench tools are listed in the �??print tool�?� and print arcpy.Usage(tool) enumeration, but in most cases, they are not listed at all, only other model tools in the toolbox. When FME workbenches are not listed, the workbenches cannot be executed as they cannot be found.

There seems to be no discernable pattern in when FME workbenches cannot be found using arcpy (in most cases), or can be found (sometimes). Closing and reopening the toolbox, ArcCatalog or even the Windows login account on the computer where this is run from makes no difference.

Note that in all cases, in arcpy, I am checking out the date interoperability license extension and include a message that I have successfully obtained the license extension. This is the code :

try:
        if arcpy.CheckExtension("DataInteroperability") == "Available":
            arcpy.CheckOutExtension("DataInteroperability")
            print "Checked out \"DataInteroperability\" Extension"
        else:
            raise LicenseError
    except LicenseError:
        print "Data Interoperability license is unavailable"
    except:
        print arcpy.GetMessages(2) 

Hence not having a license extension is not the cause of not finding the workbench aliases. It must be something else. Would someone be able to help?

Thanks very much.

Hugo
0 Kudos
2 Replies
CurtisFast
New Contributor
Hi Hugo,

While you mentioned that there is "no discernable pattern" for this issue, is there another computer with ArcGIS available to you, to determine whether this issue is reproducible?

When it comes to naming, I'm quite cautious and keep all three toolbox names the same (name & label & alias) and stick with alphanumeric characters (staying away from special characters like spaces, dashes & underscores).  Similarly, I keep the ETL Tool names simple and identical (name & label).  Then for my "first cut" of the Python script, I usually add the ETL Tool to a model and then export to Python.

Long ago, I ran into an issue where I could not invoke one of my tools.  I noticed that it had the same tool name as another tool, but in a different toolbox.  When I renamed the tool to a unique name, then it ran fine again.  Unfortunately, I don't currently have the details for this issue, so I don't know whether this was an issue with ArcGIS Geoprocessing or whether I simply hadn't set all of the names/aliases appropriately.

While trying to reproduce this issue just now, I created two toolboxes named ETLToolbox and ETLToolbox2, each containing the two ETL Tools named mif2gmlETLTool and mif2gmlETLTool2.  My Python script successfully invoked each ETL Tool in each of the toolboxes:

import arcpy
arcpy.CheckOutExtension("DataInteroperability")
arcpy.ImportToolbox("C:/data/ETLToolbox.tbx")
arcpy.ImportToolbox("C:/data/ETLToolbox2.tbx")
arcpy.mif2gmlETLTool_ETLToolbox("C:\\data\\province.mif", "C:\\data\\out\\province1.gml")
arcpy.mif2gmlETLTool2_ETLToolbox("C:\\data\\province.mif", "C:\\data\\out\\province2.gml")
arcpy.mif2gmlETLTool_ETLToolbox2("C:\\data\\province.mif", "C:\\data\\out\\province3.gml")
arcpy.mif2gmlETLTool2_ETLToolbox2("C:\\data\\province.mif", "C:\\data\\out\\province4.gml")

Hopefully something in this post might be helpful.  If you have a reproducible scenario, then I'm sure Esri support would like to hear about it!  (And so would I!)

Curtis Fast.
Safe Software, Inc.
0 Kudos
HugoBouckaert
New Contributor II
Hi Curtis

Sorry to get back to you so late and thanks for the information. I did resolve this issue some time ago, and you are right, it has to do with having name and label the same, and using simple naming for workbench tools in the toolbox. I think I also make the mistake to confuse the toolbox and toolbox alias (one has the .tbx extension and the other does not). Lastly, one has to close ArcCatalog for any changes in naming etc to take affect, and for python one has to close and restart Idle to recognise the changes made in toolbox and tool names.

Cheers

Hugo 
   

Hi Hugo,

While you mentioned that there is "no discernable pattern" for this issue, is there another computer with ArcGIS available to you, to determine whether this issue is reproducible?

When it comes to naming, I'm quite cautious and keep all three toolbox names the same (name & label & alias) and stick with alphanumeric characters (staying away from special characters like spaces, dashes & underscores).  Similarly, I keep the ETL Tool names simple and identical (name & label).  Then for my "first cut" of the Python script, I usually add the ETL Tool to a model and then export to Python.

Long ago, I ran into an issue where I could not invoke one of my tools.  I noticed that it had the same tool name as another tool, but in a different toolbox.  When I renamed the tool to a unique name, then it ran fine again.  Unfortunately, I don't currently have the details for this issue, so I don't know whether this was an issue with ArcGIS Geoprocessing or whether I simply hadn't set all of the names/aliases appropriately.

While trying to reproduce this issue just now, I created two toolboxes named ETLToolbox and ETLToolbox2, each containing the two ETL Tools named mif2gmlETLTool and mif2gmlETLTool2.  My Python script successfully invoked each ETL Tool in each of the toolboxes:

import arcpy
arcpy.CheckOutExtension("DataInteroperability")
arcpy.ImportToolbox("C:/data/ETLToolbox.tbx")
arcpy.ImportToolbox("C:/data/ETLToolbox2.tbx")
arcpy.mif2gmlETLTool_ETLToolbox("C:\\data\\province.mif", "C:\\data\\out\\province1.gml")
arcpy.mif2gmlETLTool2_ETLToolbox("C:\\data\\province.mif", "C:\\data\\out\\province2.gml")
arcpy.mif2gmlETLTool_ETLToolbox2("C:\\data\\province.mif", "C:\\data\\out\\province3.gml")
arcpy.mif2gmlETLTool2_ETLToolbox2("C:\\data\\province.mif", "C:\\data\\out\\province4.gml")

Hopefully something in this post might be helpful.  If you have a reproducible scenario, then I'm sure Esri support would like to hear about it!  (And so would I!)

Curtis Fast.
Safe Software, Inc.
0 Kudos