Skip to content

Python entrypoints

uptimely.entrypoint loads Python callables and inspects their annotated signatures. Entry points use module:function syntax and can refer to an importable module, a local Python file, an HTTPS URL, or an S3 URI.

Use Entrypoint to access the function and module. Load the callable with entrypoint.function.load() and inspect its annotations with entrypoint.function.signature.

Only load trusted code

Both loading a callable and reading its signature import and execute the referenced Python module. S3 access requires the uptimely-core[s3] extra.

entrypoint

Load Python function entrypoints and read their annotated signatures.

REMOTE_SCHEMES module-attribute

REMOTE_SCHEMES = {'https', 's3'}

REMOTE_READ_TIMEOUT module-attribute

REMOTE_READ_TIMEOUT = 30

Entrypoint

Parse and expose the module and function addressed by an entrypoint.

root instance-attribute

root = root

module property

module: Module

Return the module component of this entrypoint.

function property

function: Function

Return the function component of this entrypoint.

Module

Represent and load a Python module from a file, import path, or URL.

location instance-attribute

location = location

root instance-attribute

root = root

load

load() -> types.ModuleType

Import the represented Python module.

load_external

load_external() -> types.ModuleType

Load the represented source file from HTTPS or S3.

Function

Represent a named callable in a Python module.

module instance-attribute

module = module

name instance-attribute

name = name

signature property

signature: Signature

Return the annotated signature of this function.

load

load() -> typing.Callable[..., typing.Any]

Import the callable from its module.

Signature dataclass

Annotated input and output types of a Python function.

args class-attribute instance-attribute

args: dict[str, str] = dataclasses.field(default_factory=dict)

returns class-attribute instance-attribute

returns: str | None = None

read classmethod

read(function: Function) -> Signature

Read the annotated argument and return types of a function.

TypeAnnotation

Format Python type annotations for display.

name staticmethod

name(annotation: object) -> str

Return a readable name for a type annotation.