Skip to main content

Shared DepEd PSGC, hierarchy, territory, SQL, and Marimo primitives.

Project description

deped-primitives

Github CI

deped-primitives is the shared semantic contract layer for the DepEd data ecosystem. Producer repositories publish artifacts and source-specific contracts; consumer repositories build maps, datasets, notebooks, and dashboards. This package owns the reusable value rules and interpretation semantics between those layers.

It is intentionally not an application framework. It does not load source workbooks, dissolve geometry, persist databases, run downstream build CLIs, write artifacts, or host dashboards. It gives every DepEd repo one small, tested place to import the rules that should not be reimplemented locally.

Mental Model

The package has three layers:

  • Foundation primitives: PSGC code rules, boundary/legacy code normalization, hierarchy metadata, region groups, and shared reference vocabularies.
  • Consumer semantics: normalized PSGC frames, psgc-maps boundary artifact interpretation, legislative coverage semantics, and legislative child rollup classification.
  • Product construction helpers: territory filters, access scopes, schema-adapter SQL builders, CLI build-progress helpers, and optional Marimo notebook controls.

The root package exposes a curated facade for common foundation and product helpers. Specialized consumer-semantics helpers stay in their owner modules so their artifact contracts remain explicit.

Quick Start

from deped_primitives import (
    AccessScope,
    FilterSpec,
    GeoType,
    SCHOOL_OBSERVATIONS_ADAPTER,
    ancestor_codes,
    breakdown,
    normalize_boundary_pcode_to_psgc_id,
    normalize_code,
    scope_locks_from_access,
    summary_sql,
)

assert normalize_code(" 13-3900-0000 ") == "1339000000"
assert ancestor_codes("1380610001", GeoType.BGY) == [
    "1300000000",
    "1380600000",
    "1380610000",
]
assert breakdown("0908301001").barangay.code == "0908301001"
assert normalize_boundary_pcode_to_psgc_id("PH0102801") == "0102801000"
assert scope_locks_from_access(
    AccessScope(level="regional", psgc_region_id="1300000000")
).locked_levels == ("region",)
assert "school_observations" in summary_sql(
    SCHOOL_OBSERVATIONS_ADAPTER,
    FilterSpec(),
)

Import specialized semantics from owner modules:

from deped_primitives.boundaries import usable_area_boundary_components
from deped_primitives.legislative import legislative_child_rollups
from deped_primitives.psgc.frames import normalized_psgc_group_rows

groups = normalized_psgc_group_rows(canonical_psgc_units)
usable_components = usable_area_boundary_components(area_boundary_components)
children = legislative_child_rollups(coverage, barangay_context)

Owned Surfaces

  • deped_primitives.psgc and psgc.frames: PSGC parsing, validation, parentage, typed breakdowns, lineage, and normalized group-row construction from canonical_psgc_units.csv.
  • deped_primitives.codes: PSGC ID, PSA/NAMRIA PCODE, legacy-code, and comparable-name normalization.
  • deped_primitives.boundaries: consumer-safe interpretation of psgc-maps boundary mapping and area-boundary component artifacts.
  • deped_primitives.hierarchies and region_groups: shared hierarchy metadata, aliases, graph topology, renderability, derived IDs, and regional reporting groups.
  • deped_primitives.regions, education, and school_sizes: typed reference vocabularies.
  • deped_primitives.filters and access: territory cascades, area scopes, membership traversal, office permission scopes, and UI lock derivation.
  • deped_primitives.sql, cli, and marimo: schema-adapter SQL builders, shared CLI build-progress helpers, and optional notebook controls.
  • deped_primitives.legislative: legislative anchors, coverage policy, coverage completion, area linkage, special cases, and child rollup classification.

Documentation

Development

pre-commit run --all-files
just check

Useful narrower commands:

just test
uv run zensical build
uv run --extra marimo marimo check notebooks/*.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deped_primitives-0.0.2.tar.gz (174.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deped_primitives-0.0.2-py3-none-any.whl (82.8 kB view details)

Uploaded Python 3

File details

Details for the file deped_primitives-0.0.2.tar.gz.

File metadata

  • Download URL: deped_primitives-0.0.2.tar.gz
  • Upload date:
  • Size: 174.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for deped_primitives-0.0.2.tar.gz
Algorithm Hash digest
SHA256 cb2e708e927990b20ac5f3b4b675dcc0d9bdea152091a5306a17cd4a003bd304
MD5 fa7dd9b09ef39dc0f4f8c6d827e5da3e
BLAKE2b-256 eefd2e518e6d3433bc3b4eee2bdd2d3ed7f6ce0f116b490245116457689e7aa7

See more details on using hashes here.

File details

Details for the file deped_primitives-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: deped_primitives-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 82.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for deped_primitives-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 895fb892f365dc968bb87403523f92936ada8935357bdfb09a9c9d967ff434d4
MD5 29703a626956b5c5131bf7a0dcfe9e00
BLAKE2b-256 1e25847e3a48dfb72498b7314a558662dff102a82206a8548d7df54b3fa6a9ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page