Skip to content

Commit

Permalink
fixed signatures of decorated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
justanhduc committed Nov 18, 2021
1 parent 2a940d7 commit 34fd15f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions neural_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from imageio import imwrite
from shutil import copyfile
from collections import namedtuple, deque
import functools
import torch.distributed
from typing import (
List,
Expand All @@ -30,6 +29,7 @@
)
import pandas as pd
from easydict import EasyDict
from decorator import decorator

try:
import visdom
Expand Down Expand Up @@ -184,8 +184,8 @@ def _spawn_defaultdict_ordereddict():
return collections.OrderedDict()


@decorator
def check_path_init(f):
@functools.wraps(f)
def set_default_path(self, *args, **kwargs):
if not self._initialized:
logger.info('Working folder not initialized! Initialize working folder to default.')
Expand All @@ -197,19 +197,19 @@ def set_default_path(self, *args, **kwargs):
return set_default_path


@decorator
def standardize_name(f):
@functools.wraps(f)
def func(self, name: str, *args, **kwargs):
if name is not None:
name = name.replace(' ', '-')

f(self, name, *args, **kwargs)
return f(self, name, *args, **kwargs)

return func


@decorator
def distributed_collect(f):
@functools.wraps(f)
def func(self, name: str, value: T.Tensor, *args, **kwargs):
if self.distributed:
assert isinstance(value, T.Tensor), 'value must be a Tensor in distributed mode'
Expand All @@ -220,8 +220,8 @@ def func(self, name: str, value: T.Tensor, *args, **kwargs):
return func


@decorator
def distributed_flush(f):
@functools.wraps(f)
def func(self, *args, **kwargs):
if self.distributed and self.rank != 0:
return
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ tensorboard
imageio
git-python
pandas
decorator
easydict
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def setup_package():
'Programming Language :: Python :: 3.7'
],
platforms=['Windows', 'Linux'],
packages=find_packages(exclude=['docs']),
install_requires=['matplotlib', 'numpy', 'imageio', 'tensorboard', 'git-python', 'easydict', 'pandas'],
packages=find_packages(exclude=['docs', 'doc']),
install_requires=['matplotlib', 'numpy', 'imageio', 'tensorboard',
'git-python', 'easydict', 'pandas', 'decorator'],
project_urls={
'Bug Reports': 'https://github.com/justanhduc/neural-monitor/issues',
'Source': 'https://github.com/justanhduc/neural-monitor',
Expand Down

0 comments on commit 34fd15f

Please sign in to comment.