diff --git a/.copier-answers.yml b/.copier-answers.yml index 78ccc871..0e93755d 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v1.5.0 +_commit: v1.5.2 _src_path: gh:lincc-frameworks/python-project-template author_email: lincc-frameworks-team@lists.lsst.org author_name: LINCC Frameworks diff --git a/.github/workflows/asv-main.yml b/.github/workflows/asv-main.yml index 17c3d737..f6a6f297 100644 --- a/.github/workflows/asv-main.yml +++ b/.github/workflows/asv-main.yml @@ -23,13 +23,13 @@ jobs: steps: - name: Cache Python ${{ env.PYTHON_VERSION }} - uses: actions/cache@main + uses: actions/cache@v4 with: path: ~/.cache/pip key: python-${{ env.PYTHON_VERSION }} - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: "${{ env.PYTHON_VERSION }}" @@ -46,12 +46,12 @@ jobs: steps: - name: Checkout main branch of the repository - uses: actions/checkout@main + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Cache Python ${{ env.PYTHON_VERSION }} - uses: actions/cache@main + uses: actions/cache@v4 with: path: ~/.cache/pip key: python-${{ env.PYTHON_VERSION }} diff --git a/.github/workflows/asv-nightly.yml b/.github/workflows/asv-nightly.yml index ce5a3351..80a2d785 100644 --- a/.github/workflows/asv-nightly.yml +++ b/.github/workflows/asv-nightly.yml @@ -25,18 +25,18 @@ jobs: steps: - name: Checkout main branch of the repository - uses: actions/checkout@main + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Cache Python ${{ env.PYTHON_VERSION }} - uses: actions/cache@main + uses: actions/cache@v4 with: path: ~/.cache/pip key: python-${{ env.PYTHON_VERSION }} - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: "${{ env.PYTHON_VERSION }}" @@ -70,7 +70,7 @@ jobs: echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - name: Use last nightly commit hash from cache - uses: actions/cache@main + uses: actions/cache@v4 with: path: ${{ env.WORKING_DIR }} key: nightly-results-${{ steps.nightly-dates.outputs.yesterday }} @@ -87,7 +87,7 @@ jobs: echo $CURRENT_HASH > $HASH_FILE - name: Update last nightly hash in cache - uses: actions/cache@main + uses: actions/cache@v4 with: path: ${{ env.WORKING_DIR }} key: nightly-results-${{ steps.nightly-dates.outputs.today }} \ No newline at end of file diff --git a/.github/workflows/asv-pr.yml b/.github/workflows/asv-pr.yml index 91601b3f..bf5aed6d 100644 --- a/.github/workflows/asv-pr.yml +++ b/.github/workflows/asv-pr.yml @@ -24,12 +24,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Python ${{ env.PYTHON_VERSION }} - uses: actions/cache@main + uses: actions/cache@v4 with: path: ~/.cache/pip key: python-${{ env.PYTHON_VERSION }} - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} asv-pr: @@ -40,14 +40,14 @@ jobs: working-directory: ${{ env.WORKING_DIR }} steps: - name: Checkout PR branch of the repository - uses: actions/checkout@main + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Display Workflow Run Information run: | echo "Workflow Run ID: ${{ github.run_id }}" - name: Cache Python ${{ env.PYTHON_VERSION }} - uses: actions/cache@main + uses: actions/cache@v4 with: path: ~/.cache/pip key: python-${{ env.PYTHON_VERSION }} @@ -61,7 +61,7 @@ jobs: - name: Save pull request number run: echo ${{ github.event.pull_request.number }} > ${{ env.ARTIFACTS_DIR }}/pr - name: Get current job logs URL - uses: Tiryoh/gha-jobid-action@main + uses: Tiryoh/gha-jobid-action@v1 id: jobs with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -80,7 +80,7 @@ jobs: env: STEP_URL: "${{ steps.jobs.outputs.html_url }}#step:11:1" - name: Upload artifacts (PR number and benchmarks output) - uses: actions/upload-artifact@main + uses: actions/upload-artifact@v4 with: name: benchmark-artifacts path: ${{ env.ARTIFACTS_DIR }} \ No newline at end of file diff --git a/.github/workflows/build-documentation.yml b/.github/workflows/build-documentation.yml index 3f57c7b6..638e7b6e 100644 --- a/.github/workflows/build-documentation.yml +++ b/.github/workflows/build-documentation.yml @@ -19,9 +19,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@main + - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml index dfe2455b..23442fdd 100644 --- a/.github/workflows/code_style.yml +++ b/.github/workflows/code_style.yml @@ -21,9 +21,9 @@ jobs: python-version: ['3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@main + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/pre-commit-ci.yml b/.github/workflows/pre-commit-ci.yml index 08ff1d30..025909ca 100644 --- a/.github/workflows/pre-commit-ci.yml +++ b/.github/workflows/pre-commit-ci.yml @@ -13,11 +13,11 @@ jobs: env: SKIP: "check-lincc-frameworks-template-version,pytest-check,no-commit-to-branch,validate-pyproject,check-added-large-files,sphinx-build" steps: - - uses: actions/checkout@main + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies @@ -26,8 +26,8 @@ jobs: python -m pip install --upgrade pip pip install .[dev] if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - uses: pre-commit/action@main # Still using Node 16 + - uses: pre-commit/action@v3.0.1 with: extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} - - uses: pre-commit-ci/lite-action@main + - uses: pre-commit-ci/lite-action@v1.0.2 if: always() \ No newline at end of file diff --git a/.github/workflows/publish-benchmarks-pr.yml b/.github/workflows/publish-benchmarks-pr.yml index 1f5ab312..45ed9280 100644 --- a/.github/workflows/publish-benchmarks-pr.yml +++ b/.github/workflows/publish-benchmarks-pr.yml @@ -27,7 +27,7 @@ jobs: echo "Conclusion: ${{ github.event.workflow_run.conclusion }}" echo "Event: ${{ github.event.workflow_run.event }}" - name: Download artifact - uses: dawidd6/action-download-artifact@master + uses: dawidd6/action-download-artifact@v3 with: name: benchmark-artifacts run_id: ${{ github.event.workflow_run.id }} @@ -38,14 +38,14 @@ jobs: printf "Output:\n$(cat output)" printf "pr=$(cat pr)" >> $GITHUB_OUTPUT - name: Find benchmarks comment - uses: peter-evans/find-comment@main + uses: peter-evans/find-comment@v3 id: find-comment with: issue-number: ${{ steps.pr-info.outputs.pr }} comment-author: 'github-actions[bot]' body-includes: view all benchmarks - name: Create or update benchmarks comment - uses: peter-evans/create-or-update-comment@main + uses: peter-evans/create-or-update-comment@v4 with: comment-id: ${{ steps.find-comment.outputs.comment-id }} issue-number: ${{ steps.pr-info.outputs.pr }} diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index a3eed49f..f7cecc2e 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -22,9 +22,9 @@ jobs: permissions: id-token: write steps: - - uses: actions/checkout@main + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index a655bd03..851fc289 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -23,9 +23,9 @@ jobs: python-version: ['3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@main + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -43,7 +43,7 @@ jobs: - name: Send status to Slack app if: ${{ failure() && github.event_name != 'workflow_dispatch' }} # Only post if the workflow failed and was not manually started. Customize this as necessary. id: slack - uses: slackapi/slack-github-action@main + uses: slackapi/slack-github-action@v1 with: # For posting a rich message using Block Kit payload: | # The payload defined here can be customized to you liking https://api.slack.com/reference/block-kit/blocks diff --git a/.github/workflows/testing-and-coverage.yml b/.github/workflows/testing-and-coverage.yml index efc91209..c0da1d3b 100644 --- a/.github/workflows/testing-and-coverage.yml +++ b/.github/workflows/testing-and-coverage.yml @@ -18,9 +18,9 @@ jobs: python-version: ['3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@main + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -33,6 +33,6 @@ jobs: run: | python -m pytest --cov=hipscat --cov-report=xml - name: Upload coverage report to codecov - uses: codecov/codecov-action@main + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 1819b253..50990fec 100644 --- a/.gitignore +++ b/.gitignore @@ -145,3 +145,6 @@ tmp/ # Airspeed Velocity performance results _results/ _html/ + +# Project initialization script +.initialize_new_project.sh diff --git a/.setup_dev.sh b/.setup_dev.sh new file mode 100644 index 00000000..47bc27ae --- /dev/null +++ b/.setup_dev.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# This script should be run by new developers to install this package in +# editable mode and configure their local environment + +echo "Checking virtual environment" +if [ -z "${VIRTUAL_ENV}" ] && [ -z "${CONDA_PREFIX}" ]; then + echo 'No virtual environment detected: none of $VIRTUAL_ENV or $CONDA_PREFIX is set.' + echo + echo "=== This script is going to install the project in the system python environment ===" + echo "Proceed? [y/N]" + read -r RESPONCE + if [ "${RESPONCE}" != "y" ]; then + echo "See https://lincc-ppt.readthedocs.io/ for details." + echo "Exiting." + exit 1 + fi + +fi + +echo "Checking pip version" +MINIMUM_PIP_VERSION=22 +pipversion=( $(python -m pip --version | awk '{print $2}' | sed 's/\./ /g') ) +if let "${pipversion[0]}<${MINIMUM_PIP_VERSION}"; then + echo "Insufficient version of pip found. Requires at least version ${MINIMUM_PIP_VERSION}." + echo "See https://lincc-ppt.readthedocs.io/ for details." + exit 1 +fi + +echo "Installing package and runtime dependencies in local environment" +python -m pip install -e . > /dev/null + +echo "Installing developer dependencies in local environment" +python -m pip install -e .'[dev]' > /dev/null + +echo "Installing pre-commit" +pre-commit install > /dev/null + +####################################################### +# Include any additional configurations below this line +####################################################### diff --git a/pyproject.toml b/pyproject.toml index 9ab27050..11c44d7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ # On a mac, install optional dependencies with `pip install '.[dev]'` (include the single quotes) [project.optional-dependencies] dev = [ - "adlfs", # abfs filesytem support +"adlfs", # abfs filesytem support "asv==0.6.1", # Used to compute performance benchmarks "black", # auto-formatter "ipykernel", # Support for Jupyter notebooks @@ -50,9 +50,9 @@ dev = [ "pytest-timeout", # Used to test for code efficiency "s3fs", # s3 filesystem support "sphinx", # Used to automatically generate documentation - "sphinx-autoapi", # Used to automatically generate api documentation + "sphinx-autoapi", # Used to automatically generate api documentation "sphinx-rtd-theme" # Used to render documentation -] + ] [build-system] requires = [ @@ -80,3 +80,48 @@ target-version = ["py38"] [tool.isort] profile = "black" line_length = 110 + +[tool.ruff] +line-length = 110 +target-version = "py39" + +[tool.ruff.lint] +select = [ + # pycodestyle + "E", + "W", + # Pyflakes + "F", + # pep8-naming + "N", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", + # docstrings + "D101", + "D102", + "D103", + "D106", + "D206", + "D207", + "D208", + "D300", + "D417", + "D419", + +] + +ignore = [ + "UP006", # Allow non standard library generics in type hints + "UP007", # Allow Union in type hints + "SIM114", # Allow if with same arms + "B028", # Allow default warning level + "SIM117", # Allow nested with + "UP015", # Allow redundant open parameters + "UP028", # Allow yield in for loop +]