-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://www.github.com/hackingmaterials/atomate …
…into main
- Loading branch information
Showing
214 changed files
with
2,250,463 additions
and
4,289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
repos: | ||
- repo: git@github.com:humitos/mirrors-autoflake.git | ||
rev: v1.1 | ||
- repo: https://github.com/myint/autoflake | ||
rev: v1.4 | ||
hooks: | ||
- id: autoflake | ||
args: [ '--in-place', '--remove-all-unused-imports', '--remove-unused-variable' ] | ||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
args: [--in-place, --remove-all-unused-imports, --remove-unused-variable, --ignore-init-module-imports] | ||
- repo: https://github.com/psf/black | ||
rev: 21.4b2 | ||
hooks: | ||
- id: black | ||
language_version: python3 | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.8.4 | ||
hooks: | ||
- id: flake8 | ||
args: [--max-line-length=125] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
rev: v3.4.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: flake8 | ||
args: ["--max-line-length=125"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
# coding: utf-8 | ||
|
||
|
||
import json | ||
import os | ||
|
||
|
@@ -10,7 +7,7 @@ | |
from atomate.utils.utils import env_chk, get_logger, load_class | ||
from atomate.common.firetasks.glue_tasks import get_calc_loc | ||
|
||
__author__ = 'Shyam Dwaraknath <[email protected]>, Anubhav Jain <[email protected]>' | ||
__author__ = "Shyam Dwaraknath <[email protected]>, Anubhav Jain <[email protected]>" | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
@@ -37,7 +34,14 @@ class ToDbTask(FiretaskBase): | |
""" | ||
|
||
required_params = ["drone"] | ||
optional_params = ["mmdb", "db_file", "calc_dir", "calc_loc", "additional_fields", "options"] | ||
optional_params = [ | ||
"mmdb", | ||
"db_file", | ||
"calc_dir", | ||
"calc_loc", | ||
"additional_fields", | ||
"options", | ||
] | ||
|
||
def run_task(self, fw_spec): | ||
# get the directory that contains the dir to parse | ||
|
@@ -48,12 +52,15 @@ def run_task(self, fw_spec): | |
calc_dir = get_calc_loc(self["calc_loc"], fw_spec["calc_locs"])["path"] | ||
|
||
# parse the calc directory | ||
logger.info("PARSING DIRECTORY: {} USING DRONE: {}".format( | ||
calc_dir, self['drone'].__class__.__name__)) | ||
logger.info( | ||
"PARSING DIRECTORY: {} USING DRONE: {}".format( | ||
calc_dir, self["drone"].__class__.__name__ | ||
) | ||
) | ||
# get the database connection | ||
db_file = env_chk(self.get('db_file'), fw_spec) | ||
db_file = env_chk(self.get("db_file"), fw_spec) | ||
|
||
drone = self['drone'].__class__() | ||
drone = self["drone"].__class__() | ||
task_doc = drone.assimilate(calc_dir) | ||
if not db_file: | ||
with open("task.json", "w") as f: | ||
|
@@ -66,7 +73,9 @@ def run_task(self, fw_spec): | |
|
||
# insert the task document | ||
t_id = db.insert(task_doc) | ||
logger.info("Finished parsing with task_id: {}".format(t_id)) | ||
logger.info(f"Finished parsing with task_id: {t_id}") | ||
|
||
return FWAction(stored_data={"task_id": task_doc.get("task_id", None)}, | ||
defuse_children=(task_doc["state"] != "successful")) | ||
return FWAction( | ||
stored_data={"task_id": task_doc.get("task_id", None)}, | ||
defuse_children=(task_doc["state"] != "successful"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
# coding: utf-8 | ||
|
||
|
||
import os | ||
import subprocess | ||
|
||
|
@@ -10,7 +7,7 @@ | |
|
||
from atomate.utils.utils import env_chk, get_logger | ||
|
||
__author__ = 'Anubhav Jain <[email protected]>' | ||
__author__ = "Anubhav Jain <[email protected]>" | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
@@ -34,9 +31,9 @@ def run_task(self, fw_spec): | |
if self.get("expand_vars", False): | ||
cmd = os.path.expandvars(cmd) | ||
|
||
logger.info("Running command: {}".format(cmd)) | ||
logger.info(f"Running command: {cmd}") | ||
return_code = subprocess.call(cmd, shell=True) | ||
logger.info("Command {} finished running with returncode: {}".format(cmd, return_code)) | ||
logger.info(f"Command {cmd} finished running with returncode: {return_code}") | ||
|
||
|
||
@explicit_serialize | ||
|
@@ -58,6 +55,10 @@ class RunCustodianFromObjects(FiretaskBase): | |
optional_params = ["validators", "custodian_params"] | ||
|
||
def run_task(self, fw_spec): | ||
c = Custodian(self["handlers"], self["jobs"], self.get("validators"), | ||
**self.get("custodian_params", {})) | ||
c = Custodian( | ||
self["handlers"], | ||
self["jobs"], | ||
self.get("validators"), | ||
**self.get("custodian_params", {}), | ||
) | ||
c.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,56 @@ | ||
|
||
|
||
import os | ||
import unittest | ||
import shutil | ||
|
||
from fireworks import LaunchPad, Firework, Workflow | ||
from fireworks import Firework, Workflow | ||
from fireworks.core.rocket_launcher import rapidfire | ||
|
||
from pymatgen.apps.borg.hive import AbstractDrone | ||
|
||
from atomate.common.firetasks.parse_outputs import ToDbTask | ||
from atomate.utils.testing import AtomateTest | ||
|
||
__author__ = 'Shyam Dwaraknath <[email protected]>' | ||
__author__ = "Shyam Dwaraknath <[email protected]>" | ||
|
||
module_dir = os.path.join(os.path.dirname(os.path.abspath(__file__))) | ||
db_dir = os.path.join(module_dir, "..", "..", "test_files") | ||
|
||
|
||
class TestDrone(AbstractDrone): | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def assimilate(self, path): | ||
return {"drone": "Test Drone", | ||
"dir_name": "/test", | ||
'state': "successful"} | ||
return {"drone": "Test Drone", "dir_name": "/test", "state": "successful"} | ||
|
||
def get_valid_paths(self, path): | ||
return path | ||
|
||
|
||
class TestToDbTask(AtomateTest): | ||
|
||
def test_ToDbTask(self): | ||
d = TestDrone() | ||
|
||
fw1 = Firework([ToDbTask(drone=d, | ||
mmdb="atomate.vasp.database.VaspCalcDb", | ||
db_file=os.path.join(db_dir, "db.json"), | ||
calc_dir=db_dir)], name="fw1") | ||
fw1 = Firework( | ||
[ | ||
ToDbTask( | ||
drone=d, | ||
mmdb="atomate.vasp.database.VaspCalcDb", | ||
db_file=os.path.join(db_dir, "db.json"), | ||
calc_dir=db_dir, | ||
) | ||
], | ||
name="fw1", | ||
) | ||
|
||
wf = Workflow([fw1]) | ||
self.lp.add_wf(wf) | ||
rapidfire(self.lp) | ||
|
||
task1 = self.lp.db.tasks.find_one({"task_id":1}) | ||
self.assertEqual(task1['task_id'],1) | ||
self.assertEqual(task1['dir_name'],"/test" ) | ||
self.assertEqual(task1['drone'],'Test Drone') | ||
task1 = self.lp.db.tasks.find_one({"task_id": 1}) | ||
self.assertEqual(task1["task_id"], 1) | ||
self.assertEqual(task1["dir_name"], "/test") | ||
self.assertEqual(task1["drone"], "Test Drone") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.