Skip to main content

A composable scraper pipeline built around the medallion architecture (bronze / silver / gold).

Project description

Medallion architecture scraper pipeline

PyPI License Python

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.

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

medallion_pipeline-0.1.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

medallion_pipeline-0.1.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file medallion_pipeline-0.1.1.tar.gz.

File metadata

  • Download URL: medallion_pipeline-0.1.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for medallion_pipeline-0.1.1.tar.gz
Algorithm Hash digest
SHA256 788155cc549a5adb3fd7c879a4960d863b1505d79bd9af7f69d09fe2164fa7b6
MD5 3ca2865bc7f95288b25d1478ffc38e21
BLAKE2b-256 1cc8bb01b0925b3ef71058388f06469bb1add006a8e3a72297f55c5f76bb7a46

See more details on using hashes here.

Provenance

The following attestation bundles were made for medallion_pipeline-0.1.1.tar.gz:

Publisher: release.yml on Mcklmo/medallion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file medallion_pipeline-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for medallion_pipeline-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a060c95bd2ff3e2690c2693ded4dd4208337c1dee73d246696d684fb464f9669
MD5 fa8baa6e720b2271f7e63eda978d78bc
BLAKE2b-256 01b9adc75c90aa5c0456e52f1de96e3b8f4a6fd506e6fbb9709c910bda6dfd60

See more details on using hashes here.

Provenance

The following attestation bundles were made for medallion_pipeline-0.1.1-py3-none-any.whl:

Publisher: release.yml on Mcklmo/medallion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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