python-api

The native API’s shape, how it maps to the engine.

Generated by make records from the decisions whose topic (or also) is this one; edit the decisions, not this page.

Current

Branches and groups

  • Dependencies on groups use their roots and leaves (D56): x >> group links to its roots and group >> y links from its leaves, computed from all edges once the whole DAG is written. Dependencies on empty or cyclic groups fail parsing when the DAG block ends, naming where the dependency was written.

  • DAG JSON records task groups explicitly (D64): DAG JSON records a top-level groups list and each task’s optional innermost group. The master validates group membership, parents and cycles.

  • A group ending in a branch connects to following tasks by order edges (D94): A dependency from a group joins its last tasks, including a branch, to following tasks with order edges. Each following task applies its own run_if; the branch’s own edges remain choices.

  • Invalid group dependencies name where they were written (D97): A dependency on an empty group or a group whose tasks form a cycle is a parse error. The error is reported at the end of the DAG block and names the dependency’s location.

Typing

  • Type checkers read task calls as their values (D57): DAG calls produce runtime references but are typed as their declared values; data-free calls use handle types, and context fields are typed as values. schedr.Data and schedr.pydantic.Model provide typed DAG operations; plain outcome classes remain allowed with schedr.on and a TypingHint warning shown by dags check and pytest. make lint checks example DAGs and typing fixtures with mypy strict and basedpyright; graph/value misuse and mapped arguments still require loading-time checks. Not found in the code yet: context fields are typed as values.

Mapping

  • DAG JSON separates fixed and mapped arguments (D69): Fixed arguments remain in arguments, while expand describes the values that vary. product is an ordered list of named values and kwargs contains a list of dictionaries.

  • Mapped output lanes advance per instance (D70): An element-wise mapped-output lane expands after its upstream expands; instance i waits for upstream instance i. Other edges, an explicit order edge, or another reference to that upstream make it a whole-task barrier. Outcome narrowing with .on(...) remains per instance even behind that barrier.

  • A mapped task keeps a whole-task row (D74): Every task has a map_index = -1 row; for a mapped task it represents the task as a whole. Expansion creates runnable instances numbered 0..N-1, each with its own retries and cancellation.

  • The master sends each mapped instance its elements (D76): The master sends each instance’s resolved elements under $expand and mapped-upstream element outcomes under $expand_outcomes; task JSON is shared. The mapped list is not additionally sent whole; other inputs contain only what the task’s other arguments reference. Non-dict mapped-upstream expand_kwargs elements fail their instance at assignment, unretried, with input_mismatch. Literal expand_kwargs dictionaries have names and types checked at load, including overlap with partial arguments.

  • Mapped product arguments vary in written order (D79): In expansion over several lists, the first argument written varies slowest. This determines map-index and gather order; DAG JSON preserves product order.

  • Build mapped elements containing templates or dag_ctx per instance (D118): The master counts mapped elements containing t-strings, dag_ctx, parameters or secrets and sends them in stored form. Each instance’s runner builds its element with the referenced outputs.

Defining a DAG

  • An unmapped task limit produces a parse warning (D90): Setting max_active_per_run directly on an unmapped task produces a parse warning shown by dags check. A value inherited from StepDefaults does not produce this warning.

Values the API records

  • Shell-string commands take no placeholders (D99): A shell-string command cannot contain placeholders; the DAG loader, master and agent refuse them. Values can be passed in an argument list or through env; :raw is removed.

Calendars

  • A calendar is an event trigger, not a built-in time trigger (D388): A business calendar is written as a Python event trigger (no catchup, no backfill); the master’s schedules have no exclude= dates unless someone asks.

From other topics

  • Async task calls return coroutines outside a DAG (D49, async-tasks; built M4.10)

  • An unchosen branch edge counts as skipped (D55, outcomes; built M4.2a)

  • Pydantic JSON Schema describes model types (D59, serialization; built M4.1e)

  • Pydantic dates interoperate with schedr date types (D60, serialization; built M4.1e)

  • Schedr refuses to store naive datetimes (D63, serialization; built M4.1e)

  • Task context exposes the running instance identity (D84, task-context; built M4.3c)

  • run_dag exposes mapped instances under the task result (D85, testing-dags; built M4.3c)

  • Concurrency limits use run and current DAG versions (D87, assignment; built M4.4)

  • Mapped instances each count toward concurrency limits (D89, assignment; built M4.4)

  • Stored numbers round-trip exactly within the 64-bit integer range (D105, serialization; built M4.3e)

  • Read Pydantic models back using JSON validation (D111, serialization; built M4.3e)

  • Build structures containing references as the parameter’s type (D112, serialization; built M4.3e)

  • Mapped output outcome selection stays per element across a whole edge (D119, outcomes; built M4.3e)

  • An outcome-filtered order edge from a mapped task counts each instance (D120, outcomes; built M4.3e)

  • Reject DAG IDs that are dot or dot-dot (D127, code-delivery; built M4.4b)

  • The master checks run parameters and their schemas with jsonschema (D133, task-context; built M4.5a)

  • Run parameters are limited to 64 KiB of JSON (D135, task-context; built M4.5a)

  • Run parameters are described in DAG JSON and stored as tagged values (D138, task-context; built M4.5a)

  • schedr.script decodes run context values (D145, task-context; built M4.5b)

  • Secrets are typed as their values (D176, secrets; built M4.6e)

  • schedr.text marks a t-string as a string for Python tasks (D177, secrets; built M4.6e)

  • secrets= accepts strings and placeholders (D178, secrets; built M4.6e)

  • Tasks declare the connections they open (D179, connections; built M4.7a)

  • Connection values contain secrets and plain values (D180, connections; built M4.7a)

  • Cleanups default to three retries 30 seconds apart (D217, cleanup; built M4.8a)

  • Calling a setup twice in one DAG is a parse error (D223, cleanup; built M4.8c1)

  • Expanding a setup is a parse error (D224, cleanup; built M4.8c1)

  • first_of and at_least select completed outcomes (D347, wait-steps; built M4.11c)

