Skip to content

Commit

Permalink
Merge pull request #1 from GT4SD/main
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
yvesnana authored Aug 30, 2024
2 parents 5373f54 + 60fb56b commit 83ddc11
Show file tree
Hide file tree
Showing 39 changed files with 172 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .clabot
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "contributors": [ "Ashish13898", "C-nit", "GitHub Action", "NicolaiRee", "O-Schilter", "YoelShoshan", "avaucher", "christofid", "donovat", "drugilsberg", "edux300", "elzinga-ibm-research", "federicozipoli", "georgosgeorgos", "helderlopes97", "helenaMontenegro", "hoffmansc", "jannisborn", "jrs021", "kishimoto1974", "kwehden", "mirunacrt", "polat-c", "yvesnana" ], "message": "Thanks a lot for working on GT4SD, we strongly value contributions from our users. It appears that one of the commiters in the PR did not sign the CLA for contributors. To do so, you can open an issue to sign the CLA clicking [here](https://github.com/GT4SD/gt4sd-core/issues/new?labels=cla-signing&template=cla-signature.yaml&title=CLA+signature). More details can be found [here](https://github.com/GT4SD/gt4sd-core/blob/main/CONTRIBUTING.md#contributor-license-agreement)." }
{ "contributors": [ "Ashish13898", "C-nit", "GitHub Action", "NicolaiRee", "O-Schilter", "YoelShoshan", "avaucher", "christofid", "donovat", "drugilsberg", "edux300", "elzinga-ibm-research", "federicozipoli", "fiskrt", "georgosgeorgos", "helderlopes97", "helenaMontenegro", "hoffmansc", "jannisborn", "jrs021", "kishimoto1974", "kwehden", "mirunacrt", "polat-c", "yvesnana" ], "message": "Thanks a lot for working on GT4SD, we strongly value contributions from our users. It appears that one of the commiters in the PR did not sign the CLA for contributors. To do so, you can open an issue to sign the CLA clicking [here](https://github.com/GT4SD/gt4sd-core/issues/new?labels=cla-signing&template=cla-signature.yaml&title=CLA+signature). More details can be found [here](https://github.com/GT4SD/gt4sd-core/blob/main/CONTRIBUTING.md#contributor-license-agreement)." }
4 changes: 2 additions & 2 deletions .github/workflows/cla-signature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ jobs:
with:
branch: main
directory: gt4sd-core-main
github_token: ${{ secrets.GH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Mark signature in the issue
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
with:
add-labels: cla-signed
repo-token: ${{ secrets.GH_TOKEN }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Close issue (existing contributor)
uses: peter-evans/close-issue@v1
if: ${{ env.signing_commit_hash == '' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
conda activate gt4sd
pip install --no-deps .
# make sure we can build docs using specific dependencies
pip install "attrs==20.3.0" "markdown-it-py==0.6.2"
pip install "attrs==20.3.0" "markdown-it-py==1.0.0"
cd docs && make html && cd ..
- name: Commit documentation changes
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
max-parallel: 3
matrix:
python-version:
- "3.10"
- 3.8
- 3.7
os:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
defaults:
run:
shell: bash -l {0} # for conda command
env:
GIT_CLONE_PROTECTION_ACTIVE: false
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
Expand Down Expand Up @@ -48,7 +50,7 @@ jobs:
- name: Check mypy
run: |
conda activate gt4sd
python -m mypy src/gt4sd
python -m mypy src/gt4sd --show-traceback
- name: Run pytests
run: |
conda activate gt4sd
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Almost all pretrained models are also available via `gradio`-powered [web apps](

Currently `gt4sd` relies on:

- python>=3.7,<3.9
- pip>=19.1,<20.3
- python>=3.7,<=3.10
- pip==24.0

We are actively working on relaxing these, so stay tuned or help us with this by [contributing](./CONTRIBUTING.md) to the project.
If you need others, help us by [contributing](./CONTRIBUTING.md) to the project.

### Conda

Expand Down
5 changes: 3 additions & 2 deletions conda_cpu_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ channels:
- https://conda.anaconda.org/pyg
- https://conda.anaconda.org/conda-forge
dependencies:
- python>=3.7,<3.9
- pip>=19.1,<20.3
- setuptools==69.5.1
- python>=3.7,<3.11
- pip=24.0
- pytorch>=1.0,<=1.12.1
- cpuonly
- pytorch-scatter<=2.0.9=*cu102*
Expand Down
5 changes: 3 additions & 2 deletions conda_cpu_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ channels:
- https://conda.anaconda.org/pyg
- https://conda.anaconda.org/conda-forge
dependencies:
- python>=3.7,<3.9
- pip>=19.1,<20.3
- setuptools==69.5.1
- python>=3.7,<3.11
- pip=24.0
- pytorch>=1.0,<=1.12.1
- cpuonly
- pytorch-scatter<=2.0.9
Expand Down
5 changes: 3 additions & 2 deletions conda_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ channels:
- https://conda.anaconda.org/pyg
- https://conda.anaconda.org/conda-forge
dependencies:
- python>=3.7,<3.9
- pip>=19.1,<20.3
- setuptools==69.5.1
- python>=3.7,<3.11
- pip=24.0
- pytorch>=1.0,<=1.12.1=*cu*
- pytorch-scatter<=2.0.9=*cu102*
- torchvision<=0.13.1=*cu*
Expand Down
11 changes: 5 additions & 6 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
better-apidoc==0.3.1
better-apidoc==0.3.2
black==22.3.0
docutils==0.17.1
flake8==3.8.4
flask==1.1.2
flask_login==0.5.0
# isort==5.7.0
licenseheaders==0.8.8
mypy==0.950
myst-parser==0.13.3
pytest==6.1.1
mypy>=1.0.0
myst-parser==1.0.0
pytest==6.2.5
pytest-cov==2.10.1
sphinx==3.4.3
sphinx>=5
sphinx-autodoc-typehints==1.11.1
jinja2<3.1.0
sphinx_rtd_theme==0.5.1
12 changes: 11 additions & 1 deletion notebooks/discovery-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
"id": "d6a65c61",
"metadata": {},
"outputs": [],
"source": [
"!pip install --upgrade protobuf"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "94cd4c8c",
"metadata": {},
"outputs": [],
"source": [
"from typing import List\n",
"from rdkit import Chem\n",
Expand Down Expand Up @@ -2325,7 +2335,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand Down
11 changes: 8 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# pypi requirements
setuptools==69.5.1
accelerate>=0.12,<0.20.0
datasets>=1.11.0
diffusers<=0.6.0
Expand All @@ -11,26 +12,28 @@ gt4sd-molformer>=0.1.1
gt4sd-trainer-hf-pl>=0.0.2
keras>=2.3.1,<2.11.0
keybert>=0.7.0
markdown-it-py<3.0.0,>=2.2.0
markdown-it-py
minio==7.0.1
modlamp>=4.0.0
molgx>=0.22.0a1
nglview>=3.0.3
numpy>=1.16.5,<1.24.0
pandas<=2.0.3
protobuf<3.20
pyarrow>=8.0.0
pydantic>=1.7.3,<2.0.0
pydantic>=2.0.0
pymatgen>=2022.11.7
PyTDC==0.3.7
pytorch_lightning<=1.7.7
pyyaml>=5.4.1
rdkit>=2022.3.5
rdkit-stubs>=0.7
regex>=2.5.91
reinvent-chemistry==0.0.38
sacremoses>=0.0.41
scikit-learn>=1.0.0,<1.3.0
scikit-optimize>=0.8.1
scipy>=1.0.0
scipy>=1.0.0,<=1.11.0
sentencepiece>=0.1.95
sentence_transformers>1.0,<=2.2.2
sympy>=1.10.1
Expand All @@ -46,3 +49,5 @@ transformers>=4.22.0,<=4.24.0
typing_extensions>=3.7.4.3
wheel>=0.26
xgboost>=1.7.6
sphinx_rtd_theme==0.5.1
pydantic-settings>=2.0.0
11 changes: 10 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,20 @@ ignore = E203, E501, W503
[mypy]
check_untyped_defs = True
plugins = pydantic.mypy
exclude = ^src/gt4sd/frameworks/gflownet/envs

[mypy-gt4sd.frameworks.gflownet.envs.*]
follow_imports = skip

[mypy-pytest.*]
ignore_missing_imports = True

[mypy-rdkit.*]
ignore_missing_imports = True

[mypy-rdkit-stubs.*]
ignore_errors = True

[mypy-setuptools.*]
ignore_missing_imports = True

Expand Down Expand Up @@ -141,7 +148,6 @@ ignore_missing_imports = True
[mypy-transformers.*]
ignore_missing_imports = True

# to avoid mypy from crashing (https://github.com/python/mypy/issues/11045)
[mypy-transformers.trainer]
check_untyped_defs = False

Expand Down Expand Up @@ -284,4 +290,7 @@ ignore_missing_imports = True
ignore_missing_imports = True

[mypy-xgboost.*]
ignore_missing_imports = True

[mypy-pydantic_settings.*]
ignore_missing_imports = True
2 changes: 1 addition & 1 deletion src/gt4sd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#
"""Module initialization."""

__version__ = "1.4.1"
__version__ = "1.4.2"
__name__ = "gt4sd"

# NOTE: configure SSL to allow unverified contexts by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ def validate_output(self, sequences: List[Any]) -> Tuple[List[Any], List[int]]:
if isinstance(self.tokenizer.text_tokenizer, PolymerGraphTokenizer):
# Copolymer models require specific validation
return validate_molecules(
pattern_list=list(zip(*sequences))[0],
pattern_list=list(zip(*sequences))[0], # type: ignore
input_type=MoleculeFormat.copolymer,
)

Expand Down Expand Up @@ -1086,9 +1086,11 @@ def filter_substructures(
f"{keep} is not a valid SMILES/SELFIES. Instead substructure filtering "
f"based on sequence alone can be done and is set to: {self.text_filtering}"
)
if keep not in self.substructures_to_keep and not Chem.MolFromSmiles(
if keep not in self.substructures_to_keep and not Chem.MolFromSmiles( # type: ignore
self.target
).HasSubstructMatch(subs_mol):
).HasSubstructMatch(
subs_mol
):
logger.info(
f"{keep} could not be identified in SMILES/SELFIES on text level AND no "
"substructure match occurred, hence it will be ignored"
Expand Down Expand Up @@ -1120,7 +1122,7 @@ def filter_substructures(
sane = False
break
else:
if not mol.HasSubstructMatch(subs_mol):
if not mol.HasSubstructMatch(subs_mol): # type: ignore
# Desired substructure not found
sane = False
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ def filter_stubbed(
Tuple of tuples of length 2 with filtered, generated molecule and its properties.
"""

seed = Chem.MolFromSmiles(target)
seed = Chem.MolFromSmiles(target) # type: ignore

seed_atoms = len(list(seed.GetAtoms()))
seed_bonds = seed.GetNumBonds()
seed_atoms = len(list(seed.GetAtoms())) # type: ignore
seed_bonds = seed.GetNumBonds() # type: ignore

smis: List[str] = []
props: List[str] = []
for smi, prop in property_sequences:
if smi == "":
continue
try:
mol = Chem.MolFromSmiles(smi)
num_atoms = len(list(mol.GetAtoms()))
num_bonds = mol.GetNumBonds()
mol = Chem.MolFromSmiles(smi) # type: ignore
num_atoms = len(list(mol.GetAtoms())) # type: ignore
num_bonds = mol.GetNumBonds() # type: ignore

if num_atoms > (threshold * seed_atoms) and num_bonds > (
threshold * seed_bonds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def __init__(
targets: Dict[str, float],
property_predictors: Dict[str, PropertyPredictor],
representations: RepresentationsDict,
representation_order: List[str] = None,
representation_order: Optional[List[str]] = None,
scalers: Optional[Dict[str, Scaler]] = None,
weights: Optional[Dict[str, float]] = None,
custom_score_function: Optional[
Expand Down
22 changes: 12 additions & 10 deletions src/gt4sd/algorithms/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

import collections
from collections.abc import Hashable
import logging
import os
import shutil
Expand Down Expand Up @@ -233,7 +233,7 @@ def sample(self, number_of_items: int = 100) -> Iterator[S]:
try:
valid_item = self.configuration.validate_item(item)
# check if sample is hashable
if not isinstance(item, collections.Hashable):
if not isinstance(item, Hashable):
yield valid_item
item_set.add(str(index))
else:
Expand Down Expand Up @@ -623,9 +623,11 @@ def save_version_from_training_pipeline_arguments(
target_version,
)
filepaths_mapping = {
filename: source_filepath
if os.path.exists(source_filepath)
else os.path.join(source_missing_path, filename)
filename: (
source_filepath
if os.path.exists(source_filepath)
else os.path.join(source_missing_path, filename)
)
for filename, source_filepath in filepaths_mapping.items()
}
logger.info(f"Saving artifacts into {target_path}...")
Expand Down Expand Up @@ -713,9 +715,11 @@ def upload_version_from_training_pipeline_arguments(

# mapping between filenames and paths for a version.
filepaths_mapping = {
filename: source_filepath
if os.path.exists(source_filepath)
else os.path.join(source_missing_path, filename)
filename: (
source_filepath
if os.path.exists(source_filepath)
else os.path.join(source_missing_path, filename)
)
for filename, source_filepath in filepaths_mapping.items()
}

Expand Down Expand Up @@ -908,8 +912,6 @@ def get_configuration_class_with_attributes(


class PropertyPredictor(ABC, Generic[S, U]):
"""TODO: Might be deprecated in future release."""

def __init__(self, context: U) -> None:
"""Property predictor to investigate items.
Expand Down
4 changes: 2 additions & 2 deletions src/gt4sd/algorithms/generation/diffusion/geodiff/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ def visualize_2d_input(self, data: Data) -> None:
molSize = (450, 300)
drawer = MD2.MolDraw2DSVG(molSize[0], molSize[1])
drawer.DrawMolecule(mc)
drawer.FinishDrawing()
svg = drawer.GetDrawingText()
drawer.FinishDrawing() # type: ignore
svg = drawer.GetDrawingText() # type: ignore
display(SVG(svg.replace("svg:", "")))

def visualize_3d(self, mols_gen: List[Chem.Mol]) -> None:
Expand Down
Loading

0 comments on commit 83ddc11

Please sign in to comment.