Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Added logging configuration #46

Open
wants to merge 1 commit into
base: pnw-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions personalized_active_learning/datamodules/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import abc
from enum import Enum
from typing import List, Optional, Tuple
import logging

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -281,6 +282,10 @@ def _apply_personalised_embeddings(self) -> Tuple[pd.DataFrame, pd.DataFrame]:
self.annotations
)

logging.info(
"Preparing personalised embeddings: %s" % personalised_embeddings.name
)

self.embeddings_creator.set_personalised_embeddings_name(
personalised_embeddings.name
)
Expand Down
2 changes: 2 additions & 0 deletions personalized_active_learning/embeddings/embeddings_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import numpy as np
import torch
import logging

from settings import EMBEDDINGS_SIZES, TRANSFORMER_MODEL_STRINGS
from personalized_nlp.utils.embeddings import create_embeddings
Expand Down Expand Up @@ -85,6 +86,7 @@ def get_embeddings(self, texts: List[str]) -> torch.Tensor:
return self._load_embeddings()

def _load_embeddings(self) -> torch.Tensor:
logging.info("Loading embeddings from %s" % (self.embeddings_path))
with open(self.embeddings_path, "rb") as f:
text_idx_to_emb = pickle.load(f)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# TODO: REFACTOR!!!!
import os
import warnings
import logging

from itertools import product

from pytorch_lightning.utilities.warnings import PossibleUserWarning
Expand Down Expand Up @@ -29,6 +31,10 @@
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
os.environ["WANDB_START_METHOD"] = "thread"

logging.basicConfig(
format="%(asctime)s %(filename)s %(lineno)d [%(levelname)s]: %(message)s",
level=logging.INFO
)

if __name__ == "__main__":
wandb_project_name = "PNW_AL_Unhealthy_tests"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
from personalized_nlp.utils import seed_everything
from personalized_nlp.utils.experiments import product_kwargs
from settings import DATA_DIR
import logging

# False positive https://github.com/Lightning-AI/lightning/issues/11856
warnings.filterwarnings("ignore", category=PossibleUserWarning)
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
os.environ["WANDB_START_METHOD"] = "thread"

logging.basicConfig(
format="%(asctime)s %(filename)s %(lineno)d [%(levelname)s]: %(message)s",
level=logging.INFO
)

if __name__ == "__main__":
wandb_project_name = "PNW_AL_Wiki_Aggression"
Expand Down