-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented alternative experiment tracking functionality (#102)
- Loading branch information
Showing
15 changed files
with
1,718 additions
and
795 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,10 @@ ______________________________________________________________________ | |
|
||
Developers: | ||
|
||
- Anders Jess Pedersen ([email protected]) | ||
- Dan Saattrup Nielsen ([email protected]) | ||
- Simon Leminen Madsen ([email protected]) | ||
|
||
|
||
|
||
## Installation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type: mlflow | ||
name_experiment: CoRal | ||
name_run: ${model_id} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type: wandb | ||
name_experiment: CoRal | ||
name_run: ${model_id} | ||
name_group: default |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""The CoRal project. | ||
Experiment tracking. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Factory for experiment tracking setup.""" | ||
|
||
from omegaconf import DictConfig | ||
|
||
from .extracking_setup import ExTrackingSetup | ||
from .mlflow_setup import MLFlowSetup | ||
from .wandb_setup import WandbSetup | ||
|
||
|
||
def load_extracking_setup(config: DictConfig) -> ExTrackingSetup: | ||
"""Return the experiment tracking setup. | ||
Args: | ||
config: | ||
The configuration object. | ||
Returns: | ||
The experiment tracking setup. | ||
""" | ||
match config.experiment_tracking.type: | ||
case "wandb": | ||
return WandbSetup(config=config) | ||
case "mlflow": | ||
return MLFlowSetup(config=config) | ||
case _: | ||
raise ValueError( | ||
f"Unknown experiment tracking type: {config.experiment_tracking.type}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""This module contains the base class for an experiment tracking setup.""" | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
from omegaconf import DictConfig | ||
|
||
|
||
class ExTrackingSetup(ABC): | ||
"""Base class for an experiment tracking setup.""" | ||
|
||
@abstractmethod | ||
def __init__(self, config: DictConfig) -> None: | ||
"""Initialise the experiment tracking setup. | ||
Args: | ||
config: | ||
The configuration object. | ||
""" | ||
|
||
@abstractmethod | ||
def run_initialization(self) -> None: | ||
"""Run the initialization of the experiment tracking setup. | ||
Returns: | ||
True if the initialization was successful, False otherwise. | ||
""" | ||
|
||
@abstractmethod | ||
def run_finalization(self) -> None: | ||
"""Run the finalization of the experiment tracking setup. | ||
Returns: | ||
True if the finalization was successful, False otherwise. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""MLFlow experiment tracking setup class.""" | ||
|
||
import os | ||
|
||
import mlflow | ||
from omegaconf import DictConfig | ||
|
||
from .extracking_setup import ExTrackingSetup | ||
|
||
|
||
class MLFlowSetup(ExTrackingSetup): | ||
"""MLFlow setup class.""" | ||
|
||
def __init__(self, config: DictConfig) -> None: | ||
"""Initialise the MLFlow setup. | ||
Args: | ||
config: | ||
The configuration object. | ||
""" | ||
self.config = config | ||
self.is_main_process = os.getenv("RANK", "0") == "0" | ||
|
||
def run_initialization(self) -> None: | ||
"""Run the initialization of the experiment tracking setup.""" | ||
mlflow.set_experiment(self.config.experiment_tracking.name_experiment) | ||
mlflow.start_run(run_name=self.config.experiment_tracking.name_run) | ||
return | ||
|
||
def run_finalization(self) -> None: | ||
"""Run the finalization of the experiment tracking setup.""" | ||
mlflow.end_run() | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""wandb experiment tracking setup class.""" | ||
|
||
import os | ||
|
||
import wandb | ||
from omegaconf import DictConfig | ||
|
||
from .extracking_setup import ExTrackingSetup | ||
|
||
|
||
class WandbSetup(ExTrackingSetup): | ||
"""Wandb setup class.""" | ||
|
||
def __init__(self, config: DictConfig) -> None: | ||
"""Initialise the Wandb setup. | ||
Args: | ||
config: | ||
The configuration object. | ||
""" | ||
self.config = config | ||
self.is_main_process = os.getenv("RANK", "0") == "0" | ||
|
||
def run_initialization(self) -> None: | ||
"""Run the initialization of the experiment tracking setup.""" | ||
wandb.init( | ||
project=self.config.experiment_tracking.name_experiment, | ||
name=self.config.experiment_tracking.name_run, | ||
group=self.config.experiment_tracking.name_group, | ||
config=dict(self.config), | ||
) | ||
return | ||
|
||
def run_finalization(self) -> None: | ||
"""Run the finalization of the experiment tracking setup.""" | ||
wandb.finish() | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters