From 6e7ed3249e9d919d0f18f1a3f68a4da41257f721 Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 17:14:57 -0700 Subject: [PATCH 01/14] Infrastructure files --- dev-requirements.txt | 5 ++++ environment.yml | 18 +++++++++++++++ pytest.ini | 4 ++++ reconstructSPI/__init__.py | 1 + .../iterative_refinement/__init__.py | 1 + setup.py | 23 +++++++++++++++++++ tests/__init__.py | 0 7 files changed, 52 insertions(+) create mode 100644 dev-requirements.txt create mode 100644 environment.yml create mode 100644 pytest.ini create mode 100644 reconstructSPI/__init__.py create mode 100644 reconstructSPI/iterative_refinement/__init__.py create mode 100644 setup.py create mode 100644 tests/__init__.py diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..663cad4 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,5 @@ +black +flake8 +flake8-docstrings +isort +pre-commit diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..e52e0d7 --- /dev/null +++ b/environment.yml @@ -0,0 +1,18 @@ +name: reconstructSPI +channels: + - conda-forge + - defaults +dependencies: + - codecov + - coverage + - gemmi + - numpy + - numba + - pillow>=8.2.0 + - pip + - pytest + - pytest-cov + - pytorch + - pip : + - git+https://github.com/compSPI/simSPI.git + diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..cf93d60 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +testpaths = tests +python_files = *.py +python_functions = test_* \ No newline at end of file diff --git a/reconstructSPI/__init__.py b/reconstructSPI/__init__.py new file mode 100644 index 0000000..a16d370 --- /dev/null +++ b/reconstructSPI/__init__.py @@ -0,0 +1 @@ +"""Various particle reconstruction methods.""" diff --git a/reconstructSPI/iterative_refinement/__init__.py b/reconstructSPI/iterative_refinement/__init__.py new file mode 100644 index 0000000..5500bfe --- /dev/null +++ b/reconstructSPI/iterative_refinement/__init__.py @@ -0,0 +1 @@ +"""Iterative refinement reconstruction methods.""" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9631ff3 --- /dev/null +++ b/setup.py @@ -0,0 +1,23 @@ +"""Create instructions to build the reconstructSPI package.""" + +import setuptools + +requirements = [] + +setuptools.setup( + name="reconstructSPI", + maintainer="Frederic Poitevin", + version="0.0.1", + maintainer_email="frederic.poitevin@stanford.edu", + description="Reconstruction methods and tools for SPI", + long_description=open("README.md", encoding="utf8").read(), + long_description_content_type="text/markdown", + url="https://github.com/compSPI/reconstructSPI.git", + packages=setuptools.find_packages(), + install_requires=requirements, + classifiers=[ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", + ], + zip_safe=False, +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 From 6a9ee6963c82c93b2190944f5fa64b55ad5f63dc Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 17:16:24 -0700 Subject: [PATCH 02/14] Infrastructure files --- .codecov.yml | 24 +++++++++++++++ .coveragerc | 3 ++ .deepsource.toml | 10 ++---- .flake8 | 6 ++++ .github/auto-assign.yml | 4 +-- .github/workflows/lint.yml | 54 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 62 ++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 42 ++++++++++++++++++++++++++ 8 files changed, 195 insertions(+), 10 deletions(-) create mode 100644 .codecov.yml create mode 100644 .coveragerc create mode 100644 .flake8 create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml create mode 100644 .pre-commit-config.yaml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..c576999 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,24 @@ +coverage: + round: up + precision: 2 + status: + patch: + default: + # basic + target: 90% + threshold: 2% + base: auto + flags: + - unit + # advanced + branches: + - master + if_no_uploads: error + if_not_found: error + if_ci_failed: error + only_pulls: false + +# Files to ignore +ignore: + - "data" + - "notebooks" diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..94a9d5a --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[report] +fail_under = 90 +show_missing = True diff --git a/.deepsource.toml b/.deepsource.toml index 93a9d6f..b4f754a 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -1,6 +1,6 @@ version = 1 -test_patterns = ["test/**"] +test_patterns = ["tests/**"] exclude_patterns = ["README.md"] @@ -8,17 +8,11 @@ exclude_patterns = ["README.md"] name = "python" enabled = true - [analyzers.meta] - runtime_version = "3.x.x" - [[analyzers]] name = "test-coverage" enabled = true -[[transformers]] -name = "isort" -enabled = true - [[transformers]] name = "black" enabled = true + diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..ece9ae4 --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +docstring-convention = numpy +import_order_style = smarkets +max-line-length = 88 +extend-ignore = E203,I202,I100 +exclude = reconstructSPI/__init__.py,reconstructSPI/iterative_refinement/__init.py,tests/__init__.py diff --git a/.github/auto-assign.yml b/.github/auto-assign.yml index 115af98..a0a74eb 100644 --- a/.github/auto-assign.yml +++ b/.github/auto-assign.yml @@ -5,10 +5,10 @@ addReviewers: true addAssignees: false # A list of reviewers to be added to pull requests (GitHub user name) -reviewers: +reviewers: - fredericpoitevin -# A list of keywords to be skipped the process that add reviewers if pull requests include it +# A list of keywords to be skipped the process that add reviewers if pull requests include it skipKeywords: - wip diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..cfc5574 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,54 @@ +name: "Lint" + +on: + push: + branches: [master,github-actions-test] + paths-ignore: + - 'README.md' + - '.deepsource.toml' + - '.gitignore' + - 'setup.py' + + + pull_request: + branches: [master] + paths-ignore: + - 'README.md' + - '.deepsource.toml' + - '.gitignore' + - 'setup.py' + + +jobs: + build: + + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-18.04] + python-version: [3.9] + test-folder : ['tests'] + fail-fast: false + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Build using Python ${{matrix.python-version}} + uses: actions/setup-python@v2 + with: + python-version: ${{matrix.python-version}} + - name: install dependencies [pip] + run: | + pip install --upgrade pip setuptools wheel + for req in dev-requirements.txt; do + pip install -q -r $req + done + pip install -e . + - name: linting [black and isort] + run: | + black . --check + isort --profile black --check . + - name: linting [flake8] + run: | + flake8 reconstructSPI tests diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..49cc26f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,62 @@ +name: "Test" + +on: + push: + branches: [master,github-actions-test] + paths-ignore: + - 'README.md' + - '.deepsource.toml' + - '.gitignore' + - 'setup.py' + + + pull_request: + branches: [master] + paths-ignore: + - 'README.md' + - '.deepsource.toml' + - '.gitignore' + - 'setup.py' + + +jobs: + build: + + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-18.04] + python-version: [3.7,3.8,3.9] + test-folder : ['tests'] + fail-fast: false + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Build using Python ${{matrix.python-version}} + uses: actions/setup-python@v2 + with: + python-version: ${{matrix.python-version}} + + - name: cache conda + uses: actions/cache@v1 + with: + path: $CONDA + key: ${{ runner.os }}-conda-${{ hashFiles('environment.yml') }} + restore-keys: | + ${{ runner.os }}-conda- + - name: install dependencies [conda] + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + $CONDA/bin/conda env update --file environment.yml --name base + $CONDA/bin/pip install -e . + - name: unit testing [pytest] + env: + TEST_TOKEN: ${{ secrets.TEST_TOKEN }} + run: | + $CONDA/bin/pytest --cov-report term --cov-report xml:coverage.xml --cov=reconstructSPI ${{matrix.test-folder}} + - name: uploading code coverage [codecov] + if: ${{matrix.python-version == 3.7}} + run: | + bash <(curl -s https://codecov.io/bash) -c diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e0b31c6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,42 @@ +default_language_version : + python : python3 +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.1.0 + hooks: + - id: check-byte-order-marker + - id: check-case-conflict + - id: check-merge-conflict + - id: check-yaml + - id: mixed-line-ending + args: + - --fix=no + - id: no-commit-to-branch + args: + - --branch=master + - id: check-added-large-files + args: + - --maxkb=2048 + - id: trailing-whitespace + - repo: https://github.com/psf/black + rev: 21.8b0 + hooks: + - id: black + - repo: https://github.com/pycqa/isort + rev: 5.9.3 + hooks: + - id : isort + args : ["--profile", "black", "--filter-files"] + - repo: https://github.com/asottile/blacken-docs + rev: v1.8.0 + hooks: + - id: blacken-docs + additional_dependencies: [black==20.8b0] + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.9 + hooks: + - id: flake8 + additional_dependencies: + - flake8-docstrings + - flake8-import-order + exclude: reconstructSPI/__init__.py,tests/__init__.py \ No newline at end of file From 55ee718db684b04c348d8f1205bb9dbea620d369 Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 17:39:27 -0700 Subject: [PATCH 03/14] Changed codecov parameters --- .codecov.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index c576999..2a942b9 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -22,3 +22,5 @@ coverage: ignore: - "data" - "notebooks" + - "reconstructSPI/__init__.py" + - "reconstructSPI/iterative_refinement/__init__.py" From 0d18f66b662f5bbb0ac11f8be3395d0fe5ba8e5d Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 17:48:43 -0700 Subject: [PATCH 04/14] Removed __init__.py files --- .codecov.yml | 2 -- reconstructSPI/__init__.py | 1 - reconstructSPI/iterative_refinement/__init__.py | 1 - 3 files changed, 4 deletions(-) delete mode 100644 reconstructSPI/__init__.py delete mode 100644 reconstructSPI/iterative_refinement/__init__.py diff --git a/.codecov.yml b/.codecov.yml index 2a942b9..c576999 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -22,5 +22,3 @@ coverage: ignore: - "data" - "notebooks" - - "reconstructSPI/__init__.py" - - "reconstructSPI/iterative_refinement/__init__.py" diff --git a/reconstructSPI/__init__.py b/reconstructSPI/__init__.py deleted file mode 100644 index a16d370..0000000 --- a/reconstructSPI/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Various particle reconstruction methods.""" diff --git a/reconstructSPI/iterative_refinement/__init__.py b/reconstructSPI/iterative_refinement/__init__.py deleted file mode 100644 index 5500bfe..0000000 --- a/reconstructSPI/iterative_refinement/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Iterative refinement reconstruction methods.""" From 7f8145686e1e416aa0fc9d4438b296516e172456 Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 17:50:36 -0700 Subject: [PATCH 05/14] Revert "Removed __init__.py files" This reverts commit 0d18f66b662f5bbb0ac11f8be3395d0fe5ba8e5d. --- .codecov.yml | 2 ++ reconstructSPI/__init__.py | 1 + reconstructSPI/iterative_refinement/__init__.py | 1 + 3 files changed, 4 insertions(+) create mode 100644 reconstructSPI/__init__.py create mode 100644 reconstructSPI/iterative_refinement/__init__.py diff --git a/.codecov.yml b/.codecov.yml index c576999..2a942b9 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -22,3 +22,5 @@ coverage: ignore: - "data" - "notebooks" + - "reconstructSPI/__init__.py" + - "reconstructSPI/iterative_refinement/__init__.py" diff --git a/reconstructSPI/__init__.py b/reconstructSPI/__init__.py new file mode 100644 index 0000000..a16d370 --- /dev/null +++ b/reconstructSPI/__init__.py @@ -0,0 +1 @@ +"""Various particle reconstruction methods.""" diff --git a/reconstructSPI/iterative_refinement/__init__.py b/reconstructSPI/iterative_refinement/__init__.py new file mode 100644 index 0000000..5500bfe --- /dev/null +++ b/reconstructSPI/iterative_refinement/__init__.py @@ -0,0 +1 @@ +"""Iterative refinement reconstruction methods.""" From e583a54eaf9469bc74cb2fdafbb88211b6d3cead Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 18:01:51 -0700 Subject: [PATCH 06/14] Revert "Changed codecov parameters" This reverts commit 55ee718db684b04c348d8f1205bb9dbea620d369. --- .codecov.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 2a942b9..c576999 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -22,5 +22,3 @@ coverage: ignore: - "data" - "notebooks" - - "reconstructSPI/__init__.py" - - "reconstructSPI/iterative_refinement/__init__.py" From 15840cfcf45e877cd069b7677bdb5ebaefc2ed30 Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 18:06:26 -0700 Subject: [PATCH 07/14] Refactoring library format --- .flake8 | 2 +- reconstructSPI/__init__.py => __init__.py | 0 .../iterative_refinement => iterative_refinement}/__init__.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename reconstructSPI/__init__.py => __init__.py (100%) rename {reconstructSPI/iterative_refinement => iterative_refinement}/__init__.py (100%) diff --git a/.flake8 b/.flake8 index ece9ae4..78fd79a 100644 --- a/.flake8 +++ b/.flake8 @@ -3,4 +3,4 @@ docstring-convention = numpy import_order_style = smarkets max-line-length = 88 extend-ignore = E203,I202,I100 -exclude = reconstructSPI/__init__.py,reconstructSPI/iterative_refinement/__init.py,tests/__init__.py +exclude = __init__.py,iterative_refinement/__init.py,tests/__init__.py diff --git a/reconstructSPI/__init__.py b/__init__.py similarity index 100% rename from reconstructSPI/__init__.py rename to __init__.py diff --git a/reconstructSPI/iterative_refinement/__init__.py b/iterative_refinement/__init__.py similarity index 100% rename from reconstructSPI/iterative_refinement/__init__.py rename to iterative_refinement/__init__.py From 2f91bc6686048ac4f39c619e38b006e4268499f0 Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 18:10:42 -0700 Subject: [PATCH 08/14] Directory fixes --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0b31c6..5af6583 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,4 +39,4 @@ repos: additional_dependencies: - flake8-docstrings - flake8-import-order - exclude: reconstructSPI/__init__.py,tests/__init__.py \ No newline at end of file + exclude: __init__.py,iterative_refinement/__init__.py,tests/__init__.py \ No newline at end of file From bccb41ce29d8055ea02a632d8f1e3b8ef51080eb Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 18:13:43 -0700 Subject: [PATCH 09/14] Revert "Refactoring library format" This reverts commit 15840cfcf45e877cd069b7677bdb5ebaefc2ed30. --- .flake8 | 2 +- __init__.py => reconstructSPI/__init__.py | 0 .../iterative_refinement}/__init__.py | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename __init__.py => reconstructSPI/__init__.py (100%) rename {iterative_refinement => reconstructSPI/iterative_refinement}/__init__.py (100%) diff --git a/.flake8 b/.flake8 index 78fd79a..ece9ae4 100644 --- a/.flake8 +++ b/.flake8 @@ -3,4 +3,4 @@ docstring-convention = numpy import_order_style = smarkets max-line-length = 88 extend-ignore = E203,I202,I100 -exclude = __init__.py,iterative_refinement/__init.py,tests/__init__.py +exclude = reconstructSPI/__init__.py,reconstructSPI/iterative_refinement/__init.py,tests/__init__.py diff --git a/__init__.py b/reconstructSPI/__init__.py similarity index 100% rename from __init__.py rename to reconstructSPI/__init__.py diff --git a/iterative_refinement/__init__.py b/reconstructSPI/iterative_refinement/__init__.py similarity index 100% rename from iterative_refinement/__init__.py rename to reconstructSPI/iterative_refinement/__init__.py From 2c42e8d884fc1cc2074e409eaebb1b5885590a24 Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 18:13:56 -0700 Subject: [PATCH 10/14] Revert "Directory fixes" This reverts commit 2f91bc6686048ac4f39c619e38b006e4268499f0. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5af6583..e0b31c6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,4 +39,4 @@ repos: additional_dependencies: - flake8-docstrings - flake8-import-order - exclude: __init__.py,iterative_refinement/__init__.py,tests/__init__.py \ No newline at end of file + exclude: reconstructSPI/__init__.py,tests/__init__.py \ No newline at end of file From 9126f8684d07489d447b7b699f12c1e042d715d8 Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 18:41:00 -0700 Subject: [PATCH 11/14] Removed dependencies --- environment.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/environment.yml b/environment.yml index e52e0d7..ef85386 100644 --- a/environment.yml +++ b/environment.yml @@ -5,9 +5,6 @@ channels: dependencies: - codecov - coverage - - gemmi - - numpy - - numba - pillow>=8.2.0 - pip - pytest From 3330c11dbd0cbd2573dd6e19468f9ebaea19f8fd Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 18:59:02 -0700 Subject: [PATCH 12/14] Testing something --- .codecov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codecov.yml b/.codecov.yml index c576999..92ae275 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -13,6 +13,7 @@ coverage: # advanced branches: - master + - reconstructSPI_infrastructure if_no_uploads: error if_not_found: error if_ci_failed: error From ef10249ed795c7f5c46e73a640ca8928a0545fb0 Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 19:02:13 -0700 Subject: [PATCH 13/14] Testing things --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cfc5574..b4d4102 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,7 @@ name: "Lint" on: push: - branches: [master,github-actions-test] + branches: [master,github-actions-test,reconstructSPI_infrastructure] paths-ignore: - 'README.md' - '.deepsource.toml' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49cc26f..b9f6232 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: "Test" on: push: - branches: [master,github-actions-test] + branches: [master,github-actions-test,reconstructSPI_infrastructure] paths-ignore: - 'README.md' - '.deepsource.toml' From 5152547989399bbf5de59089676176ef88a6e17e Mon Sep 17 00:00:00 2001 From: thisTyler Date: Wed, 30 Mar 2022 19:16:15 -0700 Subject: [PATCH 14/14] Added dev branch to branches on which tests will run. --- .codecov.yml | 2 +- .github/workflows/lint.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 92ae275..fd85925 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -13,7 +13,7 @@ coverage: # advanced branches: - master - - reconstructSPI_infrastructure + - dev if_no_uploads: error if_not_found: error if_ci_failed: error diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b4d4102..38ca19a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,7 @@ name: "Lint" on: push: - branches: [master,github-actions-test,reconstructSPI_infrastructure] + branches: [master,github-actions-test,dev] paths-ignore: - 'README.md' - '.deepsource.toml' @@ -11,7 +11,7 @@ on: pull_request: - branches: [master] + branches: [master,dev] paths-ignore: - 'README.md' - '.deepsource.toml' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9f6232..0d86279 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: "Test" on: push: - branches: [master,github-actions-test,reconstructSPI_infrastructure] + branches: [master,github-actions-test,dev] paths-ignore: - 'README.md' - '.deepsource.toml' @@ -11,7 +11,7 @@ on: pull_request: - branches: [master] + branches: [master,dev] paths-ignore: - 'README.md' - '.deepsource.toml'