Code source — overview
A code source tells the runtime where to find executable code for a Function or Workflow.
Quick types
code— inline plain-text source (short scripts). See Plain text.code_src— URI to a source (local file, git repo, S3 ZIP, HTTP/HTTPS). See Code source URI.
Quick checklist
- Small snippet? use
code. - Files or archives stored remotely or in VCS? use
code_srcand pick the appropriate scheme.
Plain text source
Provide code as a string containing the source code.
Example
my_code = """
def myfunction(di):
return di
"""
func = dh.new_function(name="python-function", kind="python", code=my_code, handler="myfunction")
Code source URI
code_src points to a file or archive. Pick the scheme that matches where your code lives:
- Local single file —
path/to/file.py— details: Local file - Git repo —
git+https://...— details: Git repository - S3 ZIP —
zip+s3://bucket/key.zip— details: S3 zip archive - HTTP(S) file or ZIP —
https://.../zip+https://...— details: HTTP(S)
Handler
The handler defines the function entrypoint. Rules:
- For inline (
code), base64 and local files: use the function name (e.g.myfunction). - For repos/archives/remote ZIPs: use
module.path:funcorpath.to.file:funcdepending on runtime.
Example (git repo)
handler="src.pipeline:main" — runtime imports src/pipeline.py and calls main.