Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix release CI workflow #2728

Merged
merged 5 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
77 changes: 0 additions & 77 deletions .github/workflows/release.yml

This file was deleted.

38 changes: 33 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# This workflow runs only on Ubuntu and aims to be more complete than the Mac and Windows workflows.
# In particular, Openbabel and many of the external command line dependencies are included for testing.defaults:
# The ext package is also only tested in this workflow. Coverage is computed based on this workflow.
# Runs the complete test suite incl. many external command line dependencies (like Openbabel)
# as well as the pymatgen.ext package. Coverage is computed based on this workflow.
name: Tests

on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]
workflow_dispatch:

permissions:
contents: read
Expand All @@ -28,7 +30,7 @@ jobs:

env:
PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }}
MPLBACKEND: Agg
MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434
PMG_TEST_FILES_DIR: ${{ github.workspace }}/test_files
GULP_LIB: ${{ github.workspace }}/cmd_line/gulp/Libraries

Expand Down Expand Up @@ -56,7 +58,6 @@ jobs:
# to update the test durations, run
# pytest --store-durations --durations-path test_files/.pytest-split-durations
# and commit the results
continue-on-error: true
run: |
pytest --cov=pymatgen --splits 10 --group ${{ matrix.split }} --durations-path test_files/.pytest-split-durations
- name: Upload coverage
Expand Down Expand Up @@ -88,3 +89,30 @@ jobs:
- name: Coveralls Python
continue-on-error: true
uses: AndreMiras/coveralls-python-action@v20201129

release:
needs: pytest
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
strategy:
matrix:
os: [macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.py
- name: Release
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: |
pip install --upgrade pip wheel setuptools twine
python setup.py sdist bdist_wheel
twine upload --skip-existing dist/*.{whl,tar.gz}
continue-on-error: true
8 changes: 4 additions & 4 deletions pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,23 +1867,23 @@ def copy(self, site_properties=None, sanitize=False):
A copy of the Structure, with optionally new site_properties and
optionally sanitized.
"""
site_props = self.site_properties
props = self.site_properties
if site_properties:
site_props.update(site_properties)
props.update(site_properties)
if not sanitize:
return self.__class__(
self._lattice,
self.species_and_occu,
self.frac_coords,
charge=self._charge,
site_properties=site_props,
site_properties=props,
)
reduced_latt = self._lattice.get_lll_reduced_lattice()
new_sites = []
for idx, site in enumerate(self):
frac_coords = reduced_latt.get_fractional_coords(site.coords)
site_props = {}
for prop, val in site_props.items():
for prop, val in props.items():
site_props[prop] = val[idx]
new_sites.append(
PeriodicSite(
Expand Down
10 changes: 5 additions & 5 deletions pymatgen/entries/computed_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import os
import warnings
from itertools import combinations
from typing import Literal
from typing import Literal, cast

import numpy as np
from monty.json import MontyDecoder, MontyEncoder, MSONable
Expand Down Expand Up @@ -142,7 +142,7 @@ def explain(self):
"""
Return an explanation of how the energy adjustment is calculated.
"""
return self.description + f" ({self.value:.3f} eV)"
return f"{self.description} ({self.value:.3f} eV)"

def normalize(self, factor):
"""
Expand Down Expand Up @@ -222,7 +222,7 @@ def explain(self):
"""
Return an explanation of how the energy adjustment is calculated.
"""
return self.description + f" ({self._adj_per_atom:.3f} eV/atom x {self.n_atoms} atoms)"
return f"{self.description} ({self._adj_per_atom:.3f} eV/atom x {self.n_atoms} atoms)"

def normalize(self, factor):
"""
Expand Down Expand Up @@ -289,7 +289,7 @@ def explain(self):
"""
Return an explanation of how the energy adjustment is calculated.
"""
return self.description + f" ({self._adj_per_deg:.4f} eV/K/atom x {self.temp} K x {self.n_atoms} atoms)"
return f"{self.description} ({self._adj_per_deg:.4f} eV/K/atom x {self.temp} K x {self.n_atoms} atoms)"

def normalize(self, factor):
"""
Expand Down Expand Up @@ -491,7 +491,7 @@ def __eq__(self, other: object) -> bool:
if not all(hasattr(other, attr) for attr in needed_attrs):
return NotImplemented

assert isinstance(other, ComputedEntry) # mypy type narrowing
other = cast(ComputedEntry, other)

# Equality is defined based on composition and energy
# If structures are involved, it is assumed that a {composition, energy} is
Expand Down
16 changes: 13 additions & 3 deletions pymatgen/util/tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@ def _type_str(some_type: Any) -> str:


def test_entry_like():
assert (
_type_str(EntryLike) == "Union[Dict[str, Any], ForwardRef('Entry'), "
"ForwardRef('PDEntry'), ForwardRef('ComputedEntry'), ForwardRef('ComputedStructureEntry')]"
entries = (
"Entry",
"ComputedEntry",
"ComputedStructureEntry",
"PDEntry",
"ExpEntry",
"TransformedPDEntry",
"GrandPotPDEntry",
"CostEntry",
"GibbsComputedStructureEntry",
)
type_str = _type_str(EntryLike)
for entry in entries:
assert entry in type_str
assert Entry.__name__ in str(EntryLike)


Expand Down
7 changes: 6 additions & 1 deletion pymatgen/util/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
TransformedPDEntry,
)
from pymatgen.entries import Entry
from pymatgen.entries.computed_entries import ComputedEntry, ComputedStructureEntry
from pymatgen.entries.computed_entries import (
ComputedEntry,
ComputedStructureEntry,
GibbsComputedStructureEntry,
)
from pymatgen.entries.exp_entries import ExpEntry

VectorLike = Union[Sequence[float], np.ndarray]
Expand All @@ -55,4 +59,5 @@
"TransformedPDEntry",
"GrandPotPDEntry",
"CostEntry",
"GibbsComputedStructureEntry",
]
9 changes: 2 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.

"""Setup.py for pymatgen."""

from __future__ import annotations

import platform
Expand All @@ -13,7 +11,7 @@

extra_link_args: list[str] = []
if sys.platform.startswith("win") and platform.machine().endswith("64"):
extra_link_args.append("-Wl,--allow-multiple-definition")
extra_link_args = ["-Wl,--allow-multiple-definition"]


long_desc = """
Expand Down Expand Up @@ -79,9 +77,6 @@
),
version="2022.11.7",
python_requires=">=3.8",
setup_requires=[
"Cython>=0.29.23",
],
install_requires=[
"matplotlib>=1.5",
"monty>=3.0.2",
Expand All @@ -95,7 +90,7 @@
"requests",
"ruamel.yaml>=0.17.0",
"scipy>=1.5.0",
"spglib>=2.0",
"spglib>=2.0.2",
"sympy",
"tabulate",
"tqdm",
Expand Down