Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #234 from Aarhus-Psychiatry-Research/fix--logging-…
Browse files Browse the repository at this point in the history
…to-wandb-on-Overtaci

fix: logging to wandb on Overtaci.
  • Loading branch information
MartinBernstorff authored Oct 4, 2022
2 parents 5e9d61d + cb8276c commit b67b1d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/psycopt2d/train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
from psycopt2d.feature_transformers import ConvertToBoolean, DateTimeConverter
from psycopt2d.load import load_dataset
from psycopt2d.models import MODELS
from psycopt2d.utils import flatten_nested_dict, prediction_df_with_metadata_to_disk
from psycopt2d.utils import (
create_wandb_folders,
flatten_nested_dict,
prediction_df_with_metadata_to_disk,
)

CONFIG_PATH = Path(__file__).parent / "config"
TRAINING_COL_NAME_PREFIX = "pred_"
Expand Down Expand Up @@ -153,6 +157,7 @@ def stratified_cross_validation(
)
def main(cfg):
"""Main function for training a single model."""
create_wandb_folders()
run = wandb.init(
project=cfg.project.name,
reinit=True,
Expand Down
12 changes: 12 additions & 0 deletions src/psycopt2d/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
utilities.
"""
import sys
import tempfile
import time
from collections.abc import Iterable, MutableMapping
from pathlib import Path
Expand Down Expand Up @@ -285,3 +287,13 @@ def prediction_df_with_metadata_to_disk(df: pd.DataFrame, cfg: DictConfig) -> No
local_path.parent.mkdir(parents=True)
dump_to_pickle(metadata, local_path)
msg.good(f"Saved evaluation results to {local_path}")


def create_wandb_folders():
"""Creates folders to store logs on Overtaci."""
if sys.platform == "win32":
(Path(tempfile.gettempdir()) / "debug-cli.onerm").mkdir(
exist_ok=True,
parents=True,
)
(PROJECT_ROOT / "wandb" / "debug-cli.onerm").mkdir(exist_ok=True, parents=True)

0 comments on commit b67b1d9

Please sign in to comment.