Skip to main content
Solved

How to get the path/location of a transformer like the log files do?


nic_ran
Contributor
Forum|alt.badge.img+16

Is there any way to get the “path” of a transformer so that it can be reported for a custom error logging solution. The standard FME log file has this information but I can’t find any way of getting at it inside a workspace.

For example, in the image below we can see log lines being reported from a ParameterFetcher transformer which is inside the Log_Error custom transformer.

 

 

If I could even just get the name/instance of the custom transformer that would be helpful but something really useful would be to have access to the <prior> transformer.

I’ve seen some other posts on this topic which talk about hard-coding log messages but it would be nice to have a more automated approach and those posts are all from before Safe changed the way log files work to include the links to the transformers….

I guess what I’m really looking for is access to something like the FME equivalent of a stack trace from any point within a workspace.

Best answer by nic_ran

I got a partial solution figured out but it feels like a bit of a hack and it could easily break in future versions of FME. It would be fantastic if Safe could make an official Python API call to get this information.

The solution relies on a call to feature.getFeatureType() inside a Python caller. This call will return the name of the previous transformer plus it’s output port, plus (sometimes but not always) some random FME identifier. If the transformer is inside a custom transformer then the ct name is prepended, just like in the log files.

e.g. MyCustomTransformer_HTTPCaller_<REJECTED>_1_3kjhdD3

There are two problems with this solution:

  1. You can’t turn it into a custom transformer because then you will always get the name of the custom transformer itself (not the previous transformer outside the custom transformer).
  2. You need to hard-code the name of the output port from the previous transformer into the Python code. If you don’t care about removing the port name from the result then I guess it doesn’t matter.

 

 

Here’s the code:

   def input(self, feature):

      # Set the name of the output port from the previous transformer that's

      # connected to this PythonCaller.

      connected_port_name = 'Input'

       

      ft = feature.getFeatureType()

      portName_idx = ft.rfind(f'_{connected_port_name}')

      if portName_idx != -1:

         ft = ft[0:portName_idx] # remove the port name from the end of the transformer name

      feature.setAttribute("_transformer_name",ft)

      self.pyoutput(feature)
 

 

View original
Did this help you find an answer to your question?

3 replies

nic_ran
Contributor
Forum|alt.badge.img+16
  • Author
  • Contributor
  • Best Answer
  • June 19, 2025

I got a partial solution figured out but it feels like a bit of a hack and it could easily break in future versions of FME. It would be fantastic if Safe could make an official Python API call to get this information.

The solution relies on a call to feature.getFeatureType() inside a Python caller. This call will return the name of the previous transformer plus it’s output port, plus (sometimes but not always) some random FME identifier. If the transformer is inside a custom transformer then the ct name is prepended, just like in the log files.

e.g. MyCustomTransformer_HTTPCaller_<REJECTED>_1_3kjhdD3

There are two problems with this solution:

  1. You can’t turn it into a custom transformer because then you will always get the name of the custom transformer itself (not the previous transformer outside the custom transformer).
  2. You need to hard-code the name of the output port from the previous transformer into the Python code. If you don’t care about removing the port name from the result then I guess it doesn’t matter.

 

 

Here’s the code:

   def input(self, feature):

      # Set the name of the output port from the previous transformer that's

      # connected to this PythonCaller.

      connected_port_name = 'Input'

       

      ft = feature.getFeatureType()

      portName_idx = ft.rfind(f'_{connected_port_name}')

      if portName_idx != -1:

         ft = ft[0:portName_idx] # remove the port name from the end of the transformer name

      feature.setAttribute("_transformer_name",ft)

      self.pyoutput(feature)
 

 


hkingsbury
Celebrity
Forum|alt.badge.img+55
  • Celebrity
  • June 22, 2025

I think you should add this as in Idea - https://community.safe.com/ideas

 

You’d get my vote!


nic_ran
Contributor
Forum|alt.badge.img+16
  • Author
  • Contributor
  • June 27, 2025

@hkingsbury  I added this as an Idea if you’d like to vote for it: 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings