Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix-test-toml
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Sep 3, 2024
2 parents c1785d8 + 053ecf4 commit d4a59d0
Show file tree
Hide file tree
Showing 82 changed files with 4,240 additions and 5,469 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/issue-metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Monthly issue metrics
on:
workflow_dispatch:
schedule:
- cron: '3 2 1 * *'

permissions:
contents: read

jobs:
build:
name: issue metrics
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: read
steps:
- name: Get dates for last month
shell: bash
run: |
# Calculate the first day of the previous month
first_day=$(date -d "last month" +%Y-%m-01)
# 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
echo "$first_day..$last_day"
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"
- name: Run issue-metrics tool
uses: github/issue-metrics@v3
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:materialsproject/crystaltoolkit is:issue created:${{ env.last_month }} -reason:"not planned"'

- name: Create issue
uses: peter-evans/create-issue-from-file@v5
with:
title: Monthly issue metrics report
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
19 changes: 14 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
name: pytest
name: Testing

on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches: [main]
branches:
- main

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
Expand All @@ -29,7 +38,7 @@ jobs:
python${{ matrix.python-version }} -m pip install `grep numpy== requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt`
python${{ matrix.python-version }} -m pip install -r requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt
python${{ matrix.python-version }} -m pip install --upgrade pip
python${{ matrix.python-version }} -m pip install --no-deps .
python${{ matrix.python-version }} -m pip install --no-deps .[server]
- name: Test modules
run: python${{ matrix.python-version }} -m pytest tests
- name: Test example apps
Expand Down
26 changes: 17 additions & 9 deletions .github/workflows/pytest-docs.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
name: Tests
name: Build Docs

on: [release, workflow_dispatch]
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches:
- main
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
Expand All @@ -20,18 +30,20 @@ jobs:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install webdriver
run: sudo apt-get update && sudo apt-get install firefox-geckodriver
run: sudo apt-get update && sudo apt-get install chromium-chromedriver
- name: Install dependencies
run: |
python${{ matrix.python-version }} -m pip install --upgrade pip packaging wheel
python${{ matrix.python-version }} -m pip install `grep numpy== requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt`
python${{ matrix.python-version }} -m pip install -r requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt
python${{ matrix.python-version }} -m pip install --upgrade pip
python${{ matrix.python-version }} -m pip install --no-deps .
- name: Build new docs
run: |
cd docs_rst
make html
- name: Detect changes
- name: Detect changes on release
if: startsWith(github.head_ref, 'releases/')
id: changes
shell: bash
run: |
Expand All @@ -45,7 +57,3 @@ jobs:
git add -A
git commit -m "Automated doc build"
git push
- name: pytest
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
run: pytest --color=yes --webdriver Firefox --headless crystal_toolkit/apps/examples/tests/
50 changes: 15 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,42 @@
name: Release

on: workflow_dispatch
on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.PAT }}

- uses: actions/setup-python@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: '**/pyproject.toml'

