Skip to main content
Question

Can PythonCaller determine which transformer/source a feature is from?


I have several (SQLCreator) sources and other transformers all feeding into a PythonCaller. I'm using the PythonCaller to pull certain attributes from each feature and create new features.

Is there a good way to determine which features come from which sources/transformers inside the Python script?

Currently I'm testing each feature for specific attributes, but this will not work for situations where features from multiple sources have the same attributes.

2 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • August 1, 2016

I create a specific attribute, that explicitly contains what "stream" the data is coming from.

 

There is an attributeCreator on each stream just prior to the PythonCaller, with a common attribute (I use _!type) with a different value for each stream. I retrieve that value in the PythonCaller and test for the various values.

 

Likewise if I want to split the output, I attach a temporary attribute to the outgoing feature and use a tester/testfilter after the PythonCaller.

Forum|alt.badge.img
  • August 1, 2016

Hello @carlreedw

For these transformers:

0684Q00000ArJv0QAF.png

The following python code will display:

Creator_CREATED

Creator_2_CREATED

 

import fme
import fmeobjects

class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        print str(feature.getFeatureType())
        self.pyoutput(feature)
    def close(self):
        pass

Regards,

Larry


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