diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index 2e1832e8..573ca5be 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -1,45 +1,25 @@ -name: codestyle -# <- standard block end -> +name: codestyle check on: push: branches: - main pull_request: branches: - - dev - - develop - main - jobs: - build: - name: codestyle - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - max-parallel: 4 - matrix: - os: [ubuntu-20.04] - python-version: [3.8] - timeout-minutes: 30 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} - - - name: install dependencies + python-version: "3.9" + - name: Install dependencies run: | - # python -m pip install --upgrade --user pip + python -m pip install --upgrade pip pip install -r requirements/requirements_dev.txt - python --version - pip --version - pip list - shell: bash -# <- standard block end -> - name: check codestyle run: | - catalyst-check-codestyle --line-length 89 + ruff --config pyproject.toml --diff . \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e124e675..5c7a4c45 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,6 @@ repos: - - repo: https://github.com/catalyst-team/codestyle - rev: 'v21.09.2' + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.278' hooks: - - id: catalyst-make-codestyle - args: [--line-length=89] - - repo: https://github.com/catalyst-team/codestyle - rev: 'v21.09.2' - hooks: - - id: catalyst-check-codestyle - args: [--line-length=89] - -exclude: __init__.py + - id: ruff + args: [--fix] \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..05a5063c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,104 @@ +# CORL Contribution Guidelines + +We welcome: + +- Bug reports +- Pull requests for bug fixes +- Logs and documentation improvements +- New algorithms and datasets +- Better hyperparameters (but with proofs) + +## Contributing to the codebase + +Contributing code is done through standard github methods: + +```commandline +git clone git@github.com:tinkoff-ai/CORL.git +cd CORL +pip install -r requirements/requirements_dev.txt +``` + +1. Fork this repo +2. Make a change and commit your code +3. Submit a pull request. It will be reviewed by maintainers, and they'll give feedback or make requests as applicable + +### Code style + +The CI will run several checks on the new code pushed to the CORL repository. +These checks can also be run locally without waiting for the CI by following the steps below: +1. [install `pre-commit`](https://pre-commit.com/#install), +2. install the Git hooks by running `pre-commit install`. + +Once those two steps are done, the Git hooks will be run automatically at every new commit. +The Git hooks can also be run manually with `pre-commit run --all-files`, and +if needed they can be skipped (not recommended) with `git commit --no-verify`. + +We use [Ruff](https://github.com/astral-sh/ruff) as our main linter. If you want to see possible +problems before pre-commit, you can run `ruff check --diff .` to see exact linter suggestions and future fixes. + +## Adding new algorithms + +All new algorithms should go to the `algorithms/contrib/offline` for just +offline algorithms and to the `algorithms/contrib/finetune` for the offline-to-online algorithms. +We as a team try to keep the core as reliable and reproducible as possible, +but we may not have the resources to support all future algorithms. +Therefore, this separation is necessary, as we cannot guarantee that all +algorithms from `algorithms/contrib` exactly reproduce the results of their original publications. + +Make sure your new code is properly documented and all references to the original implementations and papers are present (for example as in [Decision Transformer](algorithms/offline/dt.py)). +Please, *explain all the tricks and possible differences from the original implementation in as much detail as possible*. +Keep in mind that this code may be used by other researchers. Make their lives easier! + +### Considerations +While we welcome any algorithms, it is better to open an issue with the proposal before +so we can discuss the details. Unfortunately, not all algorithms are equally +easy to understand and reproduce. We may be able to give a couple of advices to you, +or on the contrary warn you that this particular algorithm will require too much +computational resources to fully reproduce the results, and it is better to do something else. + +### Running benchmarks + +Although you will have to do a hyperparameter search while reproducing the algorithm, +in the end we expect to see final configs in `configs/contrib///.yaml` with the best hyperparameters for all +datasets considered. The configs should be in `yaml` format, containing all hyperparameters sorted +in alphabetical order (see existing configs for an inspiration). + +Use these conventions to name your runs in the configs: +1. `name: ` +2. `group: --multiseed-v0`, increment version if needed +3. use our [\_\_post_init\_\_](https://github.com/tinkoff-ai/CORL/blob/962688b405f579a1ce6ec1b57e6369aaf76f9e69/algorithms/offline/awac.py#L48) implementation in your config dataclass + +Since we are releasing wandb logs for all algorithms, you will need to submit multiseed (~4 seeds) +training runs the `CORL` project in the wandb [corl-team](https://wandb.ai/corl-team) organization. We'll invite you there when the time will come. + +We usually use wandb sweeps for this. You can use this example config (it will work with pyrallis as it expects `config_path` cli argument): +```yaml +# sweep_config.yaml +entity: corl-team +project: CORL +program: algorithms/contrib/.py +method: grid +parameters: + config_path: + # algo_type is offline or finetune (see sections above) + values: [ + "configs/contrib///.yaml", + "configs/contrib///.yaml", + "configs/contrib///.yaml", + ] + train_seed: + values: [0, 1, 2, 3] +``` +Then proceed as usual. Create wandb sweep with `wandb sweep sweep_config.yaml`, then run agents with `wandb agent `. + +Based on the results, you will need to make wandb reports to make it easier for other users to understand. +You can use any of the already existing ones as an example (see [README.md](README.md)). + +### Checklist + +- [ ] Issue about new algorithm is open +- [ ] Single-file implementation is added to the `algorithms/contrib` +- [ ] PR has passed all the tests +- [ ] Evidence that implementation reproduces original results is provided +- [ ] Configs with the best hyperparameters for all datasets are added to the `configs/contrib` +- [ ] Logs and reports for best hyperparameters are submitted to our wandb organization diff --git a/algorithms/finetune/awac.py b/algorithms/finetune/awac.py index f48045ab..e44cd26a 100644 --- a/algorithms/finetune/awac.py +++ b/algorithms/finetune/awac.py @@ -1,9 +1,9 @@ -from typing import Any, Dict, List, Optional, Tuple, Union -from copy import deepcopy -from dataclasses import asdict, dataclass import os import random import uuid +from copy import deepcopy +from dataclasses import asdict, dataclass +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym @@ -12,8 +12,8 @@ import torch import torch.nn as nn import torch.nn.functional -from tqdm import trange import wandb +from tqdm import trange TensorBatch = List[torch.Tensor] diff --git a/algorithms/finetune/cal_ql.py b/algorithms/finetune/cal_ql.py index 39a8102b..ea2e3df7 100644 --- a/algorithms/finetune/cal_ql.py +++ b/algorithms/finetune/cal_ql.py @@ -1,22 +1,22 @@ # source: https://github.com/nakamotoo/Cal-QL/tree/main # https://arxiv.org/pdf/2303.05479.pdf -from typing import Any, Dict, List, Optional, Tuple, Union -from copy import deepcopy -from dataclasses import asdict, dataclass import os -from pathlib import Path import random import uuid +from copy import deepcopy +from dataclasses import asdict, dataclass +from pathlib import Path +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym import numpy as np import pyrallis import torch -from torch.distributions import Normal, TanhTransform, TransformedDistribution import torch.nn as nn import torch.nn.functional as F import wandb +from torch.distributions import Normal, TanhTransform, TransformedDistribution TensorBatch = List[torch.Tensor] @@ -285,13 +285,13 @@ def get_return_to_go(dataset: Dict, env: gym.Env, config: TrainConfig) -> np.nda ep_len += 1 is_last_step = ( (t == N - 1) - or ( # noqa + or ( np.linalg.norm( dataset["observations"][t + 1] - dataset["next_observations"][t] ) - > 1e-6 # noqa + > 1e-6 ) - or ep_len == env._max_episode_steps # noqa + or ep_len == env._max_episode_steps ) if d or is_last_step: @@ -299,8 +299,8 @@ def get_return_to_go(dataset: Dict, env: gym.Env, config: TrainConfig) -> np.nda prev_return = 0 if ( config.is_sparse_reward - and r # noqa - == env.ref_min_score * config.reward_scale + config.reward_bias # noqa + and r + == env.ref_min_score * config.reward_scale + config.reward_bias ): discounted_returns = [r / (1 - config.discount)] * ep_len else: @@ -818,14 +818,14 @@ def _q_loss( torch.exp(self.log_alpha_prime()), min=0.0, max=1000000.0 ) cql_min_qf1_loss = ( - alpha_prime # noqa - * self.cql_alpha # noqa - * (cql_qf1_diff - self.cql_target_action_gap) # noqa + alpha_prime + * self.cql_alpha + * (cql_qf1_diff - self.cql_target_action_gap) ) cql_min_qf2_loss = ( - alpha_prime # noqa - * self.cql_alpha # noqa - * (cql_qf2_diff - self.cql_target_action_gap) # noqa + alpha_prime + * self.cql_alpha + * (cql_qf2_diff - self.cql_target_action_gap) ) self.alpha_prime_optimizer.zero_grad() diff --git a/algorithms/finetune/cql.py b/algorithms/finetune/cql.py index 90607dc4..867c7a5a 100644 --- a/algorithms/finetune/cql.py +++ b/algorithms/finetune/cql.py @@ -1,23 +1,23 @@ # source: https://github.com/young-geng/CQL/tree/934b0e8354ca431d6c083c4e3a29df88d4b0a24d # STRONG UNDER-PERFORMANCE ON PART OF ANTMAZE TASKS. BUT IN IQL PAPER IT WORKS SOMEHOW # https://arxiv.org/pdf/2006.04779.pdf -from typing import Any, Dict, List, Optional, Tuple, Union -from copy import deepcopy -from dataclasses import asdict, dataclass import os -from pathlib import Path import random import uuid +from copy import deepcopy +from dataclasses import asdict, dataclass +from pathlib import Path +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym import numpy as np import pyrallis import torch -from torch.distributions import Normal, TanhTransform, TransformedDistribution import torch.nn as nn import torch.nn.functional as F import wandb +from torch.distributions import Normal, TanhTransform, TransformedDistribution TensorBatch = List[torch.Tensor] @@ -729,14 +729,14 @@ def _q_loss( torch.exp(self.log_alpha_prime()), min=0.0, max=1000000.0 ) cql_min_qf1_loss = ( - alpha_prime # noqa - * self.cql_alpha # noqa - * (cql_qf1_diff - self.cql_target_action_gap) # noqa + alpha_prime + * self.cql_alpha + * (cql_qf1_diff - self.cql_target_action_gap) ) cql_min_qf2_loss = ( - alpha_prime # noqa - * self.cql_alpha # noqa - * (cql_qf2_diff - self.cql_target_action_gap) # noqa + alpha_prime + * self.cql_alpha + * (cql_qf2_diff - self.cql_target_action_gap) ) self.alpha_prime_optimizer.zero_grad() diff --git a/algorithms/finetune/iql.py b/algorithms/finetune/iql.py index 2ee38ac1..8e743aa9 100644 --- a/algorithms/finetune/iql.py +++ b/algorithms/finetune/iql.py @@ -1,23 +1,23 @@ # source: https://github.com/gwthomas/IQL-PyTorch # https://arxiv.org/pdf/2110.06169.pdf -from typing import Any, Callable, Dict, List, Optional, Tuple, Union import copy -from dataclasses import asdict, dataclass import os -from pathlib import Path import random import uuid +from dataclasses import asdict, dataclass +from pathlib import Path +from typing import Any, Callable, Dict, List, Optional, Tuple, Union import d4rl import gym import numpy as np import pyrallis import torch -from torch.distributions import Normal import torch.nn as nn import torch.nn.functional as F -from torch.optim.lr_scheduler import CosineAnnealingLR import wandb +from torch.distributions import Normal +from torch.optim.lr_scheduler import CosineAnnealingLR TensorBatch = List[torch.Tensor] diff --git a/algorithms/finetune/spot.py b/algorithms/finetune/spot.py index cf3ece8f..0cb3c3ea 100644 --- a/algorithms/finetune/spot.py +++ b/algorithms/finetune/spot.py @@ -1,12 +1,12 @@ # source: https://github.com/thuml/SPOT/tree/58c591dc48fbd9ff632b7494eab4caf778e86f4a # https://arxiv.org/pdf/2202.06239.pdf -from typing import Any, Dict, List, Optional, Tuple, Union import copy -from dataclasses import asdict, dataclass import os -from pathlib import Path import random import uuid +from dataclasses import asdict, dataclass +from pathlib import Path +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym @@ -456,7 +456,7 @@ def forward(self, state: torch.Tensor, action: torch.Tensor) -> torch.Tensor: return self.net(sa) -class SPOT: # noqa +class SPOT: def __init__( self, max_action: float, diff --git a/algorithms/offline/any_percent_bc.py b/algorithms/offline/any_percent_bc.py index 3d58e22b..edacc43e 100644 --- a/algorithms/offline/any_percent_bc.py +++ b/algorithms/offline/any_percent_bc.py @@ -1,9 +1,9 @@ -from typing import Any, Dict, List, Optional, Tuple, Union -from dataclasses import asdict, dataclass import os -from pathlib import Path import random import uuid +from dataclasses import asdict, dataclass +from pathlib import Path +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym @@ -249,7 +249,7 @@ def act(self, state: np.ndarray, device: str = "cpu") -> np.ndarray: return self(state).cpu().data.numpy().flatten() -class BC: # noqa +class BC: def __init__( self, max_action: np.ndarray, diff --git a/algorithms/offline/awac.py b/algorithms/offline/awac.py index ab18ba99..2c652de9 100644 --- a/algorithms/offline/awac.py +++ b/algorithms/offline/awac.py @@ -1,9 +1,9 @@ -from typing import Any, Dict, List, Optional, Tuple, Union -from copy import deepcopy -from dataclasses import asdict, dataclass import os import random import uuid +from copy import deepcopy +from dataclasses import asdict, dataclass +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym @@ -12,8 +12,8 @@ import torch import torch.nn as nn import torch.nn.functional -from tqdm import trange import wandb +from tqdm import trange TensorBatch = List[torch.Tensor] diff --git a/algorithms/offline/cql.py b/algorithms/offline/cql.py index 22e9bf42..a1470eb0 100644 --- a/algorithms/offline/cql.py +++ b/algorithms/offline/cql.py @@ -1,22 +1,22 @@ # source: https://github.com/young-geng/CQL/tree/934b0e8354ca431d6c083c4e3a29df88d4b0a24d # https://arxiv.org/pdf/2006.04779.pdf -from typing import Any, Dict, List, Optional, Tuple, Union -from copy import deepcopy -from dataclasses import asdict, dataclass import os -from pathlib import Path import random import uuid +from copy import deepcopy +from dataclasses import asdict, dataclass +from pathlib import Path +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym import numpy as np import pyrallis import torch -from torch.distributions import Normal, TanhTransform, TransformedDistribution import torch.nn as nn import torch.nn.functional as F import wandb +from torch.distributions import Normal, TanhTransform, TransformedDistribution TensorBatch = List[torch.Tensor] @@ -683,14 +683,14 @@ def _q_loss( torch.exp(self.log_alpha_prime()), min=0.0, max=1000000.0 ) cql_min_qf1_loss = ( - alpha_prime # noqa - * self.cql_alpha # noqa - * (cql_qf1_diff - self.cql_target_action_gap) # noqa + alpha_prime + * self.cql_alpha + * (cql_qf1_diff - self.cql_target_action_gap) ) cql_min_qf2_loss = ( - alpha_prime # noqa - * self.cql_alpha # noqa - * (cql_qf2_diff - self.cql_target_action_gap) # noqa + alpha_prime + * self.cql_alpha + * (cql_qf2_diff - self.cql_target_action_gap) ) self.alpha_prime_optimizer.zero_grad() diff --git a/algorithms/offline/dt.py b/algorithms/offline/dt.py index d5c2e6e7..37c61e67 100644 --- a/algorithms/offline/dt.py +++ b/algorithms/offline/dt.py @@ -1,24 +1,23 @@ # inspiration: # 1. https://github.com/kzl/decision-transformer/blob/master/gym/decision_transformer/models/decision_transformer.py # noqa # 2. https://github.com/karpathy/minGPT -from typing import Any, DefaultDict, Dict, List, Optional, Tuple, Union -from collections import defaultdict -from dataclasses import asdict, dataclass import os import random import uuid +from collections import defaultdict +from dataclasses import asdict, dataclass +from typing import Any, DefaultDict, Dict, List, Optional, Tuple, Union import d4rl # noqa -import gym # noqa +import gym import numpy as np import pyrallis import torch import torch.nn as nn -from torch.nn import functional as F # noqa +import wandb +from torch.nn import functional as F from torch.utils.data import DataLoader, IterableDataset from tqdm.auto import tqdm, trange # noqa -import wandb - @dataclass class TrainConfig: @@ -381,10 +380,10 @@ def eval_rollout( # step + 1 as : operator is not inclusive, last action is dummy with zeros # (as model will predict last, actual last values are not important) predicted_actions = model( # fix this noqa!!! - states[:, : step + 1][:, -model.seq_len :], # noqa - actions[:, : step + 1][:, -model.seq_len :], # noqa - returns[:, : step + 1][:, -model.seq_len :], # noqa - time_steps[:, : step + 1][:, -model.seq_len :], # noqa + states[:, : step + 1][:, -model.seq_len :], + actions[:, : step + 1][:, -model.seq_len :], + returns[:, : step + 1][:, -model.seq_len :], + time_steps[:, : step + 1][:, -model.seq_len :], ) predicted_action = predicted_actions[0, -1].cpu().numpy() next_state, reward, done, info = env.step(predicted_action) diff --git a/algorithms/offline/edac.py b/algorithms/offline/edac.py index f8686905..413801c9 100644 --- a/algorithms/offline/edac.py +++ b/algorithms/offline/edac.py @@ -1,24 +1,23 @@ # Inspired by: # 1. paper for SAC-N: https://arxiv.org/abs/2110.01548 # 2. implementation: https://github.com/snu-mllab/EDAC -from typing import Any, Dict, List, Optional, Tuple, Union -from copy import deepcopy -from dataclasses import asdict, dataclass import math import os import random import uuid +from copy import deepcopy +from dataclasses import asdict, dataclass +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym import numpy as np import pyrallis import torch -from torch.distributions import Normal import torch.nn as nn -from tqdm import trange import wandb - +from torch.distributions import Normal +from tqdm import trange @dataclass class TrainConfig: @@ -313,7 +312,7 @@ def __init__( tau: float = 0.005, eta: float = 1.0, alpha_learning_rate: float = 1e-4, - device: str = "cpu", # noqa + device: str = "cpu", ): self.device = device diff --git a/algorithms/offline/iql.py b/algorithms/offline/iql.py index 22aff0a2..257184f5 100644 --- a/algorithms/offline/iql.py +++ b/algorithms/offline/iql.py @@ -1,23 +1,23 @@ # source: https://github.com/gwthomas/IQL-PyTorch # https://arxiv.org/pdf/2110.06169.pdf -from typing import Any, Callable, Dict, List, Optional, Tuple, Union import copy -from dataclasses import asdict, dataclass import os -from pathlib import Path import random import uuid +from dataclasses import asdict, dataclass +from pathlib import Path +from typing import Any, Callable, Dict, List, Optional, Tuple, Union import d4rl import gym import numpy as np import pyrallis import torch -from torch.distributions import Normal import torch.nn as nn import torch.nn.functional as F -from torch.optim.lr_scheduler import CosineAnnealingLR import wandb +from torch.distributions import Normal +from torch.optim.lr_scheduler import CosineAnnealingLR TensorBatch = List[torch.Tensor] diff --git a/algorithms/offline/lb_sac.py b/algorithms/offline/lb_sac.py index efe8c66a..71fb8c54 100644 --- a/algorithms/offline/lb_sac.py +++ b/algorithms/offline/lb_sac.py @@ -1,24 +1,23 @@ # Inspired by: # 1. paper for LB-SAC: https://arxiv.org/abs/2211.11092 # 2. implementation: https://github.com/tinkoff-ai/lb-sac -from typing import Any, Dict, List, Optional, Tuple, Union -from copy import deepcopy -from dataclasses import asdict, dataclass import math import os import random import uuid +from copy import deepcopy +from dataclasses import asdict, dataclass +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym import numpy as np import pyrallis import torch -from torch.distributions import Normal import torch.nn as nn -from tqdm import trange import wandb - +from torch.distributions import Normal +from tqdm import trange # base batch size: 256 # base learning rate: 3e-4 @@ -328,7 +327,7 @@ def __init__( gamma: float = 0.99, tau: float = 0.005, alpha_learning_rate: float = 1e-4, - device: str = "cpu", # noqa + device: str = "cpu", ): self.device = device diff --git a/algorithms/offline/sac_n.py b/algorithms/offline/sac_n.py index 8d9874b0..0b91ddec 100644 --- a/algorithms/offline/sac_n.py +++ b/algorithms/offline/sac_n.py @@ -1,24 +1,23 @@ # Inspired by: # 1. paper for SAC-N: https://arxiv.org/abs/2110.01548 # 2. implementation: https://github.com/snu-mllab/EDAC -from typing import Any, Dict, List, Optional, Tuple, Union -from copy import deepcopy -from dataclasses import asdict, dataclass import math import os import random import uuid +from copy import deepcopy +from dataclasses import asdict, dataclass +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym import numpy as np import pyrallis import torch -from torch.distributions import Normal import torch.nn as nn -from tqdm import trange import wandb - +from torch.distributions import Normal +from tqdm import trange @dataclass class TrainConfig: @@ -308,7 +307,7 @@ def __init__( gamma: float = 0.99, tau: float = 0.005, alpha_learning_rate: float = 1e-4, - device: str = "cpu", # noqa + device: str = "cpu", ): self.device = device diff --git a/algorithms/offline/td3_bc.py b/algorithms/offline/td3_bc.py index a16c5371..a78bda30 100644 --- a/algorithms/offline/td3_bc.py +++ b/algorithms/offline/td3_bc.py @@ -1,12 +1,12 @@ # source: https://github.com/sfujim/TD3_BC # https://arxiv.org/pdf/2106.06860.pdf -from typing import Any, Dict, List, Optional, Tuple, Union import copy -from dataclasses import asdict, dataclass import os -from pathlib import Path import random import uuid +from dataclasses import asdict, dataclass +from pathlib import Path +from typing import Any, Dict, List, Optional, Tuple, Union import d4rl import gym @@ -263,7 +263,7 @@ def forward(self, state: torch.Tensor, action: torch.Tensor) -> torch.Tensor: return self.net(sa) -class TD3_BC: # noqa +class TD3_BC: def __init__( self, max_action: float, diff --git a/pyproject.toml b/pyproject.toml index e042e09b..24607c5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,10 @@ -[tool.nitpick] -style = "https://raw.githubusercontent.com/catalyst-team/codestyle/v21.09.2/styles/nitpick-style-catalyst.toml" +[tool.ruff] +select = ["E", "F", "I001", "RUF100"] +ignore = ["E402"] +line-length = 89 +target-version = "py39" -[tool.black] -line-length = 89 \ No newline at end of file +[tool.ruff.isort] +combine-as-imports = true +lines-after-imports = 1 +order-by-type = false \ No newline at end of file diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 00e3db5e..9034fc87 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -7,5 +7,4 @@ numpy==1.23.1 gym[mujoco_py,classic_control]==0.23.0 --extra-index-url https://download.pytorch.org/whl/cu113 torch==1.11.0+cu113 -sortedcontainers==2.4.0 pyrallis==0.3.1 diff --git a/requirements/requirements_dev.txt b/requirements/requirements_dev.txt index c1916cb5..14947414 100644 --- a/requirements/requirements_dev.txt +++ b/requirements/requirements_dev.txt @@ -7,8 +7,6 @@ numpy==1.23.1 gym[mujoco_py,classic_control]==0.23.0 --extra-index-url https://download.pytorch.org/whl/cu113 torch==1.11.0+cu113 -sortedcontainers==2.4.0 pyrallis==0.3.1 -pre-commit==2.20.0 -catalyst-codestyle==21.9.2 -pytest==7.1.2 \ No newline at end of file +pre-commit==3.3.3 +ruff==0.0.278 \ No newline at end of file diff --git a/results/get_finetune_scores.py b/results/get_finetune_scores.py index 9f6012e9..dd31ad19 100644 --- a/results/get_finetune_scores.py +++ b/results/get_finetune_scores.py @@ -2,8 +2,8 @@ import pickle import pandas as pd -from tqdm import tqdm import wandb +from tqdm import tqdm dataframe = pd.read_csv("runs_tables/finetune_urls.csv") diff --git a/results/get_finetune_tables_and_plots.py b/results/get_finetune_tables_and_plots.py index 0ebc3437..d8072652 100644 --- a/results/get_finetune_tables_and_plots.py +++ b/results/get_finetune_tables_and_plots.py @@ -4,8 +4,8 @@ import matplotlib.pyplot as plt import numpy as np import pandas as pd -from rliable import library as rly, metrics, plot_utils import seaborn as sns +from rliable import library as rly, metrics, plot_utils dataframe = pd.read_csv("runs_tables/finetune_urls.csv") with open("bin/finetune_scores.pickle", "rb") as handle: @@ -173,7 +173,7 @@ def get_table( if data in stds[algo]: row.append( f"{scores[algo][data]:.2f} {pm} {stds[algo][data]:.2f}" - + ( # noqa + + ( "" if scores2 is None else f"{scores_delim} {scores2[algo][data]:.2f} {pm} {stds2[algo][data]:.2f}" # noqa @@ -182,7 +182,7 @@ def get_table( else: row.append( f"{scores[algo][data]:.2f}" - + ( # noqa + + ( "" if scores2 is None else f"{scores_delim} {scores2[algo][data]:.2f}" diff --git a/results/get_offline_scores.py b/results/get_offline_scores.py index 0b78d758..a4db747b 100644 --- a/results/get_offline_scores.py +++ b/results/get_offline_scores.py @@ -2,8 +2,8 @@ import pickle import pandas as pd -from tqdm import tqdm import wandb +from tqdm import tqdm dataframe = pd.read_csv("offline_urls.csv") diff --git a/results/get_offline_tables_and_plots.py b/results/get_offline_tables_and_plots.py index a8b9c558..c30ee821 100644 --- a/results/get_offline_tables_and_plots.py +++ b/results/get_offline_tables_and_plots.py @@ -4,8 +4,8 @@ import matplotlib.pyplot as plt import numpy as np import pandas as pd -from rliable import library as rly, metrics, plot_utils import seaborn as sns +from rliable import library as rly, metrics, plot_utils dataframe = pd.read_csv("runs_tables/offline_urls.csv") with open("bin/offline_scores.pickle", "rb") as handle: diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 6dc3b40a..00000000 --- a/setup.cfg +++ /dev/null @@ -1,34 +0,0 @@ -[flake8] -ignore = C408,D100,D101,D102,D103,D104,D104,D105,D106,D107,D202,D205,D212,D415,DAR101,DAR201,E731,N806,N812,NIP319,NIP322,NIP323,E203 -max-line-length = 89 -max-doc-length = 89 -inline-quotes = double -multiline-quotes = double -docstring-quotes = double -convention = google -docstring_style = google -strictness = short -per-file-ignores = - **/__init__.py:F401 - -[darglint] -ignore_regex=^_(.*) - -[isort] -combine_as_imports = true -order_by_type = false -force_grid_wrap = 0 -force_sort_within_sections = true -line_length = 89 -lines_between_types = 0 -multi_line_output = 3 -no_lines_before = STDLIB,LOCALFOLDER -reverse_relative = true -default_section = THIRDPARTY -known_first_party = animus -known_src = src -skip_glob = **/__init__.py -force_to_top = typing -include_trailing_comma = true -use_parentheses = true -sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,SRC,LOCALFOLDER \ No newline at end of file