config
This module contains the configuration for the devices RAP project. It includes setup for logging, directory creation, and dataset paths. It also provides a Config class to manage dataset configurations and paths.
Classes:
Name | Description |
---|---|
ConfigError |
Custom exception class for configuration errors. |
Config |
Configuration class for the project, managing financial month/year, dataset paths, and Amber Report Excel configuration. |
Functions:
Name | Description |
---|---|
config_logger |
Configures the logging for the project using loguru. |
create_directory |
Creates directories if they do not already exist. |
ConfigError
Bases: LoggedException
Custom exception class for configuration errors. This class is used to raise exceptions related to configuration issues.
Config
Configuration class for the project.
Source code in devices_rap/config.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
__init__(fin_month, fin_year, use_multiprocessing=True, outputs='excel', raw_data_dir=RAW_DATA_DIR, processed_data_dir=PROCESSED_DATA_DIR, amber_report_excel_config_path=AMBER_REPORT_EXCEL_CONFIG_PATH, master_devices_csv_name=MASTER_DEVICES_CSV_NAME, exceptions_csv_name=EXCEPTIONS_CSV_NAME, provider_codes_lookup_csv_name=PROVIDER_CODES_LOOKUP_CSV_NAME, device_taxonomy_csv_name=DEVICE_TAXONOMY_CSV_NAME)
Initializes the Config class with the provided parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fin_month
|
FIN_MONTHS
|
The financial month string in the format "MM" (e.g., "12") with 01 referring to April. |
required |
fin_year
|
FIN_YEARS
|
The financial year string in the format "YY1YY2" (e.g., "2425"). |
required |
raw_data_dir
|
Path
|
The directory where raw data is stored. Defaults to the RAW_DATA_DIR constant. |
RAW_DATA_DIR
|
amber_report_excel_config_path
|
Path
|
The path to the Amber Report Excel configuration file. Defaults to the AMBER_REPORT_EXCEL_CONFIG_PATH constant. |
AMBER_REPORT_EXCEL_CONFIG_PATH
|
master_devices_csv_name
|
str
|
The name of the master devices CSV file. Defaults to the MASTER_DEVICES_CSV_NAME constant. |
MASTER_DEVICES_CSV_NAME
|
exceptions_csv_name
|
str
|
The name of the exceptions CSV file. Defaults to the EXCEPTIONS_CSV_NAME constant. |
EXCEPTIONS_CSV_NAME
|
provider_codes_lookup_csv_name
|
str
|
The name of the provider codes lookup CSV file. Defaults to the PROVIDER_CODES_LOOKUP_CSV_NAME constant. |
PROVIDER_CODES_LOOKUP_CSV_NAME
|
device_taxonomy_csv_name
|
str
|
The name of the device taxonomy CSV file. Defaults to the DEVICE_TAXONOMY_CSV_NAME constant. |
DEVICE_TAXONOMY_CSV_NAME
|
Source code in devices_rap/config.py
create_output_directory()
Creates the output directory for the Amber Report Excel files based on the financial month and year.
Returns:
Type | Description |
---|---|
Path
|
The path to the created output directory. |
Source code in devices_rap/config.py
config_logger()
Set up logging configuration for the project using loguru. This function configures loguru to log messages to both the console and a file. It also ensures that the log file is created in the 'logs' directory with a timestamped filename.
Source code in devices_rap/config.py
create_directory(directory_path)
Creates directories if they do not already exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory_path
|
Path | List[Path]
|
A single Path object or a list of Path objects representing the directories to be created. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the provided directory_path list is empty, a warning is logged and the function returns without creating any directories. |