diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..fd85925 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,25 @@ +coverage: + round: up + precision: 2 + status: + patch: + default: + # basic + target: 90% + threshold: 2% + base: auto + flags: + - unit + # advanced + branches: + - master + - dev + 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..38ca19a --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,54 @@ +name: "Lint" + +on: + push: + branches: [master,github-actions-test,dev] + paths-ignore: + - 'README.md' + - '.deepsource.toml' + - '.gitignore' + - 'setup.py' + + + pull_request: + branches: [master,dev] + 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..0d86279 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,62 @@ +name: "Test" + +on: + push: + branches: [master,github-actions-test,dev] + paths-ignore: + - 'README.md' + - '.deepsource.toml' + - '.gitignore' + - 'setup.py' + + + pull_request: + branches: [master,dev] + 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 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..ef85386 --- /dev/null +++ b/environment.yml @@ -0,0 +1,15 @@ +name: reconstructSPI +channels: + - conda-forge + - defaults +dependencies: + - codecov + - coverage + - 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