Skip to content

Python entrypoints

An entrypoint identifies a function with "module.path:function_name". Install the function's package in both the build and runtime environments. Uptimely inspects function signatures before compilation and loads the function when the engine runs. Signature inspection is performed by the independent Binding inspector, not by the compiler.

from uptimely.codebase.python.entrypoint import Entrypoint

function = Entrypoint("my_package.calculations:calculate").load()

Loading an entrypoint imports and runs the referenced module. Only load code you trust. Use PackageOrigin to inspect installed package information without importing the function module.

Compatibility façade for Python entrypoint APIs.

Entrypoint

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

module cached property

module: Module

Return the module component of this entrypoint.

function cached property

function: Function

Return the function component of this entrypoint.

read_package

read_package() -> origin.PackageOrigin

Read package provenance for this entrypoint without importing its module.

read_source_origin

read_source_origin(project_root: Path | None) -> origin.SourceOrigin

Identify the callable's implementation as project or installed code.

Parameters:

Name Type Description Default
project_root Path | None

Project directory, or None when it is unavailable.

required

Returns:

Type Description
SourceOrigin

Verified source origin and, for installed code, the distribution name.

read_signature

read_signature() -> signatures.Signature

Import this entrypoint and read its callable signature.

Raises:

Type Description
ValueError

The callable signature cannot be inspected.

from_path classmethod

from_path(path: Path, import_root: Path, function_name: str) -> Entrypoint

Create an entrypoint for a Python file beneath an import root.

Parameters:

Name Type Description Default
path Path

Python source file to address.

required
import_root Path

Directory from which the file is importable.

required
function_name str

Function or attribute name in the module.

required

Returns:

Type Description
Entrypoint

An entrypoint using the file's dotted module path.

format classmethod

format(module_path: str, function_name: str) -> str

Format validated module and function names as an entrypoint.

resolve

resolve() -> object

Resolve the object named by this entrypoint.

load

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

Load the callable and identify the entrypoint in resolution errors.

Returns:

Type Description
Callable[..., Any]

The resolved Python callable, without enforcing a package version.

Raises:

Type Description
ValueError

The module or callable cannot be resolved.

Function dataclass

Represent a named callable in a Python module.

module instance-attribute

module: Module

name instance-attribute

name: str

docstring cached property

docstring: str | None

Return the cleaned docstring of this function, importing its module.

from_callable classmethod

from_callable(function: object) -> Function

Create a function reference from a callable's module and qualified name.

read_signature

read_signature() -> signatures.Signature

Import this function and read its annotated signature.

Raises:

Type Description
ImportError

The function's module or a dependency cannot be imported.

NameError

A signature annotation refers to an unavailable name.

TypeError

The resolved function has no inspectable signature.

ValueError

The function's signature or annotations cannot be inspected.

read_display_signature

read_display_signature() -> signatures.DisplaySignature

Import this function and read its presentation-oriented signature.

resolve

resolve() -> object

Resolve the object named by this function reference.

load

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

Import the callable from its module.

Module dataclass

Represent and load an importable Python module.

location instance-attribute

location: str

source_file property

source_file: str

Return the loaded module's file path.

Accessing this property imports and executes the module if needed.

Raises:

Type Description
ValueError

The module does not identify a source file.

is_valid_location staticmethod

is_valid_location(location: str) -> bool

Return whether a string is an importable dotted module name.

find_import_root staticmethod

find_import_root(project_root: Path) -> pathlib.Path

Find the import root above enclosing regular Python packages.

Parameters:

Name Type Description Default
project_root Path

Project directory that may itself be a Python package.

required

Returns:

Type Description
Path

Directory from which the project package hierarchy can be imported.

read_package

read_package() -> origin.PackageOrigin

Read installed package provenance without importing this module.

Raises:

Type Description
ValueError

The package namespace has ambiguous distribution ownership.

load

load() -> types.ModuleType

Import the represented Python module.