OpenMed supports configuration profiles to quickly switch between different settings for development, production, testing, or custom workflows.
OpenMed ships with five built-in profiles:
| Profile | Backend | Batch size | Timeout | Use case |
|---|---|---|---|---|
dev |
Auto | Backend default | 600s | Development and debugging |
prod |
Auto | Backend default | 300s | Production deployments |
test |
Auto | Backend default | 60s | Testing and CI |
fast |
Auto | Backend default | 120s | Quick experiments |
low_resource |
CPU ONNX INT8 | 1 | 900s | CPU-only machines with 4-8 GiB RAM |
The low_resource profile lazily loads the official small PII model, caps
inference at one note per batch and one worker, and never falls back to the
Torch backend. The tested model snapshot is pinned for reproducible memory and
accuracy behavior. Install its runtime with
pip install "openmed[onnx-runtime]".
See the low-resource benchmark for the memory
envelope and reproduction commands.
from openmed import OpenMedConfig, analyze_text
# Create config from profile
config = OpenMedConfig.from_profile("dev")
print(config.log_level) # "DEBUG"
# Apply profile with overrides
config = OpenMedConfig.from_profile("prod", timeout=600)
# Apply profile to existing config
config = OpenMedConfig(default_org="MyOrg")
new_config = config.with_profile("dev")Set the OPENMED_PROFILE environment variable:
export OPENMED_PROFILE=prod
python my_script.pyfrom openmed import OpenMedConfig
# Profile is automatically applied
config = OpenMedConfig()
print(config.profile) # "prod"Programmatic example:
from openmed.core.config import save_profile
settings = {
"log_level": "INFO",
"timeout": 450,
"device": "cuda",
"use_medical_tokenizer": True,
}
save_profile("myproject", settings)from openmed import OpenMedConfig
config = OpenMedConfig.from_profile("myproject")from openmed.core.config import delete_profile
delete_profile("myproject")Note: Built-in profiles (dev, prod, test, fast, low_resource) cannot be deleted.
Custom profiles are stored in TOML format at:
~/.config/openmed/profiles/<name>.toml
Example profile file:
# OpenMed profile: myproject
# Custom profile configuration
log_level = "INFO"
timeout = 450
device = "cuda"
use_medical_tokenizer = trueProfile settings are applied in this order (later overrides earlier):
- OpenMedConfig defaults
- Environment variables
- Config file (
~/.config/openmed/config.toml) - Profile settings
- Explicit arguments
# Profile overrides config file, explicit args override profile
config = OpenMedConfig.from_profile("prod", timeout=900)
# timeout=900 overrides prod's timeout=300from openmed import OpenMedConfig, analyze_text
# Use dev profile for detailed logging
config = OpenMedConfig.from_profile("dev")
result = analyze_text(
"Patient has chronic myeloid leukemia.",
model_name="disease_detection_superclinical",
config=config,
)from openmed import OpenMedConfig, BatchProcessor
# Production settings with minimal logging
config = OpenMedConfig.from_profile("prod")
processor = BatchProcessor(
model_name="disease_detection_superclinical",
config=config,
)
results = processor.process_files(clinical_notes)export OPENMED_PROFILE=test
pytest tests/from openmed import OpenMedConfig
# Start with dev
config = OpenMedConfig.from_profile("dev")
# Switch to prod for final run
config = config.with_profile("prod")