- name: bump version and create tag
env:
DATE_FORMAT: "%Y.%m.%d"
run: |
NEXT_RELEASE=$(date "+${DATE_FORMAT}")
LAST_RELEASE=$(git tag --sort=v:refname | grep "^20[^\-]*$" | tail -n 1)
echo "Last release : ${LAST_RELEASE}"
MAJOR_LAST_RELEASE=$(echo "${LAST_RELEASE}" | awk -v l=${#NEXT_RELEASE} '{ string=substr($0, 1, l); print string; }')
echo "Last major release : ${MAJOR_LAST_RELEASE}"
if [ "${MAJOR_LAST_RELEASE}" = "${NEXT_RELEASE}" ]; then
MINOR_LAST_RELEASE="$(echo "${LAST_RELEASE}" | awk -v l=$((${#NEXT_RELEASE} + 2)) '{ string=substr($0, l); print string; }')"
NEXT_RELEASE=${MAJOR_LAST_RELEASE}.$((MINOR_LAST_RELEASE + 1))
fi
echo "Next release: ${NEXT_RELEASE}"
git config --local user.email "github-actions@github.com"
git config --local user.name "github-actions"
python -m pip install --upgrade pip
python -m pip install --user --upgrade pip build setuptools setuptools_scm wheel
SETUPTOOLS_SCM_PRETEND_VERSION=${NEXT_RELEASE} python -m setuptools_scm
git add crystal_toolkit/_version.py
git commit -m "version bump: ${NEXT_RELEASE}"
git push
git tag ${NEXT_RELEASE}
git push --tags
echo "NEXT_RELEASE=${NEXT_RELEASE}" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install `grep numpy== requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt`
python -m pip install -r requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt
python -m pip install --upgrade pip
python -m pip install --no-deps .[server]
python${{ matrix.python-version }} -m pip install --upgrade pip packaging wheel build
python${{ matrix.python-version }} -m pip install `grep numpy== requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt`
python${{ matrix.python-version }} -m pip install -r requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt
python${{ matrix.python-version }} -m pip install --upgrade pip
python${{ matrix.python-version }} -m pip install --no-deps .[server]
- name: Build package
run: SETUPTOOLS_SCM_PRETEND_VERSION=${{env.NEXT_RELEASE}} python -m build
run: python${{ matrix.python-version }} -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1.5
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/upgrade-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest']
python-version: ["3.8", "3.9", "3.10"]
os: ['ubuntu-latest']
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Upgrade Python dependencies
shell: bash
run: |
python${{ matrix.python-version }} -m pip install --upgrade pip pip-tools
python${{ matrix.python-version }} -m pip install --upgrade pip pip-tools wheel cython setuptools
python${{ matrix.python-version }} -m pip install `grep numpy== requirements/${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt`
python${{ matrix.python-version }} -m piptools compile -q --upgrade --resolver=backtracking -o requirements/${{ matrix.os }}_py${{ matrix.python-version }}.txt pyproject.toml
python${{ matrix.python-version }} -m piptools compile -q --upgrade --resolver=backtracking --all-extras -o requirements/${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt pyproject.toml
Expand All @@ -43,7 +43,7 @@ jobs:
git config user.name github-actions
git config user.email github-actions@github.com
git add requirements
git commit -m "update dependencies for ${{ matrix.os }}/py${{ matrix.python-version }}"
git commit --allow-empty -m "update dependencies for ${{ matrix.os }}/py${{ matrix.python-version }}"
git push -f origin ${{ github.ref_name }}:auto-dependency-upgrades-${{ matrix.os }}-py${{ matrix.python-version }}
pull_request:
Expand All @@ -54,10 +54,10 @@ jobs:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: detect auto-upgrade-dependency branches
Expand Down
23 changes: 7 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@ default_install_hook_types: [pre-commit, commit-msg]

# ignore generated docs and dependency lock files, the directory
# jupyterlab-extension/ and all SVG, JS and CSS files
exclude: ^(docs/.+|.*lock.*|jupyterlab-extension/.+|.*\.(svg|js|css))$
exclude: ^(docs/.+|.*lock.*|jupyterlab-extension/.+|.*\.(svg|js|css))|_version.py$

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.277
rev: v0.4.8
hooks:
- id: ruff
args: [--fix, --ignore, D]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black-jupyter
- id: ruff-format

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.3.0
# hooks:
# - id: mypy

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-symlinks
Expand All @@ -37,19 +33,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.3.0
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--ignore-words-list, "nd,te,ois"]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-ruff
args: [--ignore-words-list, "nd,te,ois,dscribe", --check-filenames]

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
args: [--drop-empty-cells, --keep-output]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you would like a new-contributor issue assigned, get in touch with project ma
## Status

[![Tests](https://github.com/materialsproject/crystaltoolkit/actions/workflows/pytest-docs.yml/badge.svg)](https://github.com/materialsproject/crystaltoolkit/actions/workflows/pytest-docs.yml)
[![Visual Regression Test Status](https://percy.io/static/images/percy-badge.svg)](https://percy.io/Materials-Project/crystaltoolkit)
[![Visual Regression Test Status](https://percy.io/static/images/percy-badge.svg)](https://percy.io/6f28436a/crystaltoolkit)
[![Docker Build Status](https://img.shields.io/docker/cloud/build/materialsproject/crystaltoolkit)](https://hub.docker.com/repository/docker/materialsproject/crystaltoolkit/general)
[![Release](https://github.com/materialsproject/crystaltoolkit/actions/workflows/release.yml/badge.svg)](https://github.com/materialsproject/crystaltoolkit/actions/workflows/release.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/materialsproject/crystaltoolkit/main.svg)](https://results.pre-commit.ci/latest/github/materialsproject/crystaltoolkit/main)
Expand Down
14 changes: 4 additions & 10 deletions crystal_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@

from monty.json import MSONable

from crystal_toolkit.msonable import (
_ipython_display_,
_repr_mimebundle_,
show_json,
to_plotly_json,
)
import crystal_toolkit.helpers.layouts as ctl
from crystal_toolkit.core.jupyter import patch_msonable
from crystal_toolkit.core.plugin import CrystalToolkitPlugin
from crystal_toolkit.renderables import (
Lattice,
Molecule,
Expand All @@ -22,10 +19,7 @@
VolumetricData,
)

MSONable.to_plotly_json = to_plotly_json
MSONable._repr_mimebundle_ = _repr_mimebundle_
MSONable.show_json = show_json
MSONable._ipython_display_ = _ipython_display_
patch_msonable()

MODULE_PATH = Path(__file__).parents[0]

Expand Down
1 change: 0 additions & 1 deletion crystal_toolkit/_version.py

This file was deleted.

4 changes: 2 additions & 2 deletions crystal_toolkit/apps/examples/bandstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
)

# example layout to demonstrate capabilities of component
my_layout = Container(
layout = Container(
[H1("Band Structure and Density of States Example"), bsdos_component.layout()]
)

# wrap your app.layout with crystal_toolkit_layout()
# to ensure all necessary components are loaded into layout
ctc.register_crystal_toolkit(app, layout=my_layout)
ctc.register_crystal_toolkit(app, layout=layout)


# run this app with "python path/to/this/file.py"
Expand Down
4 changes: 2 additions & 2 deletions crystal_toolkit/apps/examples/basic_hello_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
structure_component = ctc.StructureMoleculeComponent(structure, id="hello_structure")

# add the component's layout to our app's layout
my_layout = html.Div([structure_component.layout()])
layout = html.Div([structure_component.layout()])

# as explained in "preamble" section in documentation
ctc.register_crystal_toolkit(app=app, layout=my_layout)
ctc.register_crystal_toolkit(app=app, layout=layout)
if __name__ == "__main__":
app.run(debug=True, port=8050)
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

# now we have two entries in our app layout,
# the structure component's layout and the button
my_layout = html.Div([structure_component.layout(), my_button])
layout = html.Div([structure_component.layout(), my_button])

ctc.register_crystal_toolkit(app=app, layout=my_layout)
ctc.register_crystal_toolkit(app=app, layout=layout)


# for the interactivity, we use a standard Dash callback
Expand Down
Loading

0 comments on commit d4a59d0

Please sign in to comment.