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.0a2.tar.gz (14.8 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.0a2-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bio_analyze_core-0.1.0a2.tar.gz
  • Upload date:
  • Size: 14.8 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.0a2.tar.gz
Algorithm Hash digest
SHA256 03b8f273b3ddf03821a2fbe093a008a2cd1c317e65c1504355dc7f85de01c9cb
MD5 f6a3aa1d7624ccdc2b80903b101e3af2
BLAKE2b-256 540e61361847c032584922f2891bcb70d82bb36fe7afe480674f6dec63bf8e8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bio_analyze_core-0.1.0a2-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.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d2e63ce0d62c47443ebac755aef60288eecf6b1356019df7a05bf00f4bd1781
MD5 f1334ad3376cbf7733cda3ed387c6462
BLAKE2b-256 a38c53c3a806f90bbe833e0ae628bff8487144e706e1ef8ee96611ba68329200

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