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.
read_package
¶
Read package provenance for this entrypoint without importing its module.
read_source_origin
¶
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
¶
Import this entrypoint and read its callable signature.
Raises:
| Type | Description |
|---|---|
ValueError
|
The callable signature cannot be inspected. |
from_path
classmethod
¶
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 validated module and function names as an entrypoint.
load
¶
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.
docstring
cached
property
¶
Return the cleaned docstring of this function, importing its module.
from_callable
classmethod
¶
Create a function reference from a callable's module and qualified name.
read_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
¶
Import this function and read its presentation-oriented signature.
Module
dataclass
¶
Represent and load an importable Python module.
source_file
property
¶
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
¶
Return whether a string is an importable dotted module name.
find_import_root
staticmethod
¶
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 installed package provenance without importing this module.
Raises:
| Type | Description |
|---|---|
ValueError
|
The package namespace has ambiguous distribution ownership. |