Skip to content

Compiler

CompilerLink

The sierra.core.compiler module is responsible for taking registered invoker scripts and producing standalone Python scripts along with the corresponding YAML configuration.

Compiling invoker scripts
Python
import pathlib
import sierra

# Initialize your SierraDevelopmentClient
client = sierra.SierraDevelopmentClient(
    environment_path=pathlib.Path("default_env"),
    environment_name="default_env",
    logger=sierra.UniversalLogger(name="Sierra", level=sierra.sierra_internal_logger.LogLevel.DEBUG),
)

# Discover and register all invokers
client.load_invokers_from_scripts()

# Compile into standalone scripts and config.yaml
client.compiler.compile()

sierra.core.compiler Link

ClassesLink

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

Bases: sierra_core_base.SierraCoreObject

Compiler for Sierra invoker scripts and YAML configuration.

Generates standalone invoker scripts in the environment's invokers directory and writes a config.yaml file with PATHS and SCRIPTS entries without external dependencies.

PARAMETER DESCRIPTION
client

The client to use for logging and accessing environment information.

TYPE: SierraClient

ATTRIBUTE DESCRIPTION
client

The client instance provided during initialization.

TYPE: SierraClient

METHOD DESCRIPTION
set_invoker_commands

Generate and set the CLI command string for each registered invoker.

build_and_save_scripts

Write each invoker's generated standalone script to the invokers directory.

make_invoker_yaml

Construct a YAML configuration string for all registered invokers without relying on external YAML libraries.

compile

Complete compilation process: 1. Generate CLI command strings for invokers 2. Write standalone Python scripts 3. Write config.yaml in the root of the environment.

Initialize a SierraCoreObject.

PARAMETER DESCRIPTION
client

The Sierra development client.

TYPE: SierraDevelopmentClient

Notes

Logs each initialization step via the client's logger.

AttributesLink
client instance-attribute Link
Python
client = client
FunctionsLink
to_double_quoted_string classmethod Link
Python
to_double_quoted_string(text: str) -> str

Return the given string wrapped in double quotes.

This function ensures the output string is always enclosed with a starting and ending double-quote character ("), even if the input string already includes quotes.

PARAMETER DESCRIPTION
text

The input string to be quoted.

TYPE: str

RETURNS DESCRIPTION
str

The input string wrapped with double quotes. Any existing surrounding quotes are ignored, and only one set of double quotes will be present at the start and end.

Examples:

Python Console Session
1
2
3
4
5
6
>>> to_double_quoted_string("hello")
'"hello"'
>>> to_double_quoted_string('"world"')
'"world"'
>>> to_double_quoted_string("'quoted'")
'"\'quoted\'"'
set_invoker_commands Link
Python
set_invoker_commands() -> None

Generate and set the CLI command string for each registered invoker.

build_and_save_scripts Link
Python
build_and_save_scripts() -> None

Write each invoker's generated standalone script to the invokers directory.

make_invoker_yaml Link
Python
make_invoker_yaml() -> str

Construct a YAML configuration string for all registered invokers without relying on external YAML libraries.

RETURNS DESCRIPTION
str

YAML-formatted configuration.

merge_deduplicate_sorted_latest Link
Python
merge_deduplicate_sorted_latest(
    *lists: list[str],
) -> list[str]

Merge multiple lists of strings, remove duplicates, and retain only the highest version of versioned entries like 'package==x.y.z'. The final result is sorted alphabetically.

PARAMETER DESCRIPTION
*lists

Multiple input lists containing string elements.

TYPE: list of list of str DEFAULT: ()

RETURNS DESCRIPTION
list of str

Combined, deduplicated, and sorted list retaining highest package versions.

compile Link
Python
compile() -> None

Complete compilation process: 1. Generate CLI command strings for invokers 2. Write standalone Python scripts 3. Write config.yaml in the root of the environment.