Skip to content

Loader

LoaderLink

The sierra.core.loader module is responsible for loading compiled Sierra invoker scripts.

Loading an invoker
Python
1
2
3
4
5
6
7
8
import sierra

# Create an instance of SierraSideloader with the Sierra client
loader = sierra.SierraSideloader(client=...)

# Populate the sideloader by pulling new files from all sources
# This will cache all valid `.py` scripts from the configured sources
loader.populate()

sierra.core.loader Link

ClassesLink

SierraSideloader Link
Python
SierraSideloader(
    client: sierra_client.SierraDevelopmentClient,
)

Bases: sierra_core_base.SierraCoreObject

A sideloader that mimics APT-like behavior for fetching and managing Python invoker scripts from GitHub sources. Handles downloading, caching, and installing .py files only.

PARAMETER DESCRIPTION
client

A reference to the Sierra development client.

TYPE: sierra_client.SierraDevelopmentClient

Initialize the SierraSideloader.

PARAMETER DESCRIPTION
client

A reference to the Sierra development client.

TYPE: SierraDevelopmentClient

RAISES DESCRIPTION
SierraPathError

If the configuration path or source file does not exist.

AttributesLink
client instance-attribute Link
Python
client = client
cache instance-attribute Link
Python
cache = self.client.cache
path instance-attribute Link
Python
path: pathlib.Path = self.client.environment.config_path
sources instance-attribute Link
Python
sources: list[str] = [
    line.strip() for line in f if line.strip()
]
FunctionsLink
populate Link
Python
populate() -> None

Pulls new files from all sources and caches all valid .py scripts.

update Link
Python
update() -> None

Refreshes the sideloader by pulling from all sources again.

install Link
Python
install(name: str) -> None

Installs a cached .py script into the Sierra environment's script directory.

PARAMETER DESCRIPTION
name

The name of the file to install (without .py).

TYPE: str

RAISES DESCRIPTION
SierraCacheError

If the file is not found in the cache.

search Link
Python
search(query: str) -> list[str]

Searches for scripts in the cache by partial name match.

PARAMETER DESCRIPTION
query

The search keyword.

TYPE: str

RETURNS DESCRIPTION
List[str]

Matching script names.

list_available Link
Python
list_available() -> list[str]

Lists all .py script packages currently cached (including from disk).

RETURNS DESCRIPTION
List[str]

Cached script names.

info Link
Python
info(name: str) -> dict[str, typing.Any]

Returns metadata about a cached script.

PARAMETER DESCRIPTION
name

Name of the cached script.

TYPE: str

RETURNS DESCRIPTION
Dict[str, Any]

Metadata of the script including cache entry details.

RAISES DESCRIPTION
SierraCacheError

If script not found in cache.

cleanup_expired Link
Python
cleanup_expired() -> int

Manually clean up expired cache entries.

RETURNS DESCRIPTION
int

Number of entries removed.

get_cache_stats Link
Python
get_cache_stats() -> dict[str, typing.Any]

Get comprehensive cache statistics.

RETURNS DESCRIPTION
Dict[str, Any]

Cache statistics including file counts and sizes.