Skip to content

Commit

Permalink
Create .pre-commit-config.yaml (#1793)
Browse files Browse the repository at this point in the history
Closes #1771.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Andrew-S-Rosen and pre-commit-ci[bot] authored Feb 29, 2024
1 parent b798002 commit 1eec1dc
Show file tree
Hide file tree
Showing 41 changed files with 1,069 additions and 1,009 deletions.
9 changes: 0 additions & 9 deletions .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,3 @@ name = "python"

[analyzers.meta]
runtime_version = "3.x.x"

[[transformers]]
name = "prettier"

[[transformers]]
name = "isort"

[[transformers]]
name = "black"
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

- [ ] I have read the ["Guidelines" section](https://quantum-accelerators.github.io/quacc/dev/contributing.html#guidelines) of the contributing guide. Don't lie! 😉
- [ ] My PR is on a custom branch and is _not_ named `main`.
- [ ] I have used `black`, `isort`, and `ruff` as described in the [style guide](https://quantum-accelerators.github.io/quacc/dev/contributing.html#style).
- [ ] I have added relevant, comprehensive [unit tests](https://quantum-accelerators.github.io/quacc/dev/contributing.html#unit-tests).

### Notes
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package.json
*parsl.log
runinfo

# Docs
# Docs
.cache/
docs/reference/*
*doctrees*
Expand Down
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ci:
autoupdate_schedule: monthly
autofix_commit_msg: pre-commit auto-fixes
autoupdate_commit_msg: pre-commit autoupdate

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
## Documentation 📖

<p align="center">
<a href="https://quantum-accelerators.github.io/quacc/"><b><i>Learn More Here!</i></b></a>
<a href="https://quantum-accelerators.github.io/quacc/"><b><i>Learn More Here!</i></b></a>
</p>

... or skip straight to one of the following sections:
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ In general, please try to keep the code style consistent when possible, particul

2. Address any relevant issues raised by the GitHub Actions test suite.

3. All Python code should be formatted with [isort](https://github.com/PyCQA/isort) (`isort .`), [black](https://github.com/psf/black) (`black .`), and [ruff](https://github.com/astral-sh/ruff) (`ruff . --fix`).
3. All Python code should be formatted with [ruff](https://github.com/astral-sh/ruff) (`ruff format . --fix`).

## Unit Tests

Expand Down
4 changes: 4 additions & 0 deletions docs/dev/recipes/flows.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ quacc fully supports complex, dynamic flows where the number of jobs is not know
from random import randint
from quacc import flow, job, subflow


@job
def add(a, b):
return a + b


@job
def make_list(val):
return [val] * randint(2, 5)


@subflow
def add_distributed(vals, c):
outputs = []
Expand All @@ -60,6 +63,7 @@ quacc fully supports complex, dynamic flows where the number of jobs is not know
outputs.append(output)
return outputs


@flow
def workflow(a, b, c):
output1 = add(a, b)
Expand Down
2 changes: 1 addition & 1 deletion docs/maintainers/internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For a pull request opened by a contributor not on the whitelist, [@buildbot-prin

To upload to PyPI manually in the case of a GitHub Actions failure:

```python
```bash
pip install -e .
python -m build
twine check dist/*
Expand Down
4 changes: 3 additions & 1 deletion docs/user/advanced/vasp_hpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ First, prepare your `QUACC_VASP_PP_PATH` environment variable in the `~/.bashrc`
concurrent_jobs = 2
nodes_per_job = 1
cores_per_node = 128
vasp_parallel_cmd = f"srun -N {nodes_per_job} --ntasks-per-node={cores_per_node} --cpu_bind=cores"
vasp_parallel_cmd = (
f"srun -N {nodes_per_job} --ntasks-per-node={cores_per_node} --cpu_bind=cores"
)
min_slurm_allocations = 0
max_slurm_allocations = 1

Expand Down
4 changes: 2 additions & 2 deletions docs/user/recipes/recipes_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ print(result)

??? Info "Printed Output"

```python
```
{'atoms': Atoms(symbols='Cu', pbc=True, cell=[[0.0, 1.805, 1.805], [1.805, 0.0, 1.805], [1.805, 1.805, 0.0]], initial_magmoms=...),
'atoms_info': {'\_id': 'f8d53f110f524872f30a5cc20e8befb1'},
'builder_meta': {'build_date': datetime.datetime(2024, 1, 22, 6, 53, 30, 342389),
Expand Down Expand Up @@ -150,7 +150,7 @@ print(result2)

??? Info "Printed Output"

```python
```
{'atoms': Atoms(symbols='Cu', pbc=True, cell=[[0.0, 1.805, 1.805], [1.805, 0.0, 1.805], [1.805, 1.805, 0.0]], initial_magmoms=...),
'atoms_info': {'_id': 'f8d53f110f524872f30a5cc20e8befb1',
'_old_ids': ['f8d53f110f524872f30a5cc20e8befb1']},
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.12",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Operating System :: Microsoft :: Windows",
Expand Down Expand Up @@ -54,7 +54,7 @@ prefect = ["prefect>=2.14.14", "prefect-dask>=0.2.6", "dask-jobqueue>=0.8.2"]
redun = ["redun>=0.16.2"]
sella = ["sella>=2.3.2", "jax<=0.4.24", "jaxlib<=0.4.24"]
tblite = ["tblite[ase]>=0.3.0; platform_system=='Linux'"]
dev = ["black>=23.7.0", "codecov-cli>=0.4.1", "isort>=5.12.0", "pytest>=7.4.0", "pytest-cov>=3.0.0", "ruff>=0.0.285"]
dev = ["codecov-cli>=0.4.1", "pytest>=7.4.0", "pytest-cov>=3.0.0", "ruff>=0.0.285"]
docs = [
"blacken-docs>=1.16.0",
"mkdocs-material>=9.1.21",
Expand Down
2 changes: 1 addition & 1 deletion src/quacc/_cli/quacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def main(
help="Show the application's version and exit.",
callback=callback,
is_eager=True,
)
),
) -> None:
"""
The main CLI interface, with an option to return the version.
Expand Down
3 changes: 2 additions & 1 deletion src/quacc/atoms/defects.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def _get_defect_entry_from_defect(
defect_supercell.remove(dummy_site)

computed_structure_entry = ComputedStructureEntry(
structure=defect_supercell, energy=0.0 # needs to be set, so set to 0.0
structure=defect_supercell,
energy=0.0, # needs to be set, so set to 0.0
)

return DefectEntry(
Expand Down
9 changes: 4 additions & 5 deletions src/quacc/atoms/slabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
from ase import Atoms
from pymatgen.analysis.adsorption import AdsorbateSiteFinder
from pymatgen.core.structure import Structure
from pymatgen.core.surface import Slab, center_slab, generate_all_slabs
from pymatgen.io.ase import AseAtomsAdaptor

Expand All @@ -18,7 +19,6 @@
from typing import Literal, TypedDict

from numpy.typing import ArrayLike
from pymatgen.core.structure import Structure

class AdsSiteFinderKwargs(TypedDict, total=False):
"""
Expand Down Expand Up @@ -67,10 +67,9 @@ def flip_atoms(
Inverted slab
"""

if isinstance(atoms, Atoms):
new_atoms = copy_atoms(atoms)
else:
new_atoms = atoms.to_ase_atoms()
new_atoms = (
atoms.to_ase_atoms() if isinstance(atoms, Structure) else copy_atoms(atoms)
)

new_atoms.rotate(180, "x")
new_atoms.wrap()
Expand Down
36 changes: 18 additions & 18 deletions src/quacc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class QuaccSettings(BaseSettings):
_DEFAULT_CONFIG_FILE_PATH,
description=(
"""
Path to the YAML file to load alternative quacc configuration
Path to the YAML file to load alternative quacc configuration
defaults from.
"""
),
Expand All @@ -76,7 +76,7 @@ class QuaccSettings(BaseSettings):
Path.cwd(),
description=(
"""
Directory to permanently store I/O-based calculation results in.
Directory to permanently store I/O-based calculation results in.
Note that this behavior may be modified by the chosen workflow engine.
"""
),
Expand All @@ -85,10 +85,10 @@ class QuaccSettings(BaseSettings):
None,
description=(
"""
The base directory where calculations are run. If set to None, calculations will be run in a
temporary directory within `RESULTS_DIR`. If a `Path` is supplied, calculations will
be run in a temporary directory within `SCRATCH_DIR`. Files are always moved back
to `RESULTS_DIR` after the calculation is complete, and the temporary directory
The base directory where calculations are run. If set to None, calculations will be run in a
temporary directory within `RESULTS_DIR`. If a `Path` is supplied, calculations will
be run in a temporary directory within `SCRATCH_DIR`. Files are always moved back
to `RESULTS_DIR` after the calculation is complete, and the temporary directory
in `SCRATCH_DIR` is removed.
"""
),
Expand All @@ -97,8 +97,8 @@ class QuaccSettings(BaseSettings):
True,
description=(
"""
Whether to have a unique directory in RESULTS_DIR for each job.
Some workflow engines have an option to do this for you already,
Whether to have a unique directory in RESULTS_DIR for each job.
Some workflow engines have an option to do this for you already,
in which case you should set this to False.
"""
),
Expand Down Expand Up @@ -132,10 +132,10 @@ class QuaccSettings(BaseSettings):
None,
description=(
"""
The desired Maggma data store where calculation results will be stored. All data stores listed in
`maggma.stores.__init__.py` are supported. If a dictionary is provided, the first key must be set
The desired Maggma data store where calculation results will be stored. All data stores listed in
`maggma.stores.__init__.py` are supported. If a dictionary is provided, the first key must be set
to the desired store type. The sub-parameters are the keyword arguments accepted by the Store.
An example is shown below:
An example is shown below:
```yaml
STORE:
Expand Down Expand Up @@ -165,7 +165,7 @@ class QuaccSettings(BaseSettings):
Path(which("orca") or "orca"),
description=(
"""
Path to the ORCA executable. This must be the full, absolute path
Path to the ORCA executable. This must be the full, absolute path
for parallel calculations to work.
"""
),
Expand Down Expand Up @@ -298,7 +298,7 @@ class QuaccSettings(BaseSettings):
1.0,
description=(
"""
Default initial magmom to use for a given element if a preset
Default initial magmom to use for a given element if a preset
with magmoms is provided but an element is missing from the list.
"""
),
Expand All @@ -307,7 +307,7 @@ class QuaccSettings(BaseSettings):
0.05,
description=(
"""
If the absolute value of all magnetic moments are below this value,
If the absolute value of all magnetic moments are below this value,
they will be set to 0 such that a spin-unpolarized calculation will be performed.
"""
),
Expand All @@ -316,7 +316,7 @@ class QuaccSettings(BaseSettings):
True,
description=(
"""
If True, any pre-existing atoms.get_magnetic_moments() will be set
If True, any pre-existing atoms.get_magnetic_moments() will be set
in atoms.set_initial_magnetic_moments().
"""
),
Expand All @@ -334,7 +334,7 @@ class QuaccSettings(BaseSettings):
False,
description=(
"""
If VTST-related input swaps should be used when running Custodian.
If VTST-related input swaps should be used when running Custodian.
Requires VASP to be compiled with VTST
"""
),
Expand Down Expand Up @@ -365,7 +365,7 @@ class QuaccSettings(BaseSettings):
None,
description=(
"""
After this many seconds, Custodian will stop running
After this many seconds, Custodian will stop running
and ensure that VASP writes a STOPCAR
"""
),
Expand Down Expand Up @@ -421,7 +421,7 @@ class QuaccSettings(BaseSettings):
False,
description=(
"""
Whether to run in debug mode. This will set the logging level to DEBUG,
Whether to run in debug mode. This will set the logging level to DEBUG,
ASE logs (e.g. optimizations, vibrations, thermo) are printed to stdout.
"""
),
Expand Down
2 changes: 1 addition & 1 deletion src/quacc/utils/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def copy_decompress_files(

if source_filepath.is_symlink():
continue
elif source_filepath.is_file():
if source_filepath.is_file():
copy(source_filepath, destination_filepath)
decompress_file(destination_filepath)
elif source_filepath.is_dir():
Expand Down
Loading

0 comments on commit 1eec1dc

Please sign in to comment.