Back

Function not deploying

  • 1
  • Functions
mitsy0_0
24 May, 2023, 04:20

Hey I made a python cron function that's just adding values to collection, but when I deploy it, I get this error

TypeScript
import json
import pandas as pd
from appwrite.client import Client
from appwrite.services.databases import Database

def init_client():
    # Initialize the Appwrite client
    client = Client()
    client.set_endpoint("https://cloud.appwrite.io/v1")
    client.set_project("646769a1263324aecec0")
    client.set_key("API_KEY")

    return client

def main():

    client = init_client()
    database = Database(client)


    database.create_document("646a552f4564180c1531", {
        'company_name': "Utopia",
        'job_title': "Software Engineer",
        'about_company': "Utopia is a software company that builds software for the future",
        'location': "Remote",
        'skills_required': "Python, Java, C++",
        'job_responsibilities': "Build software for the future",
        'job_requirements': "Must have 5 years of experience",
        'logo': "https://www.utopia.com/logo.png"
    }, read=['*'])

if __name__ == "__main__":
    main()```

Error:
TL;DR
The user is experiencing issues with deploying a Python function for Appwrite. They are following a repository that may not be updated, and the function structure does not align with the Appwrite documentation. The user also has a cron function that is adding values to a collection, but they encounter an error when deploying it. Solution: 1. Use the Appwrite CLI to initialize and deploy the starter python function. 2. Ensure that the function structure aligns with the Appwrite documentation. 3. Check if the repository being followed is updated or not. 4. For the cron function, make sure that the API key and project ID are correctly
Drake
24 May, 2023, 04:48

This doesn't look like the right structure for an Appwrite Function. Make sure to follow the docs: https://appwrite.io/docs/functions

mitsy0_0
24 May, 2023, 05:39
mitsy0_0
24 May, 2023, 05:48

also, according to the docs, is it necessary to return a res, cause I just want this function to directly update values in the collection?

mitsy0_0
24 May, 2023, 06:08

Am I doing something wrong, even this is not deploying😫

TypeScript

def main(req, res):
  payload = req.payload or 'No payload provided. Add custom data when executing function.'

  secretKey = req.variables.get(
    'api_key,
    'SECRET_KEY variable not found. You can set it in Function settings.'
  )

  randomNumber = random.random()

  # trigger = req.variables['APPWRITE_FUNCTION_TRIGGER']

  return res.json({
    'message': 'Hello from Appwrite!',
    'payload': payload,
    'secretKey': secretKey,
    'Number': 123,
  })```
Drake
24 May, 2023, 07:06

That repo is archived

Drake
24 May, 2023, 07:07

I highly recommend using the Appwrite CLI to initialize and deploy the starter python function. Then, you can tweak it accordingly

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