src.utils
GPU
The GPU utilities.
src.utils.gpu.set_gpu_power_limit_if_needed
Helper function, that sets GPU power limit if specified GPU is used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gpu_name
|
str
|
The name of the GPU to assign the new power limit to. Default: "NVIDIA GeForce RTX 3090". |
'NVIDIA GeForce RTX 3090'
|
pw
|
int
|
The new power limit to set. Defaults to 250W. |
250
|
Source code in src/utils/gpu.py
6 7 8 9 10 11 12 13 14 15 16 17 |
|
Logging
The logging utilities.
src.utils.logging.get_logger
Builds a Logger
instance with provided name and log level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name for the logger. |
required |
log_level
|
int | str
|
The default log level. |
INFO
|
Returns:
Type | Description |
---|---|
Logger
|
The logger. |
Source code in src/utils/logging.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
src.utils.logging.timed
This decorator prints the execution time for the decorated function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
Callable[P, T]
|
The function to wrap. |
required |
Returns:
Type | Description |
---|---|
Callable[P, T]
|
Wrapper around the function. |
Source code in src/utils/logging.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
MLFlow
The MLFlow utilities.
src.utils.mlflow.resolve_experiment_name
Resolves MLFlow experiment name.
If environment variable "MLFLOW_EXPERIMENT_NAME"
is set, then the experiment name
will be resolved based on this environment variable. Otherwise, the default experiment name, passed as
and argument will be used.
Useful when working with Azure ML.
Notes
This function will set the environment variable "MLFLOW_EXPERIMENT_NAME"
if it is not set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default_experiment_name
|
str
|
The default experiment name to use if environment variable is not set. |
required |
Examples:
When env variable is unset, the default exp name passed as argument will be used.
>>> del os.environ["MLFLOW_EXPERIMENT_NAME"]
>>> resolve_experiment_name("custom-mlflow-experiment-name")
'custom-mlflow-experiment-name'
Otherwise, the default exp name indicated by the env var will be used.
>>> os.environ["MLFLOW_EXPERIMENT_NAME"] = "env-defined-mlflow-experiment-name"
>>> resolve_experiment_name("different-mlflow-experiment-name")
'env-defined-mlflow-experiment-name'
Source code in src/utils/mlflow.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
src.utils.mlflow.run_id_from_context
Resolves the MLFlow Run ID from the context.
Returns:
Type | Description |
---|---|
str | None
|
The MLFlow Run ID based on |
Source code in src/utils/mlflow.py
42 43 44 45 46 47 48 49 |
|
Serialization
The serialization utils.
src.utils.serialization.JsonEncoder
Bases: JSONEncoder
Custom JSON encoder that handles datatypes that are not out-of-the-box supported by the json
package.
Source code in src/utils/serialization.py
9 10 11 12 13 14 15 16 17 18 19 |
|