DiracX Core Library

0.0.12 · active · verified Thu Apr 09

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.

Warnings

Install

Imports

Quickstart

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.

import os
from diracx_core.config import BaseConfig
from pydantic import Field

class AppConfig(BaseConfig):
    app_name: str = Field('MyDiracXApp', description='Name of the application')
    api_key: str = Field(os.environ.get('DIRACX_API_KEY', ''), description='API Key for DiracX services')
    debug_mode: bool = Field(False, description='Enable debug logging')

# Example usage
# Set an environment variable for testing, e.g., export DIRACX_API_KEY="your_secret"
config = AppConfig()
print(f"Application Name: {config.app_name}")
if config.api_key:
    print("API Key loaded successfully.")
else:
    print("Warning: DIRACX_API_KEY environment variable not set. API services might not work.")

if config.debug_mode:
    print("Debug mode is ON.")

view raw JSON →