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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bio_analyze_core-0.1.0a3.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.0a3.tar.gz
Algorithm Hash digest
SHA256 f56938363b4c29866082aafc3a3d98c40f064621dc5780e01edc97e72a8ef988
MD5 553421f10406af734ccca47193c8e629
BLAKE2b-256 508d57e2e4794c978f1b5c1ddea76167ef30f4ece93848a12f7252447c83454e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bio_analyze_core-0.1.0a3-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.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 59f73e05e88440582383bb989e5366b3049ad516f2dc5a3ae5090fd7362d8569
MD5 96887cccfc55d4538f79b1573e722e77
BLAKE2b-256 5541e80c938c70079b08d82711124463fc6da81598ae03c79783c60b8b43da44

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