From 6bc687bee9cd46b2901fba0bfec10a9840970626 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 1 Oct 2024 10:30:14 -0400 Subject: [PATCH 1/7] pre-commit file --- .pre-commit-config.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c458806..3070e19 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,10 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - exclude: '\.(rst|txt)$' + - id: check-case-conflict + - id: check-merge-conflict + - id: check-toml + - id: check-added-large-files - repo: https://github.com/psf/black rev: 24.4.2 hooks: From dd57b34281235ff4ada9704941301e21d8189fad Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 1 Oct 2024 10:30:49 -0400 Subject: [PATCH 2/7] .github files --- .github/workflows/check-news-item.yml | 12 ++++ .github/workflows/docs.yml | 60 ------------------- .github/workflows/main.yml | 55 ----------------- .../matrix-and-codecov-on-merge-to-main.yml | 21 +++++++ .github/workflows/pre-commit.yml | 19 ------ .github/workflows/publish-docs-on-release.yml | 14 +++++ .github/workflows/tests-on-pr.yml | 16 +++++ 7 files changed, 63 insertions(+), 134 deletions(-) create mode 100644 .github/workflows/check-news-item.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/matrix-and-codecov-on-merge-to-main.yml delete mode 100644 .github/workflows/pre-commit.yml create mode 100644 .github/workflows/publish-docs-on-release.yml create mode 100644 .github/workflows/tests-on-pr.yml diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml new file mode 100644 index 0000000..628fe4c --- /dev/null +++ b/.github/workflows/check-news-item.yml @@ -0,0 +1,12 @@ +name: Check for News + +on: + pull_request_target: + branches: + - main + +jobs: + build: + uses: Billingegroup/release-scripts/.github/workflows/_check-news-item.yml@v0 + with: + project: diffpy.fourigui diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 9531248..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Build Documentation - -on: - push: - branches: - - main - release: - -jobs: - test: - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: build - environment-file: ./environment.yml - python-version: 3 - auto-update-conda: true - - - name: install requirements - run: | - conda config --set always_yes yes --set changeps1 no - conda config --add channels conda-forge - conda create -n build python=3.12 - conda activate build - conda install --file requirements/build.txt - conda install --file requirements/run.txt - conda install --file requirements/test.txt - conda install --file requirements/docs.txt - pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: build documents - run: make -C doc html - - - name: Run tests and upload coverage - shell: bash -l {0} - run: | - conda activate build - coverage run -m pytest -vv -s - coverage report -m - codecov - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - - name: Deploy - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./doc/build/html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 9ab89ce..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: CI - -on: - push: - branches: - - main - - CI - pull_request: - workflow_dispatch: - -jobs: - miniconda: - name: Miniconda ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["ubuntu-latest"] - steps: - - name: check out diffpy.fourigui - uses: actions/checkout@v3 - with: - repository: diffpy/diffpy.fourigui - path: . - fetch-depth: 0 # avoid shallow clone with no tags - - - name: initialize miniconda - # this uses a marketplace action that sets up miniconda in a way that makes - # it easier to use. I tried setting it up without this and it was a pain - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: test - # environment.yml file is needed by this action. Because I don't want - # maintain this but rather maintain the requirements files it just has - # basic things in it like conda and pip - environment-file: ./environment.yml - python-version: 3 - auto-activate-base: false - - - name: install diffpy.fourigui requirements - shell: bash -l {0} - run: | - conda config --set always_yes yes --set changeps1 no - conda config --add channels conda-forge - conda activate test - conda install --file requirements/run.txt - conda install --file requirements/test.txt - pip install . - - - name: Validate diffpy.fourigui - shell: bash -l {0} - run: | - conda activate test - coverage run -m pytest -vv -s - coverage report -m - codecov diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml new file mode 100644 index 0000000..534196c --- /dev/null +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -0,0 +1,21 @@ +name: CI + +on: + push: + branches: + - main + release: + types: + - prereleased + - published + workflow_dispatch: + +jobs: + coverage: + uses: Billingegroup/release-scripts/.github/workflows/_matrix-and-codecov-on-merge-to-main.yml@v0 + with: + project: diffpy.fourigui + c_extension: false + headless: false + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml deleted file mode 100644 index f2ff7e4..0000000 --- a/.github/workflows/pre-commit.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: pre-commit - -on: - pull_request: - push: - workflow_dispatch: - -jobs: - pre-commit: - # pull requests are a duplicate of a branch push if within the same repo. - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - - uses: pre-commit/action@v3.0.0 - with: - extra_args: --all-files diff --git a/.github/workflows/publish-docs-on-release.yml b/.github/workflows/publish-docs-on-release.yml new file mode 100644 index 0000000..e341881 --- /dev/null +++ b/.github/workflows/publish-docs-on-release.yml @@ -0,0 +1,14 @@ +name: Build and Deploy Docs + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + docs: + uses: Billingegroup/release-scripts/.github/workflows/_publish-docs-on-release.yml@v0 + with: + project: diffpy.fourigui + c_extension: false diff --git a/.github/workflows/tests-on-pr.yml b/.github/workflows/tests-on-pr.yml new file mode 100644 index 0000000..fa361f9 --- /dev/null +++ b/.github/workflows/tests-on-pr.yml @@ -0,0 +1,16 @@ +name: Tests on PR + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + validate: + uses: Billingegroup/release-scripts/.github/workflows/_tests-on-pr.yml@v0 + with: + project: diffpy.fourigui + c_extension: false + headless: false From 501273170f99a826f703eb4fe0fd26418623001b Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 1 Oct 2024 10:31:10 -0400 Subject: [PATCH 3/7] diffpy and tests directories --- diffpy/__init__.py | 23 ++++++++++++++++++++ diffpy/fourigui/__init__.py | 24 +++++++++++++++++++++ diffpy/fourigui/tests/__init__.py | 0 diffpy/fourigui/tests/conftest.py | 19 +++++++++++++++++ diffpy/fourigui/tests/debug.py | 35 +++++++++++++++++++++++++++++++ diffpy/fourigui/version.py | 26 +++++++++++++++++++++++ tests/conftest.py | 19 +++++++++++++++++ tests/test_version.py | 10 +++++++++ 8 files changed, 156 insertions(+) create mode 100644 diffpy/__init__.py create mode 100644 diffpy/fourigui/__init__.py create mode 100644 diffpy/fourigui/tests/__init__.py create mode 100644 diffpy/fourigui/tests/conftest.py create mode 100644 diffpy/fourigui/tests/debug.py create mode 100644 diffpy/fourigui/version.py create mode 100644 tests/conftest.py create mode 100644 tests/test_version.py diff --git a/diffpy/__init__.py b/diffpy/__init__.py new file mode 100644 index 0000000..4d4bf70 --- /dev/null +++ b/diffpy/__init__.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +############################################################################## +# +# (c) 2024 The Trustees of Columbia University in the City of New York. +# All rights reserved. +# +# File coded by: Billinge Group members and community contributors. +# +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.fourigui/graphs/contributors +# +# See LICENSE.rst for license information. +# +############################################################################## + +"""Blank namespace package for module diffpy.""" + + +from pkgutil import extend_path + +__path__ = extend_path(__path__, __name__) + +# End of file diff --git a/diffpy/fourigui/__init__.py b/diffpy/fourigui/__init__.py new file mode 100644 index 0000000..3ccc189 --- /dev/null +++ b/diffpy/fourigui/__init__.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +############################################################################## +# +# (c) 2024 The Trustees of Columbia University in the City of New York. +# All rights reserved. +# +# File coded by: Billinge Group members and community contributors. +# +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.fourigui/graphs/contributors +# +# See LICENSE.rst for license information. +# +############################################################################## + +"""Tool for visualizing 3D diffraction and PDF Images.""" + +# package version +from diffpy.fourigui.version import __version__ + +# silence the pyflakes syntax checker +assert __version__ or True + +# End of file diff --git a/diffpy/fourigui/tests/__init__.py b/diffpy/fourigui/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/diffpy/fourigui/tests/conftest.py b/diffpy/fourigui/tests/conftest.py new file mode 100644 index 0000000..e3b6313 --- /dev/null +++ b/diffpy/fourigui/tests/conftest.py @@ -0,0 +1,19 @@ +import json +from pathlib import Path + +import pytest + + +@pytest.fixture +def user_filesystem(tmp_path): + base_dir = Path(tmp_path) + home_dir = base_dir / "home_dir" + home_dir.mkdir(parents=True, exist_ok=True) + cwd_dir = base_dir / "cwd_dir" + cwd_dir.mkdir(parents=True, exist_ok=True) + + home_config_data = {"username": "home_username", "email": "home@email.com"} + with open(home_dir / "diffpyconfig.json", "w") as f: + json.dump(home_config_data, f) + + yield tmp_path diff --git a/diffpy/fourigui/tests/debug.py b/diffpy/fourigui/tests/debug.py new file mode 100644 index 0000000..60c9014 --- /dev/null +++ b/diffpy/fourigui/tests/debug.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +############################################################################## +# +# (c) 2024 The Trustees of Columbia University in the City of New York. +# All rights reserved. +# +# File coded by: Billinge Group members and community contributors. +# +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.fourigui/graphs/contributors +# +# See LICENSE.rst for license information. +# +############################################################################## + +""" +Convenience module for debugging the unit tests using + +python -m diffpy.fourigui.tests.debug + +Exceptions raised by failed tests or other errors are not caught. +""" + + +if __name__ == "__main__": + import sys + + from diffpy.fourigui.tests import testsuite + + pattern = sys.argv[1] if len(sys.argv) > 1 else "" + suite = testsuite(pattern) + suite.debug() + + +# End of file diff --git a/diffpy/fourigui/version.py b/diffpy/fourigui/version.py new file mode 100644 index 0000000..e8b1019 --- /dev/null +++ b/diffpy/fourigui/version.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +############################################################################## +# +# (c) 2024 The Trustees of Columbia University in the City of New York. +# All rights reserved. +# +# File coded by: Billinge Group members and community contributors. +# +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.fourigui/graphs/contributors +# +# See LICENSE.rst for license information. +# +############################################################################## + +"""Definition of __version__.""" + +# We do not use the other three variables, but can be added back if needed. +# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] + +# obtain version information +from importlib.metadata import version + +__version__ = version("diffpy.fourigui") + +# End of file diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e3b6313 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +import json +from pathlib import Path + +import pytest + + +@pytest.fixture +def user_filesystem(tmp_path): + base_dir = Path(tmp_path) + home_dir = base_dir / "home_dir" + home_dir.mkdir(parents=True, exist_ok=True) + cwd_dir = base_dir / "cwd_dir" + cwd_dir.mkdir(parents=True, exist_ok=True) + + home_config_data = {"username": "home_username", "email": "home@email.com"} + with open(home_dir / "diffpyconfig.json", "w") as f: + json.dump(home_config_data, f) + + yield tmp_path diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..4fc6f6a --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,10 @@ +"""Unit tests for __version__.py +""" + +import diffpy.fourigui + + +def test_package_version(): + """Ensure the package version is defined and not set to the initial placeholder.""" + assert hasattr(diffpy.fourigui, "__version__") + assert diffpy.fourigui.__version__ != "0.0.0" From 7a44b432e6498e7f1b1861526e120c246f21487f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:32:18 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit hooks --- README.rst | 2 +- doc/source/license.rst | 4 ++-- requirements/README.txt | 2 +- src/diffpy/__init__.py | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index e22485a..289a00a 100644 --- a/README.rst +++ b/README.rst @@ -90,7 +90,7 @@ Support and Contribute `Diffpy user group `_ is the discussion forum for general questions and discussions about the use of diffpy.fourigui. Please join the diffpy.fourigui users community by joining the Google group. The diffpy.fourigui project welcomes your expertise and enthusiasm! -If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. +If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. Feel free to fork the project and contribute. To install diffpy.fourigui in a development mode, with its sources being directly used by Python diff --git a/doc/source/license.rst b/doc/source/license.rst index cfab61c..9ae52a9 100644 --- a/doc/source/license.rst +++ b/doc/source/license.rst @@ -9,9 +9,9 @@ OPEN SOURCE LICENSE AGREEMENT ============================= BSD 3-Clause License -Copyright (c) 2024, The Trustees of Columbia University in +Copyright (c) 2024, The Trustees of Columbia University in the City of New York. -All Rights Reserved. +All Rights Reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/requirements/README.txt b/requirements/README.txt index dc34909..3de372a 100644 --- a/requirements/README.txt +++ b/requirements/README.txt @@ -2,7 +2,7 @@ # # This directory is where you should place your project dependencies. # "pip.txt" should contain all required packages not available on conda. -# All other files should contain only packages available to download from conda. +# All other files should contain only packages available to download from conda. # build.txt should contain all packages required to build (not run) the project. # run.txt should contain all packages (including optional packages) required for a user to run the program. # test.txt should contain all packages required for the testing suite and to ensure all tests pass. diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py index 586be9d..4d4bf70 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -21,4 +21,3 @@ __path__ = extend_path(__path__, __name__) # End of file - From 7393ed1ff2edda1808a0211beb6e117af49c8c1a Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 1 Oct 2024 14:00:40 -0400 Subject: [PATCH 5/7] remove test dir --- src/diffpy/fourigui/tests/__init__.py | 0 src/diffpy/fourigui/tests/conftest.py | 19 --------------- src/diffpy/fourigui/tests/debug.py | 35 --------------------------- 3 files changed, 54 deletions(-) delete mode 100644 src/diffpy/fourigui/tests/__init__.py delete mode 100644 src/diffpy/fourigui/tests/conftest.py delete mode 100644 src/diffpy/fourigui/tests/debug.py diff --git a/src/diffpy/fourigui/tests/__init__.py b/src/diffpy/fourigui/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/diffpy/fourigui/tests/conftest.py b/src/diffpy/fourigui/tests/conftest.py deleted file mode 100644 index e3b6313..0000000 --- a/src/diffpy/fourigui/tests/conftest.py +++ /dev/null @@ -1,19 +0,0 @@ -import json -from pathlib import Path - -import pytest - - -@pytest.fixture -def user_filesystem(tmp_path): - base_dir = Path(tmp_path) - home_dir = base_dir / "home_dir" - home_dir.mkdir(parents=True, exist_ok=True) - cwd_dir = base_dir / "cwd_dir" - cwd_dir.mkdir(parents=True, exist_ok=True) - - home_config_data = {"username": "home_username", "email": "home@email.com"} - with open(home_dir / "diffpyconfig.json", "w") as f: - json.dump(home_config_data, f) - - yield tmp_path diff --git a/src/diffpy/fourigui/tests/debug.py b/src/diffpy/fourigui/tests/debug.py deleted file mode 100644 index 60c9014..0000000 --- a/src/diffpy/fourigui/tests/debug.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2024 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.fourigui/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## - -""" -Convenience module for debugging the unit tests using - -python -m diffpy.fourigui.tests.debug - -Exceptions raised by failed tests or other errors are not caught. -""" - - -if __name__ == "__main__": - import sys - - from diffpy.fourigui.tests import testsuite - - pattern = sys.argv[1] if len(sys.argv) > 1 else "" - suite = testsuite(pattern) - suite.debug() - - -# End of file From c5f277655e8552e9ce5e8edddf277f2a0c755109 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 1 Oct 2024 14:01:08 -0400 Subject: [PATCH 6/7] remove readme.txt --- requirements/README.txt | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 requirements/README.txt diff --git a/requirements/README.txt b/requirements/README.txt deleted file mode 100644 index dc34909..0000000 --- a/requirements/README.txt +++ /dev/null @@ -1,11 +0,0 @@ -# YOU MAY DELETE THIS FILE AFTER SETTING UP DEPENDENCIES! -# -# This directory is where you should place your project dependencies. -# "pip.txt" should contain all required packages not available on conda. -# All other files should contain only packages available to download from conda. -# build.txt should contain all packages required to build (not run) the project. -# run.txt should contain all packages (including optional packages) required for a user to run the program. -# test.txt should contain all packages required for the testing suite and to ensure all tests pass. -# docs.txt should contain all packages required for building the package documentation page. -# -# YOU MAY DELETE THIS FILE AFTER SETTING UP DEPENDENCIES! From 30e9c136387b7df0ad9d0a030e544216058ec67e Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 1 Oct 2024 14:04:09 -0400 Subject: [PATCH 7/7] remove README.txt --- requirements/README.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 requirements/README.txt diff --git a/requirements/README.txt b/requirements/README.txt deleted file mode 100644 index e69de29..0000000