Skip to main content

Simple Python processors to send an array of messages to a channel and to log an incoming stream to the RDF-Connect logging system.

Project description

log-processor-py

Simple Python processors to send an array of messages to a channel and to log an incoming stream to the RDF-Connect logging system.

Usage

To use the Python rdfc:LogProcessorPy or rdfc:SendProcessorPy in your RDF-Connect pipeline, you need to have a pipeline configuration that includes the rdfc:PyRunner (check out their documentation to find out how to install and configure it).

You can install the Python runner package using the following command:

uv add rdfc_log-processor

Next, you can add the processors to your pipeline configuration as follows:

@prefix rdfc: <https://w3id.org/rdf-connect#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.

# Import the processor
<> owl:imports <./.venv/lib/python3.13/site-packages/rdfc_log_processor/processor.ttl>.

### Define the channels your processor needs
<channel> a rdfc:Writer, rdfc:Reader.

# Attach the processor to the pipeline under the PyRunner
# Add the `rdfc:processor <send>, <log>` statement under the `rdfc:consistsOf` statement of the `rdfc:PyRunner`

### Define and configure the processors
<send> a rdfc:SendProcessorPy;
       rdfc:writer <channel>;
       rdfc:msg "Hello, World!", "Good afternoon, World!",
                "Good evening, World!", "Good night, World!".

<log> a rdfc:LogProcessorPy;
      rdfc:reader <channel>;
      rdfc:level "info";
      rdfc:label "test".

Configuration

Parameters of rdfc:SendProcessorPy:

  • rdfc:writer: The channel to which the processor will write messages.
  • rdfc:msg: The messages to be sent by the processor.

Parameters of rdfc:LogProcessorPy:

  • rdfc:reader: The channel from which the processor will read messages.
  • rdfc:writer: The channel to which the processor will write log messages (optional).
  • rdfc:level: The log level to use (e.g., "debug", "info", "warning", "error", "critical"). Defaults to "info".
  • rdfc:label: A label for the log messages, which can be used to filter or categorize logs. Defaults to "log".
  • rdfc:raw: If set to true, the processor will log raw messages to stdout without any formatting instead of to the RDF-Connect logging system. Defaults to false.

Development

The Packaging Python Projects guide was used to set up this project. As build backend, the default Hatchling is used, for which the pyproject.toml file is configured. That file tells build frontend tools like pip which backend to use. This project uses uv as package manager.

First, make sure you have Hatch installed:

pip install hatch
# OR
brew install hatch
# OR another method of your choice

Then, create a virtual environment and spawn a shell. This will automatically install the project dependencies defined in pyproject.toml:

hatch env create
hatch shell

You can build the project with:

hatch build

You can run the tests using:

hatch test

Lastly, you can publish the package to PyPI with:

hatch publish

Project Structure

log-processor-py/             # Root directory of the project
├── src/                      # Source code directory
│   └── rdfc_log_processor/   # Package directory
│       ├── __init__.py       # Package initialization, allows importing as a regular package
│       ├── processor.py      # Contains the main logic for the Python processor
│       └── processor.ttl     # RDF schema for the processor, used for metadata and configuration
├── tests/                    # Directory for unit tests
├── pyproject.toml            # Project metadata and build configuration

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

rdfc_log_processor-1.0.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

rdfc_log_processor-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file rdfc_log_processor-1.0.0.tar.gz.

File metadata

  • Download URL: rdfc_log_processor-1.0.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for rdfc_log_processor-1.0.0.tar.gz
Algorithm Hash digest
SHA256 854e897a8c174b9358d72455d73fadcf8119b464a1e043501386f18600c4843c
MD5 b4024f88fe0ed70f0d6ddc0955f77288
BLAKE2b-256 23e8579128efd512ed56f8dd05d5009aa0fdb96af01e25cf0b64157af359e085

See more details on using hashes here.

File details

Details for the file rdfc_log_processor-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rdfc_log_processor-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23c24b3ffa8dd9cdbaea4956ffbc2ae08313e66636a8742e0e91acadc44b7094
MD5 c1669993269e50814e49137d760056a1
BLAKE2b-256 5cacd0f475807d365fa7e74c8cb1bf303aead09224e3bbadbf26098a037bff1e

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