From 17660207610e554776c6ddd945d8133716151421 Mon Sep 17 00:00:00 2001 From: Fabian Keller Date: Thu, 13 Feb 2025 14:33:17 +0100 Subject: [PATCH] [chore] Bump ruff version from 0.3.3 to 0.9.2 and fix some invalid/dead noqas (#3282) --- aim/acme.py | 3 ++- aim/cli/convert/commands.py | 2 +- aim/cli/init/commands.py | 4 ++-- aim/cli/runs/utils.py | 2 +- aim/cli/server/commands.py | 2 +- aim/cli/up/commands.py | 2 +- aim/ext/notifier/notifier.py | 2 +- aim/ext/sshfs/utils.py | 2 +- aim/ext/tensorboard_tracker/tracker.py | 2 +- aim/ext/transport/heartbeat.py | 6 ++---- aim/ext/transport/message_utils.py | 3 ++- aim/ext/transport/utils.py | 2 +- aim/fastai.py | 2 +- aim/hf_dataset.py | 2 +- aim/hugging_face.py | 2 +- aim/keras.py | 3 ++- aim/keras_tuner.py | 2 +- aim/mxnet.py | 2 +- aim/optuna.py | 2 +- aim/paddle.py | 2 +- aim/prophet.py | 2 +- aim/pytorch.py | 3 ++- aim/pytorch_ignite.py | 2 +- aim/pytorch_lightning.py | 2 +- aim/sb3.py | 2 +- aim/sdk/adapters/fastai.py | 8 ++++++-- aim/sdk/adapters/keras.py | 2 +- aim/sdk/adapters/lightgbm.py | 3 +-- aim/sdk/adapters/mxnet.py | 2 +- aim/sdk/adapters/pytorch_ignite.py | 5 ++--- aim/sdk/adapters/xgboost.py | 3 +-- aim/sdk/callbacks/caller.py | 2 +- aim/sdk/objects/io/wavfile.py | 12 ++++++------ aim/sdk/repo.py | 4 ++-- aim/sdk/sequences/figure_sequence.py | 2 +- aim/sdk/types.py | 3 ++- aim/storage/hashing/hashing.py | 2 +- aim/storage/proxy.py | 4 ++-- aim/storage/query.py | 2 +- aim/storage/types.py | 4 +++- aim/tensorflow.py | 3 ++- aim/utils/__init__.py | 3 ++- aim/web/api/dashboard_apps/views.py | 2 +- aim/web/api/dashboards/views.py | 8 ++++---- aim/web/api/experiments/views.py | 2 +- aim/web/api/runs/object_views.py | 6 +++--- aim/web/middlewares/profiler/profiler.py | 2 +- examples/pytorch_lightning_track.py | 2 +- examples/pytorch_track.py | 2 +- examples/pytorch_track_images.py | 2 +- performance_tests/sdk/queries.py | 6 +++--- requirements.dev.txt | 2 +- ruff.toml | 6 +++++- 53 files changed, 88 insertions(+), 76 deletions(-) diff --git a/aim/acme.py b/aim/acme.py index 44884fd7d1..30cce30375 100644 --- a/aim/acme.py +++ b/aim/acme.py @@ -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 diff --git a/aim/cli/convert/commands.py b/aim/cli/convert/commands.py index 4e23ef8064..14160a5364 100644 --- a/aim/cli/convert/commands.py +++ b/aim/cli/convert/commands.py @@ -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'] diff --git a/aim/cli/init/commands.py b/aim/cli/init/commands.py index 1ef6fc3541..4d538ec841 100644 --- a/aim/cli/init/commands.py +++ b/aim/cli/init/commands.py @@ -20,7 +20,7 @@ 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: @@ -28,7 +28,7 @@ def init(repo, yes, skip_if_exists): 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 diff --git a/aim/cli/runs/utils.py b/aim/cli/runs/utils.py index ec4c332f75..f2b64b13dd 100644 --- a/aim/cli/runs/utils.py +++ b/aim/cli/runs/utils.py @@ -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: diff --git a/aim/cli/server/commands.py b/aim/cli/server/commands.py index b84c1ae68b..7c1587021d 100644 --- a/aim/cli/server/commands.py +++ b/aim/cli/server/commands.py @@ -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) diff --git a/aim/cli/up/commands.py b/aim/cli/up/commands.py index 2044c75e46..de8ed008d5 100644 --- a/aim/cli/up/commands.py +++ b/aim/cli/up/commands.py @@ -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: diff --git a/aim/ext/notifier/notifier.py b/aim/ext/notifier/notifier.py index 1b237af620..ca73fe59ab 100644 --- a/aim/ext/notifier/notifier.py +++ b/aim/ext/notifier/notifier.py @@ -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( diff --git a/aim/ext/sshfs/utils.py b/aim/ext/sshfs/utils.py index 3dba53168d..170f9d4fed 100644 --- a/aim/ext/sshfs/utils.py +++ b/aim/ext/sshfs/utils.py @@ -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) diff --git a/aim/ext/tensorboard_tracker/tracker.py b/aim/ext/tensorboard_tracker/tracker.py index 59af672f85..f902e08069 100644 --- a/aim/ext/tensorboard_tracker/tracker.py +++ b/aim/ext/tensorboard_tracker/tracker.py @@ -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]) diff --git a/aim/ext/transport/heartbeat.py b/aim/ext/transport/heartbeat.py index 3346ccff27..d6390d63eb 100644 --- a/aim/ext/transport/heartbeat.py +++ b/aim/ext/transport/heartbeat.py @@ -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, diff --git a/aim/ext/transport/message_utils.py b/aim/ext/transport/message_utils.py index 127b1f7e58..daa1823b6d 100644 --- a/aim/ext/transport/message_utils.py +++ b/aim/ext/transport/message_utils.py @@ -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 diff --git a/aim/ext/transport/utils.py b/aim/ext/transport/utils.py index 037ad1262e..b556692fe3 100644 --- a/aim/ext/transport/utils.py +++ b/aim/ext/transport/utils.py @@ -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) diff --git a/aim/fastai.py b/aim/fastai.py index 2758828947..ab00bee140 100644 --- a/aim/fastai.py +++ b/aim/fastai.py @@ -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 diff --git a/aim/hf_dataset.py b/aim/hf_dataset.py index e629b15c93..00ecc9cc99 100644 --- a/aim/hf_dataset.py +++ b/aim/hf_dataset.py @@ -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 diff --git a/aim/hugging_face.py b/aim/hugging_face.py index 9fbde32ec8..692ec24865 100644 --- a/aim/hugging_face.py +++ b/aim/hugging_face.py @@ -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 diff --git a/aim/keras.py b/aim/keras.py index 3383dff655..e1c6ed28f1 100644 --- a/aim/keras.py +++ b/aim/keras.py @@ -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 diff --git a/aim/keras_tuner.py b/aim/keras_tuner.py index 5f6577cae7..5d264e64d2 100644 --- a/aim/keras_tuner.py +++ b/aim/keras_tuner.py @@ -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 diff --git a/aim/mxnet.py b/aim/mxnet.py index 403d33d40b..ceacfb118a 100644 --- a/aim/mxnet.py +++ b/aim/mxnet.py @@ -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 diff --git a/aim/optuna.py b/aim/optuna.py index 5069d24695..28d0b1dbfe 100644 --- a/aim/optuna.py +++ b/aim/optuna.py @@ -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 diff --git a/aim/paddle.py b/aim/paddle.py index 0c49486419..9069d936ac 100644 --- a/aim/paddle.py +++ b/aim/paddle.py @@ -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 diff --git a/aim/prophet.py b/aim/prophet.py index 1a43316f44..661e95cd44 100644 --- a/aim/prophet.py +++ b/aim/prophet.py @@ -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 diff --git a/aim/pytorch.py b/aim/pytorch.py index c493b7a84d..677a68f88c 100644 --- a/aim/pytorch.py +++ b/aim/pytorch.py @@ -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 diff --git a/aim/pytorch_ignite.py b/aim/pytorch_ignite.py index 08cd67ce77..2189c6ddf2 100644 --- a/aim/pytorch_ignite.py +++ b/aim/pytorch_ignite.py @@ -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 diff --git a/aim/pytorch_lightning.py b/aim/pytorch_lightning.py index 50d10c1aae..b9a3405f9d 100644 --- a/aim/pytorch_lightning.py +++ b/aim/pytorch_lightning.py @@ -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 diff --git a/aim/sb3.py b/aim/sb3.py index 43fd7899eb..78bdec8ee9 100644 --- a/aim/sb3.py +++ b/aim/sb3.py @@ -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 diff --git a/aim/sdk/adapters/fastai.py b/aim/sdk/adapters/fastai.py index 37390444cc..88b7c4fdd5 100644 --- a/aim/sdk/adapters/fastai.py +++ b/aim/sdk/adapters/fastai.py @@ -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__) @@ -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') diff --git a/aim/sdk/adapters/keras.py b/aim/sdk/adapters/keras.py index 4a2141249e..10af8b7118 100644 --- a/aim/sdk/adapters/keras.py +++ b/aim/sdk/adapters/keras.py @@ -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' ) diff --git a/aim/sdk/adapters/lightgbm.py b/aim/sdk/adapters/lightgbm.py index f2bae4e164..f006cd9718 100644 --- a/aim/sdk/adapters/lightgbm.py +++ b/aim/sdk/adapters/lightgbm.py @@ -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' ) diff --git a/aim/sdk/adapters/mxnet.py b/aim/sdk/adapters/mxnet.py index e10d4a19c2..88f005dd8d 100644 --- a/aim/sdk/adapters/mxnet.py +++ b/aim/sdk/adapters/mxnet.py @@ -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: diff --git a/aim/sdk/adapters/pytorch_ignite.py b/aim/sdk/adapters/pytorch_ignite.py index 42cf7d0f2e..6a9506c54d 100644 --- a/aim/sdk/adapters/pytorch_ignite.py +++ b/aim/sdk/adapters/pytorch_ignite.py @@ -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 ( @@ -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 = {} diff --git a/aim/sdk/adapters/xgboost.py b/aim/sdk/adapters/xgboost.py index 8d99262875..832110f254 100644 --- a/aim/sdk/adapters/xgboost.py +++ b/aim/sdk/adapters/xgboost.py @@ -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' ) diff --git a/aim/sdk/callbacks/caller.py b/aim/sdk/callbacks/caller.py index 6ac0c29aee..387406e225 100644 --- a/aim/sdk/callbacks/caller.py +++ b/aim/sdk/callbacks/caller.py @@ -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()) diff --git a/aim/sdk/objects/io/wavfile.py b/aim/sdk/objects/io/wavfile.py index 5c58daf4a0..34d187c7a2 100644 --- a/aim/sdk/objects/io/wavfile.py +++ b/aim/sdk/objects/io/wavfile.py @@ -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)}' ) @@ -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) @@ -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) @@ -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 @@ -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, diff --git a/aim/sdk/repo.py b/aim/sdk/repo.py index 9927949649..6d2471cb28 100644 --- a/aim/sdk/repo.py +++ b/aim/sdk/repo.py @@ -985,7 +985,7 @@ 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) @@ -993,7 +993,7 @@ 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) diff --git a/aim/sdk/sequences/figure_sequence.py b/aim/sdk/sequences/figure_sequence.py index ff6081e60f..885828f79a 100644 --- a/aim/sdk/sequences/figure_sequence.py +++ b/aim/sdk/sequences/figure_sequence.py @@ -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: diff --git a/aim/sdk/types.py b/aim/sdk/types.py index 51fdc72cd8..aa70e24ec2 100644 --- a/aim/sdk/types.py +++ b/aim/sdk/types.py @@ -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 diff --git a/aim/storage/hashing/hashing.py b/aim/storage/hashing/hashing.py index 1aaa7e52e5..eef53c5d2c 100644 --- a/aim/storage/hashing/hashing.py +++ b/aim/storage/hashing/hashing.py @@ -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, diff --git a/aim/storage/proxy.py b/aim/storage/proxy.py index 8d967837e5..cf3d84fca5 100644 --- a/aim/storage/proxy.py +++ b/aim/storage/proxy.py @@ -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 diff --git a/aim/storage/query.py b/aim/storage/query.py index 0ada6f1534..82de23657a 100644 --- a/aim/storage/query.py +++ b/aim/storage/query.py @@ -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 diff --git a/aim/storage/types.py b/aim/storage/types.py index a21caa0611..6fbf6e0129 100644 --- a/aim/storage/types.py +++ b/aim/storage/types.py @@ -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) diff --git a/aim/tensorflow.py b/aim/tensorflow.py index 93ccaed16a..17cee65496 100644 --- a/aim/tensorflow.py +++ b/aim/tensorflow.py @@ -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 diff --git a/aim/utils/__init__.py b/aim/utils/__init__.py index 761d0cd34d..c48598750b 100644 --- a/aim/utils/__init__.py +++ b/aim/utils/__init__.py @@ -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 diff --git a/aim/web/api/dashboard_apps/views.py b/aim/web/api/dashboard_apps/views.py index 50fb871238..7f1acae268 100644 --- a/aim/web/api/dashboard_apps/views.py +++ b/aim/web/api/dashboard_apps/views.py @@ -19,7 +19,7 @@ @dashboard_apps_router.get('/', response_model=ExploreStateListOut) async def dashboard_apps_list_api(session: Session = Depends(get_session)): - explore_states = session.query(ExploreState).filter(ExploreState.is_archived == False) # noqa + explore_states = session.query(ExploreState).filter(ExploreState.is_archived == False) # noqa: E712 result = [] for es in explore_states: result.append(explore_state_response_serializer(es)) diff --git a/aim/web/api/dashboards/views.py b/aim/web/api/dashboards/views.py index fe12bf69d1..5cd16c3020 100644 --- a/aim/web/api/dashboards/views.py +++ b/aim/web/api/dashboards/views.py @@ -19,7 +19,7 @@ @dashboards_router.get('/', response_model=List[DashboardOut]) async def dashboards_list_api(session: Session = Depends(get_session)): - dashboards_query = session.query(Dashboard).filter(Dashboard.is_archived == False).order_by(Dashboard.updated_at) # noqa + dashboards_query = session.query(Dashboard).filter(Dashboard.is_archived == False).order_by(Dashboard.updated_at) # noqa: E712 result = [] for dashboard in dashboards_query: @@ -50,7 +50,7 @@ async def dashboards_post_api(request_data: DashboardCreateIn, session: Session @dashboards_router.get('/{dashboard_id}/', response_model=DashboardOut) async def dashboards_get_api(dashboard_id: str, session: Session = Depends(get_session)): - dashboard = session.query(Dashboard).filter(Dashboard.uuid == dashboard_id, Dashboard.is_archived == False).first() # noqa + dashboard = session.query(Dashboard).filter(Dashboard.uuid == dashboard_id, Dashboard.is_archived == False).first() # noqa: E712 if not dashboard: raise HTTPException(status_code=404) @@ -61,7 +61,7 @@ async def dashboards_get_api(dashboard_id: str, session: Session = Depends(get_s async def dashboards_put_api( dashboard_id: str, request_data: DashboardUpdateIn, session: Session = Depends(get_session) ): - dashboard = session.query(Dashboard).filter(Dashboard.uuid == dashboard_id, Dashboard.is_archived == False).first() # noqa + dashboard = session.query(Dashboard).filter(Dashboard.uuid == dashboard_id, Dashboard.is_archived == False).first() # noqa: E712 if not dashboard: raise HTTPException(status_code=404) dashboard_name = request_data.name @@ -77,7 +77,7 @@ async def dashboards_put_api( @dashboards_router.delete('/{dashboard_id}/') async def dashboards_delete_api(dashboard_id: str, session: Session = Depends(get_session)): - dashboard = session.query(Dashboard).filter(Dashboard.uuid == dashboard_id, Dashboard.is_archived == False).first() # noqa + dashboard = session.query(Dashboard).filter(Dashboard.uuid == dashboard_id, Dashboard.is_archived == False).first() # noqa: E712 if not dashboard: raise HTTPException(status_code=404) diff --git a/aim/web/api/experiments/views.py b/aim/web/api/experiments/views.py index 9164eb78f4..a47511cd9e 100644 --- a/aim/web/api/experiments/views.py +++ b/aim/web/api/experiments/views.py @@ -114,7 +114,7 @@ async def update_experiment_properties_api(exp_id: str, exp_in: ExperimentUpdate if exp_in.archived is not None: if exp_in.archived and len(exp.runs) > 0: raise HTTPException( - status_code=400, detail=(f"Cannot archive experiment '{exp_id}'. " 'Experiment has associated runs.') + status_code=400, detail=(f"Cannot archive experiment '{exp_id}'. Experiment has associated runs.") ) exp.archived = exp_in.archived diff --git a/aim/web/api/runs/object_views.py b/aim/web/api/runs/object_views.py index 8e5d5b3f5a..6a4b4d0e93 100644 --- a/aim/web/api/runs/object_views.py +++ b/aim/web/api/runs/object_views.py @@ -32,7 +32,7 @@ class CustomObjectApiConfig: sequence_type: type = Sequence resolve_blobs: bool = False - dump_record_fn: callable = lambda x: x.data # noqa E731 + dump_record_fn: callable = lambda x: x.data model: type = BaseModel @staticmethod @@ -165,7 +165,7 @@ class TextApiConfig(CustomObjectApiConfig): class DistributionApiConfig(CustomObjectApiConfig): sequence_type = Distributions resolve_blobs = True - dump_record_fn = lambda x: numpy_to_encodable(x.weights) # noqa E731 + dump_record_fn = lambda x: numpy_to_encodable(x.weights) # noqa: E731 model = DistributionInfo @@ -178,5 +178,5 @@ class AudioApiConfig(CustomObjectApiConfig): class FigureApiConfig(CustomObjectApiConfig): sequence_type = Figures resolve_blobs = True - dump_record_fn = lambda x: x.data # noqa E731 + dump_record_fn = lambda x: x.data # noqa: E731 model = FigureInfo diff --git a/aim/web/middlewares/profiler/profiler.py b/aim/web/middlewares/profiler/profiler.py index 0956dc8b56..fc39f40061 100644 --- a/aim/web/middlewares/profiler/profiler.py +++ b/aim/web/middlewares/profiler/profiler.py @@ -61,7 +61,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: profiler = self.profiler(interval=self._profiler_interval) try: profiler.start() - except: # noqa + except: # noqa: E722 skip_profiling = True else: skip_profiling = False diff --git a/examples/pytorch_lightning_track.py b/examples/pytorch_lightning_track.py index 9d9d8c98b5..3a4b23c7ce 100644 --- a/examples/pytorch_lightning_track.py +++ b/examples/pytorch_lightning_track.py @@ -4,7 +4,7 @@ if importlib.util.find_spec('lightning'): import lightning.pytorch as pl -elif importlib.util.find_spec('pytorch_lightning'): # noqa F401 +elif importlib.util.find_spec('pytorch_lightning'): # F401 import pytorch_lightning as pl else: raise RuntimeError( diff --git a/examples/pytorch_track.py b/examples/pytorch_track.py index 3927356cb1..3c68bd51d2 100644 --- a/examples/pytorch_track.py +++ b/examples/pytorch_track.py @@ -90,7 +90,7 @@ def forward(self, x): if i % 30 == 0: logging.info( - 'Epoch [{}/{}], Step [{}/{}], ' 'Loss: {:.4f}'.format( + 'Epoch [{}/{}], Step [{}/{}], Loss: {:.4f}'.format( epoch + 1, num_epochs, i + 1, total_step, loss.item() ) ) diff --git a/examples/pytorch_track_images.py b/examples/pytorch_track_images.py index adb693a2f3..bcf4f627d9 100644 --- a/examples/pytorch_track_images.py +++ b/examples/pytorch_track_images.py @@ -94,7 +94,7 @@ def forward(self, x): if i % 30 == 0: logging.info( - 'Epoch [{}/{}], Step [{}/{}], ' 'Loss: {:.4f}'.format( + 'Epoch [{}/{}], Step [{}/{}], Loss: {:.4f}'.format( epoch + 1, num_epochs, i + 1, total_step, loss.item() ) ) diff --git a/performance_tests/sdk/queries.py b/performance_tests/sdk/queries.py index 514ce55831..38b79bf3d2 100644 --- a/performance_tests/sdk/queries.py +++ b/performance_tests/sdk/queries.py @@ -1,7 +1,7 @@ -query_0 = 'run.hparams.benchmark == "glue" ' 'and run.hparams.dataset == "cola" ' 'and metric.context.subset != "train"' -query_1 = 'run.hparams.benchmark == "glue" ' 'and run.hparams.dataset == "cola"' +query_0 = 'run.hparams.benchmark == "glue" and run.hparams.dataset == "cola" and metric.context.subset != "train"' +query_1 = 'run.hparams.benchmark == "glue" and run.hparams.dataset == "cola"' query_2 = 'run.hparams.benchmark == "glue"' -query_3 = 'run.hparams.dataset == "cola" ' 'and run.experiment.name != "baseline-warp_4-cola"' +query_3 = 'run.hparams.dataset == "cola" and run.experiment.name != "baseline-warp_4-cola"' queries = { diff --git a/requirements.dev.txt b/requirements.dev.txt index 936433a7b6..b36a02f595 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,3 +1,3 @@ wheel >= 0.31.0 twine >= 1.11.0 -ruff == 0.3.3 +ruff == 0.9.2 diff --git a/ruff.toml b/ruff.toml index d164ced829..e23481fd09 100644 --- a/ruff.toml +++ b/ruff.toml @@ -11,7 +11,11 @@ exclude = [ inline-quotes = "single" [lint] -extend-select = ["I"] +extend-select = [ + "I", + "PGH004", # blanket-noqa + "RUF100", # unused-noqa +] [lint.isort] no-lines-before = ["future", "standard-library", "first-party"]