Skip to content

Commit

Permalink
Merge pull request #142 from Lnaden/yapf
Browse files Browse the repository at this point in the history
Yapf, isort, some LGTM
  • Loading branch information
dgasmith authored Aug 26, 2019
2 parents 404a70a + 72e9379 commit 8ff164c
Show file tree
Hide file tree
Showing 34 changed files with 555 additions and 489 deletions.
2 changes: 2 additions & 0 deletions .yapfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated files
*/_version.py
42 changes: 24 additions & 18 deletions qcengine/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import os.path
import sys

from . import compute, compute_procedure # run and run-procedure
from qcelemental.models import ResultInput # run and run-procedure
from . import __version__, list_all_procedures, list_all_programs, list_available_procedures, \
list_available_programs, get_procedure, get_program # info

from . import (__version__, compute, compute_procedure, get_procedure, get_program, # run and run-procedure; info
list_all_procedures, list_all_programs, list_available_procedures, list_available_programs)
from .config import global_repr # info

__all__ = ["main"]
Expand All @@ -22,24 +22,31 @@ def parse_args():
subparsers = parser.add_subparsers(dest="command")

info = subparsers.add_parser('info', help="Print information about QCEngine setup, version, and environment.")
info.add_argument("category", nargs="*", default="all",
info.add_argument("category",
nargs="*",
default="all",
choices=["version", "programs", "procedures", "config", "all"],
help="The information categories to show.")

run = subparsers.add_parser('run', help="Run a program on a given task. Output is printed as a JSON blob.")
run.add_argument('program', type=str, help="The program to run.")
run.add_argument('data', type=str, help="Data describing the task to run. "
"One of: (i) A JSON blob, "
"(ii) A file name, "
"(iii) '-', indicating data will be read from STDIN.")

run_procedure = subparsers.add_parser('run-procedure', help="Run a procedure on a given task. "
"Output is printed as a JSON blob.")
run.add_argument('data',
type=str,
help="Data describing the task to run. "
"One of: (i) A JSON blob, "
"(ii) A file name, "
"(iii) '-', indicating data will be read from STDIN.")

run_procedure = subparsers.add_parser('run-procedure',
help="Run a procedure on a given task. "
"Output is printed as a JSON blob.")
run_procedure.add_argument('procedure', type=str, help="The procedure to run.")
run_procedure.add_argument('data', type=str, help="Data describing the task to run. "
"One of: (i) A JSON blob, "
"(ii) A file name, "
"(iii) '-', indicating data will be read from STDIN.")
run_procedure.add_argument('data',
type=str,
help="Data describing the task to run. "
"One of: (i) A JSON blob, "
"(ii) A file name, "
"(iii) '-', indicating data will be read from STDIN.")

args = vars(parser.parse_args())
if args["command"] is None:
Expand All @@ -50,15 +57,14 @@ def parse_args():


def info_cli(args):

def info_version():
import qcelemental
print(">>> Version information")
print(f"QCEngine version: {__version__}")
print(f"QCElemental version: {qcelemental.__version__}")
print()

def info_programs():
def info_programs(): # lgtm: [py/similar-function]
print(">>> Program information")
all_progs = list_all_programs()
avail_progs = list_available_programs()
Expand All @@ -74,7 +80,7 @@ def info_programs():
print(" ".join(sorted(all_progs - avail_progs)))
print()

def info_procedures():
def info_procedures(): # lgtm: [py/similar-function]
print(">>> Procedure information")
all_procs = list_all_procedures()
avail_procs = list_available_procedures()
Expand Down
1 change: 0 additions & 1 deletion qcengine/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def compute(input_data: Union[Dict[str, Any], 'ResultInput'],
except:
raise


return handle_output_metadata(output_data, metadata, raise_error=raise_error, return_dict=return_dict)


Expand Down
2 changes: 1 addition & 1 deletion qcengine/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class JobConfig(pydantic.BaseModel):
ncores: int # Number of ncores per job
memory: float # Amount of memory in GiB per node
scratch_directory: Optional[str] # What location to use as scratch
retries: int # Number of retries on random failures
retries: int # Number of retries on random failures

class Config:
extra = "forbid"
Expand Down
2 changes: 1 addition & 1 deletion qcengine/procedures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""

from typing import Set
from ..exceptions import InputError, ResourceError

from ..exceptions import InputError, ResourceError
from .geometric import GeometricProcedure

__all__ = ["register_procedure", "get_procedure", "list_all_procedures", "list_available_procedures"]
Expand Down
7 changes: 5 additions & 2 deletions qcengine/procedures/geometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ class GeometricProcedure(ProcedureHarness):
class Config(ProcedureHarness.Config):
pass

def found(self, raise_error: bool=False) -> bool:
return which_import('geometric', return_bool=True, raise_error=raise_error, raise_msg='Please install via `conda install geometric -c conda-forge`.')
def found(self, raise_error: bool = False) -> bool:
return which_import('geometric',
return_bool=True,
raise_error=raise_error,
raise_msg='Please install via `conda install geometric -c conda-forge`.')

def build_input_model(self, data: Union[Dict[str, Any], 'OptimizationInput']) -> 'OptimizationInput':
return self._build_model(data, OptimizationInput)
Expand Down
7 changes: 3 additions & 4 deletions qcengine/procedures/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, **kwargs):
super().__init__(**{**self._defaults, **kwargs})

@abc.abstractmethod
def build_input_model(self, data: Union[Dict[str, Any], 'BaseModel'], raise_error: bool=True) -> 'BaseModel':
def build_input_model(self, data: Union[Dict[str, Any], 'BaseModel'], raise_error: bool = True) -> 'BaseModel':
"""
Build and validate the input model, passes if the data was a normal BaseModel input.
Expand All @@ -35,13 +35,12 @@ def build_input_model(self, data: Union[Dict[str, Any], 'BaseModel'], raise_erro
BaseModel
The input model for the procedure.
"""

@abc.abstractmethod
def compute(self, input_data: 'BaseModel', config: 'JobConfig') -> 'BaseModel':
pass

@abc.abstractmethod
def found(self, raise_error: bool=False) -> bool:
def found(self, raise_error: bool = False) -> bool:
"""
Checks if the program can be found.
Expand All @@ -66,4 +65,4 @@ def get_version(self) -> str:
str
Return a valid, safe python version string.
"""
pass
pass
4 changes: 2 additions & 2 deletions qcengine/programs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"""

from typing import Set
from ..exceptions import InputError, ResourceError

from ..exceptions import InputError, ResourceError
from .cfour import CFOURHarness
from .dftd3 import DFTD3Harness
from .entos import EntosHarness
from .gamess import GAMESSHarness
from .nwchem import NWChemHarness
from .molpro import MolproHarness
from .mopac import MopacHarness
from .mp2d import MP2DHarness
from .nwchem import NWChemHarness
from .psi4 import Psi4Harness
from .rdkit import RDKitHarness
from .terachem import TeraChemHarness
Expand Down
Loading

0 comments on commit 8ff164c

Please sign in to comment.