Skip to content

Teach the codec context argument as part of the signature - #290

Open
dimitri-yatsenko wants to merge 1 commit into
mainfrom
docs/codec-context
Open

dimitri-yatsenko wants to merge 1 commit into
mainfrom
docs/codec-context

Conversation

@dimitri-yatsenko

Copy link
Copy Markdown
Member

Documents the context argument added in datajoint/datajoint-python#1556, and teaches it as the signature rather than an option — so a codec written from these pages needs no change when the compatibility code is removed in 2.4 (datajoint/datajoint-python#1557).

Why now rather than at 2.4

The backward-compatible path is what makes 2.3.4 safe to ship, but it is not what anyone should be writing against. Two third-party codecs — dj-figpack-codecs#6 and dj-canvasxpress-codecs#3 — shipped the silent-wrong-store bug by copying the documented example, so the example is the thing that most needs to be right.

Changes

reference/specs/codec-api.md — a new section on context: what the four keys carry, and why threading config into _build_path() / _get_backend() is a correctness matter rather than a style one (both fall back to the global dj.config without it, which in a multi-connection process belongs to no one and resolves a different store silently instead of raising). The pre-2.3.4 form is marked deprecated with its removal release named, and a two-line migration is given.

how-to/create-custom-codec.md, explanation/custom-codecs.md, tutorials/advanced/custom-codecs.ipynb — the same signature throughout: 29 encode and 28 decode examples across the four pages, plus the _extract_context(key, context) and _codec_config(key, context) call sites that go with them.

Verification

mkdocs build --strict clean, check_links.py passes across 142 pages, check_notebook_versions.py clean.

The two notebook code cells carry no outputs, verified programmatically against HEAD, so nothing needs re-executing.

Ordering

Independent of #288 and #289 — different files, no overlap. Safe to merge in any order, though the behavior it describes only exists once datajoint/datajoint-python#1556 lands.

Every documented codec signature now declares `context`, so a codec written
from these pages is ready for 2.4, when the compatibility code that reads
connection context out of the `key` dict is removed
(datajoint-python#1557).

- codec-api.md gains a section on `context`: what the four keys mean, why
  threading `config` into _build_path/_get_backend is a correctness matter
  rather than a style one, and a two-line migration for an existing codec.
  The pre-2.3.4 form is marked deprecated with its removal release named.
- create-custom-codec.md, custom-codecs.md and the custom-codecs tutorial
  carry the same signature throughout — 29 encode and 28 decode examples
  across the four pages, plus the `_extract_context` and `_codec_config`
  call sites that go with them.

The two notebook cells hold no outputs, so nothing needs re-executing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant