Skip to main content

ra-law-db

RA Suite logo

Public dataset workspace and installable runtime library for Japanese chemical law screening.

ra-law-db is now the canonical non-MCP API for direct law-screening consumers. ra-law-mcp is a thin wrapper over this package.

Direct package usage

Most consumers should install the package and use the bundled SQLite database directly:

pip install ra-law-db
uv add ra-law-db
from ra_law_db import get_law_screening_database

db = get_law_screening_database()

lookup_result = db.lookup(cas_number="75-09-2", language="ja")
search_result = db.search(query="ジクロロメタン", mode="auto", limit=10, min_score=0.6)

Public runtime API:

  • get_law_screening_database(law_db_path: str | None = None)
  • LawScreeningDatabase.lookup(cas_number=None, substance_name=None, language="ja")
  • LawScreeningDatabase.search(query, mode="auto", law_id=None, limit=20, min_score=0.6)

Default behavior:

  • If law_db_path is omitted, ra-law-db uses the packaged bundled SQLite database.
  • law_db_path may optionally point to:
    • a direct SQLite file
    • a checked-out ra-law-db directory containing regulatory.sqlite3 and compatibility artifacts

Runtime artifact

The canonical runtime artifact is the bundled SQLite database:

  • packaged path: src/ra_law_db/data/regulatory.sqlite3
  • published repo artifact: regulatory.sqlite3

Normal installed consumers should rely on the packaged bundled database. CSV/JSONL files remain published for compatibility, inspection, and debugging, but they are not required for normal runtime use.

At runtime, the bundled database is resolved safely via importlib.resources and opened through a real filesystem path using importlib.resources.as_file(...).

MCP usage

ra-law-mcp consumes this package directly. In the normal case it does not need a separate ra-law-db checkout.

RA_LAW_DB_PATH is still supported as an override when you want to point the MCP server at:

  • a custom SQLite bundle
  • a local development checkout of ra-law-db

Directory layout

  • regulatory.sqlite3: published SQLite bundle
  • src/ra_law_db/data/regulatory.sqlite3: packaged SQLite bundle used by installs
  • parsed/: normalized parsed entries and source snapshot manifests
    • source_snapshots.jsonl
    • law_entries.jsonl
  • mappings/: CAS mapping outputs and unresolved entries
    • cas_mappings.jsonl
    • unresolved_entries.jsonl
  • exports/: compatibility export files
    • regulatory_substances.csv
  • masters/: public-safe law master datasets and alias rows

Generation and releases

This repository is published by the private ra-law-scraper pipeline. The public repo contains the generated dataset and compatibility exports, not the private scraping workflow itself.

Release model:

  • the package version moves with the bundled SQLite database
  • a new bundled DB refresh should be released as a new ra-law-db package version
  • direct consumers receive data updates by upgrading ra-law-db

Development

uv sync --group dev
uv run pre-commit install
uv run pre-commit run --all-files
uv run pytest -q

Release

PyPI publishing is handled by GitHub Actions only when a matching v* tag is pushed. See docs/release.md for the cleanup and release checklist.

Notes

  • SQLite is the canonical runtime format for downstream consumers.
  • Alias data is published in masters/substance_aliases.csv and bundled into regulatory.sqlite3.
  • Unresolved law entries are tracked in mappings/unresolved_entries.jsonl for manual review.
  • ra-law-db remains law-source-driven. It is not replaced by CREATE-SIMPLE workbook data when ra-library / ra-mcp adopt a newer CREATE-SIMPLE methodology version.

Release files for ra-law-db 0.3.1

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

Source distribution (sdist)

Source distribution for ra-law-db 0.3.1
File Size Uploaded
ra_law_db-0.3.1.tar.gz 580.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ra-law-db 0.3.1
File Interpreter ABI Platform
ra_law_db-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / ra_law_db-0.3.1.tar.gz

Download URL ra_law_db-0.3.1.tar.gz
Size 580.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4d63a6021e5723af8db3745b8604b2db35babd9cdcc37bebaa15ada12a977681
BLAKE2b-256 checksum
How to use checksums
b298944768c826643424091bf6a9909bfafcae67fda6f487bc81eff59f801c12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release files / ra_law_db-0.3.1-py3-none-any.whl

Download URL ra_law_db-0.3.1-py3-none-any.whl
Size 604.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae7ddd98b0fe2bbde6162177af2ac3890cfe73533951f4e0b82e7df8d3ac9cdf
BLAKE2b-256 checksum
How to use checksums
99a82629e785915497d626e780f03c877462b1d9c42f25ee4fe82307aff9c2fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

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