Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] lint/test/docs on PR and push to main #742

Merged
merged 51 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
40d74f5
lint/test on PR and push to main
lbluque Jun 26, 2024
02affe9
Run docs CI on every push to main
zulissimeta Jun 26, 2024
d33efa3
Merge pull request #743 from FAIR-Chem/docs-build-every-push
lbluque Jun 26, 2024
bd44f25
Fail docs when a notebook doesn't build
zulissimeta Jun 26, 2024
367d693
Merge pull request #750 from FAIR-Chem/main
zulissimeta Jul 8, 2024
cec7af7
skip eval_metrics fix in tutorial_utils
zulissimeta Jul 8, 2024
abe5889
when writing extxyz in docs, specific force as a column explicitly
zulissimeta Jul 8, 2024
c522ef0
task.dataset -> dataset.format
zulissimeta Jul 8, 2024
7f5d308
small fixes in config in tutorial
zulissimeta Jul 8, 2024
a4e9136
make train dataset optional if only used test dataset
zulissimeta Jul 8, 2024
7da170b
more small fixes if you don't specify a train dataset
zulissimeta Jul 8, 2024
dd3f70d
loss_fns -> loss_functions in tutorial
zulissimeta Jul 8, 2024
283af83
eval_metrics -> evaluation_metrics in OCP tutorial
zulissimeta Jul 8, 2024
655912c
FixAtoms as int
zulissimeta Jul 9, 2024
cbebc4b
don't clear train dataset if present but src is missing
zulissimeta Jul 9, 2024
bf16cad
invert train dataset load logic
zulissimeta Jul 9, 2024
a853451
fix logic
zulissimeta Jul 9, 2024
bf2b26e
bool mask
zulissimeta Jul 9, 2024
6823551
require docs test on main
zulissimeta Jul 9, 2024
a5d94fc
Merge branch 'lint-test-triggers' of https://github.com/FAIR-Chem/fai…
lbluque Jul 9, 2024
c221617
pull_request_review to trigger doc build
lbluque Jul 9, 2024
df28acc
use FixAtoms fix from stress-relaxations branch
lbluque Jul 9, 2024
f03f845
sneak in a push trigger to test docs
lbluque Jul 9, 2024
5ace5ba
upload only html artifact
lbluque Jul 10, 2024
f5ee8fd
sneaky push
lbluque Jul 10, 2024
db62854
fix artifact path
lbluque Jul 10, 2024
36a17ad
fix job names
lbluque Jul 10, 2024
9950796
no deploy docs on push
lbluque Jul 10, 2024
d90aa27
Merge branch 'main' into lint-test-triggers
zulissimeta Jul 11, 2024
b125659
add devcontainer settings
zulissimeta Jul 11, 2024
1e6e101
Merge branch 'lint-test-triggers' of github.com:FAIR-Chem/fairchem in…
zulissimeta Jul 11, 2024
152565b
small fix to legacy tutorial
zulissimeta Jul 11, 2024
350f469
small fix to legacy tutorial
zulissimeta Jul 12, 2024
64c8e54
another small tutorial fix
zulissimeta Jul 12, 2024
91c31b3
Merge branch 'main' into lint-test-triggers
zulissimeta Jul 12, 2024
6675b80
add rest of tutorial back
zulissimeta Jul 12, 2024
14cfab1
clean up logic in load_datasets
zulissimeta Jul 12, 2024
30c24b7
typo
zulissimeta Jul 12, 2024
c840e47
logic typo in load_datasets
zulissimeta Jul 12, 2024
1ae5401
Merge branch 'main' into lint-test-triggers
zulissimeta Jul 12, 2024
372b6ec
convert all md to ipynb on launch
zulissimeta Jul 12, 2024
20970d6
Merge branch 'lint-test-triggers' of github.com:FAIR-Chem/fairchem in…
zulissimeta Jul 12, 2024
0d5d952
add minimum spec on devcontainer to make sure everything runs
zulissimeta Jul 12, 2024
2ffe035
include subdirectories in conversion
zulissimeta Jul 12, 2024
788847d
758 fix
mshuaibii Jul 12, 2024
3611942
minor fixes
mshuaibii Jul 12, 2024
eceb4c4
relax otf
mshuaibii Jul 12, 2024
a98e50d
Merge branch 'lint-test-triggers' into relax758_fix
zulissimeta Jul 13, 2024
0ef7cb0
Merge pull request #760 from FAIR-Chem/relax758_fix
zulissimeta Jul 13, 2024
99c2dcb
typo
zulissimeta Jul 13, 2024
79f4aab
try removing comments in build_docs yml
zulissimeta Jul 13, 2024
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
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"image": "mcr.microsoft.com/devcontainers/anaconda:0.205.0-3",
"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh",
"forwardPorts": [
8888
],
"postStartCommand": "nohup bash -c 'jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root --NotebookApp.token='' &'",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
]
}
},
"hostRequirements": {
"memory": "16gb",
}
}
11 changes: 11 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
if [ -f packages/requirements.txt ]; then pip install -r packages/requirements.txt; fi
if [ -f packages/requirements-optional.txt ]; then pip install -r packages/requirements-optional.txt; fi
pip install -e packages/fairchem-core[dev]
pip install -e packages/fairchem-data-oc[dev]
pip install -e packages/fairchem-demo-ocpapi[dev]
pip install -e packages/fairchem-applications-cattsunami
pip install jupytext

