Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
3 changes: 2 additions & 1 deletion aim/acme.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Alias to SDK acme interface
from aim.sdk.adapters.acme import AimCallback, AimWriter # noqa F401
from aim.sdk.adapters.acme import AimCallback as AimCallback
from aim.sdk.adapters.acme import AimWriter as AimWriter
2 changes: 1 addition & 1 deletion aim/cli/convert/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def convert_tensorboard(ctx, logdir, flat, no_cache):
@click.option('--flat', '-f', required=False, is_flag=True, default=False)
def convert_tensorflow(ctx, logdir, flat):
click.secho(
"WARN: Command 'tf' is deprecated and will be removed in future releases," " please use 'tensorboard' instead.",
"WARN: Command 'tf' is deprecated and will be removed in future releases, please use 'tensorboard' instead.",
fg='red',
)
repo_inst = ctx.obj['repo_inst']
Expand Down
4 changes: 2 additions & 2 deletions aim/cli/init/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def init(repo, yes, skip_if_exists):
re_init = False
if Repo.exists(repo_path):
if yes and skip_if_exists:
raise click.BadParameter('Conflicting init options.' 'Either specify -y/--yes or -s/--skip-if-exists')
raise click.BadParameter('Conflicting init options.Either specify -y/--yes or -s/--skip-if-exists')
elif yes:
re_init = True
elif skip_if_exists:
click.echo('Repo exists at {}. Skipped initialization.'.format(repo_path))
return
else:
re_init = click.confirm(
'Aim repository is already initialized. ' 'Do you want to re-initialize to empty Aim repository?'
'Aim repository is already initialized. Do you want to re-initialize to empty Aim repository?'
)
if not re_init:
return
Expand Down
2 changes: 1 addition & 1 deletion aim/cli/runs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def upload_repo_runs(buffer: io.BytesIO, bucket_name: str) -> Tuple[bool, str]:
import boto3
except ImportError:
raise RuntimeError(
"This command requires 'boto3' to be installed. " 'Please install it with command: \n pip install boto3'
"This command requires 'boto3' to be installed. Please install it with command: \n pip install boto3"
)

