Skip to main content

scigantic-cards

A JSON format for describing a dataset to an LLM agent, and a linter for it.

A card holds what the agent is unlikely to know already: which published dataset this is, how this copy differs from it, how large it is, and a snippet that opens it. A card that only restates what the model already knows fails the lint.

Install

pip install scigantic-cards

Python 3.10 or newer. No dependencies.

Format

A card is a JSON object. Only name is required for the file to load. The linter checks the rest.

Field Type Meaning
name string Short id for the card
identity string The published dataset, release or paper this copy comes from
summary string One or two sentences
layout string How files are organized
approx_bytes, approx_items integer or null Size, for choosing between streaming and loading
fields list of {name, dtype, note, group} Columns or variables. group is the table or file a field belongs to, optional
differs_from_upstream list of strings How this copy differs from the well-known version
gotchas list of strings Sentinel values, unit conventions, known bad files
access list of {goal, snippet, verified} Code that opens the data. verified is true if you ran it
checked_at string ISO date the card was last checked against the data

Unknown keys are rejected. See examples/acme-stations.json, a fictional dataset.

The same rules are published as JSON Schema in src/scigantic_cards/card.schema.json, for validating cards from other languages.

Lint

$ scigantic-cards lint examples/needs-work.json
examples/needs-work.json: error: identity: No identity. Name the canonical dataset, release, or paper so the agent can recall what it already knows.
examples/needs-work.json: error: delta: No differences or gotchas. A card with neither only restates what the agent already knows.
examples/needs-work.json: warn: size: No size. Agents choose between streaming and loading based on it.
examples/needs-work.json: warn: unverified-access: 'List files': snippet was not executed.
examples/needs-work.json: error: tilde-path: 'List files': a path starting with ~/ is not expanded by Python unless it goes through os.path.expanduser or Path.expanduser.
examples/needs-work.json: warn: checked-at: checked_at is missing or not an ISO date (YYYY-MM-DD).

Options: --strict counts warnings as failures. --budget N sets the size limit in bytes (default 4000).

Exit codes: 0 no problems, 1 lint errors (or warnings with --strict), 2 a file could not be read or is not a valid card.

Rules

Rule Severity Fires when
name error name is blank
identity error identity is blank
delta error differs_from_upstream and gotchas have no non-blank entry
access error there are no access snippets
empty-snippet error a snippet is blank
tilde-path error a snippet has a string starting with ~/ and no expanduser
size warn neither size field is set
unverified-access warn a snippet has verified: false
field-dtype warn a field has no dtype
field-duplicate warn the same name appears twice in the same group
checked-at warn checked_at is not an ISO date
budget warn the card is over the budget as compact UTF-8 JSON

Python

from scigantic_cards import Card, CardError, lint

try:
    card = Card.from_json(open("card.json", encoding="utf-8").read())
except CardError as e:
    print(e)  # for example: card.fields[2].dtype: required
else:
    for issue in lint(card):
        print(issue.severity, issue.rule, issue.message)

Card.from_dict and Card.from_json accept the same documents as the JSON Schema and raise CardError with the path of the bad value otherwise.

Tests

pip install -e ".[dev]"
pytest

The suite includes property-based tests (Hypothesis) that generate valid and slightly broken cards and check that the Python loader and the JSON Schema agree on every one.

License

MIT-0.

Metadata

Release files for scigantic-cards 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scigantic-cards 0.2.0
File Size Uploaded Provenance
scigantic_cards-0.2.0.tar.gz 13.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for scigantic-cards 0.2.0
File Interpreter ABI Platform
scigantic_cards-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.0 kB

Release files / scigantic_cards-0.2.0.tar.gz

Download URL scigantic_cards-0.2.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
89274aee024ea1a3c24517ac7b571b3db603bd8aa2d5a45f37344461345d80f3
BLAKE2b-256 checksum
How to use checksums
77ea7644c1b0f3cc622f929512c3970d4a4d893ade08ac8ef56a361c5c6c2d27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / scigantic_cards-0.2.0-py3-none-any.whl

Download URL scigantic_cards-0.2.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5e9e4e2f50f5308e0ae6a9a83cdd31dcd3692ed9112ef4be42f365539155789
BLAKE2b-256 checksum
How to use checksums
a766c3d2c6dd2cfdad564014425e576e5579f79af5cf0c6d921eba69c2727687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Security for scigantic-cards 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page