{"id":5608,"library":"diracx-core","title":"DiracX Core Library","description":"DiracX Core Library (diracx-core) provides foundational utilities, data structures, and base classes shared across the DiracX ecosystem. Currently at version 0.0.12, it's in early development, implying a rapid release cadence with potential for frequent API changes.","status":"active","version":"0.0.12","language":"en","source_language":"en","source_url":"https://github.com/DiracX/diracx-core","tags":["core-library","utilities","configuration","shared-code","pydantic"],"install":[{"cmd":"pip install diracx-core","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for data validation and configuration management.","package":"pydantic","optional":false},{"reason":"Used for YAML configuration parsing.","package":"pyyaml","optional":false},{"reason":"Used for enhanced console output and logging.","package":"rich","optional":false}],"imports":[{"symbol":"BaseConfig","correct":"from diracx_core.config import BaseConfig"},{"symbol":"DiracXError","correct":"from diracx_core.errors import DiracXError"},{"symbol":"LoggableMixin","correct":"from diracx_core.logger import LoggableMixin"}],"quickstart":{"code":"import os\nfrom diracx_core.config import BaseConfig\nfrom pydantic import Field\n\nclass AppConfig(BaseConfig):\n    app_name: str = Field('MyDiracXApp', description='Name of the application')\n    api_key: str = Field(os.environ.get('DIRACX_API_KEY', ''), description='API Key for DiracX services')\n    debug_mode: bool = Field(False, description='Enable debug logging')\n\n# Example usage\n# Set an environment variable for testing, e.g., export DIRACX_API_KEY=\"your_secret\"\nconfig = AppConfig()\nprint(f\"Application Name: {config.app_name}\")\nif config.api_key:\n    print(\"API Key loaded successfully.\")\nelse:\n    print(\"Warning: DIRACX_API_KEY environment variable not set. API services might not work.\")\n\nif config.debug_mode:\n    print(\"Debug mode is ON.\")","lang":"python","description":"This quickstart demonstrates how to define and use a configuration class inheriting from `diracx_core.config.BaseConfig`. It showcases field definitions with descriptions and how to integrate environment variables for sensitive data like API keys."},"warnings":[{"fix":"Pin your `diracx-core` dependency to an exact version (e.g., `diracx-core==0.0.12`) in `requirements.txt` or `pyproject.toml` to prevent unexpected breakages. Regularly check the project's GitHub for breaking changes before upgrading.","message":"As a pre-1.0 version library (currently 0.0.12), diracx-core's API is subject to frequent and significant breaking changes without prior deprecation warnings. Users should pin exact versions and regularly review the GitHub repository for updates.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Understand that while you can use its components, full application logic might require other DiracX components or custom wrappers. Review the specific use cases in the official DiracX ecosystem if available.","message":"DiracX Core is primarily designed as a foundational library to be extended by other DiracX packages, not necessarily for standalone complex application development. While it provides utilities, its core strength lies in providing base classes and structures for a larger ecosystem.","severity":"gotcha","affected_versions":"All"},{"fix":"Always explicitly define expected configuration sources (e.g., `os.environ.get`) or ensure `.env` files are loaded correctly if used. When debugging, print the resulting configuration object to verify loaded values.","message":"The `BaseConfig` class, being a Pydantic `BaseModel`, relies on specific mechanisms for configuration loading and overriding (e.g., environment variables, `.env` files, or explicit instantiation). Misunderstanding the priority or source of configuration values can lead to unexpected behavior.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}