Skip to content

Commit 486ab48

Browse files
committed
merge with dev
2 parents bb84d62 + 6206f15 commit 486ab48

File tree

12 files changed

+361
-84
lines changed

12 files changed

+361
-84
lines changed

.github/actions/install-python-and-package/action.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ runs:
3939
activate-environment: deeprank2
4040
environment-file: env/deeprank2.yml
4141
use-mamba: true
42+
if: ${{ inputs.pkg-installation-type != 'frozen' }}
43+
44+
- name: Setup miniconda with frozen dependencies
45+
uses: conda-incubator/setup-miniconda@v2
46+
with:
47+
auto-update-conda: true
48+
miniforge-variant: Mambaforge
49+
channels: conda-forge
50+
python-version: ${{ inputs.python-version }}
51+
activate-environment: deeprank2
52+
environment-file: env/deeprank2_frozen.yml
53+
use-mamba: true
54+
if: ${{ inputs.pkg-installation-type == 'frozen' }}
4255

4356
- run: |
4457
conda --version
@@ -53,7 +66,7 @@ runs:
5366
5467
- name: Install the GitHub repository version of the package
5568
shell: bash -l {0}
56-
if: ${{ inputs.pkg-installation-type == 'repository' }}
69+
if: ${{ inputs.pkg-installation-type == 'repository' || inputs.pkg-installation-type == 'frozen' }}
5770
run: |
5871
conda activate deeprank2
5972
pip install .'[${{ inputs.extras-require }}]'
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: build (repository package) using the frozen environment
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
# specific folder locations
7+
- ".vscode/**"
8+
- "docs/**"
9+
# filetypes
10+
- "**.md"
11+
- "**.rst"
12+
- "**.ipynb"
13+
- "**.cff"
14+
- "**.png"
15+
branches:
16+
- main
17+
pull_request:
18+
types: [opened, synchronize, reopened, ready_for_review]
19+
paths-ignore:
20+
# specific folder locations
21+
- ".vscode/**"
22+
- "docs/**"
23+
# filetypes
24+
- "**.md"
25+
- "**.rst"
26+
- "**.ipynb"
27+
- "**.cff"
28+
- "**.png"
29+
30+
jobs:
31+
build:
32+
if: github.event.pull_request.draft == false
33+
name: Build for (${{ matrix.python-version }}, ${{ matrix.os }})
34+
runs-on: ${{ matrix.os }}
35+
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
os: ["ubuntu-latest"]
40+
python-version: ["3.10"] # ["3.10", "3.11"]
41+
42+
# https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell
43+
defaults:
44+
run:
45+
shell: bash -l {0}
46+
47+
steps:
48+
- uses: actions/checkout@v3
49+
50+
- uses: ./.github/actions/install-python-and-package
51+
with:
52+
python-version: ${{ matrix.python-version }}
53+
extras-require: test, publishing
54+
pkg-installation-type: "frozen"
55+
56+
- name: Run unit tests
57+
run: pytest -v
58+
59+
- name: Verify that we can build the package
60+
run: python3 -m build

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ conda activate deeprank2
115115
pip install deeprank2
116116
```
117117

118+
We also provide a frozen environment YML file located at `env/deeprank2_frozen.yml` with all dependencies set to fixed versions. The `env/deeprank2_frozen.yml` file provides a frozen environment with all dependencies set to fixed versions. This ensures reproducibility of experiments and results by preventing changes in package versions that could occur due to updates or modifications in the default `env/deeprank2.yml`. Use this frozen environment file for a stable and consistent setup, particularly if you encounter issues with the default environment file.
119+
118120
#### Manual installation (customizable)
119121

120122
If you want to use the GPUs, choose a specific python version (note that at the moment we support python 3.10 only), are a MacOS user, or if the YML installation was not successful, you can install the package manually. We advise to do this inside a [conda virtual environment](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).

deeprank2/tools/target.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ def add_target( # noqa: C901
3535
1ATN_xxx-3 0
3636
1ATN_xxx-4 0
3737
"""
38-
target_dict = {}
39-
4038
labels = np.loadtxt(target_list, delimiter=sep, usecols=[0], dtype=str)
4139
values = np.loadtxt(target_list, delimiter=sep, usecols=[1])
42-
for label, value in zip(labels, values, strict=True):
43-
target_dict[label] = value
40+
target_dict = dict(zip(labels, values, strict=False))
4441

4542
if os.path.isdir(graph_path):
4643
graphs = glob.glob(f"{graph_path}/*.hdf5")

deeprank2/trainer.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ def _precluster(self, dataset: GraphDataset) -> None:
350350
f5.close()
351351

352352
def _put_model_to_device(self, dataset: GraphDataset | GridDataset) -> None:
353-
"""
354-
Puts the model on the available device.
353+
"""Puts the model on the available device.
355354
356355
Args:
357356
dataset (:class:`GraphDataset` | :class:`GridDataset`): GraphDataset object.
@@ -407,8 +406,7 @@ def configure_optimizers(
407406
lr: float = 0.001,
408407
weight_decay: float = 1e-05,
409408
) -> None:
410-
"""
411-
Configure optimizer and its main parameters.
409+
"""Configure optimizer and its main parameters.
412410
413411
Args:
414412
optimizer (:class:`torch.optim`, optional): PyTorch optimizer object. If none, defaults to :class:`torch.optim.Adam`.
@@ -437,8 +435,7 @@ def set_lossfunction( # noqa: C901
437435
lossfunction: nn.modules.loss._Loss | None = None,
438436
override_invalid: bool = False,
439437
) -> None:
440-
"""
441-
Set the loss function.
438+
"""Set the loss function.
442439
443440
Args:
444441
lossfunction (optional): Make sure to use a loss function that is appropriate for
@@ -526,8 +523,7 @@ def train( # noqa: PLR0915, C901
526523
best_model: bool = True,
527524
filename: str | None = "model.pth.tar",
528525
) -> None:
529-
"""
530-
Performs the training of the model.
526+
"""Performs the training of the model.
531527
532528
Args:
533529
nepoch (int, optional): Maximum number of epochs to run.
@@ -687,8 +683,7 @@ def train( # noqa: PLR0915, C901
687683
self.model.load_state_dict(self.model_load_state_dict)
688684

689685
def _epoch(self, epoch_number: int, pass_name: str) -> float | None:
690-
"""
691-
Runs a single epoch.
686+
"""Runs a single epoch.
692687
693688
Args:
694689
epoch_number (int): the current epoch number
@@ -753,8 +748,7 @@ def _eval(
753748
epoch_number: int,
754749
pass_name: str,
755750
) -> float | None:
756-
"""
757-
Evaluates the model.
751+
"""Evaluates the model.
758752
759753
Args:
760754
loader (Dataloader): Data to evaluate on.
@@ -820,8 +814,7 @@ def _eval(
820814

821815
@staticmethod
822816
def _log_epoch_data(stage: str, loss: float, time: float) -> None:
823-
"""
824-
Prints the data of each epoch.
817+
"""Prints the data of each epoch.
825818
826819
Args:
827820
stage (str): Train or valid.
@@ -865,8 +858,7 @@ def test(
865858
batch_size: int = 32,
866859
num_workers: int = 0,
867860
) -> None:
868-
"""
869-
Performs the testing of the model.
861+
"""Performs the testing of the model.
870862
871863
Args:
872864
batch_size (int, optional): Sets the size of the batch.
@@ -937,8 +929,7 @@ def _load_params(self) -> None:
937929
self.ngpu = state["ngpu"]
938930

939931
def _save_model(self) -> dict[str, Any]:
940-
"""
941-
Saves the model to a file.
932+
"""Saves the model to a file.
942933
943934
Args:
944935
filename (str, optional): Name of the file. Defaults to None.

deeprank2/utils/parsing/residue.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ def __init__(
1010
absent_atom_names: list[str],
1111
):
1212
self.class_name = class_name
13-
1413
self.amino_acid_names = amino_acid_names
15-
1614
self.present_atom_names = present_atom_names
1715
self.absent_atom_names = absent_atom_names
1816

@@ -26,11 +24,7 @@ def matches(self, amino_acid_name: str, atom_names: list[str]) -> bool:
2624
return False
2725

2826
# check the atom names that should be present
29-
if not all(atom_name in atom_names for atom_name in self.present_atom_names):
30-
return False
31-
32-
# all checks passed
33-
return True
27+
return all(atom_name in atom_names for atom_name in self.present_atom_names)
3428

3529

3630
class ResidueClassParser: # noqa: D101

docs/source/installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ conda activate deeprank2
5454
pip install deeprank2
5555
```
5656

