Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

sws-spark-dissemination-helper

Python/PySpark helper library for the FAO SWS (Statistical Working System) data dissemination pipelines. It provides a set of classes that move a dataset from the SWS Postgres database, through an Iceberg-backed Bronze → Silver → Gold medallion pipeline, to the CSV/Iceberg artifacts and SWS "dissemination tags" consumed downstream (including SDMX and FAOSTAT-shaped outputs).

Pipeline overview

Layer Class Role
Source SWSPostgresSparkReader Reads SWS Postgres tables (observations, codelists, datatables) into Spark and stages them as Iceberg tables. Every stage reads the specific datatables it needs on demand through this class, rather than a single upfront import.
Bronze SWSBronzeIcebergSparkHelper Denormalizes the raw observation/coordinate/metadata tables into one wide table (codes instead of ids, metadata and unit-of-measure attached). Can also be filtered to a dimension-value selection provided as input and republished as a separate "disseminated tag" table.
Silver SWSSilverIcebergSparkHelper Applies dissemination business rules on top of Bronze data: code correction, time-validity checks, dissemination flags/exceptions, duplicate detection.
Gold SWSGoldIcebergSparkHelper Produces the published output shapes from Silver/Bronze data: SWS variants, a pre-SDMX/FMR-layout variant (SDMX doesn't accept dots in coded values and requires the value column named OBS_VALUE), an SDMX-shaped variant, and FAOSTAT variants — the SDMX and FAOSTAT variants are both produced by mapping the pre-SDMX output through a remote SDMX structure-map chain run as SWS plugin tasks. Also applies display-decimal rounding.
Standalone SWSEasyIcebergSparkHelper Exports a huge dataset to Iceberg as a single denormalized table, for datasets large enough that querying them directly in SWS is impractical or impossible.

Each helper writes its output to Iceberg, creates a version tag, optionally caches a CSV copy on S3, and can register the result in the SWS dissemination-tag metadata via the sws_api_client Tags API. See each class's docstring for the exact tables/columns it reads and writes.

Installation

pip install sws-spark-dissemination-helper

Requires Python 3.9 or 3.11 (see pyproject.toml).

Construct SWSPostgresSparkReader once per job, then pass it into whichever helper class(es) you need for the pipeline stage(s) you're running — see the architecture page for how the stages relate and the API reference (or each class's docstring) for the exact constructor arguments.

Configuration

The package expects to run on Amazon EMR, with AWS access already configured (an EMR instance profile):

  • EMR_BUCKET: S3 bucket used as the Spark/Iceberg warehouse location (see utils.get_spark).
  • DB_SECRET: name of the AWS Secrets Manager secret holding the Postgres JDBC connection properties (host, port, database, user, password), used when SWSPostgresSparkReader is instantiated without explicit jdbc_conn_properties.
  • AWS credentials are picked up from the default boto3 credential chain and used both for S3/Glue access and to build the temporary Spark s3a credentials.

Documentation

The full documentation (architecture, configuration, and the generated API reference) is built with Sphinx from this README and the package's docstrings. Build it locally with:

pip install -e ".[docs]"
make docs

Then open docs/build/html/index.html. See docs/source/ for the source.

How to use (development)

Make sure to have make installed on your system and run make help to see the available commands.

Upload a new version

A new version is published to PyPI automatically by the publish workflow whenever a GitHub release is published. The workflow verifies that the release tag matches v<project.version>, so the two must always be kept in sync.

  1. Update project.version in the pyproject.toml file (e.g. 0.1.9.dev0) and commit the change.

  2. Create and push a tag matching the new version (note the leading v):

    git tag v0.1.9.dev0
    git push origin --tags
    
  3. Go to the tags page, select the tag and create a release from it. Use the Latest release label for official releases or Pre-release for development versions, then fill in the release notes.

  4. Wait for the GitHub action to run. If it succeeds the new version will be available on PyPI; otherwise check the workflow logs for the failure reason (a common one is the tag not matching project.version) and fix it.

Metadata

Release files for sws-spark-dissemination-helper 0.1.19.dev3

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

Source distribution (sdist)

Source distribution for sws-spark-dissemination-helper 0.1.19.dev3
File Size Uploaded
sws_spark_dissemination_helper-0.1.19.dev3.tar.gz 87.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sws-spark-dissemination-helper 0.1.19.dev3
File Interpreter ABI Platform
sws_spark_dissemination_helper-0.1.19.dev3-py3-none-any.whl Python 3 none any Details

Total release size: 163.9 kB

Release files / sws_spark_dissemination_helper-0.1.19.dev3.tar.gz

Download URL sws_spark_dissemination_helper-0.1.19.dev3.tar.gz
Size 87.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8cdea6a262f8e1ff21851e5867ef5f1205305d14fb1d4a71d2925ced65e5800b
BLAKE2b-256 checksum
How to use checksums
aff67b1fd5a3f329e7146f22ef189ca23d0d5735f039b24d305789061f0355a8
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 Sep 29, 2026.

Transparency log

Release files / sws_spark_dissemination_helper-0.1.19.dev3-py3-none-any.whl

Download URL sws_spark_dissemination_helper-0.1.19.dev3-py3-none-any.whl
Size 76.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c83fba10eb811de7d23b56badc3dec469083f4405c897ad1833114c669d3a74
BLAKE2b-256 checksum
How to use checksums
31dd54fc21d2fdf63834b8e5c7dafd6cb0900cf80ba3ed76e86eb18b69fc2864
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 Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.19.dev3 This release

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.86

2 release files

0.0.85

2 release files

0.0.84

2 release files

0.0.83

2 release files

0.0.82

2 release files

0.0.81

2 release files

0.0.80

2 release files

0.0.79

2 release files

0.0.78

2 release files

0.0.77

2 release files

0.0.76

2 release files

0.0.75

2 release files

0.0.74

2 release files

0.0.73

2 release files

0.0.72

2 release files

0.0.71

2 release files

0.0.70

2 release files

0.0.69

2 release files

0.0.68

2 release files

0.0.67

2 release files

0.0.66

2 release files

0.0.65

2 release files

0.0.64

2 release files

0.0.63

2 release files

0.0.62

2 release files

0.0.61

2 release files

0.0.60

2 release files

0.0.52

2 release files

0.0.51

2 release files

0.0.50

2 release files

0.0.49

2 release files

0.0.48

2 release files

0.0.47

2 release files

0.0.46

2 release files

0.0.45

2 release files

0.0.44

2 release files

0.0.43

2 release files

0.0.42

2 release files

0.0.41

2 release files

0.0.40

2 release files

0.0.39

2 release files

0.0.38

2 release files

0.0.37

2 release files

0.0.36

2 release files

0.0.35

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.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