Skip to main content

Hi group (especially @mark2catsafe I think).

Is it possible to build a custom transformer with Python with multiple INPUT tags? Much like what's possible with a custom transformer in Workbench.

I have the multiple OUTPUT tags option covered, but can't seem to find any examples of multiple INPUTs.

I've scrutinized an FMW file with an embedded custom transformer with two input tags, but can't find anything relating to tags, just a bunch of TeeFactory's.

Is it possible to make one such? And if so, how should one define them in the FMX file?

Cheers

 

Lars

After some thinking, it dawned on me, that the custom transformers i a Workbench is really an illusion, since it all ends up in a single FME file, with the custom transformer(s) being added into the general workflow. That explains the TeeFactories. So no help there :-(

What I'm looking for, or rather: asking about, is something like the FeatureMerger, which has 2 inputs and 4 outputs. As I wrote, I know how to add multiple outputs, but multiple inputs is not as obvious.

Cheers

 

Lars

After some thinking, it dawned on me, that the custom transformers i a Workbench is really an illusion, since it all ends up in a single FME file, with the custom transformer(s) being added into the general workflow. That explains the TeeFactories. So no help there :-(

What I'm looking for, or rather: asking about, is something like the FeatureMerger, which has 2 inputs and 4 outputs. As I wrote, I know how to add multiple outputs, but multiple inputs is not as obvious.

Cheers

 

Lars

Just an idea: have you tried saving your custom transformer as a linked transformer (.fmx) file and looking inside?


After some thinking, it dawned on me, that the custom transformers i a Workbench is really an illusion, since it all ends up in a single FME file, with the custom transformer(s) being added into the general workflow. That explains the TeeFactories. So no help there :-(

What I'm looking for, or rather: asking about, is something like the FeatureMerger, which has 2 inputs and 4 outputs. As I wrote, I know how to add multiple outputs, but multiple inputs is not as obvious.

Cheers

 

Lars

I don't know how to implement a transformer with Python, but the syntax for GUI definition in fmx files is common to every language and that is described in the "Transformer Definition Documentation" (Knowledge Center > FME Documentation).

In the documentation you can see how to define multiple input tags, and also there are many examples in the "<FME_HOME>/transformers/fmesuite.fmx" file.


Alas, David, the exported FMX file has a completely different format from what is used with the sample custom tranformers. It includes some XML format which I'm uncertain what to do with, and the same FME factories I saw in the original FMW file.

Takashi, yes, the fmesuite.fmx did contain the examples I needed ! :-)

It also includes samples of versioned transformers, something I most likely will get to at some point, so it's a great reference. I wasn't aware that FME had this external reference to its internal transformers.

Thanks guys for helping me along.

Cheers

 

Lars

Hi Lars. Glad to see you have this working. The only other thing I can add is that it might be useful for you to sign up to our developer program. With this you can get free dev licenses and specific development support direct from Safe. You can find more information online at:

https://www.safe.com/partners/technology-partner/


Just in case anyone arrives here in the future looking for some answers, achieving this can be quick tricky depending on what you are trying to achieve. The answer definitely lies in the the Transformer fmx definition which, as takashi highlights, can be found in the documentation though at times unclear so the fmesuite.fmx makes a good reference.

Generally, using the fmx format, one defines the input ports as named ports. The Python factory works the same as the PythonCaller, so with only one input method and only pyoutput to export features this means any given Python class is a straight through 1:1 pipe. However, with other built in FME factories (like the aforementioned TeeFactory) you can play clever games.

For the N:1 case where you simply want to bring in features with a particular tag to drive processing logic, you can set a new attribute on the Python factory input that can be addressed within your class.

For the 1:N case the best option is before you call pyoutput on your feature, to set a temporary attribute for routing. Then in the Python factory definition, set the output to an internal location, then follow the Python factory with some TestFactories or TeeFactories etc... similar to the AttributeFilter to route the features to their respective output ports

For the N:N case, well that could get quite tricky and require a fair amount of planning and tricks depending on how much the data needs to interact. You could use the combination of the two above, or you could create a more complex class hierarchy with an instance for each input/output port combo, then set each instance with an attribute representing the other instances so they can communicate, then do some complex internal routing.


Reply