try:
Expand Down
2 changes: 1 addition & 1 deletion aim/cli/server/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ def server(host, port, repo, ssl_keyfile, ssl_certfile, base_path, log_level, de
)
exec_cmd(cmd, stream_output=True)
except ShellCommandException:
click.echo('Failed to run Aim Tracking Server. ' 'Please see the logs above for details.')
click.echo('Failed to run Aim Tracking Server. Please see the logs above for details.')
exit(1)
2 changes: 1 addition & 1 deletion aim/cli/up/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def up(
db_cmd = build_db_upgrade_command()
exec_cmd(db_cmd, stream_output=True)
except ShellCommandException:
click.echo('Failed to initialize Aim DB. ' 'Please see the logs above for details.')
click.echo('Failed to initialize Aim DB. Please see the logs above for details.')
return

if port == 0:
Expand Down
2 changes: 1 addition & 1 deletion aim/ext/notifier/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def notify(self, message: Optional[str] = None, **kwargs):
except Exception as e:
attempt += 1
if attempt == self.MAX_RETRIES:
logger.error(f'Notifier {sub} failed to send message "{message}". ' f'No retries left.')
logger.error(f'Notifier {sub} failed to send message "{message}". No retries left.')
raise NotificationSendError(e)
else:
logger.error(
Expand Down
2 changes: 1 addition & 1 deletion aim/ext/sshfs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def unmount_remote_repo(mount_point: str, mount_root: str):
if exit_code != 0:
# in case of failure log warning so the user can unmount manually if needed
logger.warning(
f'Could not unmount path: {mount_point}.\n' f'Please unmount manually using command:\n' f'{" ".join(cmd)}'
f'Could not unmount path: {mount_point}.\nPlease unmount manually using command:\n{" ".join(cmd)}'
)
else:
shutil.rmtree(mount_root)
2 changes: 1 addition & 1 deletion aim/ext/tensorboard_tracker/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _decode_histogram(value):

# This is a bit weird but it seems the histogram counts is usually padded by 0 as tensorboard
# only stores the right limits?
# See https://github.com/pytorch/pytorch/blob/7d2a18da0b3427fcbe44b461a0aa508194535885/torch/utils/tensorboard/summary.py#L390 # noqa
# See https://github.com/pytorch/pytorch/blob/7d2a18da0b3427fcbe44b461a0aa508194535885/torch/utils/tensorboard/summary.py#L390
bin_counts = bin_counts[1:]

bin_range = (bucket_limits[0], bucket_limits[-1])
Expand Down
6 changes: 2 additions & 4 deletions aim/ext/transport/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ class HeartbeatSender(object):
HEARTBEAT_INTERVAL_DEFAULT = 10
NETWORK_CHECK_INTERVAL = 180

NETWORK_UNSTABLE_WARNING_TEMPLATE = (
'Network connection between client `{}` ' 'and server `{}` appears to be unstable.'
)
NETWORK_ABSENT_WARNING_TEMPLATE = 'Network connection between client `{}` ' 'and server `{}` appears to be absent.'
NETWORK_UNSTABLE_WARNING_TEMPLATE = 'Network connection between client `{}` and server `{}` appears to be unstable.'
NETWORK_ABSENT_WARNING_TEMPLATE = 'Network connection between client `{}` and server `{}` appears to be absent.'

def __init__(
self,
Expand Down
3 changes: 2 additions & 1 deletion aim/ext/transport/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from typing import Iterator, Tuple

from aim.storage.object import CustomObject
from aim.storage.treeutils import decode_tree, encode_tree # noqa
from aim.storage.treeutils import decode_tree as decode_tree
from aim.storage.treeutils import encode_tree as encode_tree
from aim.storage.types import BLOB


Expand Down
2 changes: 1 addition & 1 deletion aim/ext/transport/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def inner(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except exc_type as e: # noqa
except exc_type:
if error_message is not None:
logger.error(error_message)
raise RuntimeError(error_message)
Expand Down
2 changes: 1 addition & 1 deletion aim/fastai.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK fast.ai interface
from aim.sdk.adapters.fastai import AimCallback # noqa F401
from aim.sdk.adapters.fastai import AimCallback as AimCallback
2 changes: 1 addition & 1 deletion aim/hf_dataset.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK Hugging Face Datasets interface
from aim.sdk.objects.plugins.hf_datasets_metadata import HFDataset # noqa F401
from aim.sdk.objects.plugins.hf_datasets_metadata import HFDataset as HFDataset
2 changes: 1 addition & 1 deletion aim/hugging_face.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK Hugging Face interface
from aim.sdk.adapters.hugging_face import AimCallback # noqa F401
from aim.sdk.adapters.hugging_face import AimCallback as AimCallback
3 changes: 2 additions & 1 deletion aim/keras.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Alias to SDK Keras interface
from aim.sdk.adapters.keras import AimCallback, AimTracker # noqa F401
from aim.sdk.adapters.keras import AimCallback as AimCallback
from aim.sdk.adapters.keras import AimTracker as AimTracker
2 changes: 1 addition & 1 deletion aim/keras_tuner.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK Keras-Tuner interface
from aim.sdk.adapters.keras_tuner import AimCallback # noqa F401
from aim.sdk.adapters.keras_tuner import AimCallback as AimCallback
2 changes: 1 addition & 1 deletion aim/mxnet.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK mxnet interface
from aim.sdk.adapters.mxnet import AimLoggingHandler # noqa F401
from aim.sdk.adapters.mxnet import AimLoggingHandler as AimLoggingHandler
2 changes: 1 addition & 1 deletion aim/optuna.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK Optuna interface
from aim.sdk.adapters.optuna import AimCallback # noqa F401
from aim.sdk.adapters.optuna import AimCallback as AimCallback
2 changes: 1 addition & 1 deletion aim/paddle.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK PaddlePaddle interface
from aim.sdk.adapters.paddle import AimCallback # noqa F401
from aim.sdk.adapters.paddle import AimCallback as AimCallback
2 changes: 1 addition & 1 deletion aim/prophet.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK Prophet interface
from aim.sdk.adapters.prophet import AimLogger # noqa F401
from aim.sdk.adapters.prophet import AimLogger as AimLogger
3 changes: 2 additions & 1 deletion aim/pytorch.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Alias to SDK PyTorch utils
from aim.sdk.adapters.pytorch import track_params_dists, track_gradients_dists # noqa
from aim.sdk.adapters.pytorch import track_gradients_dists as track_gradients_dists
from aim.sdk.adapters.pytorch import track_params_dists as track_params_dists
2 changes: 1 addition & 1 deletion aim/pytorch_ignite.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK PyTorch Ignite interface
from aim.sdk.adapters.pytorch_ignite import AimLogger # noqa F401
from aim.sdk.adapters.pytorch_ignite import AimLogger as AimLogger
2 changes: 1 addition & 1 deletion aim/pytorch_lightning.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK PyTorch Lightning interface
from aim.sdk.adapters.pytorch_lightning import AimLogger # noqa F401
from aim.sdk.adapters.pytorch_lightning import AimLogger as AimLogger
2 changes: 1 addition & 1 deletion aim/sb3.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Alias to SDK sb3 interface
from aim.sdk.adapters.sb3 import AimCallback # noqa F401
from aim.sdk.adapters.sb3 import AimCallback as AimCallback
8 changes: 6 additions & 2 deletions aim/sdk/adapters/fastai.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fastcore.basics import detuplify, ignore_exceptions, store_attr
except ImportError:
raise RuntimeError(
'This contrib module requires fastai to be installed. ' 'Please install it with command: \n pip install fastai'
'This contrib module requires fastai to be installed. Please install it with command: \n pip install fastai'
)

logger = getLogger(__name__)
Expand Down Expand Up @@ -107,7 +107,11 @@ def gather_args(self):
args['n_inp'] = n_inp
xb = self.dls.valid.one_batch()[:n_inp]
args.update(
{f'input {n+1} dim {i+1}': d for n in range(n_inp) for i, d in enumerate(list(detuplify(xb[n]).shape))}
{
f'input {n + 1} dim {i + 1}': d
for n in range(n_inp)
for i, d in enumerate(list(detuplify(xb[n]).shape))
}
)
except Exception:
logger.warning('Failed to gather input dimensions')
Expand Down
2 changes: 1 addition & 1 deletion aim/sdk/adapters/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from keras.callbacks import Callback
except ImportError:
raise RuntimeError(
'This contrib module requires keras to be installed. ' 'Please install it with command: \n pip install keras'
'This contrib module requires keras to be installed. Please install it with command: \n pip install keras'
)


Expand Down
3 changes: 1 addition & 2 deletions aim/sdk/adapters/lightgbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from lightgbm.callback import CallbackEnv
except ImportError:
raise RuntimeError(
'This contrib module requires Lightgbm to be installed. '
'Please install it with command: \n pip install lightgbm'
'This contrib module requires Lightgbm to be installed. Please install it with command: \n pip install lightgbm'
)


Expand Down
2 changes: 1 addition & 1 deletion aim/sdk/adapters/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def train_begin(self, estimator: Optional[Estimator], *args, **kwargs):
optimizer = trainer.optimizer.__class__.__name__
lr = trainer.learning_rate

estimator.logger.info('Training begin: using optimizer %s ' 'with current learning rate %.4f ', optimizer, lr)
estimator.logger.info('Training begin: using optimizer %s with current learning rate %.4f ', optimizer, lr)
if estimator.max_epoch:
estimator.logger.info('Train for %d epochs.', estimator.max_epoch)
else:
Expand Down
5 changes: 2 additions & 3 deletions aim/sdk/adapters/pytorch_ignite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from torch.optim import Optimizer
except ImportError:
raise RuntimeError(
'This contrib module requires PyTorch to be installed. ' 'Please install it with command: \n pip install torch'
'This contrib module requires PyTorch to be installed. Please install it with command: \n pip install torch'
)
try:
from ignite.contrib.handlers.base_logger import (
Expand Down Expand Up @@ -185,8 +185,7 @@ def __call__(self, engine: Engine, logger: AimLogger, event_name: Union[str, Eve

if not isinstance(global_step, int):
raise TypeError(
f'global_step must be int, got {type(global_step)}.'
' Please check the output of global_step_transform.'
f'global_step must be int, got {type(global_step)}. Please check the output of global_step_transform.'
)

metrics = {}
Expand Down
3 changes: 1 addition & 2 deletions aim/sdk/adapters/xgboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from xgboost.callback import TrainingCallback
except ImportError:
raise RuntimeError(
'This contrib module requires XGBoost to be installed. '
'Please install it with command: \n pip install xgboost'
'This contrib module requires XGBoost to be installed. Please install it with command: \n pip install xgboost'
)


Expand Down
2 changes: 1 addition & 1 deletion aim/sdk/callbacks/caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def trigger(self, event_name: str, **kwargs):
for handler in handlers:
try:
handler(**all_kwargs)
except Exception: # noqa
except Exception:
# TODO catch errors on handler invocation (nice-to-have)
logger.warning(f"Failed to run callback '{handler.__name__}'.")
logger.warning(traceback.format_exc())
12 changes: 6 additions & 6 deletions aim/sdk/objects/io/wavfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def _raise_bad_format(format_tag):
except ValueError:
format_name = f'{format_tag:#06x}'
raise ValueError(
f"Unknown wave file format: {format_name}. Supported formats: {', '.join(x.name for x in KNOWN_WAVE_FORMATS)}"
f'Unknown wave file format: {format_name}. Supported formats: {", ".join(x.name for x in KNOWN_WAVE_FORMATS)}'
)


Expand Down Expand Up @@ -447,12 +447,12 @@ def _read_data_chunk(fid, format_tag, channels, bit_depth, is_big_endian, block_
# Remaining bit depths can map directly to signed numpy dtypes
dtype = f'{fmt}i{bytes_per_sample}'
else:
raise ValueError('Unsupported bit depth: the WAV file ' f'has {bit_depth}-bit integer data.')
raise ValueError(f'Unsupported bit depth: the WAV file has {bit_depth}-bit integer data.')
elif format_tag == WAVE_FORMAT.IEEE_FLOAT:
if bit_depth in {32, 64}:
dtype = f'{fmt}f{bytes_per_sample}'
else:
raise ValueError('Unsupported bit depth: the WAV file ' f'has {bit_depth}-bit floating-point data.')
raise ValueError(f'Unsupported bit depth: the WAV file has {bit_depth}-bit floating-point data.')
else:
_raise_bad_format(format_tag)

Expand Down Expand Up @@ -480,7 +480,7 @@ def _read_data_chunk(fid, format_tag, channels, bit_depth, is_big_endian, block_
data = numpy.memmap(fid, dtype=dtype, mode='c', offset=start, shape=(n_samples,))
fid.seek(start + size)
else:
raise ValueError('mmap=True not compatible with ' f'{bytes_per_sample}-byte container size.')
raise ValueError(f'mmap=True not compatible with {bytes_per_sample}-byte container size.')

_handle_pad_byte(fid, size)

Expand Down Expand Up @@ -516,7 +516,7 @@ def _read_riff_chunk(fid):
fmt = '>I'
else:
# There are also .wav files with "FFIR" or "XFIR" signatures?
raise ValueError(f'File format {repr(str1)} not understood. Only ' "'RIFF' and 'RIFX' supported.")
raise ValueError(f"File format {repr(str1)} not understood. Only 'RIFF' and 'RIFX' supported.")

# Size of entire file
file_size = struct.unpack(fmt, fid.read(4))[0] + 8
Expand Down Expand Up @@ -554,7 +554,7 @@ def read(buffer, mmap=False):
if data_chunk_received:
# End of file but data successfully read
warnings.warn(
'Reached EOF prematurely; finished at {:d} bytes, ' 'expected {:d} bytes from header.'.format(
'Reached EOF prematurely; finished at {:d} bytes, expected {:d} bytes from header.'.format(
fid.tell(), file_size
),
WavFileWarning,
Expand Down
4 changes: 2 additions & 2 deletions aim/sdk/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,15 +985,15 @@ def _backup_run(self, run_hash):
from aim.sdk.utils import backup_run

if self.is_remote_repo:
self._remote_repo_proxy._restore_run(run_hash) # noqa
self._remote_repo_proxy._restore_run(run_hash)
else:
backup_run(self, run_hash)

def _restore_run(self, run_hash):
from aim.sdk.utils import restore_run_backup

if self.is_remote_repo:
self._remote_repo_proxy._restore_run(run_hash) # noqa
self._remote_repo_proxy._restore_run(run_hash)
else:
restore_run_backup(self, run_hash)

Expand Down
2 changes: 1 addition & 1 deletion aim/sdk/sequences/figure_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Figures(Sequence):

@classmethod
def allowed_dtypes(cls) -> Union[str, Tuple[str, ...]]:
return (Figure.get_typename(),) # noqa : need a tuple for consitancy
return (Figure.get_typename(),) # need a tuple for consitancy

@classmethod
def sequence_name(cls) -> str:
Expand Down
3 changes: 2 additions & 1 deletion aim/sdk/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from aim.storage.types import * # noqa F401
from enum import Enum

from aim.storage.types import * # noqa: F403


class QueryReportMode(Enum):
DISABLED = 0
Expand Down
2 changes: 1 addition & 1 deletion aim/storage/hashing/hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from typing import Tuple, Union

from aim.storage.encoding import decode_int64, encode_int64 # noqa
from aim.storage.encoding import decode_int64, encode_int64
from aim.storage.hashing import c_hash
from aim.storage.types import (
AimObject,
Expand Down
4 changes: 2 additions & 2 deletions aim/storage/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def __name__(self, value):
def __class__(self):
return self.__wrapped__().__class__

@__class__.setter # noqa
def __class__(self, value): # noqa
@__class__.setter
def __class__(self, value):
self.__wrapped__().__class__ = value

@property
Expand Down
2 changes: 1 addition & 1 deletion aim/storage/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def safer_getattr(object, name, default=None, getattr=getattr):
if name == 'format' and isinstance(object, str):
raise NotImplementedError('Using format() on a %s is not safe.' % object.__class__.__name__)
if name[0] == '_':
raise AttributeError('"{name}" is an invalid attribute name because it ' 'starts with "_"'.format(name=name))
raise AttributeError('"{name}" is an invalid attribute name because it starts with "_"'.format(name=name))
val = getattr(object, name, default)
return val

Expand Down
4 changes: 3 additions & 1 deletion aim/storage/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from aim.storage.utils import BLOB # noqa F401
from typing import Dict, List, Tuple, Union

from aim.storage.utils import BLOB as BLOB


NoneType = type(None)


Expand Down
3 changes: 2 additions & 1 deletion aim/tensorflow.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Alias to SDK TensorFlow Keras interface
from aim.sdk.adapters.tensorflow import AimCallback, AimTracker # noqa F401
from aim.sdk.adapters.tensorflow import AimCallback as AimCallback
from aim.sdk.adapters.tensorflow import AimTracker as AimTracker
3 changes: 2 additions & 1 deletion aim/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from aim.ext.exception_resistant import enable_safe_mode, disable_safe_mode # noqa
from aim.ext.exception_resistant import disable_safe_mode as disable_safe_mode
from aim.ext.exception_resistant import enable_safe_mode as enable_safe_mode
Loading
Loading