Skip to main content

pyprocessors_metadata_from_categories

license tests codecov docs version PyPI - Python Version

Turn the categories carried by a document into a metadata value.

How it works

For every input document the processor converts its categories into a metadata entry and then clears the categories. Conversion happens systematically at both levels:

  • Document level — the document's categories are turned into document.metadata[metadata_name], then document.categories is cleared.
  • Segment level — the same conversion is applied to each sentence: its categories become sentence.metadata[metadata_name], then the sentence's categories are cleared.

For a given set of categories, only those whose score is greater than or equal to multi_label_threshold are kept, and the resulting metadata value is:

  • None (the metadata key is removed) when no category passes the threshold,
  • a single value when exactly one category passes,
  • a list of values when several categories pass.

Parameters

Parameter Default Description
metadata_name None Name of the generated metadata key.
multi_label_threshold 0.0 Only categories with a score greater than or equal to this value are kept.

Installation

You can simply pip install pyprocessors_metadata_from_categories.

Development

The build is driven by Task and uv, with the shared stages coming from the python-archetype submodule.

Getting started

The stages live in a Git submodule, so clone with --recurse-submodules:

git clone --recurse-submodules git@bitbucket.org:kairntech/pyprocessors_metadata_from_categories.git
cd pyprocessors_metadata_from_categories
sh -c "$(curl -sSL https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
task

Already cloned without it? The submodule directory is empty, and task fails on:

task: No Taskfile found at ".../submodules/python-archetype/resources/Taskfile.yml"

which means exactly that, and nothing worse:

git submodule update --init

Task is the only manual prerequisite. An archetype cannot bootstrap itself: uv and the Python interpreter install themselves on demand (every task that runs uv depends on an internal install-python task), but the thing that runs them does not. Make sure ~/.local/bin is on your PATH — that is where task and uv both land.

Running the pipeline

task stages          # print the pipeline stages, in order
task                 # run the pipeline up to (but excluding) py:publish
task -- --skip-tests # same, without the test stage
task up-to -- py:lint # run the pipeline up to and including one stage
task jenkins         # run every stage, exactly what Jenkins runs

task with no argument is safe by construction: it runs every stage but the last, and that bound is computed from the STAGES list rather than written down. The last stage is the only one with an effect outside your machine.

STAGES, declared once in Taskfile.yml, is the single definition of the pipeline order — so what you run locally is what Jenkins runs.

Individual stages

Task Description
task py:sync Install the project and its dependencies (uv sync)
task py:lint ruff check and ruff format --check
task py:format Reformat the code with ruff
task py:test Run the test suite
task py:test-marker -- <m> Run the tests carrying one pytest marker
task py:sbom Generate a CycloneDX SBOM of the resolved environment
task py:check-vulnerabilities Check for known CVEs
task py:check-updates Check for dependency updates
task py:build Build the wheel and sdist (uv build)
task py:publish Publish the distributions (uv publish)
task py:version-file Print the path of the file carrying __version__
task py:set-version VERSION=x Write that version into it

uv.lock is not versioned here, so py:sync always resolves from scratch (--upgrade): a stale lock lying around on a machine would otherwise make you test and audit versions the CI never sees.

SBOM & vulnerability check

task py:sbom and task py:check-vulnerabilities wrap the underlying tools. To run them by hand:

uv sync --extra test --extra sbom
uv run cyclonedx-py environment -o sbom.cdx.json --output-format json
uv run pip-audit --skip-editable --format json --output audit-report.json

Ask for all the extras, not just sbom: uv sync synchronises rather than adds, so whatever the requested extras do not pull in gets removed. --extra sbom on its own uninstalls ruff and pytest, leaving an environment that can no longer lint or test.

--skip-editable skips the project itself, which no advisory database can know about. The tasks do the same, and pip-audit still exits non-zero when it finds a real vulnerability — which is the contract the CI relies on. Avoid --strict: it turns "dependency not found on PyPI" into a fatal error, so it breaks as soon as the local version is not a published one.

Metadata

Release files for pyprocessors-metadata_from_categories 1.6.15

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

Source distribution (sdist)

Source distribution for pyprocessors-metadata_from_categories 1.6.15
File Size Uploaded Provenance
pyprocessors_metadata_from_categories-1.6.15.tar.gz 8.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyprocessors-metadata_from_categories 1.6.15
File Interpreter ABI Platform
pyprocessors_metadata_from_categories-1.6.15-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / pyprocessors_metadata_from_categories-1.6.15.tar.gz

Download URL pyprocessors_metadata_from_categories-1.6.15.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b44016ba8db285040a4214f69044e777c3ac1410ecde6260bb4dabf8a9d8a2eb
BLAKE2b-256 checksum
How to use checksums
d9b1bfd75d910b7cd228870c4b709fbef7e6ec53ffc7d70a06b497dcc9f04968
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pyprocessors_metadata_from_categories-1.6.15-py3-none-any.whl

Download URL pyprocessors_metadata_from_categories-1.6.15-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
332f4a17fa8124bebcb82c40b5e275bfbf21e3df3a2b2e783feffb4b82710798
BLAKE2b-256 checksum
How to use checksums
d644262a32c11435e85899b8f8d031019226b1a83a1911f5aaf2426456923b3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pyprocessors-metadata_from_categories 1.6.15

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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