Skip to main content

scitex-config

SciTeX

Configuration + path management with `direct → yaml → env → default` priority cascade.

Full Documentation · uv pip install scitex-config[all]

pypi python docs

tests install-check quality cov


Problem and Solution

# Problem Solution
1 Config values come from many sources (CLI flags, YAML files, env vars, hard-coded defaults) and ad-hoc precedence rules drift between scripts. PriorityConfig.resolve() enforces a single direct → yaml → env → default cascade with a resolution log.
2 Runtime directories (cache, logs, sessions) get hardcoded to ~/.cache/<pkg>/ and ignore the user's $SCITEX_DIR. get_paths() / ScitexPaths roots directories at $SCITEX_DIR; _ecosystem.local_state.runtime_path() resolves per-package <pkg>/runtime/ paths canonically.
3 .env loading is reinvented per project (cwd-only, no walk-up, silent override of process env). read_dotenv(walk_up=True) walks parents to $HOME and returns a dict without touching os.environ; load_dotenv(keys=[...]) is the explicit opt-in that exports only the named keys and never overrides existing process env. Importing the package reads no .env.

Quick Start

import scitex_config as cfg

config = cfg.get_config()
log_level = config.resolve("logging.level", default="INFO")

paths = cfg.get_paths()
print(paths.cache)            # ~/.scitex/cache

# SciTeX-ecosystem packages: use the per-package state resolver
from scitex_config._ecosystem import local_state
log_path = local_state.runtime_path("hpc", "dispatch.log")
print(log_path)               # ~/.scitex/hpc/runtime/dispatch.log

Demo

flowchart LR
    D[direct_val=cli_arg] -->|wins if not None| R[ScitexConfig.resolve]
    Y["yaml: config/app.yaml<br/>database.url"] -->|2nd| R
    E["env: SCITEX_DATABASE_URL"] -->|3rd| R
    F["default='postgresql://localhost/dev'"] -->|fallback| R
    R --> V["resolved value"]

Figure 1. Demo. Priority cascade: direct argument wins, then YAML, then env var, then default.

Installation

uv pip install "scitex-config[all]"
Extras
Extra Enables
all Everything below (dev + docs)
dev Test/lint tools (pytest, ruff, scitex-dev)
docs Sphinx build (sphinx, theme/parser extensions)

Architecture

flowchart LR
    SRC[direct / dictionary / env / default] --> PC[PriorityConfig.resolve]
    PC --> VAL[resolved value]
    PC --> LOG[resolution log]
    ENV[.env files] -->|read_dotenv: dict| SC
    ENV -.->|explicit load_dotenv keys| OSenv[os.environ]
    OSenv --> PC
    YAML[default.yaml or explicit YAML] --> SC[ScitexConfig]
    SC --> VAL

Figure 2. Architecture. PriorityConfig resolves dictionary inputs; ScitexConfig supplies YAML-backed dotted-path reads.

1 Interfaces

Python API
import scitex_config as cfg

# YAML-based (recommended)
config = cfg.get_config()
print(config.get("logging.level", default="INFO"))
log_level = config.resolve("logging.level", default="INFO")

# Path resolution
paths = cfg.get_paths()
paths.function_cache       # ~/.scitex/cache/function/...

# Explicit YAML file; nested keys use dot notation.
config = cfg.ScitexConfig(config_path="config/app.yaml")
db_url = config.resolve(
    "database.url",
    direct_val=None,  # pass an explicit override here when supplied
    default="postgresql://localhost/dev",
)

# Dictionary primitive: direct > dictionary > environment > default.
pc = cfg.PriorityConfig(config_dict={"port": 8000}, env_prefix="APP_")
port = pc.resolve("port", direct_val=None, default=3000, type=int)

Status

Standalone fork of scitex.config. Core deps are PyYAML + scitex-logging. The umbrella package's scitex.config import path is preserved via a sys.modules-alias bridge.

Part of SciTeX

scitex-config is part of SciTeX. Install via the umbrella with pip install scitex[config] to use as scitex.config (Python) or scitex config ... (CLI).

Four Freedoms for Research

  1. The freedom to run your research anywhere — your machine, your terms.
  2. The freedom to study how every step works — from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. The freedom to modify any module and share improvements with the community.

AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.

License

AGPL-3.0-only (see LICENSE).


SciTeX

Metadata

Release files for scitex-config 0.4.0

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

Source distribution (sdist)

Source distribution for scitex-config 0.4.0
File Size Uploaded Provenance Actions
scitex_config-0.4.0.tar.gz 39.9 kB Without provenance Details for scitex_config-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scitex-config 0.4.0
File Interpreter ABI Platform Actions
scitex_config-0.4.0-py3-none-any.whl Python 3 none any Details for scitex_config-0.4.0-py3-none-any.whl

Total release size: 83.4 kB

Release files / scitex_config-0.4.0.tar.gz

Download URL scitex_config-0.4.0.tar.gz
Size 39.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a45ea8f511ae78590d640912e87cf90efbe5f36a9ad06e328523809974999a2c
BLAKE2b-256 checksum
How to use checksums
639d6322fae55993b691f8448b0d190d106f0472464138eb1d3794abaf21e3f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / scitex_config-0.4.0-py3-none-any.whl

Download URL scitex_config-0.4.0-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
161fa1e3b2aace1cba277e0faf2584da0bad85fafe20736f85027385f70e665b
BLAKE2b-256 checksum
How to use checksums
ce31b788567ae3259009c694e55e5d006e448d6d59f68f6a1d3e2c6f05a9aec4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.14

Security for scitex-config 0.4.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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