Skip to content

Commit ff218d9

Browse files
authored
Brings pre-commit hooks and lints (#15)
* Updates table printing to save a table for ehrlich * Brings pre-commit hooks * Runs isort * Makes sure ruff checks well * Installs and runs pre-commit hooks * Adds dev dependencies * Updates the preprocessing env action to not run on drafts * Adds extra formatting and lint to GitHub action * Adds requirements dev * Updates dev requirements in project * removes isorting * Adds CPU torch installation by default in all tox envs
1 parent 998d6c8 commit ff218d9

File tree

75 files changed

+351
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+351
-324
lines changed

.github/workflows/hdbo-base.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
python -m pip install tox
3535
- name: Check linting
3636
run: |
37-
tox -e formatting-py310
37+
tox -e formatting-and-linting-py310
3838
- name: Check tests with tox on base env
3939
run: |
4040
tox -e hdbo-base-py310

.github/workflows/preprocessing-env-builds.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ name: Data preprocessing env builds (conda, python 3.10)
22

33
on:
44
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [opened, synchronize, reopened, ready_for_review, closed]
9+
branches:
10+
- master
511
schedule:
6-
- cron: "0 0 * * 0"
12+
- cron: '0 0 * * 0'
713

814
jobs:
915
build-linux:
1016
runs-on: ubuntu-latest
17+
timeout-minutes: 8
18+
if: github.event.pull_request.draft == false
1119
strategy:
1220
max-parallel: 5
1321

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.2.0
4+
hooks:
5+
- id: trailing-whitespace
6+
exclude: '.*\.pdb$'
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- repo: https://github.com/psf/black
10+
rev: 24.1.1
11+
hooks:
12+
- id: black
13+
- repo: https://github.com/PyCQA/isort
14+
rev: 5.13.2
15+
hooks:
16+
- id: isort
17+
- repo: https://github.com/astral-sh/ruff-pre-commit
18+
# Ruff version.
19+
rev: v0.5.5
20+
hooks:
21+
# Run the linter.
22+
- id: ruff
23+
args: [ --fix ]

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: hdbo_benchmark
1+
name: hdbo_benchmark
22
channels:
33
- defaults
44
dependencies:

envs/environment.bounce.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: hdbo_bounce
1+
name: hdbo_bounce
22
channels:
33
- defaults
44
dependencies:

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ dependencies = [
1919
]
2020

2121
[project.optional-dependencies]
22+
dev = [
23+
"mypy",
24+
"pandas-stubs",
25+
"types-Pillow",
26+
"ruff",
27+
"black",
28+
"isort",
29+
"pre-commit",
30+
"tox",
31+
]
2232
bounce = [
2333
"poli-baselines[bounce]@git+https://github.com/MachineLearningLifeScience/poli-baselines.git"
2434
]
@@ -52,6 +62,9 @@ warn_return_any = true
5262
warn_unused_configs = true
5363
ignore_missing_imports = true
5464

65+
[tool.isort]
66+
profile = "black"
67+
5568
[tool.pytest.ini_options]
5669
markers = [
5770
"hdbo_base: base tests for HDBO",

requirements-dev.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mypy
2+
pandas-stubs
3+
types-Pillow
4+
ruff
5+
black
6+
isort
7+
pre-commit
8+
tox

requirements.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@ poli-core @ git+https://github.com/MachineLearningLifeScience/poli.git
66
poli-baselines @ git+https://github.com/MachineLearningLifeScience/poli-baselines.git@main
77
wandb
88
lightning
9-
fair-esm
10-
mypy
11-
pandas-stubs
12-
types-Pillow
9+
fair-esm

run.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,24 @@
1010

1111
import click
1212
import numpy as np
13-
14-
from poli.core.util.seeding import seed_python_numpy_and_torch
1513
from poli.core.exceptions import BudgetExhaustedException
14+
from poli.core.util.seeding import seed_python_numpy_and_torch
1615

17-
from hdbo_benchmark.utils.experiments.load_solvers import (
18-
load_solver_from_problem,
19-
SOLVER_NAMES,
20-
CONTINUOUS_SPACE_SOLVERS,
21-
)
22-
from hdbo_benchmark.utils.experiments.load_problems import load_problem
2316
from hdbo_benchmark.utils.experiments.load_generative_models import (
2417
load_generative_model_and_bounds,
2518
)
26-
from hdbo_benchmark.utils.experiments.verify_status_pre_experiment import (
27-
verify_repos_are_clean,
19+
from hdbo_benchmark.utils.experiments.load_problems import load_problem
20+
from hdbo_benchmark.utils.experiments.load_solvers import (
21+
CONTINUOUS_SPACE_SOLVERS,
22+
SOLVER_NAMES,
23+
load_solver_from_problem,
2824
)
2925
from hdbo_benchmark.utils.experiments.problem_transformations import (
3026
transform_problem_from_discrete_to_continuous,
3127
)
32-
28+
from hdbo_benchmark.utils.experiments.verify_status_pre_experiment import (
29+
verify_repos_are_clean,
30+
)
3331
from hdbo_benchmark.utils.logging.idempotence_of_experiments import (
3432
experiment_has_already_run,
3533
)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ include_package_data = True
2121
where=src
2222

2323
[options.package_data]
24-
* = *.sht, *.yml, *.jar, *.pt, *.json, *.pdb, *.npz
24+
* = *.sht, *.yml, *.jar, *.pt, *.json, *.pdb, *.npz

src/hdbo_benchmark/data_preprocessing/zinc250k/01_from_smiles_to_selfies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
molecules in the ZINC dataset to SELFIES.
66
"""
77

8-
from typing import List
98
import pickle
109
from pathlib import Path
10+
from typing import List
1111

1212
import selfies as sf
1313

@@ -44,7 +44,7 @@ def translate_smiles_to_selfies(
4444
selfies_strings.append(sf.encoder(smile))
4545
except sf.EncoderError:
4646
if strict:
47-
raise ValueError(f"Failed to encode SMILES to SELFIES.")
47+
raise ValueError("Failed to encode SMILES to SELFIES.")
4848
else:
4949
selfies_strings.append(None)
5050

src/hdbo_benchmark/data_preprocessing/zinc250k/04_computing_alphabet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""Computes the alphabet by counting the tokens in the dataset."""
22

33
from __future__ import annotations
4+
5+
import json
46
from collections import defaultdict
57
from pathlib import Path
6-
import json
78

8-
import pandas as pd
99
import matplotlib.pyplot as plt
10-
10+
import pandas as pd
1111
import selfies as sf # type: ignore
1212

1313
if __name__ == "__main__":

src/hdbo_benchmark/data_preprocessing/zinc250k/05_computing_integer_and_onehot_representations.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
experiments/assets/data/small_molecules/processed/
99
"""
1010

11-
from pathlib import Path
1211
import json
12+
from pathlib import Path
1313

1414
import numpy as np
1515
import pandas as pd
16-
1716
import selfies as sf # type: ignore
1817

1918
if __name__ == "__main__":

src/hdbo_benchmark/data_preprocessing/zinc250k/06_human_readable_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
sequence length, and the length of the alphabet.
66
"""
77

8-
from pathlib import Path
98
import json
9+
from pathlib import Path
1010

1111
import pandas as pd
1212

src/hdbo_benchmark/experiments/benchmark_on_ehrlich/run.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,25 @@
77
from uuid import uuid4
88

99
import click
10-
11-
import torch
1210
import numpy as np
13-
1411
import poli
12+
import poli_baselines
13+
import torch
14+
from poli.core.exceptions import BudgetExhaustedException
1515
from poli.core.util.seeding import seed_numpy, seed_python
1616
from poli.objective_repository import EhrlichHoloBlackBox
17-
from poli.core.exceptions import BudgetExhaustedException
18-
19-
import poli_baselines
2017

2118
import hdbo_benchmark
19+
from hdbo_benchmark.utils.constants import DEVICE, ROOT_DIR
2220
from hdbo_benchmark.utils.experiments.load_solvers import (
23-
load_solver_class,
2421
SOLVER_NAMES,
22+
load_solver_class,
2523
)
26-
from hdbo_benchmark.utils.constants import ROOT_DIR, DEVICE
27-
from hdbo_benchmark.utils.logging.uncommited_changes import has_uncommitted_changes
28-
29-
from hdbo_benchmark.utils.logging.wandb_observer import initialize_observer
3024
from hdbo_benchmark.utils.logging.idempotence_of_experiments import (
3125
experiment_has_already_run,
3226
)
27+
from hdbo_benchmark.utils.logging.uncommited_changes import has_uncommitted_changes
28+
from hdbo_benchmark.utils.logging.wandb_observer import initialize_observer
3329

3430
torch.set_default_dtype(torch.float32)
3531

src/hdbo_benchmark/experiments/benchmark_on_foldx/run.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,45 @@
22
Running the benchmark on FoldX stability.
33
"""
44

5+
import json
6+
57
# mypy: disable-error-code="import-untyped"
68
from typing import Callable
79
from uuid import uuid4
8-
import json
910

1011
import click
11-
12-
import pandas as pd
13-
import torch
1412
import numpy as np
15-
13+
import pandas as pd
1614
import poli
17-
from poli.repository import FoldXStabilityProblemFactory
18-
from poli.core.util.seeding import seed_numpy, seed_python
15+
import poli_baselines
16+
import torch
1917
from poli.core.abstract_black_box import AbstractBlackBox
2018
from poli.core.exceptions import BudgetExhaustedException
2119
from poli.core.problem import Problem
22-
23-
import poli_baselines
20+
from poli.core.util.seeding import seed_numpy, seed_python
21+
from poli.repository import FoldXStabilityProblemFactory
2422

2523
import hdbo_benchmark
2624
from hdbo_benchmark.generative_models.ae_for_esm import LitAutoEncoder
25+
from hdbo_benchmark.utils.constants import DEVICE, ROOT_DIR
26+
from hdbo_benchmark.utils.experiments.load_generative_models import (
27+
load_generative_model_and_bounds,
28+
)
2729
from hdbo_benchmark.utils.experiments.load_solvers import (
28-
load_solver_class,
29-
SOLVER_NAMES,
3030
DISCRETE_SPACE_SOLVERS,
31+
SOLVER_NAMES,
3132
SOLVERS_THAT_DONT_ALLOW_CUSTOM_INPUTS,
32-
)
33-
from hdbo_benchmark.utils.experiments.load_generative_models import (
34-
load_generative_model_and_bounds,
33+
load_solver_class,
3534
)
3635
from hdbo_benchmark.utils.experiments.normalization import (
37-
from_unit_cube_to_range,
3836
from_range_to_unit_cube,
37+
from_unit_cube_to_range,
3938
)
40-
from hdbo_benchmark.utils.constants import ROOT_DIR, DEVICE
41-
from hdbo_benchmark.utils.logging.uncommited_changes import has_uncommitted_changes
42-
43-
from hdbo_benchmark.utils.logging.wandb_observer import initialize_observer
4439
from hdbo_benchmark.utils.logging.idempotence_of_experiments import (
4540
experiment_has_already_run,
4641
)
42+
from hdbo_benchmark.utils.logging.uncommited_changes import has_uncommitted_changes
43+
from hdbo_benchmark.utils.logging.wandb_observer import initialize_observer
4744

4845
torch.set_default_dtype(torch.float32)
4946

src/hdbo_benchmark/experiments/benchmark_on_pmo/run.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,31 @@
77
from uuid import uuid4
88

99
import click
10-
11-
import torch
1210
import numpy as np
13-
from selfies import split_selfies
14-
1511
import poli
16-
from poli.core.util.seeding import seed_numpy, seed_python
12+
import poli_baselines
13+
import torch
1714
from poli.core.abstract_black_box import AbstractBlackBox
1815
from poli.core.exceptions import BudgetExhaustedException
19-
20-
import poli_baselines
16+
from poli.core.util.seeding import seed_numpy, seed_python
17+
from selfies import split_selfies
2118

2219
import hdbo_benchmark
23-
from hdbo_benchmark.generative_models.vae_factory import VAEFactory, VAESelfies, VAE
24-
from hdbo_benchmark.utils.experiments.load_solvers import (
25-
load_solver_class,
26-
SOLVER_NAMES,
27-
)
20+
from hdbo_benchmark.generative_models.vae_factory import VAE, VAEFactory, VAESelfies
21+
from hdbo_benchmark.utils.constants import DEVICE, ROOT_DIR
2822
from hdbo_benchmark.utils.experiments.load_metadata_for_vaes import (
2923
load_alphabet_for_pmo,
3024
load_sequence_length_for_pmo,
3125
)
32-
from hdbo_benchmark.utils.constants import ROOT_DIR, DEVICE
33-
from hdbo_benchmark.utils.logging.uncommited_changes import has_uncommitted_changes
34-
35-
from hdbo_benchmark.utils.logging.wandb_observer import initialize_observer
26+
from hdbo_benchmark.utils.experiments.load_solvers import (
27+
SOLVER_NAMES,
28+
load_solver_class,
29+
)
3630
from hdbo_benchmark.utils.logging.idempotence_of_experiments import (
3731
experiment_has_already_run,
3832
)
33+
from hdbo_benchmark.utils.logging.uncommited_changes import has_uncommitted_changes
34+
from hdbo_benchmark.utils.logging.wandb_observer import initialize_observer
3935

4036
torch.set_default_dtype(torch.float32)
4137

0 commit comments

Comments
 (0)