Replaced

None.

Where in code

  • crates/schedr-agent/src/ctx.rs (D145)

  • crates/schedr-agent/src/render.rs (D138)

  • crates/schedr-agent/src/render.rs::ShellPlaceholder (D99)

  • crates/schedr-agent/src/secrets.rs (D176)

  • crates/schedr-agent/src/secrets.rs::with_connections (D179)

  • crates/schedr-api/src/views.rs (D133, D179)

  • crates/schedr-db/src/attempts.rs (D70)

  • crates/schedr-db/src/instances.rs (D74)

  • crates/schedr-db/src/runs.rs (D138)

  • crates/schedr-master/src/limits.rs (D90)

  • crates/schedr-master/src/limits.rs::of_task (D89)

  • crates/schedr-master/src/limits.rs::reached (D87)

  • crates/schedr-master/src/mapping.rs (D69)

  • crates/schedr-master/src/mapping.rs::built_by_runner (D118)

  • crates/schedr-master/src/mapping.rs::coordinates (D74, D79)

  • crates/schedr-master/src/mapping.rs::into_inputs (D76)

  • crates/schedr-master/src/mapping.rs::lane_sources (D70)

  • crates/schedr-master/src/mapping.rs::narrows_per_element (D119)

  • crates/schedr-master/src/params.rs (D135)

  • crates/schedr-master/src/params.rs::keyword_problems (D133)

  • crates/schedr-master/src/params.rs::run_params (D138)

  • crates/schedr-master/src/params.rs::validator (D133)

  • crates/schedr-master/src/progress.rs::Instances (D74)

  • crates/schedr-master/src/progress.rs::edge_state (D55)

  • crates/schedr-master/src/progress.rs::edge_states (D120)

  • crates/schedr-master/src/progress.rs::instance_taken (D119)

  • crates/schedr-master/src/progress.rs::lane_state (D70)

  • crates/schedr-master/src/scheduler.rs (D133)

  • crates/schedr-master/src/validate.rs (D69, D94)

  • crates/schedr-master/src/validate.rs::first_of_problems (D347)

  • crates/schedr-master/src/validate.rs::group_problems (D64)

  • crates/schedr-master/src/validate.rs::shell_problems (D99)

  • crates/schedr-model/src/commands.rs (D176)

  • crates/schedr-model/src/connection.rs::problems (D179)

  • crates/schedr-model/src/ctx.rs (D145)

  • crates/schedr-model/src/dag.rs (D56)

  • crates/schedr-model/src/dag.rs::Group (D64)

  • crates/schedr-model/src/ids.rs::DotSegment (D127)

  • crates/schedr-model/src/params.rs::MAX_PARAMS_BYTES (D135)

  • crates/schedr-model/src/secret.rs (D176)

  • crates/schedr-model/src/task.rs (D64, D79, D87, D347)

  • crates/schedr-model/src/task.rs::DEFAULT_CLEANUP_RETRIES (D217)

  • crates/schedr-model/src/task.rs::DEFAULT_CLEANUP_RETRY_DELAY_MS (D217)

  • crates/schedr-model/src/task.rs::Expand (D69)

  • crates/schedr-model/src/types.rs (D59)

  • crates/schedr/src/ctx.rs (D145)

  • python/schedr/_build.py (D180)

  • python/schedr/_build.py::hint_unmapped_per_run (D90)

  • python/schedr/_build.py::make_group_dependencies (D56, D94, D97)

  • python/schedr/_build.py::refuse_second_setup (D223)

  • python/schedr/_model/tasks.py (D99)

  • python/schedr/_model/tasks.py::ExpandProduct (D69, D79)

  • python/schedr/_model/types.py (D59)

  • python/schedr/_params.py::MAX_PARAMS_BYTES (D135)

  • python/schedr/_params.py::declare (D138)

  • python/schedr/_secrets.py::Secrets (D176)

  • python/schedr/_secrets.py::declared (D178)

  • python/schedr/_serialization/codec.py::INTEGERS (D105)

  • python/schedr/_serialization/codec.py::_decode_time (D60)

  • python/schedr/_serialization/codec.py::_encode_time (D63)

  • python/schedr/_serialization/compatibility.py::assignment_problem (D59)

  • python/schedr/_serialization/models.py::parse_date (D60)

  • python/schedr/_serialization/models.py::validate (D111)

  • python/schedr/_serialization/schemas.py (D60)

  • python/schedr/_serialization/schemas.py::from_desc (D59)

  • python/schedr/_templates.py::text (D177)

  • python/schedr/connections.py::defined_values (D180)

  • python/schedr/connections.py::take_connections (D180)

  • python/schedr/context.py::TaskValues (D84)

  • python/schedr/context.py::secret_value (D176)

  • python/schedr/first_of.py::first_of (D347)

  • python/schedr/outcomes.py::Data (D57)

  • python/schedr/resources.py::_declare (D224)

  • python/schedr/runner/coroutines.py::run_coroutine (D49)

  • python/schedr/runner/task.py (D76)

  • python/schedr/runner/task.py::build (D112)

  • python/schedr/script.py::_values (D145)

  • python/schedr/script.py::load (D145)

  • python/schedr/tasks.py::is_async (D49)

  • python/schedr/testing.py::__getitem__ (D85)

Open

None.

Details and edge cases, with the reasons; read them before changing this:

  • JOURNAL.md: D388

  • archive/PROJECT.md: Native API, Scope