Skip to content

Commit

Permalink
Merge pull request #168 from SebChw/kcyganik-add-tags
Browse files Browse the repository at this point in the history
add_tags functionality for our loggers
  • Loading branch information
SebChw authored Nov 19, 2023
2 parents dfbb7c7 + a4dd0f2 commit 2312767
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion art/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uuid
from datetime import datetime
from pathlib import Path
from typing import Optional, Union
from typing import Optional, Union, List

import numpy as np
from lightning.pytorch.loggers import NeptuneLogger, WandbLogger
Expand Down Expand Up @@ -126,6 +126,17 @@ def download_ckpt(
def stop(self):
self.run.stop()

def add_tags(self, tags: Union[List[str], str]):
"""
Adds tags to the Neptune experiment.
Args:
tags (Union[List[str], str]): Tag or list of tags to add.
"""
if isinstance(tags, str):
tags = [tags]
self.experiment.add_tags(tags)


class WandbLoggerAdapter(WandbLogger):
"""
Expand Down Expand Up @@ -169,3 +180,14 @@ def log_figure(self, figure, path="figure"):
path (str, optional): Path to log figure to. Defaults to "figure".
"""
wandb.log({path: figure})

def add_tags(self, tags: Union[List[str], str]):
"""
Adds tags to the Wandb run.
Args:
tags (Union[List[str], str]): Tag or list of tags to add.
"""
if isinstance(tags, str):
tags = [tags]
wandb.run.tags += tags

0 comments on commit 2312767

Please sign in to comment.