Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ docs/dev/*
!docs/dev/notes
!docs/dev/orcapod-design.md
!docs/dev/security-exceptions.md
!docs/dev/documentation-style.md

# General JSON files at project root
/*.json
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Orcapod to a uv project (start one with `uv init` in a new directory), and `uv r
your code in that project's environment:

```bash
uv add "orcapod>=0.4.0rc4"
uv add "orcapod>=0.4.0rc7"
```

In an environment not managed by uv, use `pip install "orcapod>=0.4.0rc4"` instead. For the
In an environment not managed by uv, use `pip install "orcapod>=0.4.0rc7"` instead. For the
development version, install from the repository:
`uv add git+https://github.com/metamorphic-labs/orcapod-python`.

Expand All @@ -39,7 +39,7 @@ Optional features are installed as extras, for example `uv add "orcapod[spiraldb
| `orcapod[ray]` | Distributed execution with `RayExecutor` (Ray 2.60 or later, which has no wheel for Intel macOS) |
| `orcapod[redis]` | `RedisCacher`, a Redis-backed hash cache |
| `orcapod[postgresql]` | The PostgreSQL connector, table source and file hash cache (psycopg 3.1.17 or later) |
| `orcapod[spiraldb]` | The SpiralDB connector and table source |
| `orcapod[spiraldb]` | The SpiralDB connector and table source, read only (spiral-sdk) |
| `orcapod[torch]` | PyTorch, for `torch.Tensor` values (any installed `torch` works) |
| `orcapod[all]` | All of the above |

Expand Down Expand Up @@ -99,9 +99,10 @@ session.

- [Getting Started](https://github.com/metamorphic-labs/orcapod-python/blob/main/docs/getting-started.md):
sources, streams and function pods, step by step.
- [Tutorial](https://github.com/metamorphic-labs/orcapod-python/blob/main/docs/tutorial/index.md):
a self-paced course in eleven short parts, from a first stream to a stored, re-runnable
pipeline over files, with exercises.
- [Tutorials](https://github.com/metamorphic-labs/orcapod-python/blob/main/docs/tutorial/index.md):
a self-paced core course in seven parts, from a first stream to a stored, re-runnable
pipeline, and short tutorials on files, inspecting results, tracing a value, chaining
pipelines and handling errors, with exercises.
- [Concepts](https://github.com/metamorphic-labs/orcapod-python/tree/main/docs/concepts): sources,
streams, function pods, operators, pipelines and jobs, identity and hashing, file types,
arrays and your own data types.
Expand Down
60 changes: 49 additions & 11 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,24 +299,23 @@ repository of the organization.

The `spiral-integration` job of `Run Tests` runs on every push to `main` and by hand
(`workflow_dispatch`) on `metamorphic-labs/orcapod-python`, never on pull requests. It runs
beside the test jobs, not after them, so its result comes in minutes. It authenticates to SpiralDB with a workload private key (ITL-1185): pyspiral reads
beside the test jobs, not after them, so its result comes in minutes. It authenticates to SpiralDB with a workload private key (ITL-1185): spiral-sdk reads
`SPIRAL_CLIENT_ID` (the workload id) and `SPIRAL_PRIVATE_KEY` (the private key as a JSON Web
Key) from the environment, signs a client assertion with the key, and requests a token from
`https://auth.spiraldb.com/oauth/token` with the `client_credentials` grant. It requests no
GitHub OIDC token: pyspiral's workload identity path posts a token exchange that the server
rejects. Client secrets are not used: the server no longer issues them. The job fails at its
Key) from the environment. It requests no GitHub OIDC token. The job fails at its
first step, naming each missing setting, when one of the three below is not set or the key
is not a private JWK naming its `kid`. No agent creates, reads or sets any of them.

The tests read through Orcapod and write their fixed tables through spiral-sdk, in the dataset
`orcapod_conformance` of the test project. spiral-sdk cannot drop a keyed table, so they stay;
each run writes the same rows.

On `metamorphic-labs/orcapod-python` and in SpiralDB, the developer sets:

1. The SpiralDB workload the job runs as (today `orcapod-gha`) holds the **editor** role on
the test project ("Orcapod testing"): the tests create, write, read and drop tables there.
2. A key pair registered for that workload. pyspiral's own CLI has no command for this; use
Studio or the newer SpiralDB CLI, in an environment of its own and never installed beside
pyspiral (both provide a top-level `spiral` module):
`spiral workloads keys add <workload id> --kid <key id> --output -` prints the private key
as a JWK that names its `kid`. A PEM key is not accepted.
the test project ("Orcapod testing"): the tests create, write and read tables there.
2. A key pair registered for that workload, made in Studio or with
`spiral workloads keys add <workload id> --kid <key id> --output -`, which prints the private
key as a JWK that names its `kid`. A PEM key is not accepted.
3. Repository secrets (`Settings → Secrets and variables → Actions → Secrets`):
`SPIRAL_CLIENT_ID`, the workload id (`work_...`), and `SPIRAL_PRIVATE_KEY`, the private JWK
as one line of JSON. Keep the key file out of the repository and delete it once the secret
Expand All @@ -335,6 +334,45 @@ If the key may have been exposed (for example printed in a log), remove it from
first (`spiral workloads keys rm`), so it stops signing in at once, then add a new key and
replace the secret as above. The job fails in between; that is the price of containment.

### Moving the spiral-sdk pin

`pyproject.toml` pins one version of `spiral-sdk` (the `spiraldb` extra): a pre-alpha that
releases daily, of which Orcapod uses two attributes that are not public API
(`Client._native.api_url` and `Client._native.access_token`, for the documented table listing).
To move the pin: change it there, run `uv lock`, and run the conformance tests live
(`tests/test_databases/test_spiraldb_connector_integration.py`, see its docstring). A refusal or a
value that changed is a change of `tests/test_databases/fake_spiral_sdk.py` (its `RULES`) first.

### Migrating a SpiralDB dataset from pyspiral

Once per dataset that an Orcapod release on pyspiral wrote, by a person who may write there.
Nothing else may write to the dataset meanwhile. The two clients cannot share an environment, so
each step has its own; `<old>` is the last commit on pyspiral
(`7a2248bfb3867a3ccb6dd55e21cb0e2a90769a9f`), `<new>` the commit or release being used.

```bash
uv run --no-project --isolated --python 3.12 \
--with "orcapod[spiraldb] @ git+https://github.com/metamorphic-labs/orcapod-python@<old>" \
--with pyspiral==0.16.33 scripts/migrate_spiral_schemas.py \
dry-run --project <project> --dataset <dataset> --plan plan.json

uv run --no-project --isolated --python 3.12 \
--with "orcapod[spiraldb] @ git+https://github.com/metamorphic-labs/orcapod-python@<new>" \
--with spiral-sdk==0.16.74 scripts/migrate_spiral_schemas.py \
write --project <project> --dataset <dataset> --plan plan.json --digest <printed digest>

uv run --no-project --isolated --python 3.12 \
--with "orcapod[spiraldb] @ git+https://github.com/metamorphic-labs/orcapod-python@<new>" \
--with spiral-sdk==0.16.74 scripts/migrate_spiral_schemas.py \
verify --project <project> --dataset <dataset> --plan plan.json
```

`--dataset` can be repeated. `write` refuses unless the plan and every table are as the dry run
found them; an interrupted `write` is refused by every read of the dataset and is finished by
running it again (one stopped while it created the schema table asks for `--adopt <table id>`, for
a table you know that run made). `verify` compares schemas, table ids, versions, source ids, content and pipeline
hashes and each table's first rows with the plan; it does not read every row.

## Pre-releases

A pre-release is a version with an alpha, beta or release candidate part, or a development
Expand Down
24 changes: 24 additions & 0 deletions changelog.d/ITL-1186.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### Breaking changes and migration

- SpiralDB is read through `spiral-sdk` (the `spiraldb` extra pins `spiral-sdk==0.16.74`), and `pyspiral` is gone. Both packages provide a module named `spiral`: install into an environment without `pyspiral`.
- Orcapod only reads SpiralDB for now. Every write of `SpiralDBConnector` (`create_table_if_not_exists`, `upsert_records`, `delete_table`) and every job whose database is on one raises `SpiralDBWriteNotSupportedError`, before anything is buffered or run. Writing is a follow-up of ITL-1186.
- A table's non-nullable columns and Arrow metadata are read from its dataset's schema table, `__orcapod_schemas__`, not from the table's metadata. Datasets written by an earlier release must be migrated once with `scripts/migrate_spiral_schemas.py` (`RELEASING.md`); then schemas, hashes and source ids are as before. Until then their tables read with every column nullable, with `UnrecordedTableSchemaWarning`, and their hashes differ.
- `read_nullability_record` and `write_nullability_record` are removed, and `NullabilityRecordError` is replaced by `TableSchemaError`.
- Row counts are counted from the keys: `row_count_estimate` is exact and reads every key, the `max_rows` check reads at most `max_rows + 1` keys, and a preview of more than 100,000 rows shows no total.
- `overrides` takes `server.url` only; other keys are refused. `~/.spiral.toml` is not read.
- A pinned version (`asof=`) whose columns differ from the table's recorded schema is refused.

### Added

- `scripts/migrate_spiral_schemas.py`: the one-time migration of a dataset's schemas (dry run, write, verify).
- `SpiralDBSignInError`: raised when no SpiralDB sign-in is found, instead of starting one.
- `TableSchemaError` and `UnrecordedTableSchemaWarning` for a table whose recorded schema is missing, incomplete or disagrees with it.

### Changed

- A `where` condition on a `uint64` column, which `pyspiral` could not compare, is answered.

### Known limitations

- A saved SpiralDB login that has expired is not detected: the client may print a sign-in prompt and wait. Run `uv run spiral login` again.
- A `SpiralDBConnector` cannot be used in a forked process (`spawn` works); it is refused there.
7 changes: 7 additions & 0 deletions changelog.d/ITL-1454.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Changed

- **A job shows a source by its own label.** Where the source bound to a slot has an assigned label, the job's diagram, the node's preview and `RestrictedAggregationWarning` name it by that label instead of its slot's name; the diagram's details and the warning give the full source id. Sources sharing a label, or a label that is another node's name, are shown as `label (part)`, with the shortest part that tells them apart (a SpiralDB table's dataset, then its project, then the source's name). Display only: slot names, node labels, the keys of `job.nodes`, saved files, hashes, ids and stored paths are unchanged, and so is the text of a source without a label and of a loaded job. (ITL-1454)

### Fixed

- **`UnrecordedTableSchemaWarning` holds no lock while it warns.** A warning hook may wait for another thread that reads an unrecorded SpiralDB table, or read the table itself. The warning is usually shown once per table and process: threads reading a table at the same time may each show it, and once shown it is not shown again. Turned into an error, it is raised by every reader. (ITL-1454)
3 changes: 3 additions & 0 deletions changelog.d/ITL-1455.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- **The pipeline diagram draws an input that only constrains apart.** The right input of a `SemiJoin` decides which rows of the left input pass and passes none on: the diagram draws it as a dashed edge entering the box from the side, its details say which tags the rows match on, and the text form says `<- a; constrained by b`. Folding (`collapse=True`) keeps it. An operator declares such inputs in `CONSTRAINING_INPUTS`. Display only: no hash, id, stored path, node label or saved file changes, and a diagram without such an input is drawn as before. (ITL-1455)
5 changes: 5 additions & 0 deletions changelog.d/ITL-1459.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Changed

- Getting Started and the tutorial are shorter and in plainer language, loop over a stream with
`for tag, data in stream`, and install at least 0.4.0rc7. Part 6 is titled "Re-runs" and
Part 9 "Handling errors". (ITL-1459)
9 changes: 9 additions & 0 deletions changelog.d/ITL-1460.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Changed

- The tutorial section is "Tutorials": a core course (Parts 0 to 6) and short tutorials that
each cover one subject and can be read in any order afterwards. Part 8 is split into
"Inspecting results", "Tracing a value" and "Chaining pipelines"; Parts 7, 9 and 10 are
"Working with files", "Handling errors" and "Where next". Their pages have new addresses
(`docs/tutorial/files.md`, `inspecting-results.md`, `tracing-a-value.md`,
`chaining-pipelines.md`, `handling-errors.md`, `where-next.md`). The pages list a job's
steps with `print(job.diagram())`. (ITL-1460)
9 changes: 9 additions & 0 deletions changelog.d/ITL-1470.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Fixed

- A chain of operators built before a job is opened, with a step over it added inside the
`with` block, gives the same nodes, system-tag column names, pipeline hashes and stored
tables as the same chain built inside the block (ITL-1470). The stream used to become a
source slot, which named its system-tag columns by its own schema and had its own
pipeline hash, while its content hash was that of the chain. The change that fixes it is
ITL-1387 (a stream given to a job brings its upstream steps); this entry adds the test
that compares the two forms, on the sync and the async path.
2 changes: 1 addition & 1 deletion docs/concepts/data-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ the stores keep it on every write (first write, append, merge, schema evolution;
memory and on Delta). A database states whether it keeps
field metadata with `keeps_field_metadata`
(`orcapod.protocols.database_protocols.FieldMetadataKeepingDatabaseProtocol`): the
in-memory, Delta and SpiralDB databases do; the SQLite and PostgreSQL databases keep no
in-memory and Delta databases do; the SQLite and PostgreSQL databases keep no
Arrow metadata at all. A node that would store a data-tag in a database that does
not state it (a database without the member included) is refused when its database is
attached, before anything is written. Use a database that keeps field metadata, or keep
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/file-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pipelines over scientific data pass references to files between steps. Orcapod h
for this, and the choice of type decides **what a result's validity depends on**: the
content of the file, or only its location.

For a guided introduction see the tutorial, [Part 7](../tutorial/07-files.md).
For a guided introduction see the tutorial [Working with files](../tutorial/files.md).

## The types

Expand Down
6 changes: 4 additions & 2 deletions docs/concepts/notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ One row per function node: `rows` is every input row the run accounted for in th
how many its function computed in this run, `from store` how many it read back from the
database instead, `failed` how many raised, and `first error` the first of those errors, with the call that
prints its full traceback (`job.last_run.print_traceback("rates")`). Here one `rates` row
was found in the store during the run itself ([Part 5](../tutorial/05-pipeline-job.md#record-then-run)
was found in the store during the run itself ([Part 5](../tutorial/05-pipeline-job.md#run-a-recorded-job)
of the tutorial explains why). A load-only run (`job.run(load_only=True)`) shows how many
rows each node loaded and how many had no stored result instead. The job keeps the summary as
`job.last_run`. A cell that ends with `job.run();` (a semicolon) shows nothing. What a run
Expand Down Expand Up @@ -218,7 +218,7 @@ print(job.nodes["rates"].run().header())

A view holds the default columns only (tags and data). For system tags, source info and
the other hidden columns, ask the node: `as_table(columns=...)`, as in
[Part 8 of the tutorial](../tutorial/08-inspecting-and-tracing.md). `run()` on each kind of
the tutorial [Inspecting results](../tutorial/inspecting-results.md#tracing-rows). `run()` on each kind of
object is the table "What `run()` does on each kind of object" in
[Streams](streams.md#computing-a-stream-outside-a-job-run).

Expand Down Expand Up @@ -256,6 +256,8 @@ laid out left to right. Here is `job` as the last line of a cell, after its run,
- **A node's details.** Click a node (or focus it and press Enter) to see its schema: its tag
and data columns, the nodes it reads from and, for a job, its run status and the row counts
of the job's last run.
- **Constraining inputs.** The right input of a `SemiJoin` only decides which rows pass: a
dashed edge entering from the side of the box.
- **Statuses.** Each node of a job shows one: `not run`, `current`, `stale`, `failed`,
`loaded only`, `partial`, or `bound` or `unbound` for a source slot. Before `job.run()`
every node but the sources says `not run`.
Expand Down
Loading
Loading