Skip to content

Commit 1242222

Browse files
authored
Merge pull request #115 from alchem0x2A/master
Update api update workflow and paper
2 parents 183fca3 + fafcf9a commit 1242222

File tree

7 files changed

+48
-44
lines changed

7 files changed

+48
-44
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
id-token: write
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
- uses: conda-incubator/setup-miniconda@v3
2424
with:
25-
python-version: "3.10"
25+
python-version: "3.11"
2626
mamba-version: "*"
2727
channels: conda-forge,defaults
2828
channel-priority: true

.github/workflows/update_api.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
run:
1818
shell: bash -l {0}
1919
runs-on: ubuntu-latest
20+
# Only the upstream repo runs the automatic API update
21+
if: |
22+
!github.event.repository.fork || github.event_name == 'workflow_dispatch'
2023
2124
steps:
2225
- uses: actions/checkout@v4
@@ -48,37 +51,34 @@ jobs:
4851
echo UPDATE_NEEDED is "${UPDATE_NEEDED}"
4952
echo API version is "${API_VERSION}"
5053
continue-on-error: true
51-
- name: Create PR body text
54+
- name: Create or Update Pull Request
55+
# Manually disable to make sure it can rerun
5256
if: env.UPDATE_NEEDED == 'true'
53-
run: |
54-
touch pr_body.txt
55-
echo "## Automated JSON API Update" >> pr_body.txt
56-
echo "Hello! This is an automatic pull request to merge the new JSON API version **${API_VERSION}** into the master branch." >> pr_body.txt
57-
echo "### Details" >> pr_body.txt
58-
echo "- **Workflow Trigger**: This update is triggered by the **Update JSON API (recurring job)** workflow." >> pr_body.txt
59-
echo "- **Reason for Update**: A new JSON schema version was generated that differs from the existing one in the repository." >> pr_body.txt
60-
echo "### Notes" >> pr_body.txt
61-
echo "- If you notice any issues or have questions regarding this update, please contact @alchem0x2a or other maintainers of the repository." >> pr_body.txt
62-
echo "Thank you for keeping the SPARC-X-API project up-to-date! 🚀" >> pr_body.txt
63-
cat pr_body.txt
64-
- name: Create Pull Request
65-
# Do not create PR from another PR
66-
if: (env.UPDATE_NEEDED == 'true') && (github.event_name != 'pull_request')
67-
run: |
68-
git config --global user.email "alchem0x2a@gmail.com"
69-
git config --global user.name "Github Action Bot"
70-
echo "New version is ${API_VERSION}"
71-
BRANCH_NAME="update-api-${GITHUB_RUN_ID}"
72-
echo "Checking new branch ${BRANCH_NAME}"
73-
git checkout -b $BRANCH_NAME
74-
mv parameters.json sparc/sparc_json_api/
75-
git add sparc/sparc_json_api/parameters.json
76-
git commit -m "Add new json api version ${API_VERSION}"
77-
git push --force --set-upstream origin ${BRANCH_NAME}
57+
uses: peter-evans/create-pull-request@v7
58+
with:
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
commit-message: |
61+
Update JSON API to version ${{ env.API_VERSION }}
62+
63+
The commit is created by a scheduled CI job.
64+
""
65+
branch: update-api-${{ env.API_VERSION }}
66+
title: "[Automated] Update JSON API to version ${{ env.API_VERSION }}"
67+
body: |
68+
## Automated JSON API Update
69+
70+
Hello! This is an automatic pull request to merge the new JSON API to version **${{ env.API_VERSION }}**.
71+
72+
### Details
73+
- **Workflow Trigger:** Update JSON API (recurring job).
74+
- **Reason for Update:** A new JSON schema version was generated that differs from the existing one in the repository.
75+
76+
### Notes
77+
- If you notice any issues or have questions regarding this update, please reach out to the maintainers.
7878
79-
gh pr create --base master \
80-
--title "[PR Bot] New JSON API version ${API_VERSION}" \
81-
--body-file pr_body.txt \
82-
-R ${{ github.repository_owner }}/SPARC-X-API
83-
env:
84-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
# Eliminate unnecessary PRs if not closed
80+
delete-branch: true
81+
# Prevent PRs on forks
82+
base: master
83+
delete-branch: true
84+
base: master

paper/paper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ authors:
2929
corresponding: true
3030
affiliation: "1, 2"
3131
affiliations:
32-
- name: College of Engineering, Georgia Institute of Technology, Atlanta, GA 30332, USA
32+
- name: College of Engineering, Georgia Institute of Technology, Atlanta, GA 30332, United States of America
3333
index: 1
34-
- name: College of Computing, Georgia Institute of Technology, Atlanta, GA 30332, USA
34+
- name: College of Computing, Georgia Institute of Technology, Atlanta, GA 30332, United States of America
3535
index: 2
3636
- name: Department of Chemical and Materials Engineering, University of Alberta, Edmonton AB, T6G 2R3, Canada
3737
index: 3

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
#
66
# Note: the actual installation is still handled by setup.py
77
[build-system]
8-
requires = ["setuptools >= 64", "wheel"]
8+
requires = ["setuptools >= 64", "wheel", "setuptools-scm>=8"]
99
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
from setuptools import find_packages
77
from setuptools.command.install import install
8+
from setuptools_scm import get_version
9+
10+
print(f"Version from setuptools_scm is {get_version()}")
811

912
test_requires = [
1013
"pytest",
@@ -25,7 +28,9 @@
2528

2629
setup(
2730
name="sparc-x-api",
28-
version="1.0.8",
31+
# @TT 2025.06.07 we use setuptools_scm for future
32+
# releases before fully transition to pyproject.toml
33+
version=get_version(),
2934
python_requires=">=3.8",
3035
description="Python API for the SPARC DFT Code",
3136
long_description=open("README.md").read(),

sparc/common.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from pathlib import Path
1+
import importlib.resources
22

3-
import pkg_resources
4-
5-
repo_dir = Path(pkg_resources.resource_filename("sparc", "."))
6-
psp_dir = Path(pkg_resources.resource_filename("sparc", "psp"))
3+
repo_dir = importlib.resources.files("sparc")
4+
psp_dir = repo_dir / "psp"

sparc/docparser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ def sanitize_type(param_dict, suppress_warnings=False):
728728
f"The error is {e}"
729729
)
730730
_array_test = False # Retain
731+
_bool_test = False
731732

732733
if _array_test is True:
733734
sanitized_type = f"{origin_type} array"
@@ -796,4 +797,4 @@ def sanitize_type(param_dict, suppress_warnings=False):
796797
with open(output, "w", encoding="utf8") as fd:
797798
fd.write(json_string)
798799
print(f"SPARC parameter specifications written to {output}!")
799-
print("If you need to fintune the definitions, please edit them manually.")
800+
print("If you need to finetune the definitions, please edit them manually.")

0 commit comments

Comments
 (0)