Back

python function

  • 1
  • Functions
Mosh Ontong
25 Apr, 2023, 14:40

I tried to list all the available functions by calling this

TypeScript
list_functions = functions.list()

This 64440ec6e53a950b0858 function id is included in list_functions, now this is my main code:

TypeScript
for index, row in df.iterrows():
    audio_file_id = row['$id']
    file_name = row['name']
    data={"audio_id":audio_file_id, "name":file_name}
    json_encode = json.dumps(data)
    create_copy = functions.create_execution("64440ec6e53a950b0858", data= json_encode)
    create_copy
    # print("result ", index, ": ",data)
    break

But it gives me this:

Error: 500 Server Error: Internal Server Error for url Return: {"message":"Function with the requested ID could not be found.","code":404,"type":"function_not_found","version":"1.3.1"}

TL;DR
The user is experiencing an error when executing a Python function via a request in the newer version of Appwrite. The error suggests a server error. Another user suggests checking the logs in the appwrite folder to debug the issue. The original poster confirms that this solution works. The user also asks how to view the logs when hosting Appwrite on Digital Ocean. One user provides the solution to view logs in a self-hosted setup. The original poster confirms that the code now works. The user then asks how to view the logs for the function execution and provides two more questions related to the error. Another user asks for the full error from the
joeyouss
25 Apr, 2023, 14:52

Hi - let me look into this

joeyouss
25 Apr, 2023, 15:06

what does the create_execution method give you if you do not add data param

Mosh Ontong
25 Apr, 2023, 15:22

still the same Ms.

Mosh Ontong
25 Apr, 2023, 15:55

is this a bug Ms? @joeyouss

joeyouss
25 Apr, 2023, 16:57

It does not seem like a bug, can you check how did you make your API key? we usually need API keys for authentication and they need to be created with execution.write scope, can you confirm this was done?

Ponguta_
25 Apr, 2023, 17:48

Can you share a bit more of your code?

Mosh Ontong
26 Apr, 2023, 00:19

the api have this scopes

Mosh Ontong
26 Apr, 2023, 00:29

I will private message my colab link @joeyouss @Ponguta_

joeyouss
26 Apr, 2023, 08:30

replied to you in DMs

Ponguta_
26 Apr, 2023, 14:41

I have replied to you

Ponguta_
27 Apr, 2023, 14:01

Did you fix it @Mosh Ontong ?

Mosh Ontong
27 Apr, 2023, 23:13

Not yet

Drake
27 Apr, 2023, 23:30

can i see the code too?

Mosh Ontong
27 Apr, 2023, 23:58

I will dm it to you sir @Steven

Drake
28 Apr, 2023, 00:04

what's the full error from appwrite docker logs for the 500 error?

Drake
28 Apr, 2023, 00:19

And 2 more things:

  1. I got the code to run by changing the create_exection to:
TypeScript
create_copy = functions.create_execution("64440ec6e53a950b0858", "{}", False)
  1. I think the function was executed successfully, but the function itself had problems. What do the function logs show?
Mosh Ontong
28 Apr, 2023, 00:21

How can I view the logs? Since I hosted my appwrite in digital ocean?

Mosh Ontong
28 Apr, 2023, 00:24

Ohhhhh thank you steve, this code works thank youuu

Drake
28 Apr, 2023, 00:25

same as any self-hosted setup. Your appwrite folder is probably at /root/appwrite. See https://appwrite.io/docs/debugging#logs

Luczek
14 Jun, 2023, 16:24

Hi I have some issue with function execution via request. My request looks like this:

TypeScript
from appwrite.client import Client
from appwrite.services.functions import Functions

client = Client()
    (client
     .set_endpoint(api_endpoint)  # Your API Endpoint
     .set_project(project_ID)  # Your project ID
     .set_key(api_key) # Your secret API key
     )

    functions = Functions(client)

    result = functions.create_execution(function_ID, data=json.dumps({
        'before': before,
        'after': after,
        'responder': responder,
    }))```

Through payload my cloud function receives data needed for work. Same request worked for earlier appwrite version but my company requested me to work with the newer one and that's when the problem started. Request above throws an error like this:
```  File "/home/jan/.local/lib/python3.10/site-packages/appwrite/client.py", line 109, in call
    raise AppwriteException(response.json()['message'], response.status_code, response.json().get('type'), response.json())
appwrite.exception.AppwriteException: Server Error

How to wokr though this error ?

Drake
14 Jun, 2023, 17:31

It would be best to create a new post rather than posting in an old thread

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more