primer_runtime

protoprimer execution runtimes

TODO: It seems like this concept of runtimes is redundant: - python_executable cover python exec transition - conf_leap covers configuration discovery What does runtime explain? Whether control is transferred outside of implementation done by protoprimer. When does the transition from one runtime to another change? Execution of user code.

There are a few primer runtimes:

  • proto = independent (stand-alone)

    This runtime runs proto_code.

    It is designed to start outside of venv (or inside arbitrary venv without protoprimer package installed).

    Subsequently, it switches to initialized venv with installed protoprimer and runs protoprimer.primer_kernel module directly before switching to meta runtime eventually.

  • meta

    This runtime is client-specific (custom) setup that may perform any other setup (using packages in venv).

    • protoprimer package only implements transition into that runtime (proto -> meta).

      But protoprimer does not implement meta states (they are out of its scope).

    • metaprimer package implements states to be run in meta runtime.

      These states can be run as is or customized by the client code.

Why do we need these runtimes?

The proto runtime must not import other non-standard packages (which are accessed via venv later) when it starts - it runs a stand-alone proto_code (limited only to the states defined there).

Any client-specific states only become accessible in meta runtime which starts another python_executable.

How does transition from proto to meta runtimes work?

It relies on a helper function from proto_code used by the entry_script - see boot_vs_start.

Depending on whether it is venv or not (see primer_runtime), the helper function passes control to different selected_main:

  • Outside venv (without necessary packages), it executes selected_main from proto_kernel.

  • Inside venv (with necessary packages), it executes selected_main from client_code.

It also requires CLI_compatibility.

How to specify target state available only in meta runtime?

See DAG_extension.