Skip to content

Commit

Permalink
Merge pull request #45 from usnistgov/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
knc6 authored Nov 15, 2021
2 parents 7c2bd37 + 484b755 commit b5e8f50
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 64 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ jobs:
coverage report -m
codecov
codecov --token="85bd9c5d-9e55-4f6d-bd69-350ee5e3bb41"
# alignn_train_folder.py --root_dir "alignn/examples/sample_data" --config "alignn/examples/sample_data/config_example.json" --output_dir=temp
echo 'Train folder'
train_folder.py -h
echo 'Pre-trained models'
pretrained.py -h
#train_folder.py --root_dir "alignn/examples/sample_data" --config "alignn/examples/sample_data/config_example.json" --output_dir=temp
2 changes: 1 addition & 1 deletion alignn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Version number."""
__version__ = "2021.11.13"
__version__ = "2021.11.14"
10 changes: 7 additions & 3 deletions alignn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@

# from typing import List

VERSION = (
subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
)
try:
VERSION = (
subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
)
except Exception as exp:
VERSION = "NA"
pass


FEATURESET_SIZE = {"basic": 11, "atomic_number": 1, "cfid": 438, "cgcnn": 92}
Expand Down
120 changes: 115 additions & 5 deletions alignn/pretrained.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

"""Module to download and load pre-trained ALIGNN models."""
import requests
import os
Expand All @@ -12,11 +14,119 @@
from jarvis.core.atoms import Atoms
from jarvis.core.graphs import Graph

all_models = loadjson(
str(os.path.join(os.path.dirname(__file__), "pretrained_models.json"))
)


# Name of the model, figshare link, number of outouts
all_models = {
"jv_formation_energy_peratom_alignn": [
"https://figshare.com/ndownloader/files/31458679",
1,
],
"jv_optb88vdw_total_energy_alignn": [
"https://figshare.com/ndownloader/files/31459642",
1,
],
"jv_optb88vdw_bandgap_alignn": [
"https://figshare.com/ndownloader/files/31459636",
1,
],
"jv_mbj_bandgap_alignn": [
"https://figshare.com/ndownloader/files/31458694",
1,
],
"jv_spillage_alignn": [
"https://figshare.com/ndownloader/files/31458736",
1,
],
"jv_slme_alignn": ["https://figshare.com/ndownloader/files/31458727", 1],
"jv_bulk_modulus_kv_alignn": [
"https://figshare.com/ndownloader/files/31458649",
1,
],
"jv_shear_modulus_gv_alignn": [
"https://figshare.com/ndownloader/files/31458724",
1,
],
"jv_n-Seebeck_alignn": [
"https://figshare.com/ndownloader/files/31458718",
1,
],
"jv_n-powerfact_alignn": [
"https://figshare.com/ndownloader/files/31458712",
1,
],
"jv_magmom_oszicar_alignn": [
"https://figshare.com/ndownloader/files/31458685",
1,
],
"jv_kpoint_length_unit_alignn": [
"https://figshare.com/ndownloader/files/31458682",
1,
],
"jv_avg_elec_mass_alignn": [
"https://figshare.com/ndownloader/files/31458643",
1,
],
"jv_avg_hole_mass_alignn": [
"https://figshare.com/ndownloader/files/31458646",
1,
],
"jv_epsx_alignn": ["https://figshare.com/ndownloader/files/31458667", 1],
"jv_mepsx_alignn": ["https://figshare.com/ndownloader/files/31458703", 1],
"jv_max_efg_alignn": [
"https://figshare.com/ndownloader/files/31458691",
1,
],
"jv_ehull_alignn": ["https://figshare.com/ndownloader/files/31458658", 1],
"jv_dfpt_piezo_max_dielectric_alignn": [
"https://figshare.com/ndownloader/files/31458652",
1,
],
"jv_dfpt_piezo_max_dij_alignn": [
"https://figshare.com/ndownloader/files/31458655",
1,
],
"jv_exfoliation_energy_alignn": [
"https://figshare.com/ndownloader/files/31458676",
1,
],
"mp_e_form_alignnn": [
"https://figshare.com/ndownloader/files/31458811",
1,
],
"mp_gappbe_alignnn": [
"https://figshare.com/ndownloader/files/31458814",
1,
],
"qm9_U0_alignn": ["https://figshare.com/ndownloader/files/31459054", 1],
"qm9_U_alignn": ["https://figshare.com/ndownloader/files/31459051", 1],
"qm9_alpha_alignn": ["https://figshare.com/ndownloader/files/31459027", 1],
"qm9_gap_alignn": ["https://figshare.com/ndownloader/files/31459036", 1],
"qm9_G_alignn": ["https://figshare.com/ndownloader/files/31459033", 1],
"qm9_HOMO_alignn": ["https://figshare.com/ndownloader/files/31459042", 1],
"qm9_LUMO_alignn": ["https://figshare.com/ndownloader/files/31459045", 1],
"qm9_ZPVE_alignn": ["https://figshare.com/ndownloader/files/31459057", 1],
"hmof_co2_absp_alignnn": [
"https://figshare.com/ndownloader/files/31459198",
5,
],
"hmof_max_co2_adsp_alignnn": [
"https://figshare.com/ndownloader/files/31459207",
1,
],
"hmof_surface_area_m2g_alignnn": [
"https://figshare.com/ndownloader/files/31459222",
1,
],
"hmof_surface_area_m2cm3_alignnn": [
"https://figshare.com/ndownloader/files/31459219",
1,
],
"hmof_pld_alignnn": ["https://figshare.com/ndownloader/files/31459216", 1],
"hmof_lcd_alignnn": ["https://figshare.com/ndownloader/files/31459201", 1],
"hmof_void_fraction_alignnn": [
"https://figshare.com/ndownloader/files/31459228",
1,
],
}
parser = argparse.ArgumentParser(
description="Atomistic Line Graph Neural Network Pretrained Models"
)
Expand Down
41 changes: 0 additions & 41 deletions alignn/pretrained_models.json

This file was deleted.

19 changes: 15 additions & 4 deletions alignn/tests/test_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,23 @@


def test_runtime_training():
cmd1 = 'python alignn/scripts/train_folder.py --root_dir "alignn/examples/sample_data" --config "alignn/examples/sample_data/config_example.json"'
cmd1 = 'python alignn/train_folder.py --root_dir "alignn/examples/sample_data" --config "alignn/examples/sample_data/config_example.json"'
os.system(cmd1)
cmd2 = 'python alignn/scripts/train_folder.py --root_dir "alignn/examples/sample_data" --classification_threshold 0.01 --config "alignn/examples/sample_data/config_example.json"'
cmd2 = 'python alignn/train_folder.py --root_dir "alignn/examples/sample_data" --classification_threshold 0.01 --config "alignn/examples/sample_data/config_example.json"'
os.system(cmd2)
cmd3 = 'python alignn/scripts/train_folder.py --root_dir "alignn/examples/sample_data_multi_prop" --config "alignn/examples/sample_data/config_example.json"'
cmd3 = 'python alignn/train_folder.py --root_dir "alignn/examples/sample_data_multi_prop" --config "alignn/examples/sample_data/config_example.json"'
os.system(cmd3)


def test_minor_configs():
tmp = config
# tmp["log_tensorboard"] = True
tmp["n_early_stopping"] = 2
tmp["model"]["name"] = "alignn"
config["write_predictions"] = True
result = train_dgl(tmp)


def test_models():
"""Test CGCNN end to end training."""
config["model"]["name"] = "dense_alignn"
Expand All @@ -57,6 +66,7 @@ def test_models():
print()
print()

config["write_predictions"] = True
config["model"]["name"] = "alignn"
t1 = time.time()
result = train_dgl(config)
Expand Down Expand Up @@ -172,7 +182,7 @@ def test_models():

config["model"]["name"] = "alignn_cgcnn"
config["write_predictions"] = False
config["save_dataloader"] = False
config["save_dataloader"] = True
config["classification_threshold"] = 0.0
t1 = time.time()
result = train_dgl(config)
Expand Down Expand Up @@ -226,6 +236,7 @@ def test_pretrained():
os.system(cmd1)


# test_minor_configs()
# test_pretrained()
# test_runtime_training()

Expand Down
9 changes: 7 additions & 2 deletions alignn/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
from typing import Any, Dict, Union
import ignite
import torch

from ignite.contrib.handlers import TensorboardLogger
from ignite.handlers.stores import EpochOutputStore
try:
from ignite.contrib.handlers.stores import EpochOutputStore
# For different version of pytorch-ignite
except Exception as exp:
from ignite.handlers.stores import EpochOutputStore

# from ignite.contrib.handlers.stores import EpochOutputStore
pass
from ignite.handlers import EarlyStopping
from ignite.contrib.handlers.tensorboard_logger import (
global_step_from_engine,
Expand Down
2 changes: 2 additions & 0 deletions alignn/scripts/train_folder.py → alignn/train_folder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

"""Module to train for a folder with formatted dataset."""
import csv
import os
Expand Down
9 changes: 2 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setuptools.setup(
name="alignn",
version="2021.11.13",
version="2021.11.14",
author="Kamal Choudhary, Brian DeCost",
author_email="[email protected]",
description="alignn",
Expand All @@ -33,12 +33,7 @@
"pyparsing>=2.2.1,<3",
],
# scripts=["alignn/alignn_train_folder.py"],
entry_points={
"console_scripts": [
"train_folder=alignn.script.train_folder"
"pretrained=alignn.pretrained"
],
},
scripts=['alignn/pretrained.py','alignn/train_folder.py'],
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/usnistgov/alignn",
Expand Down

0 comments on commit b5e8f50

Please sign in to comment.