57+
We also provide a frozen environment YML file located at `env/deeprank2_frozen.yml` with all dependencies set to fixed versions. The `env/deeprank2_frozen.yml` file provides a frozen environment with all dependencies set to fixed versions. This ensures reproducibility of experiments and results by preventing changes in package versions that could occur due to updates or modifications in the default `env/deeprank2.yml`. Use this frozen environment file for a stable and consistent setup, particularly if you encounter issues with the default environment file.
58+
5759
## Manual installation (customizable)
5860

5961
(manual-installation)=

env/deeprank2.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ channels:
77
- conda-forge
88
- sbl
99
dependencies:
10-
- sbl::libcifpp>=5.1.0
11-
- sbl::dssp>=4.2.2.1
12-
- msms>=2.6.1
10+
- python=3.10
11+
- pip>=23.3
12+
- sbl::libcifpp=5.1.0
13+
- sbl::dssp=4.2.2.1
14+
- msms=2.6.1
1315
- pytorch=2.1.1
1416
- torchvision>=0.16.1
1517
- torchaudio>=2.1.1
1618
- cpuonly>=2.0
17-
- pyg>=2.4.0
19+
- pyg=2.4.0
1820
- pytorch-scatter>=2.1.2
1921
- pytorch-sparse>=0.6.18
2022
- pytorch-cluster>=1.6.3

0 commit comments

Comments
 (0)