Skip to main content

Shared core utilities for the bio-analyze toolbox.

Project description

bio-analyze-core

Shared core utilities for the toolbox: provides reusable capabilities (configuration, logging, I/O, external command execution, etc.) for various analysis modules and the CLI.

📦 Core Functional Modules

1. Logging Management

Provides a unified logging initialization and management mechanism based on loguru.

Python API

from bio_analyze_core.logging import get_logger, setup_logging

# 1. Unified initialization at the application entry point
# Idempotent design: multiple calls only update the level without breaking existing sinks
setup_logging(level="INFO")

# 2. Get a module-specific logger
# Automatically binds extra["name"] = "my_module"
logger = get_logger("my_module")
logger.info("This is a log message")

# 3. Independent file logging
# Supports setting an independent log file for a specific module
file_logger = get_logger("my_task", log_path="./logs/task.log")
file_logger.info("This goes to file AND console")

get_logger parameters:

  • name (str): Logger name.
  • log_path (str | Path, optional): If provided, logs will also be written to this file.
  • level (str): Log level for the file (default "INFO").

2. Pipeline Framework

Provides a Node-based stream processing framework supporting context sharing and state persistence.

Python API

from bio_analyze_core.pipeline import Pipeline, Node, Context, Progress

class MyNode(Node):
    def run(self, context: Context, progress: Progress, logger):
        logger.info(f"Processing {context.data}")
        progress.update(message="Working...", percentage=50)
        context.result = "done"

# Create a pipeline
pipeline = Pipeline("my_pipeline", state_file="pipeline_state.json")
pipeline.context.data = "input_data"

# Add nodes
pipeline.add_node(MyNode("step1"))

# Run the pipeline
pipeline.run()

3. Subprocess Management

Wraps subprocess.run to provide safer external command execution and output capturing.

Python API

from bio_analyze_core.subprocess import run, CalledProcessError

try:
    result = run(
        ["ls", "-la"],
        cwd="./",
        check=True,          # Raises exception on non-zero exit code
        capture_output=True  # Captures stdout/stderr
    )
    print(result.stdout)
except CalledProcessError as e:
    print(f"Command failed: {e.stderr}")

4. Configuration Management

Supports loading configurations from JSON/YAML and provides deep merge utilities.

Python API

from bio_analyze_core.utils import load_config

# Automatically recognizes .json or .yaml
config = load_config("config.yaml")
print(config["input_dir"])

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

bio_analyze_core-0.1.0a1.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

bio_analyze_core-0.1.0a1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file bio_analyze_core-0.1.0a1.tar.gz.

File metadata

  • Download URL: bio_analyze_core-0.1.0a1.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bio_analyze_core-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 98ad2f5c32e568989d9c7e9f4ca2606920f48e52c1db04e24cb5f7dc41fb57b9
MD5 7587adc463890475c205ac033b95063c
BLAKE2b-256 e1ec4e7d52acb329f271b1634d6c15bcbd6596545dc3f2dc419b27b28ae878ff

See more details on using hashes here.

File details

Details for the file bio_analyze_core-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: bio_analyze_core-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bio_analyze_core-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6ea960f959686d146acabe09e6768449a7a5c1204b19dfee26516b2b76c1b31
MD5 e0be715e5e9b5a93d9a1c2f7e983e295
BLAKE2b-256 088c452563b31d51cb34d5bf0a9351fcab55e446421a17a91e8c1542b3b520c6

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