Classifier Discovery Service

Discovers classifiers from registry and local filesystem.

Classifier discovery service.

Discovers available classifiers from the local filesystem (assets/models/). Models are baked into the Docker image at build time from the GitLab Model Registry — no runtime registry access is needed.

Usage:

from ai4drpm.services.shared.classifier_discovery import get_classifier_discovery_service

service = get_classifier_discovery_service()

# List all available classifiers classifiers = service.discover_all()

# Check if a specific classifier exists if service.exists(“data_classifier”):

info = service.get(“data_classifier”)

class ai4drpm.services.shared.classifier_discovery.DiscoveredClassifier(name, source, latest_version)[source]

A classifier discovered from the local filesystem.

name

Classifier name (e.g., “data_classifier”)

source

Discovery source - always “local”

latest_version

Always None (version info not available from filesystem)

name: str
source: str
latest_version: str | None
__init__(name, source, latest_version)
class ai4drpm.services.shared.classifier_discovery.ClassifierDiscoveryService(model_dir='assets/models')[source]

Discovers available classifiers from the local filesystem.

Scans assets/models/ for model files. Models are baked into the Docker image at build time from the GitLab Model Registry.

Supports two directory layouts: 1. Subdirectory: {model_dir}/{name}/model.joblib + vectorizer.joblib 2. Flat (legacy): {model_dir}/{name}_model.joblib + {name}_vectorizer.joblib

__init__(model_dir='assets/models')[source]

Initialize the discovery service.

Parameters:

model_dir (str) – Directory containing local model files (default: assets/models)

discover_all()[source]

List all available classifiers from the local filesystem.

Return type:

list[DiscoveredClassifier]

Returns:

List of DiscoveredClassifier objects sorted by name

exists(classifier_name)[source]

Check if a classifier exists locally.

Parameters:

classifier_name (str) – Name of the classifier to check

Return type:

bool

Returns:

True if the classifier exists, False otherwise

get(classifier_name)[source]

Get a single classifier’s discovery info.

Parameters:

classifier_name (str) – Name of the classifier to look up

Return type:

DiscoveredClassifier | None

Returns:

DiscoveredClassifier if found, None otherwise

ai4drpm.services.shared.classifier_discovery.get_classifier_discovery_service()[source]

Get or create the classifier discovery service singleton.

Return type:

ClassifierDiscoveryService

Returns:

ClassifierDiscoveryService instance (same instance on repeated calls)

ai4drpm.services.shared.classifier_discovery.reset_classifier_discovery_service()[source]

Reset the discovery service singleton (for testing).

Forces re-initialization on next get_classifier_discovery_service() call.

Return type:

None