From f33389a50a29c91d93e68fb74269ce697b362b3e Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Wed, 18 Sep 2024 23:07:48 +0800 Subject: [PATCH 01/16] comment tweaks --- .github/workflows/issue-metrics.yml | 2 +- .github/workflows/release.yml | 18 +++++++++++------- .github/workflows/test.yml | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/issue-metrics.yml b/.github/workflows/issue-metrics.yml index 4fbcdc6b066..043bd3ea572 100644 --- a/.github/workflows/issue-metrics.yml +++ b/.github/workflows/issue-metrics.yml @@ -26,7 +26,7 @@ jobs: # Calculate the last day of the previous month last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) - #Set an environment variable with the date range + # Set an environment variable with the date range echo "$first_day..$last_day" echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 271d06eff91..716043d5901 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ -name: Release # makes PyPI releases +# Make PyPI releases +name: Release on: release: @@ -26,12 +27,12 @@ jobs: - name: Check out repo uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - name: Install Python + - name: Install Python + uses: actions/setup-python@v5 with: python-version: "3.12" - - name: Build sdist + - name: Build source distribution run: | pip install build python -m build --sdist @@ -66,7 +67,7 @@ jobs: needs: [build_wheels, build_sdist] runs-on: ubuntu-latest permissions: - # For pypi trusted publishing + # For PyPI trusted publishing id-token: write steps: - name: Set up Python @@ -81,9 +82,12 @@ jobs: merge-multiple: true path: dist - - name: Publish to PyPi or TestPyPI + - name: Publish to PyPI or TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: skip-existing: true verbose: true - repository-url: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.task == 'test-release' && 'https://test.pypi.org/legacy/' || '' }} + repository-url: > + ${{ github.event_name == 'workflow_dispatch' && + github.event.inputs.task == 'test-release' && + 'https://test.pypi.org/legacy/' || '' }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba8c3db7f0c..20c98ea3123 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -71,7 +71,8 @@ jobs: - name: Install ubuntu-only conda dependencies if: matrix.config.os == 'ubuntu-latest' run: | - micromamba install -n pmg -c conda-forge bader enumlib openff-toolkit packmol pygraphviz tblite --yes + micromamba install -n pmg -c conda-forge bader enumlib \ + openff-toolkit packmol pygraphviz tblite --yes - name: Install pymatgen and dependencies via uv run: | From 5d5f8248a7e4e1ec4ffd8ee3f5315a1c88cd2b80 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 10:40:21 +0800 Subject: [PATCH 02/16] pin python 3.12 in CI --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 993aee068b6..909acc5aafd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: resolution: highest extras: ci,optional,numpy-v1 # Test NP1 on Windows (quite buggy ATM) - os: ubuntu-latest - python: ">3.10" + python: "3.12" resolution: lowest-direct extras: ci,optional - os: macos-latest From 0eb4d0c87c9d74f9dfb18cc71acc1f353076534a Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 10:53:15 +0800 Subject: [PATCH 03/16] try to install from sdist --- .github/workflows/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 909acc5aafd..7199d568126 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,7 +85,12 @@ jobs: # see: https://discuss.dgl.ai/t/filenotfounderror-cannot-find-dgl-c-graphbolt-library/4302 pip install torch==2.2.1 - uv pip install --editable '.[${{ matrix.config.extras }}]' --resolution=${{ matrix.config.resolution }} + # Install from sdist + uv pip install build + python -m build --sdist + + uv pip install dist/*.tar.gz + uv pip install "pymatgen[${{ matrix.config.extras }}]" # --resolution=${{ matrix.config.resolution }} - name: Install optional Ubuntu dependencies if: matrix.config.os == 'ubuntu-latest' From 5dc1b25a48db2f6e84e5f2b41a7f0843199183af Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 11:38:17 +0800 Subject: [PATCH 04/16] try to add test files dir --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7199d568126..2029d06652d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -107,6 +107,8 @@ jobs: echo "$(realpath vampire-5.0/)" >> $GITHUB_PATH - name: pytest split ${{ matrix.split }} + env: + PMG_TEST_FILES_DIR: "${{ github.workspace }}/tests/files" run: | micromamba activate pmg pytest --splits 10 --group ${{ matrix.split }} --durations-path tests/files/.pytest-split-durations tests From 70b0f99c8ddb618bbf3d1ae6476bbe92e291f375 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 11:46:57 +0800 Subject: [PATCH 05/16] uncomment resolution --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2029d06652d..29f99bb09ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,7 +90,7 @@ jobs: python -m build --sdist uv pip install dist/*.tar.gz - uv pip install "pymatgen[${{ matrix.config.extras }}]" # --resolution=${{ matrix.config.resolution }} + uv pip install "pymatgen[${{ matrix.config.extras }}]" --resolution=${{ matrix.config.resolution }} - name: Install optional Ubuntu dependencies if: matrix.config.os == 'ubuntu-latest' From a4f88e30ec3b2ac0cf15de7491ecaaadd6a5e01b Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 11:54:31 +0800 Subject: [PATCH 06/16] set lower pin for bs4 from year 2017 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e136b4b52e6..49aa41805c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,7 +99,7 @@ ci = ["pytest-cov>=4", "pytest-split>=0.8", "pytest>=8"] docs = ["invoke", "sphinx", "sphinx_markdown_builder", "sphinx_rtd_theme"] optional = [ "ase>=3.23.0", - "beautifulsoup4", + "beautifulsoup4>=4.6.0", # BoltzTraP2 build fails on Windows GitHub runners "BoltzTraP2>=24.9.4 ; platform_system != 'Windows'", "chemview>=0.6", From c9f995f20b3e0589c0c56e4995a01730c135ec47 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 11:56:59 +0800 Subject: [PATCH 07/16] remove duplicate in dep declare --- pyproject.toml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 49aa41805c3..6442d024663 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,7 +90,7 @@ Pypi = "https://pypi.org/project/pymatgen" ase = ["ase>=3.23.0"] # tblite only support Python 3.12+ through conda-forge # https://github.com/tblite/tblite/issues/175 -tblite = ["tblite[ase]>=0.3.0; python_version<'3.12'"] +tblite = ["tblite[ase]>=0.3.0; platform_system=='Linux' and python_version<'3.12'"] vis = ["vtk>=6.0.0"] abinit = ["netcdf4>=1.7.1"] mlp = ["chgnet>=0.3.8", "matgl>=1.1.3"] @@ -98,26 +98,22 @@ electronic_structure = ["fdint>=2.0.2"] ci = ["pytest-cov>=4", "pytest-split>=0.8", "pytest>=8"] docs = ["invoke", "sphinx", "sphinx_markdown_builder", "sphinx_rtd_theme"] optional = [ - "ase>=3.23.0", + "pymatgen[abinit,ase,mlp,tblite]", "beautifulsoup4>=4.6.0", # BoltzTraP2 build fails on Windows GitHub runners "BoltzTraP2>=24.9.4 ; platform_system != 'Windows'", "chemview>=0.6", - "chgnet>=0.3.8", "f90nml>=1.1.2", "galore>=0.6.1", "h5py>=3.11.0", "jarvis-tools>=2020.7.14", - "matgl>=1.1.3", "matplotlib>=3.8", - "netCDF4>=1.6.5", "phonopy>=2.23", "seekpath>=2.0.1", # tblite only support Python 3.12+ through conda-forge # https://github.com/tblite/tblite/issues/175 "hiphive>=1.3.1", "openbabel-wheel>=3.1.1.20", - "tblite[ase]>=0.3.0; platform_system=='Linux' and python_version<'3.12'", ] numba = ["numba>=0.55"] numpy-v1 = ["numpy>=1.25.0,<2"] # Test NP1 on Windows (quite buggy ATM) From 7c60d84d9ef9ecc7f2a76eb6b4921c147cb1f769 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 12:14:25 +0800 Subject: [PATCH 08/16] drop quotes --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29f99bb09ab..721aba8dd83 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,12 +85,12 @@ jobs: # see: https://discuss.dgl.ai/t/filenotfounderror-cannot-find-dgl-c-graphbolt-library/4302 pip install torch==2.2.1 - # Install from sdist + # Install from sdist to test the content uv pip install build python -m build --sdist uv pip install dist/*.tar.gz - uv pip install "pymatgen[${{ matrix.config.extras }}]" --resolution=${{ matrix.config.resolution }} + uv pip install pymatgen[${{ matrix.config.extras }}] --resolution=${{ matrix.config.resolution }} - name: Install optional Ubuntu dependencies if: matrix.config.os == 'ubuntu-latest' From c2a233303b043a9c0ff5c179d642ec95074dc4af Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 12:31:17 +0800 Subject: [PATCH 09/16] remove duplicated comment --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6442d024663..c6e22799a52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -110,8 +110,6 @@ optional = [ "matplotlib>=3.8", "phonopy>=2.23", "seekpath>=2.0.1", - # tblite only support Python 3.12+ through conda-forge - # https://github.com/tblite/tblite/issues/175 "hiphive>=1.3.1", "openbabel-wheel>=3.1.1.20", ] From 8bf104fbefb41743ef5777a0b63c540c35cda66d Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 12:32:43 +0800 Subject: [PATCH 10/16] sort optional dependencies --- pyproject.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c6e22799a52..1f1f7880955 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,16 +87,14 @@ Issues = "https://github.com/materialsproject/pymatgen/issues" Pypi = "https://pypi.org/project/pymatgen" [project.optional-dependencies] -ase = ["ase>=3.23.0"] -# tblite only support Python 3.12+ through conda-forge -# https://github.com/tblite/tblite/issues/175 -tblite = ["tblite[ase]>=0.3.0; platform_system=='Linux' and python_version<'3.12'"] -vis = ["vtk>=6.0.0"] abinit = ["netcdf4>=1.7.1"] -mlp = ["chgnet>=0.3.8", "matgl>=1.1.3"] -electronic_structure = ["fdint>=2.0.2"] +ase = ["ase>=3.23.0"] ci = ["pytest-cov>=4", "pytest-split>=0.8", "pytest>=8"] docs = ["invoke", "sphinx", "sphinx_markdown_builder", "sphinx_rtd_theme"] +electronic_structure = ["fdint>=2.0.2"] +mlp = ["chgnet>=0.3.8", "matgl>=1.1.3"] +numba = ["numba>=0.55"] +numpy-v1 = ["numpy>=1.25.0,<2"] # Test NP1 on Windows (quite buggy ATM) optional = [ "pymatgen[abinit,ase,mlp,tblite]", "beautifulsoup4>=4.6.0", @@ -113,8 +111,10 @@ optional = [ "hiphive>=1.3.1", "openbabel-wheel>=3.1.1.20", ] -numba = ["numba>=0.55"] -numpy-v1 = ["numpy>=1.25.0,<2"] # Test NP1 on Windows (quite buggy ATM) +# tblite only support Python 3.12+ through conda-forge +# https://github.com/tblite/tblite/issues/175 +tblite = ["tblite[ase]>=0.3.0; platform_system=='Linux' and python_version<'3.12'"] +vis = ["vtk>=6.0.0"] [project.scripts] pmg = "pymatgen.cli.pmg:main" From 0dba0284903f640da953ab70e50ff5eef6562f7d Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 12:42:50 +0800 Subject: [PATCH 11/16] TEST: test exclude a required file from sdist would lead to CI failure --- MANIFEST.in | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000000..53cb37c29be --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +# DEBUG: test exclude a required file from sdist would lead to CI failure + +prune src/pymatgen/core/ From 4d5a319f300949ac345475f0d800653d32e95646 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Sun, 13 Oct 2024 12:50:40 +0800 Subject: [PATCH 12/16] Revert "TEST: test exclude a required file from sdist would lead to CI failure" This reverts commit 0dba0284903f640da953ab70e50ff5eef6562f7d. --- MANIFEST.in | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 53cb37c29be..00000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -# DEBUG: test exclude a required file from sdist would lead to CI failure - -prune src/pymatgen/core/ From 17b1acf203302669c7cc2776eb3e17545cf1838b Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Mon, 14 Oct 2024 18:47:29 +0800 Subject: [PATCH 13/16] perhaps install from wheels? --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 721aba8dd83..eaa84bff708 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,11 +85,11 @@ jobs: # see: https://discuss.dgl.ai/t/filenotfounderror-cannot-find-dgl-c-graphbolt-library/4302 pip install torch==2.2.1 - # Install from sdist to test the content + # Install from wheels to test the content uv pip install build - python -m build --sdist + python -m build --wheel - uv pip install dist/*.tar.gz + uv pip install dist/*.whl uv pip install pymatgen[${{ matrix.config.extras }}] --resolution=${{ matrix.config.resolution }} - name: Install optional Ubuntu dependencies From 3fcf1fa7d7a15218ef4d34fc660f55bfae069773 Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 22 Oct 2024 11:38:45 +0800 Subject: [PATCH 14/16] skip failing test as dgl doesn't support torch 2.4.1 --- tests/transformations/test_advanced_transformations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/transformations/test_advanced_transformations.py b/tests/transformations/test_advanced_transformations.py index f1964cc4f2c..b4b7648fb5a 100644 --- a/tests/transformations/test_advanced_transformations.py +++ b/tests/transformations/test_advanced_transformations.py @@ -182,6 +182,8 @@ def test_apply_transformation(self): for struct_trafo in alls: assert "energy" not in struct_trafo + pytest.skip(reason="dgl don't support torch 2.4.1+, #4073") + def test_m3gnet(self): pytest.importorskip("matgl") enum_trans = EnumerateStructureTransformation(refine_structure=True, sort_criteria="m3gnet_relax") @@ -197,6 +199,7 @@ def test_m3gnet(self): # Check ordering of energy/atom assert alls[0]["energy"] / alls[0]["num_sites"] <= alls[-1]["energy"] / alls[-1]["num_sites"] + @pytest.skip(reason="dgl don't support torch 2.4.1+, #4073") def test_callable_sort_criteria(self): matgl = pytest.importorskip("matgl") from matgl.ext.ase import Relaxer From b2c97bc390f97b9e7ad03d1cc5a72d84ec489d1f Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 22 Oct 2024 11:42:48 +0800 Subject: [PATCH 15/16] revert pyproject in favor in separate PR --- pyproject.toml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4e30b2c9612..8805c438ae0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,34 +87,40 @@ Issues = "https://github.com/materialsproject/pymatgen/issues" Pypi = "https://pypi.org/project/pymatgen" [project.optional-dependencies] -abinit = ["netcdf4>=1.7.1"] ase = ["ase>=3.23.0"] +# tblite only support Python 3.12+ through conda-forge +# https://github.com/tblite/tblite/issues/175 +tblite = ["tblite[ase]>=0.3.0; python_version<'3.12'"] +vis = ["vtk>=6.0.0"] +abinit = ["netcdf4>=1.7.1"] +mlp = ["chgnet>=0.3.8", "matgl>=1.1.3"] +electronic_structure = ["fdint>=2.0.2"] ci = ["pytest-cov>=4", "pytest-split>=0.8", "pytest>=8"] docs = ["invoke", "sphinx", "sphinx_markdown_builder", "sphinx_rtd_theme"] -electronic_structure = ["fdint>=2.0.2"] -mlp = ["chgnet>=0.3.8", "matgl>=1.1.3"] -numba = ["numba>=0.55"] -numpy-v1 = ["numpy>=1.25.0,<2"] # Test NP1 on Windows (quite buggy ATM) optional = [ - "pymatgen[abinit,ase,mlp,tblite]", - "beautifulsoup4>=4.6.0", + "ase>=3.23.0", + "beautifulsoup4", # BoltzTraP2 build fails on Windows GitHub runners "BoltzTraP2>=24.9.4 ; platform_system != 'Windows'", "chemview>=0.6", + "chgnet>=0.3.8", "f90nml>=1.1.2", "galore>=0.6.1", "h5py>=3.11.0", "jarvis-tools>=2020.7.14", + "matgl>=1.1.3", "matplotlib>=3.8", + "netCDF4>=1.6.5", "phonopy>=2.23", "seekpath>=2.0.1", + # tblite only support Python 3.12+ through conda-forge + # https://github.com/tblite/tblite/issues/175 "hiphive>=1.3.1", "openbabel-wheel>=3.1.1.20", + "tblite[ase]>=0.3.0; platform_system=='Linux' and python_version<'3.12'", ] -# tblite only support Python 3.12+ through conda-forge -# https://github.com/tblite/tblite/issues/175 -tblite = ["tblite[ase]>=0.3.0; platform_system=='Linux' and python_version<'3.12'"] -vis = ["vtk>=6.0.0"] +numba = ["numba>=0.55"] +numpy-v1 = ["numpy>=1.25.0,<2"] # Test NP1 on Windows (quite buggy ATM) [project.scripts] pmg = "pymatgen.cli.pmg:main" From 8d11d91b9e6ebceb600c1190561d696fe94e061d Mon Sep 17 00:00:00 2001 From: "Haoyu (Daniel)" Date: Tue, 22 Oct 2024 11:43:55 +0800 Subject: [PATCH 16/16] fix missing @ --- tests/transformations/test_advanced_transformations.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/transformations/test_advanced_transformations.py b/tests/transformations/test_advanced_transformations.py index b4b7648fb5a..39a58e15f9d 100644 --- a/tests/transformations/test_advanced_transformations.py +++ b/tests/transformations/test_advanced_transformations.py @@ -182,8 +182,7 @@ def test_apply_transformation(self): for struct_trafo in alls: assert "energy" not in struct_trafo - pytest.skip(reason="dgl don't support torch 2.4.1+, #4073") - + @pytest.mark.skip(reason="dgl don't support torch 2.4.1+, #4073") def test_m3gnet(self): pytest.importorskip("matgl") enum_trans = EnumerateStructureTransformation(refine_structure=True, sort_criteria="m3gnet_relax") @@ -199,7 +198,7 @@ def test_m3gnet(self): # Check ordering of energy/atom assert alls[0]["energy"] / alls[0]["num_sites"] <= alls[-1]["energy"] / alls[-1]["num_sites"] - @pytest.skip(reason="dgl don't support torch 2.4.1+, #4073") + @pytest.mark.skip(reason="dgl don't support torch 2.4.1+, #4073") def test_callable_sort_criteria(self): matgl = pytest.importorskip("matgl") from matgl.ext.ase import Relaxer