A composable scraper pipeline built around the medallion architecture (bronze / silver / gold).
Project description
Medallion architecture scraper pipeline
Plug and play library with batteries included for caching parser output at each step as blobs.
Installation
pip install medallion-pipeline
The distribution is published as medallion-pipeline, but the Python import name is medallion:
from medallion import Extractor, TransformerSingle, TransformerMultiple
Users define scraper scripts in Python, implementing an interface as specified below.
The tool can be executed like:
medallion PDFExtractor NaivePDFTransformer
Given an __init__.py file either at the root of the current directory or in any folder that the environment variable MEDALLION_ROOT points to.
Example __init__.py:
from .extractors import PDFExtractor
from .transformers import NaivePDFTransformer
The interfaces a user must implement
The class first in the pipeline must inherit from Extractor. All subsequent classes must inherit from either TransformerSingle or TransformerMultiple.
Extractors have no input type, they obtain data from some source, like a webserver or a file drive. Transformers have an input type that matches the output type of the previous processing step (which can be either Transformer or Extractor).
All of the types are user defined. ConfigType can be used to inject runtime configuration, s.a. a set of urls to visit, or any other custom user-based field.
class ProcessingStep:
def __init__(
self,
config: ConfigType|None=None,
):
self._config=config
class TransformerSingle(ABC, ProcessingStep):
def transform_single(
item: InputType,
) -> OutputType:
pass
class TransformerMultiple(ABC, ProcessingStep):
def transform_multiple(
items: list[InputType],
) -> list[OutputType]:
pass
class Extractor(ABC, ProcessingStep):
def extract(self,
) -> list[OutputType]:
pass
Developer notes
User-facing example pipelines live in /example/__init__.py. To execute them via the Run User Pipeline (example) launch configuration (or directly from the CLI), the MEDALLION_ROOT environment variable must be set to that folder so the resolver can locate the user package.
Releasing
Releases are automated: pushing a tag matching v* to main triggers .github/workflows/release.yml, which builds the package with Poetry and publishes it to PyPI via OIDC trusted publishing (no API token needed).
Cutting a release
-
Bump
versioninpyproject.toml(semver: patch for bug fixes, minor for new features, major for breaking changes). -
Commit and push to
main. -
Tag and push the tag — the tag's version must match
pyproject.toml, or the workflow fails its sanity check:git tag v0.1.3 git push origin v0.1.3
-
PyPI rejects re-uploads of an existing version. If a release ships broken, bump again — don't try to overwrite.
Local build (optional, but recommended for some changes)
poetry build
ls dist/
unzip -l dist/medallion_pipeline-*-py3-none-any.whl # inspect contents
Worth doing before tagging when:
- You edited
pyproject.toml(entry points, dependencies, classifiers, license). - You added non-Python files (
py.typed, data files, templates) — Poetry can silently omit these. - You're unsure the package still imports cleanly.
For pure code changes, skip the local build and just push + tag.
Pre-release / dry run
Push an rc tag first to publish to PyPI as a pre-release (won't be installed by default by pip install medallion-pipeline):
git tag v0.1.3rc1
git push origin v0.1.3rc1
Verify on https://pypi.org/project/medallion-pipeline/, then cut the real tag.
Initial PyPI trusted-publisher setup (one-time, already done)
For reference, if the trusted publisher ever needs to be reconfigured: https://pypi.org/manage/account/publishing/ → pending publisher with owner Mcklmo, repo medallion, workflow release.yml, environment pypi.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file medallion_pipeline-0.1.3.tar.gz.
File metadata
- Download URL: medallion_pipeline-0.1.3.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e2189a155e428bcadf98cf5b6274b6c04c567d6f40964b5940449d4cbf6255f
|
|
| MD5 |
35a46bd3a5dd77a28a509a5d1e511e05
|
|
| BLAKE2b-256 |
d6b7d07c842b3917f2bae145b84de1db51197ba5c8f5dec370c5148ca785e7a8
|
Provenance
The following attestation bundles were made for medallion_pipeline-0.1.3.tar.gz:
Publisher:
release.yml on Mcklmo/medallion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
medallion_pipeline-0.1.3.tar.gz -
Subject digest:
4e2189a155e428bcadf98cf5b6274b6c04c567d6f40964b5940449d4cbf6255f - Sigstore transparency entry: 1509090306
- Sigstore integration time:
-
Permalink:
Mcklmo/medallion@8d93c30b252e55fc8be4546e3b2a92ea37a87de5 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Mcklmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8d93c30b252e55fc8be4546e3b2a92ea37a87de5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file medallion_pipeline-0.1.3-py3-none-any.whl.
File metadata
- Download URL: medallion_pipeline-0.1.3-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
005fbd4a9eecf0083892f58175cb5ff5ca44fae6409e09809264155ac5edad38
|
|
| MD5 |
2ac0e66e5679c45d6afc46c3864ddf0c
|
|
| BLAKE2b-256 |
211f10d003e4151a6dd33be43791ba1e4d2d906017b2cae4ae99e1a424203337
|
Provenance
The following attestation bundles were made for medallion_pipeline-0.1.3-py3-none-any.whl:
Publisher:
release.yml on Mcklmo/medallion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
medallion_pipeline-0.1.3-py3-none-any.whl -
Subject digest:
005fbd4a9eecf0083892f58175cb5ff5ca44fae6409e09809264155ac5edad38 - Sigstore transparency entry: 1509090404
- Sigstore integration time:
-
Permalink:
Mcklmo/medallion@8d93c30b252e55fc8be4546e3b2a92ea37a87de5 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Mcklmo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8d93c30b252e55fc8be4546e3b2a92ea37a87de5 -
Trigger Event:
push
-
Statement type: