Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.
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
14 changes: 6 additions & 8 deletions docs/concepts/pipeline-job.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,19 @@ A non-null column is created `NOT NULL` and reads back non-null. SQLite refuses
other type (lists,
structs, dates or timestamps on SQLite, narrower integers and floats, logical types) is
refused. PostgreSQL also refuses a column name or a table name longer than
63 bytes, which it would truncate (`UnstorableTableNameError` for a table). `SpiralDBConnector` stores other types as written, except a
timestamp with a time zone (SpiralDB drops the zone), a logical (extension) type such as
`File`, `Path`, `UUID`, a user class or `set[int]` (SpiralDB drops the field metadata that
names it), and a null struct; SpiralDB reserves the `__` prefix on
value columns (the `__record_id` key is allowed) and `.` in any column name. The full list,
63 bytes, which it would truncate (`UnstorableTableNameError` for a table). A database on
`SpiralDBConnector` refuses every write for now (`SpiralDBWriteNotSupportedError`): Orcapod
reads SpiralDB only. The full list,
type by type, is [Data types per database](../reference/database-types.md).

Orcapod's own stored tables hold such columns. A function node's result table holds
list-valued executor columns and `__`-prefixed columns. A side-effect node's log holds a UTC
timestamp and `__data_context`, and an operator cache and a cached source hold
`__data_context` too. So a job refuses these nodes when it is built, before anything runs:

- every function node, on all three connectors;
- every side-effect node, on SQLite and SpiralDB;
- every operator cache (an operator node with caching on) and cached source, on SpiralDB.
- every function node, on SQLite and PostgreSQL;
- every side-effect node, on SQLite;
- every node that stores anything, on SpiralDB.

An operator cache or cached source on a SQL connector is refused when it is written, before
anything is stored, if one of its columns has a type or name the connector does not store. On
Expand Down
Loading
Loading