CLI Helpers#
- _run_from_project(project_root: Path, verbose: bool, create_report: bool, results_dir: str) None[source]#
Run experiments from a project directory.
Loads algorithms, metrics, and configuration from a project directory and executes the training workflow. This function is used when running experiments from project files.
- Parameters:
- project_rootpathlib.Path
Path to the project root directory containing algorithms.py, metrics.py, and settings.py files.
- verbosebool
Whether to enable verbose logging output.
- create_reportbool
Whether to generate an HTML report after experiments complete.
- results_dirstr
Directory path where experiment results will be saved.
- Raises:
- FileNotFoundError
If required project files are missing.
- ImportError
If there are issues importing project modules.
- AttributeError
If required functions or objects are not found in modules.
- ValueError
If there are configuration or data validation errors.
Notes
This function expects the following files to exist in the project root: - algorithms.py: Contains algorithm definitions - metrics.py: Contains metric configurations - settings.py: Contains a create_configuration function
- _run_from_config(project_root: Path, verbose: bool, create_report: bool, results_dir: str, config_file: str) None[source]#
Run experiments from a saved configuration file.
Loads a previously saved experiment configuration and reruns the experiments with the same settings. Validates environment compatibility and dataset integrity before execution.
- Parameters:
- project_rootPath
Path to the project root directory.
- verbosebool
Whether to enable verbose logging output.
- create_reportbool
Whether to generate an HTML report after experiments complete.
- results_dirstr
Directory path where experiment results will be saved.
- config_filestr
Name of the results directory (without path) to load the configuration from.
- Raises:
- RuntimeError
If the configuration was created with a different Brisk version.
- FileNotFoundError
If the configuration file or dataset files are missing.
- ValueError
If dataset validation fails or there are configuration errors.
Notes
The configuration file should be located at: {project_root}/results/{config_file}/run_config.json
This function performs several validation checks: - Package version compatibility - Dataset file existence and integrity - Environment package compatibility
- load_sklearn_dataset(name: str) dict | None[source]#
Load a dataset from scikit-learn.
- Parameters:
- name{‘iris’, ‘wine’, ‘breast_cancer’, ‘diabetes’, ‘linnerud’}
Name of the dataset to load
- Returns:
- dict or None
Loaded dataset object or None if not found
- _validate_dataset(dataset_path: str, metadata: Dict[str, Any]) None[source]#
Validate dataset file against expected metadata.
Checks that the dataset file exists and matches the expected structure including number of samples, features, and feature names.
- Parameters:
- dataset_pathstr
Path to the dataset file to validate.
- metadatadict
Dictionary containing expected dataset metadata with keys: - table_name: Name of the table in the dataset file - num_samples: Expected number of rows/samples - num_features: Expected number of columns/features - feature_names: List of expected feature column names
- Raises:
- FileNotFoundError
If the dataset file does not exist.
- ValueError
If the dataset dimensions or feature names don’t match expectations.
Notes
This function loads the dataset using the IOService and performs validation to ensure data integrity for experiment reruns.
- _handle_incompatible(config_file: str, differences: List[EnvironmentDiff], env_manager: EnvironmentManager) None[source]#
Handle environment compatibility warnings and provide guidance.
Displays warnings about environment differences and provides instructions for recreating the original environment or continuing with potential compatibility issues.
- Parameters:
- config_filestr
Name of the configuration file being rerun.
- differenceslist
List of environment differences detected by EnvironmentManager.
- env_managerEnvironmentManager
Environment manager instance used for comparison.
Notes
This function identifies critical package differences and provides detailed instructions for: - Recreating the original environment - Exporting environment requirements - Checking detailed environment differences
The function categorizes differences as critical if they involve: - Missing packages - Incompatible versions of critical packages - Python version changes