Skip to main content
Gathering Interest

Make the 'NoFeaturesTester' a Standard Transformer

Related products:FME Form
  • September 24, 2021
  • 9 replies
  • 237 views

mmccart
Enthusiast
Forum|alt.badge.img+28

The 'NoFeaturesTester' custom transformer currently out on FME Hub is powerful. However, we're getting pushback from IT from using it in our production workspaces in FME Server. We've benchmarked their work-arounds, and it slows down the workspace significantly (2 seconds with NFT vs. 2.5 minutes with their suggested alternatives).


My idea: Harden this transformer and turn into a standard transformer.

9 replies

redgeographics
Celebrity
Forum|alt.badge.img+62

Great idea, but I do have a workaround for your IT department:

A custom transformer is essentially a couple of FME transformers pretending they're a new one... so really it's nothing you couldn't have done yourself, but I'm assuming it's the "downloaded off the internet" that's triggering your IT people.

You can right-click it, see how it's made and then essentially recreate the whole thing yourself ¯\\_(?)_/¯


mmccart
Enthusiast
Forum|alt.badge.img+28
  • Author
  • Enthusiast
  • October 5, 2021

Thanks @redgeographics for the suggestion. We had already tried that before I posted this idea. They shut us down on that work-around as well.


fmelizard
Safer
Forum|alt.badge.img+21
  • Safer
  • October 8, 2021

Couldn't resist giving this a try with the PythonCaller and a tiny bit of Python code (below).

 

My test workspace is at https://safe.my.salesforce.com/sfc/p/30000000ePES/a/4Q00000062X8/qxo57.8oLO_rAboNjMhtCPdEoJmLdAuLjB0KRXrSv4c

 

@mhab has in the past suggested we build in a set of "logic" type transformers like this -- NAND, NOR, EOR, OR, AND, etc -- that basically produce logic output (true/false) by either emitting or not emitting a feature based on the arrival (or not) of features into one or two input ports (depending on the primitive we're evaluating). Seems like we should do this.

 

In the short term, I trust you're allowed to use a simple PythonCaller...

 

Python code for the PythonCaller below:

 

import fme

import fmeobjects

 

class FeatureProcessor(object):

 

  def __init__(self):

    """Base constructor for class members."""

    self.noFeatures_ = True;

    pass

 

  def input(self, feature):

    """

    If any feature comes in, we just delete it and set the flag to indicate that we did receive

    something. We don't output the feature -- it is just swallowed up.

    """

    self.noFeatures_ = False;

 

  def close(self):

    """

    If we never saw any input features, then we will output something. Otherwise, no output.

    """

    if self.noFeatures_:

      newFeature = fmeobjects.FMEFeature()

      self.pyoutput(newFeature)

 

    pass

 


mmccart
Enthusiast
Forum|alt.badge.img+28
  • Author
  • Enthusiast
  • October 11, 2021

Thanks @daleatsafe! I'll take a look.


ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • October 13, 2021

I've used python in a similar way to @daleatsafe 's suggestion - details here as I can't post code or images as a comment https://community.safe.com/s/question/0D54Q000080hL1rSAE/is-there-a-way-to-log-an-error-when-no-features-in-input-file-or-when-feature-type-not-exists-


mmccart
Enthusiast
Forum|alt.badge.img+28
  • Author
  • Enthusiast
  • October 14, 2021

Thanks @ebygomm, I'll take a look.


david_r
Celebrity
  • April 5, 2023

This is such an incredibly useful transformer, I'm surprised that it hasn't been promoted to a first order transformer yet!


david_r
Celebrity
  • April 5, 2023

Formatting for legibility :-)

import fme
import fmeobjects
 
class FeatureProcessor(object):
 
  def __init__(self):
    """Base constructor for class members."""
    self.noFeatures_ = True
 
  def input(self, feature):
    """
    If any feature comes in, we just delete it and set the flag to indicate that
    we did receive something.
    We don't output the feature -- it is just swallowed up.
    """
    self.noFeatures_ = False
 
  def close(self):
    """
    If we never saw any input features, then we will output something. 
    Otherwise, no output.
    """
    if self.noFeatures_:
      newFeature = fmeobjects.FMEFeature()
      self.pyoutput(newFeature)

 


LizAtSafe
Safer
Forum|alt.badge.img+18
  • Safer
  • November 26, 2025
OpenGathering Interest