Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9150bb6
Create .gitignore
aditya0by0 May 7, 2025
06a71a6
update precommit + github action
aditya0by0 May 7, 2025
ff1adc9
pre-commit format files
aditya0by0 May 7, 2025
d7f30d3
change graph from directed to UNDIRECTED
aditya0by0 May 7, 2025
b8189d1
add test data
aditya0by0 May 14, 2025
ad301e6
edge_features should be calculated after undirected graph
aditya0by0 May 14, 2025
344d828
directed edge which form an un-dir edge should be adjancent
aditya0by0 May 14, 2025
8a69828
add test for GraphPropertyReader
aditya0by0 May 14, 2025
e0064b8
add gt test data for aspirin
aditya0by0 May 14, 2025
a9c7228
Update test_data.py
aditya0by0 May 14, 2025
0a9760d
add more graph test
aditya0by0 May 14, 2025
1a8dcb6
first src to tgt edges then tgt to src
aditya0by0 May 14, 2025
5d4c174
add test for duplicate directed edges
aditya0by0 May 14, 2025
945ef7c
restore import
aditya0by0 May 14, 2025
53a240a
concat edge attr for undirected graph
aditya0by0 May 14, 2025
b1f2da3
concat prop values instead of edge_attr
aditya0by0 May 15, 2025
3615fb1
Merge branch 'dev' into fix/directed-to-undirected-graph
aditya0by0 May 21, 2025
7a8b664
Merge branch 'dev' into fix/directed-to-undirected-graph
aditya0by0 May 21, 2025
53ca438
inherit from ChebiOverX
aditya0by0 May 23, 2025
4319e47
`nan_to_num` numpy2.x compatibility
aditya0by0 May 25, 2025
7c0a484
add print statements
aditya0by0 May 25, 2025
ffc0b75
remove print for dataloader phase
aditya0by0 May 25, 2025
0a39749
Update .gitignore
aditya0by0 May 28, 2025
51e609e
why input channels needed? when n_atom_properties is there
aditya0by0 May 28, 2025
dcf38a4
remove in_length from config
aditya0by0 May 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
171 changes: 171 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
docs/build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# configs/ # commented as new configs can be added as a part of a feature

/.idea
/data
/logs
/results_buffer
electra_pretrained.ckpt
.isort.cfg
/.vscode
28 changes: 22 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
repos:
#- repo: https://github.com/PyCQA/isort
# rev: "5.12.0"
# hooks:
# - id: isort
- repo: https://github.com/psf/black
rev: "22.10.0"
rev: "24.2.0"
hooks:
- id: black
- id: black
- id: black-jupyter # for formatting jupyter-notebook

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args: ["--profile=black"]

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## Installation

Some requirements may not be installed successfully automatically.
Some requirements may not be installed successfully automatically.
To install the `torch-` libraries, use

`pip install torch-${lib} -f https://data.pyg.org/whl/torch-2.1.0+${CUDA}.html`

where `${lib}` is either `scatter`, `geometric`, `sparse` or `cluster`, and
`${CUDA}` is either `cpu`, `cu118` or `cu121` (depending on your system, see e.g.
`${CUDA}` is either `cpu`, `cu118` or `cu121` (depending on your system, see e.g.
[torch-geometric docs](https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html))


Expand All @@ -31,7 +31,7 @@ We recommend the following setup:

If you run the command from the `python-chebai` directory, you can use the same data for both chebai- and chebai-graph-models (e.g., Transformers and GNNs).
Then you have to use `{path-to-chebai} -> .` and `{path-to-chebai-graph} -> ../python-chebai-graph`.

Pretraining on a atom / bond masking task with PubChem data (feature-branch):
```
python3 -m chebai fit --model={path-to-chebai-graph}/configs/model/gnn_resgated_pretrain.yml --data={path-to-chebai-graph}/configs/data/pubchem_graph.yml --trainer={path-to-chebai}/configs/training/pretraining_trainer.yml
Expand Down
9 changes: 5 additions & 4 deletions chebai_graph/models/gin_net.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import typing

import torch
import torch.nn.functional as F
import torch_geometric
from torch_scatter import scatter_add

from chebai_graph.models.graph import GraphBaseNet
import torch_geometric
import torch.nn.functional as F
import torch
import typing


class AggregateMLP(torch.nn.Module):
Expand Down
40 changes: 17 additions & 23 deletions chebai_graph/models/graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import typing
from abc import ABC

import torch
import torch.nn.functional as F
Expand All @@ -15,7 +16,7 @@
logging.getLogger("pysmiles").setLevel(logging.CRITICAL)


class GraphBaseNet(ChebaiBaseNet):
class GraphBaseNet(ChebaiBaseNet, ABC):
def _get_prediction_and_labels(self, data, labels, output):
return torch.sigmoid(output), labels.int()

Expand Down Expand Up @@ -84,8 +85,6 @@ class ResGatedGraphConvNetBase(GraphBaseNet):

def __init__(self, config: typing.Dict, **kwargs):
super().__init__(**kwargs)

self.in_length = config["in_length"]
self.hidden_length = config["hidden_length"]
self.dropout_rate = config["dropout_rate"]
self.n_conv_layers = config["n_conv_layers"] if "n_conv_layers" in config else 3
Expand All @@ -104,26 +103,26 @@ def __init__(self, config: typing.Dict, **kwargs):

self.activation = F.elu
self.dropout = nn.Dropout(self.dropout_rate)

self.convs = torch.nn.ModuleList([])
for i in range(self.n_conv_layers):
if i == 0:
self.convs.append(
tgnn.ResGatedGraphConv(
self.n_atom_properties,
self.in_length,
# dropout=self.dropout_rate,
edge_dim=self.n_bond_properties,
)
)

self.convs.append(
tgnn.ResGatedGraphConv(
self.n_atom_properties,
self.hidden_length,
# dropout=self.dropout_rate,
edge_dim=self.n_bond_properties,
)
)

for _ in range(self.n_conv_layers - 1):
self.convs.append(
tgnn.ResGatedGraphConv(
self.in_length, self.in_length, edge_dim=self.n_bond_properties
self.hidden_length,
self.hidden_length,
# dropout=self.dropout_rate,
edge_dim=self.n_bond_properties,
)
)
self.final_conv = tgnn.ResGatedGraphConv(
self.in_length, self.hidden_length, edge_dim=self.n_bond_properties
)

def forward(self, batch):
graph_data = batch["features"][0]
Expand All @@ -136,11 +135,6 @@ def forward(self, batch):
a = self.activation(
conv(a, graph_data.edge_index.long(), edge_attr=graph_data.edge_attr)
)
a = self.activation(
self.final_conv(
a, graph_data.edge_index.long(), edge_attr=graph_data.edge_attr
)
)
return a


Expand Down
4 changes: 2 additions & 2 deletions chebai_graph/preprocessing/collate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Dict

import torch
from chebai.preprocessing.collate import RaggedCollator
from torch_geometric.data import Data as GeomData
from torch_geometric.data.collate import collate as graph_collate
from chebai_graph.preprocessing.structures import XYGraphData

from chebai.preprocessing.collate import RaggedCollator
from chebai_graph.preprocessing.structures import XYGraphData


class GraphCollator(RaggedCollator):
Expand Down
Loading