From bf03fb8c8b3d5fa06106672439f9ee954b567c90 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Wed, 17 Jul 2024 20:52:41 +0530 Subject: [PATCH 01/11] add pyright config --- .pre-commit-config.yaml | 4 ++++ lobsterpy/featurize/utils.py | 4 ++-- pyproject.toml | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c3c2333..413a5f8d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -65,3 +65,7 @@ repos: stages: [commit, commit-msg] args: [--ignore-words-list, 'titel,alls,ans,nd,mater,nwo,te,hart,ontop,ist,ot,fo'] types_or: [python, rst, markdown] +- repo: https://github.com/RobertCraigie/pyright-python + rev: v1.1.372 + hooks: + - id: pyright diff --git a/lobsterpy/featurize/utils.py b/lobsterpy/featurize/utils.py index 26bc9044..4b20e82d 100644 --- a/lobsterpy/featurize/utils.py +++ b/lobsterpy/featurize/utils.py @@ -60,7 +60,7 @@ def get_file_paths( if file_path.exists(): file_paths[file] = file_path else: - gz_file_path = Path(zpath(file_path)) + gz_file_path = Path(zpath(str(file_path.as_posix()))) if gz_file_path.exists(): file_paths[file] = gz_file_path else: @@ -86,7 +86,7 @@ def get_structure_path(lobster_path: Path) -> Path: poscar_path = lobster_path / filename if poscar_path.exists(): return poscar_path - gz_file_path = Path(zpath(poscar_path)) + gz_file_path = Path(zpath(str(poscar_path.as_posix()))) if gz_file_path.exists(): return gz_file_path diff --git a/pyproject.toml b/pyproject.toml index 3d1ef676..a4d2915d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,3 +181,12 @@ no_implicit_optional = false [tool.codespell] ignore-words-list = "titel,alls,ans,nd,mater,nwo,te,hart,ontop,ist,ot,fo" check-filenames = true + +[tool.pyright] +typeCheckingMode = "off" +reportPossiblyUnboundVariable = true +reportUnboundVariable = true +reportMissingImports = false +reportMissingModuleSource = false +reportInvalidTypeForm = false +exclude = ["**/tests"] From ecf18bbc0558f59993cb05af4f475af5ac96a108 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 18 Jul 2024 20:34:28 +0530 Subject: [PATCH 02/11] fix exceptions test > failed due to spglib updates and new warnings --- tests/cohp/test_describe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index cf3b1784..82b208b4 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -407,7 +407,7 @@ def test_warnings(self): potcar_symbols=["C"], bva_comp=True, ) - assert "Oxidation states from BVA analyzer cannot" in str(w2[0].message) + assert "Oxidation states from BVA analyzer cannot" in str(w2[-1].message) calc_des2 = Description.get_calc_quality_description(calc_quality_warnings2) From f1aa2de0a369111c203db97bb4643229b5aa1066 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 18 Jul 2024 20:35:56 +0530 Subject: [PATCH 03/11] update pyright config --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a4d2915d..b62bc95b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -184,7 +184,7 @@ check-filenames = true [tool.pyright] typeCheckingMode = "off" -reportPossiblyUnboundVariable = true +reportPossiblyUnboundVariable = false reportUnboundVariable = true reportMissingImports = false reportMissingModuleSource = false From c91645a678056db426339985c768c96eb31546d9 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 18 Jul 2024 20:45:16 +0530 Subject: [PATCH 04/11] test pre-commit by lowering pyright version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 413a5f8d..a0b8e602 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,6 +66,6 @@ repos: args: [--ignore-words-list, 'titel,alls,ans,nd,mater,nwo,te,hart,ontop,ist,ot,fo'] types_or: [python, rst, markdown] - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.372 + rev: v1.1.369 hooks: - id: pyright From 5bad4a481427306b26cc0183e28a84b84bba2e71 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 18 Jul 2024 20:51:17 +0530 Subject: [PATCH 05/11] upgrade pyright --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a0b8e602..413a5f8d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,6 +66,6 @@ repos: args: [--ignore-words-list, 'titel,alls,ans,nd,mater,nwo,te,hart,ontop,ist,ot,fo'] types_or: [python, rst, markdown] - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.369 + rev: v1.1.372 hooks: - id: pyright From 03c4eab98ce3b8d49e8cb2c3c9c66851e07ea8f3 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 19 Jul 2024 09:26:09 +0530 Subject: [PATCH 06/11] skip pyright (already runs in lint) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 413a5f8d..48eb5dd8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ exclude: ^(docs|examples|tests/test_data) ci: autoupdate_schedule: monthly - skip: [mypy] + skip: [mypy,pyright] autofix_commit_msg: pre-commit auto-fixes autoupdate_commit_msg: pre-commit autoupdate From 2fb5940f66139a940b5057ffed19d11fb54baa0f Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 19 Jul 2024 09:28:19 +0530 Subject: [PATCH 07/11] attempt to switch to uv --- .github/workflows/python-package.yml | 43 +++++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 257501ae..954b996a 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -31,22 +31,43 @@ jobs: python-version: ["3.9", "3.10", "3.11", "3.12"] split: [1, 2, 3, 4, 5, 6] + steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Check out repo + uses: actions/checkout@v4 + + - name: Set up micromamba + uses: mamba-org/setup-micromamba@main + + - name: Create mamba environment run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest pytest-mock pytest-split pytest-cov - python -m pip install types-setuptools - pip install .[featurizer] + micromamba create -n lobpy python=${{ matrix.python-version }} --yes + + - name: Install uv + run: micromamba run -n lobpy pip install uv + + - name: Install lobsterpy and dependencies + run: | + micromamba activate lobpy + + uv pip install --upgrade pip + uv pip install --editable '.[tests,featurizer]' + +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python-version }} +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# python -m pip install flake8 pytest pytest-mock pytest-split pytest-cov +# python -m pip install types-setuptools +# pip install .[featurizer] - name: Test with pytest and coverage # run this locally to update tests durations # pytest --cov=lobsterpy --cov-append --splits 1 --group 1 --durations-path ./tests/test_data/.pytest-split-durations --store-durations run: | + micromamba activate lobpy pytest --cov=lobsterpy --cov-report term-missing --cov-append --splits 6 --group ${{ matrix.split }} -vv --durations-path ./tests/test_data/.pytest-split-durations - name: Upload coverage uses: actions/upload-artifact@v3 @@ -58,7 +79,7 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v4 with: From 2602cc5404ab7bcc94336cfcfed4276ee9ce5115 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 19 Jul 2024 09:30:59 +0530 Subject: [PATCH 08/11] add bash shell activation --- .github/workflows/python-package.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 954b996a..60acf30c 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -25,6 +25,9 @@ jobs: test: runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} # enables conda/mamba env activation by reading bash profile strategy: fail-fast: false matrix: From 2e28ddb95485a0a7455514f40c6f32a7498bfcb6 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 19 Jul 2024 09:48:02 +0530 Subject: [PATCH 09/11] clean up workflow --- .github/workflows/python-package.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 60acf30c..c60c1881 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -56,22 +56,13 @@ jobs: uv pip install --upgrade pip uv pip install --editable '.[tests,featurizer]' -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v4 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip -# python -m pip install flake8 pytest pytest-mock pytest-split pytest-cov -# python -m pip install types-setuptools -# pip install .[featurizer] - name: Test with pytest and coverage # run this locally to update tests durations # pytest --cov=lobsterpy --cov-append --splits 1 --group 1 --durations-path ./tests/test_data/.pytest-split-durations --store-durations run: | micromamba activate lobpy pytest --cov=lobsterpy --cov-report term-missing --cov-append --splits 6 --group ${{ matrix.split }} -vv --durations-path ./tests/test_data/.pytest-split-durations + - name: Upload coverage uses: actions/upload-artifact@v3 with: @@ -87,17 +78,21 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.10' + - name: Install Coverage run: | python -m pip install coverage[toml] + - name: Download coverage artifacts continue-on-error: true uses: actions/download-artifact@v3 + - name: Run coverage continue-on-error: true run: | coverage combine coverage*/.coverage* coverage report --show-missing + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.1 with: From cf1f92d646a9eed578be203e3b85ceb05fb56bf4 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 19 Jul 2024 10:07:02 +0530 Subject: [PATCH 10/11] test without mamba --- .github/workflows/python-package.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index c60c1881..dd1062bf 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -39,28 +39,26 @@ jobs: - name: Check out repo uses: actions/checkout@v4 - - name: Set up micromamba - uses: mamba-org/setup-micromamba@main +# - name: Set up micromamba +# uses: mamba-org/setup-micromamba@main - - name: Create mamba environment - run: | - micromamba create -n lobpy python=${{ matrix.python-version }} --yes +# - name: Create mamba environment +# run: | +# micromamba create -n lobpy python=${{ matrix.python-version }} --yes - - name: Install uv - run: micromamba run -n lobpy pip install uv +# - name: Install uv +# run: micromamba run -n lobpy pip install uv - - name: Install lobsterpy and dependencies + - name: Install LobsterPy and dependencies run: | - micromamba activate lobpy - - uv pip install --upgrade pip + pip install --upgrade pip + pip install uv uv pip install --editable '.[tests,featurizer]' - name: Test with pytest and coverage # run this locally to update tests durations # pytest --cov=lobsterpy --cov-append --splits 1 --group 1 --durations-path ./tests/test_data/.pytest-split-durations --store-durations run: | - micromamba activate lobpy pytest --cov=lobsterpy --cov-report term-missing --cov-append --splits 6 --group ${{ matrix.split }} -vv --durations-path ./tests/test_data/.pytest-split-durations - name: Upload coverage From 10fab08ba16836fff9cddce8c69c57e3f019ac01 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 19 Jul 2024 10:10:01 +0530 Subject: [PATCH 11/11] revert to mamba --- .github/workflows/python-package.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index dd1062bf..2fe03c24 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -39,26 +39,27 @@ jobs: - name: Check out repo uses: actions/checkout@v4 -# - name: Set up micromamba -# uses: mamba-org/setup-micromamba@main + - name: Set up micromamba + uses: mamba-org/setup-micromamba@main -# - name: Create mamba environment -# run: | -# micromamba create -n lobpy python=${{ matrix.python-version }} --yes + - name: Create mamba environment + run: | + micromamba create -n lobpy python=${{ matrix.python-version }} --yes -# - name: Install uv -# run: micromamba run -n lobpy pip install uv + - name: Install uv + run: micromamba run -n lobpy pip install uv - name: Install LobsterPy and dependencies run: | - pip install --upgrade pip - pip install uv + micromamba activate lobpy + uv pip install --upgrade pip uv pip install --editable '.[tests,featurizer]' - name: Test with pytest and coverage # run this locally to update tests durations # pytest --cov=lobsterpy --cov-append --splits 1 --group 1 --durations-path ./tests/test_data/.pytest-split-durations --store-durations run: | + micromamba activate lobpy pytest --cov=lobsterpy --cov-report term-missing --cov-append --splits 6 --group ${{ matrix.split }} -vv --durations-path ./tests/test_data/.pytest-split-durations - name: Upload coverage