Giter VIP home page Giter VIP logo

Comments (8)

KevinRich651 avatar KevinRich651 commented on August 20, 2024

I think it should be
returnData.items = parseShellOutput(returnData.stdout)

from n8n-nodes-python.

naskio avatar naskio commented on August 20, 2024

Hi @KevinRich651
You can read this section on README https://github.com/naskio/n8n-nodes-python#notes
Actually, the stderr is the one used to pass data the between if the code == 0 otherwise stderr will represent an error.
Could you please provide more details such as your code and the error you are getting ?

from n8n-nodes-python.

KevinRich651 avatar KevinRich651 commented on August 20, 2024

hi @naskio

Many thanks for your reply.
Just now I read the note in Readme. Yes, the code logic is as you described.

The entire python code is huge. I removed the irrelevant code, only left the key part related to this issue. The code is as following:


# Get latest filename
filename_query = "SELECT filename......."

####......

print(new_filename)

# 5. Create points file based on rewards, aggregated by ABN & Name
##.........

# 6. Save points file

##...........

# 7. Add new rewards to GBQ table if file sent successfully saved

##...........

# 8. Update log table

points_amt = all_points_owed['points_amt'].sum()

query_string = f"""
    INSERT INTO ..........
"""

update = client.query(query_string).result()

fileNames = [{'filename':new_filename}]

print(fileNames)

return fileNames #CHANGE
  1. In the above code, print(fileNames) can be executed normally, and the fileNames is as expected:
    [{'filename': 'AWALLX03P.079'}]
    But this python node still failed.
  2. The failure reason I got on the n8n webpage is out of memory as the screenshot:
image
  1. But I the error I got on GCP logging (the n8n is self-hosted on GCP container) as following:
image

from n8n-nodes-python.

KevinRich651 avatar KevinRich651 commented on August 20, 2024

hi @naskio any ideas about this issue? Thank you in advance.

from n8n-nodes-python.

KevinRich651 avatar KevinRich651 commented on August 20, 2024

hi @naskio would you mind to take a brief look at this issue. Perhaps a cue from you will help me a lot.

from n8n-nodes-python.

naskio avatar naskio commented on August 20, 2024

Hi @KevinRich651
I don't think that the error is related to this package.
I suggest that you move all the code related to read/write data to DB outside the PythonNode
and keep only the processing part in the PythonNode, and move the queries to different nodes (You may find other nodes that will simplify the integration with the DB).

from n8n-nodes-python.

KevinRich651 avatar KevinRich651 commented on August 20, 2024

Thanks for your suggestion. I will take a try.

I am still confused why the error response in n8n web page and cloud logging is totally different?

from n8n-nodes-python.

KevinRich651 avatar KevinRich651 commented on August 20, 2024

hi @naskio I located the accurate line, which triggers the failure. I have never encountered so weird a issue...

try:
    # Bonus points offer, valid for KYC Pass Date >= 2023-06-01 & <= 2023-07-31
    qbr_eofy_new = all_data.copy()
    qbr_eofy_new = qbr_eofy_new[(qbr_eofy_new['kyc_pass_date']>=date(2023,6,1)) & (qbr_eofy_new['kyc_pass_date']<=date(2023,7,31))]
    qbr_eofy_new100k = qbr_eofy_new[(qbr_eofy_new['f_60_aud_fx_volume']>=50000)]
    qbr_eofy_new100k['points_owed_to_date'] = 100000
except:
    print("error")

print(qbr_eofy_new100k)

print(items)
return items

In the above code, all_data is a pandas Dataframe containing hundreds of rows.

It can run normally and output what I expect, no error log and items is a valid json array from the previous node.
But the workflow node PythonFunction containing the code still fail for an unknown reason...
image

But if I comment or remove the line qbr_eofy_new100k['points_owed_to_date'] = 100000
The workflow can function normally without any error... I have no idea what's wrong with such a simple code.

I run the above code in local environment, the code also runs normally.

My thoughts:

In the GCP logging, I still get the same error as I attached couple weeks ago.
But now I think that error SyntaxError: Unexpected token / in JSON at position 0 is not the root cause.
the return value items in the code didn't really return.

What weird! Hope to get some suggestions from you

from n8n-nodes-python.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.