Skip to main content
Question

Compress FGDB with ArcGIS Pro tool in FME

  • May 1, 2025
  • 1 reply
  • 25 views

fikusas
Contributor
Forum|alt.badge.img+5

I’m trying to compress FGDB with ArcToolbox tool with PythonCaller. This gives no error, but nothing happens after running it. What I am missing? Using FME 2024 with ArcGIS Pro 3.4. Compatability is set to ArcGIS Python 3.11.

 

import fme
import arcpy

def compress_fgdb(fme_feature):

    fgdb_path = fme.macroValues['FGDB_PATH']

    arcpy.management.CompressFileGeodatabaseData(fgdb_path, "Lossless compression")

    return fme_feature

 

1 reply

hkingsbury
Celebrity
Forum|alt.badge.img+54
  • Celebrity
  • May 1, 2025

As python in FME has evolved, its gotten a bit stricter with how its setup. I generally reccomend to not make any changes to the initial setup of the PythonCaller.

In older versions you were able to call a function directly like that, but now you need to specify a class for the transformer to call.

 

in 2024.2 this is how the python caller should look. Note that your above code is in the input function on lines 30 and 32. The transformer is calling the FeatureProcessor class

 

import fme
from fme import BaseTransformer
import fmeobjects


class FeatureProcessor(BaseTransformer):
    """Template Class Interface:
    When using this class, make sure its name is set as the value of the 'Class to Process Features'
    transformer parameter.

    This class inherits from 'fme.BaseTransformer'. For full details of this class, its methods, and
    expected usage, see https://docs.safe.com/fme/html/fmepython/api/fme.html#fme.BaseTransformer.
    """

    def __init__(self):
        """Base constructor for class members."""
        pass

    def has_support_for(self, support_type: int):
        """This method is called by FME to determine if the PythonCaller supports Bulk mode,
        which allows for significant performance gains when processing large numbers of features.
        """
        return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM

    def input(self, feature: fmeobjects.FMEFeature):
        """This method is called for each feature which enters the PythonCaller."""



        fgdb_path = fme.macroValues['FGDB_PATH']

        arcpy.management.CompressFileGeodatabaseData(fgdb_path, "Lossless compression")



        self.pyoutput(feature, output_tag="PYOUTPUT")

    def close(self):
        """This method is called once all the FME Features have been processed from input()."""
        pass

    def process_group(self):
        """This method is called by FME for each group when group processing mode is enabled."""
        pass

    def reject_feature(self, feature: fmeobjects.FMEFeature, code: str, message: str):
        """This method can be used to output a feature to the <Rejected> port."""
        feature.setAttribute("fme_rejection_code", code)
        feature.setAttribute("fme_rejection_message", message)
        self.pyoutput(feature, output_tag="<Rejected>")

 


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