Skip to content

Commit

Permalink
Fix for abinp.py vasp
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Oct 27, 2024
1 parent 7337f2f commit efc58b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
cp abipy/data/managers/gh_manager.yml $HOME/.abinit/abipy/manager.yml
cp abipy/data/managers/gh_scheduler.yml $HOME/.abinit/abipy/scheduler.yml
# FIXME TEMPORARY HACK
pip install git+https://github.com/gmatteo/pymatgen.git@master -U
#pip install git+https://github.com/gmatteo/pymatgen.git@master -U
- name: Build docs with Sphinx
run: |
Expand All @@ -74,7 +74,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: site/ # Important. Set to your output dir in MkDocs
path: _build/html/ # Important. Set to the website output dir

deploy:
environment:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
run:
shell: bash -l {0} # enables conda/mamba env activation by reading bash profile

strategy:
fail-fast: false
matrix:
config:
- os: ubuntu-latest
python: '3.11'
config:
- os: ubuntu-latest
python: '3.12'
#strategy:
# fail-fast: false
# matrix:
# config:
# - os: ubuntu-latest
# python: '3.11'
# config:
# - os: ubuntu-latest
# python: '3.12'

runs-on: ${{ matrix.config.os }}
env:
Expand Down
12 changes: 6 additions & 6 deletions abipy/scripts/abinp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@
from typing import Type
from monty.termcolor import cprint
from monty.functools import prof_main
from pymatgen.io.vasp.sets import DictSet
from pymatgen.io.vasp.sets import VaspInputSet
from abipy import abilab
from abipy.abio import factories
from abipy.abio.inputs import AnaddbInput
from abipy.dfpt.ddb import DdbFile


def vasp_dict_set_cls(s: str | DictSet) -> Type | list[str]:
def vasp_dict_set_cls(s: str | VaspInputSet) -> Type | list[str]:
"""
Return a subclass of DictSect from string `s`.
If s == "__all__", return list with all DictSet subclasses supported by pymatgen.
If s == "__all__", return list with all VaspInputSet subclasses supported by pymatgen.
"""
from inspect import isclass
from pymatgen.io.vasp import sets
def is_dict_set(key: str) -> bool:
return isclass(obj := getattr(sets, key)) and issubclass(obj, DictSet)
return isclass(obj := getattr(sets, key)) and issubclass(obj, VaspInputSet)

valid_keys = [key for key in dir(sets) if is_dict_set(key)]

if s == "__all__":
return valid_keys

if isinstance(s, DictSet):
if isinstance(s, VaspInputSet):
return s

if s not in valid_keys:
raise ValueError(f"Unknown DictSet {s}, must be one of {valid_keys}")
raise ValueError(f"Unknown VaspInputSet {s}, must be one of {valid_keys}")

return getattr(sets, s)

Expand Down

0 comments on commit efc58b5

Please sign in to comment.