From bb7b1a335e9a3f89bdee7fd38dc7b3ec53b67448 Mon Sep 17 00:00:00 2001 From: Sandro Campos Date: Mon, 12 Feb 2024 16:36:33 -0500 Subject: [PATCH 1/8] Update template to consolidate pre-commit logic --- .copier-answers.yml | 2 +- .github/workflows/asv-nightly.yml | 10 ++--- .github/workflows/asv-pr.yml | 12 +++--- .github/workflows/build-documentation.yml | 4 +- .github/workflows/code_style.yml | 40 ------------------ .github/workflows/pre-commit-ci.yml | 15 ++++--- .github/workflows/publish-to-pypi.yml | 4 +- ...e_project.sh => .initialize_new_project.sh | 24 +++++++++-- .setup_dev.sh | 41 +++++++++++++++++++ benchmarks/asv.conf.json | 2 +- pyproject.toml | 5 ++- 11 files changed, 89 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/code_style.yml rename .prepare_project.sh => .initialize_new_project.sh (56%) create mode 100644 .setup_dev.sh 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..cfb6d9c 100644 --- a/.github/workflows/pre-commit-ci.yml +++ b/.github/workflows/pre-commit-ci.yml @@ -10,25 +10,24 @@ on: 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 + 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: always() \ 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/.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/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 = [ From 8ef230ea19cd3882c26dabaf25d02eb83a9fac36 Mon Sep 17 00:00:00 2001 From: Sandro Campos Date: Mon, 12 Feb 2024 16:45:23 -0500 Subject: [PATCH 2/8] Test pre-commit stages --- benchmarks/benchmarks.py | 6 +- docs/notebooks/intro_notebook.ipynb | 71 +++++++++++++++++-- src/benchmarking_asv/example_module.py | 11 ++- tests/benchmarking_asv/test_example_module.py | 2 + 4 files changed, 77 insertions(+), 13 deletions(-) diff --git a/benchmarks/benchmarks.py b/benchmarks/benchmarks.py index 3a81576..febd517 100644 --- a/benchmarks/benchmarks.py +++ b/benchmarks/benchmarks.py @@ -1,5 +1,5 @@ from benchmarking_asv import example_module - +import sys class TimeSuite: # pylint: disable=too-few-public-methods """An example benchmark that times the performance of various kinds @@ -13,6 +13,10 @@ def setup(self): for x in range(500): self.d[x] = None + + + + def time_keys(self): """Time first method.""" example_module.run_time_computation() diff --git a/docs/notebooks/intro_notebook.ipynb b/docs/notebooks/intro_notebook.ipynb index 3799499..4c0b020 100644 --- a/docs/notebooks/intro_notebook.ipynb +++ b/docs/notebooks/intro_notebook.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "actual-thirty", "metadata": {}, "outputs": [], @@ -49,10 +49,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "1e837f01", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Printing order 0 triangle\n", + "*\n", + "Printing order 1 triangle\n", + " * \n", + "* *\n", + "Printing order 2 triangle\n", + " * \n", + " * * \n", + " * * \n", + "* * * *\n" + ] + } + ], "source": [ "for order in range(3):\n", " sierpinsky(order)" @@ -60,13 +77,45 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "026f4f06", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Printing order 4 triangle\n", + " * \n", + " * * \n", + " * * \n", + " * * * * \n", + " * * \n", + " * * * * \n", + " * * * * \n", + " * * * * * * * * \n", + " * * \n", + " * * * * \n", + " * * * * \n", + " * * * * * * * * \n", + " * * * * \n", + " * * * * * * * * \n", + " * * * * * * * * \n", + "* * * * * * * * * * * * * * * *\n" + ] + } + ], "source": [ "sierpinsky(4)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3a7bb740", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -77,6 +126,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/src/benchmarking_asv/example_module.py b/src/benchmarking_asv/example_module.py index 951e926..c7731fe 100644 --- a/src/benchmarking_asv/example_module.py +++ b/src/benchmarking_asv/example_module.py @@ -2,19 +2,16 @@ import random import time +import os def greetings() -> str: - """A friendly greeting for a future friend. - - Returns - ------- - str - A typical greeting from a software engineer. - """ return "Hello from LINCC-Frameworks!" + + + def meaning() -> int: """The meaning of life, the universe, and everything. diff --git a/tests/benchmarking_asv/test_example_module.py b/tests/benchmarking_asv/test_example_module.py index 8c0ab54..1adc312 100644 --- a/tests/benchmarking_asv/test_example_module.py +++ b/tests/benchmarking_asv/test_example_module.py @@ -2,6 +2,8 @@ from benchmarking_asv import example_module +import pytest + def test_greetings() -> None: """Verify the output of the `greetings` function""" From 69a5c265369d36869273bd545e3a6e18bd2b1ef5 Mon Sep 17 00:00:00 2001 From: Sandro Campos Date: Mon, 12 Feb 2024 17:07:44 -0500 Subject: [PATCH 3/8] Test pre-commit logic --- .pre-commit-config.yaml | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) 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 From e29841b2e3fd889de20f444e57a6a323370d87ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 22:10:59 +0000 Subject: [PATCH 4/8] [pre-commit.ci lite] apply automatic fixes --- benchmarks/benchmarks.py | 4 +- docs/notebooks/intro_notebook.ipynb | 51 ++----------------- src/benchmarking_asv/example_module.py | 2 +- tests/benchmarking_asv/test_example_module.py | 4 +- 4 files changed, 11 insertions(+), 50 deletions(-) diff --git a/benchmarks/benchmarks.py b/benchmarks/benchmarks.py index febd517..6e413e1 100644 --- a/benchmarks/benchmarks.py +++ b/benchmarks/benchmarks.py @@ -1,6 +1,8 @@ -from benchmarking_asv import example_module import sys +from benchmarking_asv import example_module + + class TimeSuite: # pylint: disable=too-few-public-methods """An example benchmark that times the performance of various kinds of iterating over dictionaries in Python.""" diff --git a/docs/notebooks/intro_notebook.ipynb b/docs/notebooks/intro_notebook.ipynb index 4c0b020..a711b63 100644 --- a/docs/notebooks/intro_notebook.ipynb +++ b/docs/notebooks/intro_notebook.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "actual-thirty", "metadata": {}, "outputs": [], @@ -49,27 +49,10 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "1e837f01", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Printing order 0 triangle\n", - "*\n", - "Printing order 1 triangle\n", - " * \n", - "* *\n", - "Printing order 2 triangle\n", - " * \n", - " * * \n", - " * * \n", - "* * * *\n" - ] - } - ], + "outputs": [], "source": [ "for order in range(3):\n", " sierpinsky(order)" @@ -77,34 +60,10 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "026f4f06", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Printing order 4 triangle\n", - " * \n", - " * * \n", - " * * \n", - " * * * * \n", - " * * \n", - " * * * * \n", - " * * * * \n", - " * * * * * * * * \n", - " * * \n", - " * * * * \n", - " * * * * \n", - " * * * * * * * * \n", - " * * * * \n", - " * * * * * * * * \n", - " * * * * * * * * \n", - "* * * * * * * * * * * * * * * *\n" - ] - } - ], + "outputs": [], "source": [ "sierpinsky(4)" ] diff --git a/src/benchmarking_asv/example_module.py b/src/benchmarking_asv/example_module.py index c7731fe..0ebd74d 100644 --- a/src/benchmarking_asv/example_module.py +++ b/src/benchmarking_asv/example_module.py @@ -1,8 +1,8 @@ """An example module containing simplistic functions.""" +import os import random import time -import os def greetings() -> str: diff --git a/tests/benchmarking_asv/test_example_module.py b/tests/benchmarking_asv/test_example_module.py index 1adc312..33bd493 100644 --- a/tests/benchmarking_asv/test_example_module.py +++ b/tests/benchmarking_asv/test_example_module.py @@ -1,9 +1,9 @@ """An example module containing testing of mock functions.""" -from benchmarking_asv import example_module - import pytest +from benchmarking_asv import example_module + def test_greetings() -> None: """Verify the output of the `greetings` function""" From 856e2fe01b4b757f96356184f1d6803ac0a28cb0 Mon Sep 17 00:00:00 2001 From: Sandro Campos Date: Mon, 12 Feb 2024 17:18:39 -0500 Subject: [PATCH 5/8] Fix all pre-commit issues --- benchmarks/benchmarks.py | 6 ------ src/benchmarking_asv/example_module.py | 11 +++++++---- tests/benchmarking_asv/test_example_module.py | 2 -- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/benchmarks/benchmarks.py b/benchmarks/benchmarks.py index 6e413e1..3a81576 100644 --- a/benchmarks/benchmarks.py +++ b/benchmarks/benchmarks.py @@ -1,5 +1,3 @@ -import sys - from benchmarking_asv import example_module @@ -15,10 +13,6 @@ def setup(self): for x in range(500): self.d[x] = None - - - - def time_keys(self): """Time first method.""" example_module.run_time_computation() diff --git a/src/benchmarking_asv/example_module.py b/src/benchmarking_asv/example_module.py index 0ebd74d..951e926 100644 --- a/src/benchmarking_asv/example_module.py +++ b/src/benchmarking_asv/example_module.py @@ -1,15 +1,18 @@ """An example module containing simplistic functions.""" -import os import random import time def greetings() -> str: - return "Hello from LINCC-Frameworks!" - - + """A friendly greeting for a future friend. + Returns + ------- + str + A typical greeting from a software engineer. + """ + return "Hello from LINCC-Frameworks!" def meaning() -> int: diff --git a/tests/benchmarking_asv/test_example_module.py b/tests/benchmarking_asv/test_example_module.py index 33bd493..8c0ab54 100644 --- a/tests/benchmarking_asv/test_example_module.py +++ b/tests/benchmarking_asv/test_example_module.py @@ -1,7 +1,5 @@ """An example module containing testing of mock functions.""" -import pytest - from benchmarking_asv import example_module From 0bbbeb579cdb1e07576cba0ddaa3bc645ff99485 Mon Sep 17 00:00:00 2001 From: Sandro Campos Date: Tue, 13 Feb 2024 10:16:21 -0500 Subject: [PATCH 6/8] Run bot fixes only on non-draft PRs --- .github/workflows/pre-commit-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit-ci.yml b/.github/workflows/pre-commit-ci.yml index cfb6d9c..b0248dd 100644 --- a/.github/workflows/pre-commit-ci.yml +++ b/.github/workflows/pre-commit-ci.yml @@ -5,7 +5,10 @@ name: Run pre-commit hooks on: + push: + branches: [ main ] pull_request: + branches: [ main ] jobs: pre-commit-ci: @@ -30,4 +33,4 @@ jobs: 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: always() \ No newline at end of file + if: failure() && github.event_name == 'pull_request' && github.event.pull_request.draft == false \ No newline at end of file From f6611d9fea7423ed1d34ca0e20123bbd0f98a8a0 Mon Sep 17 00:00:00 2001 From: Sandro Campos Date: Tue, 13 Feb 2024 10:20:43 -0500 Subject: [PATCH 7/8] Add one isort fix to test pre-commit --- src/benchmarking_asv/example_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchmarking_asv/example_module.py b/src/benchmarking_asv/example_module.py index 951e926..6e35792 100644 --- a/src/benchmarking_asv/example_module.py +++ b/src/benchmarking_asv/example_module.py @@ -1,7 +1,7 @@ """An example module containing simplistic functions.""" -import random import time +import random def greetings() -> str: From 3f2241557f19898317f299823fec2b15e7b933de Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:45:43 +0000 Subject: [PATCH 8/8] [pre-commit.ci lite] apply automatic fixes --- src/benchmarking_asv/example_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchmarking_asv/example_module.py b/src/benchmarking_asv/example_module.py index 6e35792..951e926 100644 --- a/src/benchmarking_asv/example_module.py +++ b/src/benchmarking_asv/example_module.py @@ -1,7 +1,7 @@ """An example module containing simplistic functions.""" -import time import random +import time def greetings() -> str: