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} Columns or variables
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 a field name appears twice
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.1.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.1.0
File Size Uploaded Provenance
scigantic_cards-0.1.0.tar.gz 13.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 22.4 kB

Release files / scigantic_cards-0.1.0.tar.gz

Download URL scigantic_cards-0.1.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
44fad88d214e4f469506c1f2e27fa10683e77d94d18d75d840b4f87309c8f6dc
BLAKE2b-256 checksum
How to use checksums
ae28ca7c20305fa893ef7d45d35db267e49bd00b323dd479d9b00e798d613e75
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.1.0-py3-none-any.whl

Download URL scigantic_cards-0.1.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6fd24af37938bc47625d3bf0c0129fab3761d1e6508ce0afe4cae163fecd76e
BLAKE2b-256 checksum
How to use checksums
3e6ccef5965099f5495b1ebbc2f0cd34109f67bb0fdfbaf73750a228750605b2
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.1.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