Skip to main content
Question

Python caller gives no output


bertbooneman
Participant
Forum|alt.badge.img

When i use the python caller i get a translation successful, but it gives no output.

I'm not very good at python, so do any of you have an idea what i did wrong?

 

6 replies

j.botterill
Influencer
Forum|alt.badge.img+40
  • Influencer
  • April 22, 2024

One tip might be to capture some of the Python processing into your FME transaction log https://support.safe.com/s/article/logging-with-python-scripts

 

In a PythonCaller (or PythonCreator) transformer, messages are added to the logfile with the FMELogFile object, which is part of the fmeobjects. You need to create a logger object: logger = fmeobjects.FMELogFile() and then you will need to send messages to the logger: logger.logMessageString("Hello I am Logging Now")


jkr_wrk
Influencer
Forum|alt.badge.img+29
  • April 22, 2024

On what row did you type:

self.pyoutput(feature)

?


hkingsbury
Celebrity
Forum|alt.badge.img+54
  • Celebrity
  • April 22, 2024

  

As @jkr_wrk mentioned, you’re missing

self.pyoutput(feature)

The purpose of this line is to output the resulting features. At a guess, you’d want this to be on line 25, indented to the same level as line 18.


Having it here will output every feature you input into the pythoncaller


shelton786
BANNED

Hello,

If your python script completes without errors but lacks output, check for print statements to ensure results are displayed. Verify input handaling and run the script interactively for step by step debugging. Look for silent errors in the console and test with sample data to confirm expected behavior.


geomancer
Evangelist
Forum|alt.badge.img+48
  • Evangelist
  • April 23, 2024

I'm no python expert, but these lines look very strange:

y = 'true' if not feature.getattribute('Score 6 t/m 18') else 'false' 

if "bebouwing" in x and y == "true": 

I'm pretty certain this will not do what you want it to do.


jkr_wrk
Influencer
Forum|alt.badge.img+29
  • April 23, 2024

I did not look into all the PythonCaller code before.

FME is in principal a NoCode application to do all the things you want to do. It looks like you don't have much experience in coding in Python or using Python in FME.

The function you are writing is very easy to do using 1 or 2 transformers, so it looks like you should keep away from the PythonCaller.

Except when your only goal is to learn to use the PythonCaller in general because you are certain that there are things you want to do that FME can't do with basic transformers.


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