Skip to main content
Question

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

  • August 1, 2016
  • 2 replies
  • 62 views

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

jdh
Contributor
Forum|alt.badge.img+41
  • 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