Skip to content

YepCode Python Code Rules

This file provides guidelines for LLMs to write Python code compatible with YepCode platform and ready to use its specific helpers.

Download this file

AspectGuideline
RuntimePython 3.13
Main file (process)main.py
Entry pointdef main()
Parametersyepcode.context.parameters
Variablesos.getenv("X") or yepcode.env.X
Modulesyepcode.import_module("module-slug")
  • Always define a main() function
  • Never call main() directly
  • Always add try/except around the main flow for actionable errors
  • ✅ Follow PEP 8 (and add type hints when useful)
def main():
# Access input parameters
parameters = yepcode.context.parameters
# Your code here
# Return result
return { "message": "Success!" }
  • Access execution info: execution_id = yepcode.execution.id
  • Access process info: process_id = yepcode.execution.process.id
  • Access schedule info (if present): scheduleId, scheduleComment = yepcode.execution.schedule.id, yepcode.execution.schedule.comment
  • Access team timezone: timezone = yepcode.execution.timezone
  • Use environment variables: api_key = os.getenv("API_KEY") # or yepcode.env.API_KEY
  • Import YepCode modules: client = yepcode.import_module("module-name")
    • Caution: module names must be hardcoded strings (no variables)
  • Import with version: client = yepcode.import_module("module-name", "v1.0")
  • Run another process: yepcode.processes.run("process-identifier", options)
print("INFO message") # Generates INFO level log
logger.debug("DEBUG message")
logger.info("INFO message")
logger.warn("WARNING message")
logger.error("ERROR message")
  • You may use external pip packages.
  • Just add the import statement and the package will be installed automatically.
  • If the package name differs from the import name, use the @add-package comment:
# @add-package requests
import requests
import os
# Calculate the path to the temporary file
file_path = os.path.join(os.environ.get("TMP_DATA_DIR"), "myfile.txt")
# Writing a file
with open(file_path, 'w') as f:
f.write('Hello from YepCode!')
import json
# Setting a value
yepcode.datastore.set("key", "value")
# Setting a object value
yepcode.datastore.set("key", json.dumps({ "name": "John", "age": 30 }))
# Getting a value
value = yepcode.datastore.get("key")
# Deleting a value
yepcode.datastore.delete("key")
import os
local_path = os.path.join(os.environ.get("TMP_DATA_DIR"), "localfile.txt")
# Uploading a file
with open(local_path, "rb") as f:
obj = yepcode.storage.upload("path/myfile.txt", f)
print("Uploaded:", obj.name, obj.size, obj.link)
# Listing files
objects = yepcode.storage.list()
# Downloading a file
content = yepcode.storage.download("path/myfile.txt")
with open(local_path, "wb") as f:
f.write(content)
# Deleting a file
yepcode.storage.delete("path/myfile.txt")
return { "message": "Success!" }
  • This is the format for custom HTTP status codes:
return {
"status": 404,
"body": { "message": "Not found" },
"headers": { "Content-Type": "application/json" }
}
return {
"transient": True,
"data": sensitive_data
}