Skip to main content
Solved

Multiple output tags in custom Python transformer ?

  • March 12, 2017
  • 2 replies
  • 57 views

Forum|alt.badge.img

Hi,

As my alter-ego "lifalin2016" i brazenly proclaimed in a post in June that "I have the multiple OUTPUT tags option covered". This is unfortunately not really the case (anymore).

The PythonFactory documentation clearly states, that multiple output tags are possible (as in the "[...]*" notation), but I get an error when using them: "The clause 'OUTPUT PYOUTPUT ...' is incorrect.  The OUTPUT PYOUTPUT clause is already specified". I assume the doc is faulty then.

It's then back to a single output + a number of TeeFactory's. I seem to remember this being mentioned by one of y'all at some point, but I can't seem to locate it anywhere :-/

Unfortunately my experience with factories is limited, but here's my best shot (using an attribute named "___output_type___" to route features to the output tags SUCCEEDED and FAILED. But no features are output :-(

# after PythonFactory
FACTORY_DEF * TeeFactory
   FACTORY_NAME $(XFORMER_NAME)_Splitter1
   INPUT FEATURE_TYPE * ___output_type___ 1
   OUTPUT FEATURE_TYPE SUCCEEDED

FACTORY_DEF * TeeFactory
   FACTORY_NAME $(XFORMER_NAME)_Splitter2
   INPUT FEATURE_TYPE * ___output_type___ 2
   OUTPUT FEATURE_TYPE FAILED

Any help on this is appreciated.

Cheers

Lars I.

Best answer by gispro

Hi again,

Well, posting a question gives one time to pause and regroup ones thoughts, I suppose.

I managed to work it out, and is posting the resulting combination here for others that have the same need:

FACTORY_DEF * PythonFactory
    FACTORY_NAME $(XFORMER_NAME)
    PYTHON_NAMESPACE FMEOBJECTS
    INPUT FEATURE_TYPE *
    SYMBOL_NAME MyApplication.__instance__$(FME_UUID)
    OUTPUT PYOUTPUT FEATURE_TYPE ___from_python___
    
FACTORY_DEF * TeeFactory
   FACTORY_NAME $(XFORMER_NAME)_Splitter1
   INPUT FEATURE_TYPE ___from_python___ ___output_type___ 1
   OUTPUT FEATURE_TYPE $(OUTPUT_SUCCEEDED_FTYPE)

FACTORY_DEF * TeeFactory
   FACTORY_NAME $(XFORMER_NAME)_Splitter2
   INPUT FEATURE_TYPE ___from_python___ ___output_type___ 2
   OUTPUT FEATURE_TYPE $(OUTPUT_FAILED_FTYPE)

You set a feature attribute named "___output_type___" to a value of 1 or 2 before outputting the featurew with self.pyoutput(). The TeeFactory's route the features based on this value to the relevant output tag of the transformer.

Cheers.

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

Forum|alt.badge.img
  • Author
  • Best Answer
  • March 12, 2017

Hi again,

Well, posting a question gives one time to pause and regroup ones thoughts, I suppose.

I managed to work it out, and is posting the resulting combination here for others that have the same need:

FACTORY_DEF * PythonFactory
    FACTORY_NAME $(XFORMER_NAME)
    PYTHON_NAMESPACE FMEOBJECTS
    INPUT FEATURE_TYPE *
    SYMBOL_NAME MyApplication.__instance__$(FME_UUID)
    OUTPUT PYOUTPUT FEATURE_TYPE ___from_python___
    
FACTORY_DEF * TeeFactory
   FACTORY_NAME $(XFORMER_NAME)_Splitter1
   INPUT FEATURE_TYPE ___from_python___ ___output_type___ 1
   OUTPUT FEATURE_TYPE $(OUTPUT_SUCCEEDED_FTYPE)

FACTORY_DEF * TeeFactory
   FACTORY_NAME $(XFORMER_NAME)_Splitter2
   INPUT FEATURE_TYPE ___from_python___ ___output_type___ 2
   OUTPUT FEATURE_TYPE $(OUTPUT_FAILED_FTYPE)

You set a feature attribute named "___output_type___" to a value of 1 or 2 before outputting the featurew with self.pyoutput(). The TeeFactory's route the features based on this value to the relevant output tag of the transformer.

Cheers.


david_r
Celebrity
  • March 13, 2017

That's pretty fancy, would you perhaps share an example of how that would be implemented in a small sample workspace?