# Convert all .md docs to ipynb for easy viewing in vscode later!
jupytext --to ipynb docs/**/*.md
26 changes: 10 additions & 16 deletions .github/workflows/docs.yml → .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: documentation
# build the documentation and upload the built artifact
name: build documentation

on:
workflow_call:
workflow_dispatch:
# this will run a build when a review is submitted to make sure the PR does not break docs before merging
pull_request_review:
types: [submitted, edited]
lbluque marked this conversation as resolved.
Show resolved Hide resolved

# This job installs dependencies, build the book, and pushes it to `gh-pages`
jobs:
build-and-deploy:
build:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -36,17 +39,8 @@ jobs:
run: |
jupyter-book build docs

# Deploy the book's HTML to gh-pages branch # TODO remove once ODAC link updated
- name: Deploy to ghpages branch
uses: peaceiris/actions-gh-pages@v3
- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_build/html

- name: Deploy to fair-chem.github.io
uses: peaceiris/actions-gh-pages@v4
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: FAIR-Chem/fair-chem.github.io
publish_branch: gh-pages
publish_dir: docs/_build/html
name: docs-html
path: docs/_build/html/*
34 changes: 34 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: build and deploy docs

on:
workflow_call:
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/build_docs.yml

deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Download docs artifact
uses: actions/download-artifact@v4
with:
name: docs-html
path: docs-html/

- name: Deploy to ghpages branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs-html

- name: Deploy to fair-chem.github.io
uses: peaceiris/actions-gh-pages@v4
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: FAIR-Chem/fair-chem.github.io
publish_branch: gh-pages
publish_dir: docs-html
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: lint

on:
push:
workflow_call:
workflow_dispatch:
pull_request:
branches: [main]
push:
zulissimeta marked this conversation as resolved.
Show resolved Hide resolved

jobs:
lint:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: tests

on:
workflow_call:
workflow_dispatch:
pull_request:
branches: [main]
workflow_dispatch:
push:
branches: [main]

jobs:
test:
Expand Down
2 changes: 2 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ sphinx:
autosummary_generate: True
autoapi_dirs: ['../src/fairchem/core','../src/fairchem/data','../src/fairchem/applications/AdsorbML/adsorbml','../src/fairchem/applications/cattsunami','../src/fairchem/demo/ocpapi']
autoapi_python_use_implicit_namespaces: True
nb_execution_show_tb: True
nb_execution_raise_on_error: True
4 changes: 3 additions & 1 deletion docs/core/fine-tuning/fine-tuning-oxides.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,23 @@ yml = generate_yml_config(checkpoint_path, 'config.yml',
'optim.loss_force', # the checkpoint setting causes an error
'dataset', 'test_dataset', 'val_dataset'],
update={'gpus': 1,
'task.dataset': 'ase_db',
'optim.eval_every': 10,
'optim.max_epochs': 1,
'optim.batch_size': 4,
'logger':'tensorboard', # don't use wandb!
# Train data
'dataset.train.src': 'train.db',
'dataset.train.format': 'ase_db',
'dataset.train.a2g_args.r_energy': True,
'dataset.train.a2g_args.r_forces': True,
# Test data - prediction only so no regression
'dataset.test.src': 'test.db',
'dataset.test.format': 'ase_db',
'dataset.test.a2g_args.r_energy': False,
'dataset.test.a2g_args.r_forces': False,
# val data
'dataset.val.src': 'val.db',
'dataset.val.format': 'ase_db',
'dataset.val.a2g_args.r_energy': True,
'dataset.val.a2g_args.r_forces': True,
})
Expand Down
8 changes: 7 additions & 1 deletion docs/core/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ with ase.db.connect('full_data.db') as full_db:
if 'tag' in atoms.info['key_value_pairs']:
atoms.info['key_value_pairs']['tag'] = int(atoms.info['key_value_pairs']['tag'])

for key in atoms.info["key_value_pairs"]:
if atoms.info["key_value_pairs"][key] == "True":
atoms.info["key_value_pairs"][key] = True
elif atoms.info["key_value_pairs"][key] == "False":
atoms.info["key_value_pairs"][key] = False

subset_db.write(atoms, **atoms.info['key_value_pairs'])
```

Expand Down Expand Up @@ -78,11 +84,11 @@ yml = generate_yml_config(checkpoint_path, 'config.yml',
'dataset', 'slurm'],
update={'amp': True,
'gpus': 1,
'task.dataset': 'ase_db',
'task.prediction_dtype': 'float32',
'logger':'tensorboard', # don't use wandb!
# Test data - prediction only so no regression
'dataset.test.src': 'data.db',
'dataset.test.format': 'ase_db',
'dataset.test.a2g_args.r_energy': False,
'dataset.test.a2g_args.r_forces': False,
'dataset.test.select_args.selection': 'natoms>5,xc=PBE',
Expand Down
40 changes: 20 additions & 20 deletions docs/legacy_tutorials/OCP_Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ dyn.run(fmax=0, steps=100)
traj = ase.io.read("data/toy_c3h8_relax.traj", ":")

# convert traj format to extxyz format (used by OC20 dataset)
columns = (['symbols','positions', 'move_mask', 'tags'])
columns = (['symbols','positions', 'move_mask', 'tags', 'forces'])
with open('data/toy_c3h8_relax.extxyz','w') as f:
extxyz.write_xyz(f, traj, columns=columns)
```
Expand Down Expand Up @@ -925,8 +925,8 @@ trainer = OCPTrainer(
dataset=dataset,
optimizer=optimizer,
outputs={},
loss_fns={},
eval_metrics={},
loss_functions={},
evaluation_metrics={},
name="s2ef",
identifier="S2EF-example",
run_dir=".", # directory to save results if is_debug=False. Prediction files are saved here so be careful not to override!
Expand Down Expand Up @@ -1007,8 +1007,8 @@ pretrained_trainer = OCPTrainer(
dataset=dataset,
optimizer=optimizer,
outputs={},
loss_fns={},
eval_metrics={},
loss_functions={},
evaluation_metrics={},
name="s2ef",
identifier="S2EF-val-example",
run_dir="./", # directory to save results if is_debug=False. Prediction files are saved here so be careful not to override!
Expand Down Expand Up @@ -1211,8 +1211,8 @@ energy_trainer = OCPTrainer(
dataset=dataset,
optimizer=optimizer,
outputs={},
loss_fns={},
eval_metrics={},
loss_functions={},
evaluation_metrics={},
name="is2re",
identifier="IS2RE-example",
run_dir="./", # directory to save results if is_debug=False. Prediction files are saved here so be careful not to override!
Expand Down Expand Up @@ -1289,8 +1289,8 @@ pretrained_energy_trainer = OCPTrainer(
dataset=dataset,
optimizer=optimizer,
outputs={},
loss_fns={},
eval_metrics={},
loss_functions={},
evaluation_metrics={},
name="is2re",
identifier="IS2RE-val-example",
run_dir="./", # directory to save results if is_debug=False. Prediction files are saved here so be careful not to override!
Expand Down Expand Up @@ -1427,7 +1427,6 @@ task = {
'grad_input': 'atomic forces',
'train_on_free_atoms': True,
'eval_on_free_atoms': True,
'relax_dataset': {"src": relax_dataset},
'write_pos': True,
'relaxation_steps': 200,
'num_relaxation_batches': 1,
Expand Down Expand Up @@ -1489,10 +1488,11 @@ optimizer = {
'force_coefficient': 100,
}
# Dataset
dataset = [
{'src': train_src, 'normalize_labels': False}, # train set
{'src': val_src}, # val set (optional)
]
dataset = {
'train': {'src': train_src, 'normalize_labels': False}, # train set
'val': {'src': val_src}, # val set (optional)
'relax': {"src": relax_dataset},
}
```


Expand All @@ -1514,8 +1514,8 @@ trainer = OCPTrainer(
dataset=dataset,
optimizer=optimizer,
outputs={},
loss_fns={},
eval_metrics={},
loss_functions={},
evaluation_metrics={},
name="s2ef",
identifier="is2rs-example",
run_dir="./", # directory to save results if is_debug=False. Prediction files are saved here so be careful not to override!
Expand Down Expand Up @@ -1904,8 +1904,8 @@ trainer = OCPTrainer(
dataset=dataset,
optimizer=optimizer,
outputs={},
loss_fns={},
eval_metrics={},
loss_functions={},
evaluation_metrics={},
name="s2ef",
identifier="S2EF-simple",
run_dir="./", # directory to save results if is_debug=False. Prediction files are saved here so be careful not to override!
Expand Down Expand Up @@ -1980,8 +1980,8 @@ trainer = OCPTrainer(
dataset=dataset,
optimizer=optimizer,
outputs={},
loss_fns={},
eval_metrics={},
loss_functions={},
evaluation_metrics={},
name="s2ef",
identifier="S2EF-gemnet-t",
run_dir="./", # directory to save results if is_debug=False. Prediction files are saved here so be careful not to override!
Expand Down
2 changes: 1 addition & 1 deletion docs/legacy_tutorials/data_visualization.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dyn.run(fmax=0, steps=100)
traj = ase.io.read("data/toy_c3h8_relax.traj", ":")

# convert traj format to extxyz format (used by OC20 dataset)
columns = (['symbols','positions', 'move_mask', 'tags'])
columns = (['symbols','positions', 'move_mask', 'tags', 'forces'])
with open('data/toy_c3h8_relax.extxyz','w') as f:
extxyz.write_xyz(f, traj, columns=columns)

Expand Down
4 changes: 3 additions & 1 deletion docs/tutorials/advanced/fine-tuning-in-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,23 @@ yml = generate_yml_config(checkpoint_path, 'config.yml',
'optim.loss_force', # the checkpoint setting causes an error
'dataset', 'test_dataset', 'val_dataset'],
update={'gpus': 1,
'task.dataset': 'ase_db',
'optim.eval_every': 10,
'optim.max_epochs': 1,
'optim.batch_size': 4,
'logger': 'tensorboard', # don't use wandb unless you already are logged in
# Train data
'dataset.train.src': 'train.db',
'dataset.train.format': 'ase_db',
'dataset.train.a2g_args.r_energy': True,
'dataset.train.a2g_args.r_forces': True,
# Test data - prediction only so no regression
'dataset.test.src': 'test.db',
'dataset.test.format': 'ase_db',
'dataset.test.a2g_args.r_energy': False,
'dataset.test.a2g_args.r_forces': False,
# val data
'dataset.val.src': 'val.db',
'dataset.val.format': 'ase_db',
'dataset.val.a2g_args.r_energy': True,
'dataset.val.a2g_args.r_forces': True,
})
Expand Down
2 changes: 1 addition & 1 deletion src/fairchem/core/common/relaxation/ase_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def batch_to_atoms(batch):
n_systems = batch.natoms.shape[0]
natoms = batch.natoms.tolist()
numbers = torch.split(batch.atomic_numbers, natoms)
fixed = torch.split(batch.fixed, natoms)
fixed = torch.split(batch.fixed.to(torch.bool), natoms)
forces = torch.split(batch.force, natoms)
positions = torch.split(batch.pos, natoms)
tags = torch.split(batch.tags, natoms)
Expand Down
4 changes: 0 additions & 4 deletions src/fairchem/core/common/tutorial_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ def nested_set(dic, keys, value):
keys = _key.split(".")
nested_set(config, keys, update[_key])

# TODO : Do not rename keys in utils.py when reading a config
config["evaluation_metrics"] = config["eval_metrics"]
config.pop("eval_metrics")

out = dump(config)
with open(yml, "wb") as f:
f.write(out.encode("utf-8"))
Expand Down
Loading
Loading