diff --git a/.copier-answers.yml b/.copier-answers.yml index 358ea41..6ef826a 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v1.4.6-59-g4c84e58 +_commit: v1.5.1-11-g34358f1 _src_path: gh:lincc-frameworks/python-project-template author_email: scampos@andrew.cmu.edu author_name: Sandro Campos diff --git a/.github/workflows/asv-nightly.yml b/.github/workflows/asv-nightly.yml index ce5a335..80a2d78 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 91601b3..bf5aed6 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 7e80a7f..3c27651 100644 --- a/.github/workflows/build-documentation.yml +++ b/.github/workflows/build-documentation.yml @@ -18,9 +18,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 deleted file mode 100644 index f327e09..0000000 --- a/.github/workflows/code_style.yml +++ /dev/null @@ -1,40 +0,0 @@ -# This workflow will install Python dependencies, then perform static analysis for code style and type checking. -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Code Style analysis - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.9', '3.10', '3.11'] - - steps: - - uses: actions/checkout@main - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@main - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Analyze code with pylint - run: | - pylint -rn -sn --recursive=y ./src --rcfile=./src/.pylintrc - pylint -rn -sn --recursive=y ./tests --rcfile=./tests/.pylintrc - pylint -rn -sn --recursive=y ./benchmarks --rcfile=./tests/.pylintrc \ No newline at end of file diff --git a/.github/workflows/pre-commit-ci.yml b/.github/workflows/pre-commit-ci.yml index 9248beb..b0248dd 100644 --- a/.github/workflows/pre-commit-ci.yml +++ b/.github/workflows/pre-commit-ci.yml @@ -5,30 +5,32 @@ name: Run pre-commit hooks on: + push: + branches: [ main ] pull_request: + branches: [ main ] jobs: pre-commit-ci: runs-on: ubuntu-latest - 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 run: | sudo apt-get update python -m pip install --upgrade pip - pip install . 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 - if: always() \ No newline at end of file + extra_args: --all-files --verbose + env: + SKIP: "check-lincc-frameworks-template-version,no-commit-to-branch,check-added-large-files,validate-pyproject,sphinx-build,pytest-check" + - uses: pre-commit-ci/lite-action@v1.0.2 + if: failure() && github.event_name == 'pull_request' && github.event.pull_request.draft == false \ No newline at end of file diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index a3eed49..f7cecc2 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/.prepare_project.sh b/.initialize_new_project.sh similarity index 56% rename from .prepare_project.sh rename to .initialize_new_project.sh index 1f82c2b..fdb0f82 100644 --- a/.prepare_project.sh +++ b/.initialize_new_project.sh @@ -1,8 +1,23 @@ #!/usr/bin/env bash +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=( $(pip --version | awk '{print $2}' | sed 's/\./ /g') ) +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." @@ -25,10 +40,13 @@ echo "Initializing local git repository" } > /dev/null echo "Installing package and runtime dependencies in local environment" -pip install -e . > /dev/null +python -m pip install -e . > /dev/null echo "Installing developer dependencies in local environment" -pip install -e .'[dev]' > /dev/null +python -m pip install -e .'[dev]' > /dev/null echo "Installing pre-commit" pre-commit install > /dev/null + +echo "Committing initial files" +git add . && SKIP="no-commit-to-branch" git commit -m "Initial commit" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93da1a1..0e09d56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,3 @@ -fail_fast: true repos: # Compare the local template version to the latest remote template version @@ -23,21 +22,6 @@ repos: language: system entry: jupyter nbconvert --clear-output - # Run unit tests, verify that they pass. Note that coverage is run against - # the ./src directory here because that is what will be committed. In the - # github workflow script, the coverage is run against the installed package - # and uploaded to Codecov by calling pytest like so: - # `python -m pytest --cov= --cov-report=xml` - - repo: local - hooks: - - id: pytest-check - name: Run unit tests - description: Run unit tests with pytest. - entry: bash -c "if python -m pytest --co -qq; then python -m pytest --cov=./src --cov-report=html; fi" - language: system - pass_filenames: false - always_run: true - # Prevents committing directly branches named 'main' and 'master'. - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 @@ -128,3 +112,18 @@ repos: "-D", # Flag to override settings in conf.py "exclude_patterns=notebooks/*", # Exclude our notebooks from pre-commit ] + + # Run unit tests, verify that they pass. Note that coverage is run against + # the ./src directory here because that is what will be committed. In the + # github workflow script, the coverage is run against the installed package + # and uploaded to Codecov by calling pytest like so: + # `python -m pytest --cov= --cov-report=xml` + - repo: local + hooks: + - id: pytest-check + name: Run unit tests + description: Run unit tests with pytest. + entry: bash -c "if python -m pytest --co -qq; then python -m pytest --cov=./src --cov-report=html; fi" + language: system + pass_filenames: false + always_run: true \ No newline at end of file diff --git a/.setup_dev.sh b/.setup_dev.sh new file mode 100644 index 0000000..47bc27a --- /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/benchmarks/asv.conf.json b/benchmarks/asv.conf.json index 12731f9..676495b 100644 --- a/benchmarks/asv.conf.json +++ b/benchmarks/asv.conf.json @@ -32,7 +32,7 @@ // variable. "environment_type": "virtualenv", // the base URL to show a commit for the project. - "show_commit_url": "https://github.com/lincc-frameworks/benchmarking-asv/commit", + "show_commit_url": "https://github.com/lincc-frameworks/benchmarking-asv/commit/", // The Pythons you'd like to test against. If not provided, defaults // to the current version of Python used to run `asv`. "pythons": [ diff --git a/docs/notebooks/intro_notebook.ipynb b/docs/notebooks/intro_notebook.ipynb index 3799499..a711b63 100644 --- a/docs/notebooks/intro_notebook.ipynb +++ b/docs/notebooks/intro_notebook.ipynb @@ -67,6 +67,14 @@ "source": [ "sierpinsky(4)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3a7bb740", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -77,6 +85,18 @@ "display_name": "Python 3", "language": "python", "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" } }, "nbformat": 4, diff --git a/pyproject.toml b/pyproject.toml index 08095bc..3395439 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ classifiers = [ "Programming Language :: Python", ] dynamic = ["version"] +requires-python = ">=3.9" dependencies = [ "ipykernel", # Support for Jupyter notebooks ] @@ -56,7 +57,7 @@ testpaths = [ [tool.black] line-length = 110 -target-version = ["py38"] +target-version = ["py39"] [tool.isort] profile = "black" @@ -64,7 +65,7 @@ line_length = 110 [tool.ruff] line-length = 110 -target-version = "py38" +target-version = "py39" [tool.ruff.lint] select = [