From 7c32f5fefb9a9e38aeb65070492d60f4c1c1f5cd Mon Sep 17 00:00:00 2001 From: shadeMe Date: Thu, 16 May 2024 11:05:42 +0200 Subject: [PATCH 1/4] ci: Add workflows --- .github/CODEOWNERS | 11 + .github/actionlint.yml | 3 + .github/dependabot.yml | 6 + .github/pull_request_template.md | 25 ++ .github/workflows/docstrings_linting.yml | 20 + .github/workflows/linting.yml | 84 +++++ .github/workflows/linting_skipper.yml | 29 ++ .github/workflows/project.yml | 16 + .github/workflows/pypi_release.yml | 42 +++ .github/workflows/stale.yml | 15 + .github/workflows/tests.yml | 375 +++++++++++++++++++ .github/workflows/tests_skipper_trigger.yml | 46 +++ .github/workflows/tests_skipper_workflow.yml | 24 ++ .github/workflows/workflows_linting.yml | 19 + 14 files changed, 715 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/actionlint.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/docstrings_linting.yml create mode 100644 .github/workflows/linting.yml create mode 100644 .github/workflows/linting_skipper.yml create mode 100644 .github/workflows/project.yml create mode 100644 .github/workflows/pypi_release.yml create mode 100644 .github/workflows/stale.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/tests_skipper_trigger.yml create mode 100644 .github/workflows/tests_skipper_workflow.yml create mode 100644 .github/workflows/workflows_linting.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..c559d08f --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,11 @@ +# See https://help.github.com/articles/about-codeowners/ for syntax + +# Core Engineering will be the default owners for everything +# in the repo. Unless a later match takes precedence, +# @deepset-ai/core-engineering will be requested for review +# when someone opens a pull request. +* @deepset-ai/open-source-engineering + +# Documentation +*.md @deepset-ai/documentation @deepset-ai/open-source-engineering +releasenotes/notes/* @deepset-ai/documentation @deepset-ai/open-source-engineering diff --git a/.github/actionlint.yml b/.github/actionlint.yml new file mode 100644 index 00000000..60646952 --- /dev/null +++ b/.github/actionlint.yml @@ -0,0 +1,3 @@ +self-hosted-runner: + # Labels of self-hosted runner in array of string + labels: ["cml", "ubuntu-latest-4-cores"] diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..6778b049 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'daily' diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..c6a58287 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,25 @@ +### Related Issues + +- fixes #issue-number + +### Proposed Changes: + + + + +### How did you test it? + + + +### Notes for the reviewer + + + +### Checklist + +- I have read the [contributors guidelines](https://github.com/deepset-ai/haystack/blob/main/CONTRIBUTING.md) and the [code of conduct](https://github.com/deepset-ai/haystack/blob/main/code_of_conduct.txt) +- I have updated the related issue with new insights and changes +- I added unit tests and updated the docstrings +- I've used one of the [conventional commit types](https://www.conventionalcommits.org/en/v1.0.0/) for my PR title: `fix:`, `feat:`, `build:`, `chore:`, `ci:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`. +- I documented my code +- I ran [pre-commit hooks](https://github.com/deepset-ai/haystack/blob/main/CONTRIBUTING.md#installation) and fixed any issue diff --git a/.github/workflows/docstrings_linting.yml b/.github/workflows/docstrings_linting.yml new file mode 100644 index 00000000..ba530e53 --- /dev/null +++ b/.github/workflows/docstrings_linting.yml @@ -0,0 +1,20 @@ +name: run docstrings linting + +on: + push: + branches: + - docstrings-linting + +jobs: + docstrings-linting: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Hatch + run: pip install hatch=="1.9.3" + + - name: ruff docstrings linting + run: hatch run ruff check haystack-experimental diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 00000000..75b76f61 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,84 @@ +# If you change this name also do it in linting-skipper.yml and ci_metrics.yml +name: Linting + +on: + pull_request: + paths: + - "haystack-experimental/**/*.py" + - "test/**/*.py" + - "pyproject.toml" + +env: + PYTHON_VERSION: "3.8" + HATCH_VERSION: "1.9.3" + +jobs: + license-header: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check License Header + run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check + + mypy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # With the default value of 1, there are corner cases where tj-actions/changed-files + # fails with a `no merge base` error + fetch-depth: 0 + + - name: Get changed files + id: files + uses: tj-actions/changed-files@v44 + with: + files: | + **/*.py + files_ignore: | + test/** + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} + + - name: Mypy + if: steps.files.outputs.any_changed == 'true' + run: | + mkdir .mypy_cache + hatch run test:types ${{ steps.files.outputs.all_changed_files }} + + pylint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # With the default value of 1, there are corner cases where tj-actions/changed-files + # fails with a `no merge base` error + fetch-depth: 0 + + - name: Get changed files + id: files + uses: tj-actions/changed-files@v44 + with: + files: | + haystack-experimental/**/*.py + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} + + - name: Pylint + if: steps.files.outputs.any_changed == 'true' + run: | + hatch run test:lint ${{ steps.files.outputs.all_changed_files }} diff --git a/.github/workflows/linting_skipper.yml b/.github/workflows/linting_skipper.yml new file mode 100644 index 00000000..a48767b8 --- /dev/null +++ b/.github/workflows/linting_skipper.yml @@ -0,0 +1,29 @@ +# If you change this name also do it in linting.yml and ci_metrics.yml +name: Linting + +on: + pull_request: + paths-ignore: + - "haystack/preview/**/*.py" + - "test/preview/**/*.py" + - "e2e/preview/**/*.py" + - "**/pyproject.toml" + +jobs: + license-header: + runs-on: ubuntu-latest + steps: + - name: Skip mypy + run: echo "Skipped mypy" + + mypy: + runs-on: ubuntu-latest + steps: + - name: Skip mypy + run: echo "Skipped mypy" + + pylint: + runs-on: ubuntu-latest + steps: + - name: Skip pylint + run: echo "Skipped pylint" diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml new file mode 100644 index 00000000..62730b7f --- /dev/null +++ b/.github/workflows/project.yml @@ -0,0 +1,16 @@ +name: Track issues with Github project + +on: + issues: + types: + - opened + +jobs: + add-to-project: + name: Add new issues to project for triage + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@v1.0.1 + with: + project-url: https://github.com/orgs/deepset-ai/projects/5 + github-token: ${{ secrets.GH_PROJECT_PAT }} diff --git a/.github/workflows/pypi_release.yml b/.github/workflows/pypi_release.yml new file mode 100644 index 00000000..a0ffefd1 --- /dev/null +++ b/.github/workflows/pypi_release.yml @@ -0,0 +1,42 @@ +name: Project release on PyPi + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+*" + # We must not release versions tagged with -rc0 suffix + - "!v[0-9]+.[0-9]+.[0-9]-rc0" + +env: + HATCH_VERSION: "1.9.3" + +jobs: + release-on-pypi: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} + + - name: Build Haystack Experimental + run: hatch build + + - name: Publish on PyPi + env: + HATCH_INDEX_USER: __token__ + HATCH_INDEX_AUTH: ${{ secrets.HAYSTACK_AI_PYPI_TOKEN }} + run: hatch publish -y + + - name: Notify Slack + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + VERSION: ${{ github.ref_name }} + if: always() + uses: act10ns/slack@v2 + with: + status: ${{ job.status }} + channel: "#haystack-notifications" + config: .github/config/pypi-release-slack-notification.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 00000000..4ac6c92f --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,15 @@ +name: 'Stalebot' +on: + schedule: + - cron: '30 1 * * *' + +jobs: + makestale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + any-of-labels: 'proposal,community-triage' + stale-pr-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.' + days-before-stale: 30 + days-before-close: 10 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..b4f4ab12 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,375 @@ +# If you change this name also do it in tests_skipper.yml and ci_metrics.yml +name: Tests + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: # Activate this workflow manually + push: + branches: + - main + # release branches have the form v1.9.x + - "v[0-9].*[0-9].x" + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + paths: + # Keep the list in sync with the paths defined in the `tests_skipper.yml` workflow + - "haystack-experimental/**/*.py" + - "test/**/*.py" + - "pyproject.toml" + +env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + CORE_AZURE_CS_ENDPOINT: ${{ secrets.CORE_AZURE_CS_ENDPOINT }} + CORE_AZURE_CS_API_KEY: ${{ secrets.CORE_AZURE_CS_API_KEY }} + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} + AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HF_API_TOKEN: ${{ secrets.HUGGINGFACE_API_KEY }} + PYTHON_VERSION: "3.8" + HATCH_VERSION: "1.9.3" + +jobs: + black: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} + + - name: Check status + run: hatch run default:format-check + + - name: Calculate alert data + id: calculator + shell: bash + if: (success() || failure()) && github.ref_name == 'main' + run: | + if [ "${{ job.status }}" = "success" ]; then + echo "alert_type=success" >> "$GITHUB_OUTPUT"; + else + echo "alert_type=error" >> "$GITHUB_OUTPUT"; + fi + + - name: Send event to Datadog + if: (success() || failure()) && github.ref_name == 'main' + uses: masci/datadog@v1 + with: + api-key: ${{ secrets.CORE_DATADOG_API_KEY }} + api-url: https://api.datadoghq.eu + events: | + - title: "${{ github.workflow }} workflow" + text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" + alert_type: "${{ steps.calculator.outputs.alert_type }}" + source_type_name: "Github" + host: ${{ github.repository_owner }} + tags: + - "project:${{ github.repository }}" + - "job:${{ github.job }}" + - "run_id:${{ github.run_id }}" + - "workflow:${{ github.workflow }}" + - "branch:${{ github.ref_name }}" + - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + install-dependencies: + name: Install and cache ${{ matrix.os }} dependencies + needs: black + strategy: + matrix: + os: [ubuntu-latest, macos-12, windows-latest] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} + + - name: Install dependencies + # To actually install and sync the dependencies + run: hatch run test:pip list + + - uses: actions/cache@v4 + with: + path: ${{ env.pythonLocation }} + key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} + + unit-tests: + name: Unit / ${{ matrix.os }} + needs: install-dependencies + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-12 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Restore Python dependencies + uses: actions/cache/restore@v4 + with: + path: ${{ env.pythonLocation }} + key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} + + - name: Run + run: hatch run test:unit + + - name: Coveralls + # We upload only coverage for ubuntu as handling both os + # complicates the workflow too much for little to no gain + if: matrix.os == 'ubuntu-latest' + uses: coverallsapp/github-action@v2 + with: + path-to-lcov: coverage.xml + + - name: Calculate alert data + id: calculator + shell: bash + if: (success() || failure()) && github.ref_name == 'main' + run: | + if [ "${{ job.status }}" = "success" ]; then + echo "alert_type=success" >> "$GITHUB_OUTPUT"; + else + echo "alert_type=error" >> "$GITHUB_OUTPUT"; + fi + + - name: Send event to Datadog + if: (success() || failure()) && github.ref_name == 'main' + uses: masci/datadog@v1 + with: + api-key: ${{ secrets.CORE_DATADOG_API_KEY }} + api-url: https://api.datadoghq.eu + events: | + - title: "${{ github.workflow }} workflow" + text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" + alert_type: "${{ steps.calculator.outputs.alert_type }}" + source_type_name: "Github" + host: ${{ github.repository_owner }} + tags: + - "project:${{ github.repository }}" + - "job:${{ github.job }}" + - "run_id:${{ github.run_id }}" + - "workflow:${{ github.workflow }}" + - "branch:${{ github.ref_name }}" + - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + - name: Nightly - run unit tests with Haystack main branch + if: github.event_name == 'schedule' + id: nightly-haystack-main + run: | + hatch run pip install git+https://github.com/deepset-ai/haystack.git + hatch run test:unit + + - name: Send event to Datadog for nightly failures + if: failure() && github.event_name == 'schedule' + uses: ./.github/actions/send_failure + with: + title: | + core-integrations failure: + ${{ (steps.tests.conclusion == 'nightly-haystack-main') && 'nightly-haystack-main' || 'tests' }} + - ${{ github.workflow }} + api-key: ${{ secrets.CORE_DATADOG_API_KEY }} + + integration-tests-linux: + name: Integration / ubuntu-latest + needs: unit-tests + runs-on: ubuntu-latest + services: + tika: + image: apache/tika:2.9.0.0 + ports: + - 9998:9998 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Install dependencies + run: | + sudo apt update + sudo apt install ffmpeg # for local Whisper tests + + - name: Restore Python dependencies + uses: actions/cache/restore@v4 + with: + path: ${{ env.pythonLocation }} + key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} + + - name: Run + run: hatch run test:integration + + - name: Calculate alert data + id: calculator + shell: bash + if: (success() || failure()) && github.ref_name == 'main' + run: | + if [ "${{ job.status }}" = "success" ]; then + echo "alert_type=success" >> "$GITHUB_OUTPUT"; + else + echo "alert_type=error" >> "$GITHUB_OUTPUT"; + fi + + - name: Send event to Datadog + if: (success() || failure()) && github.ref_name == 'main' + uses: masci/datadog@v1 + with: + api-key: ${{ secrets.CORE_DATADOG_API_KEY }} + api-url: https://api.datadoghq.eu + events: | + - title: "${{ github.workflow }} workflow" + text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" + alert_type: "${{ steps.calculator.outputs.alert_type }}" + source_type_name: "Github" + host: ${{ github.repository_owner }} + tags: + - "project:${{ github.repository }}" + - "job:${{ github.job }}" + - "run_id:${{ github.run_id }}" + - "workflow:${{ github.workflow }}" + - "branch:${{ github.ref_name }}" + - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + integration-tests-macos: + name: Integration / macos-12 + needs: unit-tests + runs-on: macos-12 + env: + HAYSTACK_MPS_ENABLED: false + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Install dependencies + run: | + brew install ffmpeg # for local Whisper tests + + - name: Restore Python dependencies + uses: actions/cache/restore@v4 + with: + path: ${{ env.pythonLocation }} + key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} + + - name: Run + run: hatch run test:integration-mac + + - name: Calculate alert data + id: calculator + shell: bash + if: (success() || failure()) && github.ref_name == 'main' + run: | + if [ "${{ job.status }}" = "success" ]; then + echo "alert_type=success" >> "$GITHUB_OUTPUT"; + else + echo "alert_type=error" >> "$GITHUB_OUTPUT"; + fi + + - name: Send event to Datadog + if: (success() || failure()) && github.ref_name == 'main' + uses: masci/datadog@v1 + with: + api-key: ${{ secrets.CORE_DATADOG_API_KEY }} + api-url: https://api.datadoghq.eu + events: | + - title: "${{ github.workflow }} workflow" + text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" + alert_type: "${{ steps.calculator.outputs.alert_type }}" + source_type_name: "Github" + host: ${{ github.repository_owner }} + tags: + - "project:${{ github.repository }}" + - "job:${{ github.job }}" + - "run_id:${{ github.run_id }}" + - "workflow:${{ github.workflow }}" + - "branch:${{ github.ref_name }}" + - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + integration-tests-windows: + name: Integration / windows-latest + needs: unit-tests + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "${{ env.PYTHON_VERSION }}" + + - name: Restore Python dependencies + uses: actions/cache/restore@v4 + with: + path: ${{ env.pythonLocation }} + key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} + + - name: Run + run: hatch run test:integration-windows + + - name: Calculate alert data + id: calculator + shell: bash + if: (success() || failure()) && github.ref_name == 'main' + run: | + if [ "${{ job.status }}" = "success" ]; then + echo "alert_type=success" >> "$GITHUB_OUTPUT"; + else + echo "alert_type=error" >> "$GITHUB_OUTPUT"; + fi + + - name: Send event to Datadog + if: (success() || failure()) && github.ref_name == 'main' + uses: masci/datadog@v1 + with: + api-key: ${{ secrets.CORE_DATADOG_API_KEY }} + api-url: https://api.datadoghq.eu + events: | + - title: "${{ github.workflow }} workflow" + text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" + alert_type: "${{ steps.calculator.outputs.alert_type }}" + source_type_name: "Github" + host: ${{ github.repository_owner }} + tags: + - "project:${{ github.repository }}" + - "job:${{ github.job }}" + - "run_id:${{ github.run_id }}" + - "workflow:${{ github.workflow }}" + - "branch:${{ github.ref_name }}" + - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + trigger-catch-all: + name: Tests completed + # This job will be executed only after all the other tests + # are successful. + # This way we'll be able to mark only this test as required + # and skip it accordingly. + needs: + - integration-tests-linux + - integration-tests-macos + - integration-tests-windows + uses: ./.github/workflows/tests_skipper_workflow.yml + with: + tests_were_skipped: false diff --git a/.github/workflows/tests_skipper_trigger.yml b/.github/workflows/tests_skipper_trigger.yml new file mode 100644 index 00000000..f492d9e9 --- /dev/null +++ b/.github/workflows/tests_skipper_trigger.yml @@ -0,0 +1,46 @@ +# If you change this name also do it in tests.yml and ci_metrics.yml +name: Tests + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + paths-ignore: + # we skip the tests unless the code changes. The problem is that GitHub will run the check anyway if any other + # file outside the code changed (e.g. the release notes). Hence, we need a second filter down below. + # keep the list in sync with the paths defined in the `tests.yml` workflow + - "haystack-experimental/**/*.py" + - "test/**/*.py" + +jobs: + check_if_changed: + name: Check if changed + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + code_changes: ${{ steps.changes.outputs.code_changes }} + steps: + - uses: actions/checkout@v4 + - name: Check for changed code + id: changes + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 + with: + # keep the list in sync with the paths defined in the `tests.yml` workflow + filters: | + code_changes: + - haystack-experimental/**/*.py + - test/**/*.py + - "pyproject.toml" + + trigger-catch-all: + name: Tests completed + # Don't run this check if the PR contains both code and non-code changes (e.g. release notes) + needs: check_if_changed + if: needs.check_if_changed.outputs.code_changes == 'false' + uses: ./.github/workflows/tests_skipper_workflow.yml + with: + tests_were_skipped: true diff --git a/.github/workflows/tests_skipper_workflow.yml b/.github/workflows/tests_skipper_workflow.yml new file mode 100644 index 00000000..4554c827 --- /dev/null +++ b/.github/workflows/tests_skipper_workflow.yml @@ -0,0 +1,24 @@ +# If you change this name also do it in tests.yml and ci_metrics.yml +# We use a separate workflow to skip the tests if the PR contains both code and non-code changes (e.g. release notes). +# Skipping the job unfortunately doesn't work because GitHub will treat these jobs as successful even if they are +# skipped. Hence, we need to revert to a separate workflow. +name: Tests +on: + workflow_call: + inputs: + tests_were_skipped: + type: boolean + required: true + +jobs: + catch-all: + # Don't run this check if the PR contains both code and non-code changes (e.g. release notes) + name: Mark tests as completed + runs-on: ubuntu-latest + steps: + - name: Skip tests + if: ${{ github.event.inputs.tests_were_skipped }} + run: echo "Skipped!" + - name: Tests completed successfully + if: ${{ !github.event.inputs.tests_were_skipped }} + run: echo "Tests completed!" diff --git a/.github/workflows/workflows_linting.yml b/.github/workflows/workflows_linting.yml new file mode 100644 index 00000000..6fe24e15 --- /dev/null +++ b/.github/workflows/workflows_linting.yml @@ -0,0 +1,19 @@ +name: Github workflows linter + +on: + pull_request: + paths: + - ".github/workflows" + +jobs: + lint-workflows: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install actionlint + run: go install github.com/rhysd/actionlint/cmd/actionlint@latest + + - name: Run actionlint + run: actionlint From 24a0b7fbfeebc4b3d7cef3560bc23a74796c708f Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Wed, 22 May 2024 08:37:46 +0200 Subject: [PATCH 2/4] fix --- .github/actionlint.yml | 3 - .github/workflows/docstrings_linting.yml | 20 -- .github/workflows/licensing.yml | 18 + .github/workflows/linting.yml | 84 ----- .github/workflows/linting_skipper.yml | 29 -- .github/workflows/pypi_release.yml | 4 +- .github/workflows/stale.yml | 15 - .github/workflows/tests.yml | 329 ++----------------- .github/workflows/tests_skipper_trigger.yml | 46 --- .github/workflows/tests_skipper_workflow.yml | 24 -- haystack_experimental/__init__.py | 3 + haystack_experimental/version.py | 7 +- pyproject.toml | 171 ++-------- releasenotes/config.yaml | 47 --- test/test_experimental.py | 2 + 15 files changed, 79 insertions(+), 723 deletions(-) delete mode 100644 .github/actionlint.yml delete mode 100644 .github/workflows/docstrings_linting.yml create mode 100644 .github/workflows/licensing.yml delete mode 100644 .github/workflows/linting.yml delete mode 100644 .github/workflows/linting_skipper.yml delete mode 100644 .github/workflows/stale.yml delete mode 100644 .github/workflows/tests_skipper_trigger.yml delete mode 100644 .github/workflows/tests_skipper_workflow.yml create mode 100644 haystack_experimental/__init__.py delete mode 100644 releasenotes/config.yaml create mode 100644 test/test_experimental.py diff --git a/.github/actionlint.yml b/.github/actionlint.yml deleted file mode 100644 index 60646952..00000000 --- a/.github/actionlint.yml +++ /dev/null @@ -1,3 +0,0 @@ -self-hosted-runner: - # Labels of self-hosted runner in array of string - labels: ["cml", "ubuntu-latest-4-cores"] diff --git a/.github/workflows/docstrings_linting.yml b/.github/workflows/docstrings_linting.yml deleted file mode 100644 index ba530e53..00000000 --- a/.github/workflows/docstrings_linting.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: run docstrings linting - -on: - push: - branches: - - docstrings-linting - -jobs: - docstrings-linting: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Hatch - run: pip install hatch=="1.9.3" - - - name: ruff docstrings linting - run: hatch run ruff check haystack-experimental diff --git a/.github/workflows/licensing.yml b/.github/workflows/licensing.yml new file mode 100644 index 00000000..ebaf4556 --- /dev/null +++ b/.github/workflows/licensing.yml @@ -0,0 +1,18 @@ +name: Licensing + +on: + pull_request: + paths: + - "haystack_experimental/**/*.py" + - "test/**/*.py" + - "pyproject.toml" + +jobs: + license-header: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check License Header + run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index 75b76f61..00000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,84 +0,0 @@ -# If you change this name also do it in linting-skipper.yml and ci_metrics.yml -name: Linting - -on: - pull_request: - paths: - - "haystack-experimental/**/*.py" - - "test/**/*.py" - - "pyproject.toml" - -env: - PYTHON_VERSION: "3.8" - HATCH_VERSION: "1.9.3" - -jobs: - license-header: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Check License Header - run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check - - mypy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - # With the default value of 1, there are corner cases where tj-actions/changed-files - # fails with a `no merge base` error - fetch-depth: 0 - - - name: Get changed files - id: files - uses: tj-actions/changed-files@v44 - with: - files: | - **/*.py - files_ignore: | - test/** - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - - name: Install Hatch - run: pip install hatch==${{ env.HATCH_VERSION }} - - - name: Mypy - if: steps.files.outputs.any_changed == 'true' - run: | - mkdir .mypy_cache - hatch run test:types ${{ steps.files.outputs.all_changed_files }} - - pylint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - # With the default value of 1, there are corner cases where tj-actions/changed-files - # fails with a `no merge base` error - fetch-depth: 0 - - - name: Get changed files - id: files - uses: tj-actions/changed-files@v44 - with: - files: | - haystack-experimental/**/*.py - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - - name: Install Hatch - run: pip install hatch==${{ env.HATCH_VERSION }} - - - name: Pylint - if: steps.files.outputs.any_changed == 'true' - run: | - hatch run test:lint ${{ steps.files.outputs.all_changed_files }} diff --git a/.github/workflows/linting_skipper.yml b/.github/workflows/linting_skipper.yml deleted file mode 100644 index a48767b8..00000000 --- a/.github/workflows/linting_skipper.yml +++ /dev/null @@ -1,29 +0,0 @@ -# If you change this name also do it in linting.yml and ci_metrics.yml -name: Linting - -on: - pull_request: - paths-ignore: - - "haystack/preview/**/*.py" - - "test/preview/**/*.py" - - "e2e/preview/**/*.py" - - "**/pyproject.toml" - -jobs: - license-header: - runs-on: ubuntu-latest - steps: - - name: Skip mypy - run: echo "Skipped mypy" - - mypy: - runs-on: ubuntu-latest - steps: - - name: Skip mypy - run: echo "Skipped mypy" - - pylint: - runs-on: ubuntu-latest - steps: - - name: Skip pylint - run: echo "Skipped pylint" diff --git a/.github/workflows/pypi_release.yml b/.github/workflows/pypi_release.yml index a0ffefd1..3c5a3447 100644 --- a/.github/workflows/pypi_release.yml +++ b/.github/workflows/pypi_release.yml @@ -4,11 +4,9 @@ on: push: tags: - "v[0-9]+.[0-9]+.[0-9]+*" - # We must not release versions tagged with -rc0 suffix - - "!v[0-9]+.[0-9]+.[0-9]-rc0" env: - HATCH_VERSION: "1.9.3" + HATCH_VERSION: "1.9.4" jobs: release-on-pypi: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 4ac6c92f..00000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: 'Stalebot' -on: - schedule: - - cron: '30 1 * * *' - -jobs: - makestale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - any-of-labels: 'proposal,community-triage' - stale-pr-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.' - days-before-stale: 30 - days-before-close: 10 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b4f4ab12..35bced01 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,14 +2,17 @@ name: Tests on: + # Activate this workflow manually + workflow_dispatch: + + # Run tests nightly against Haystack's main branch schedule: - cron: "0 0 * * *" - workflow_dispatch: # Activate this workflow manually + push: branches: - main - # release branches have the form v1.9.x - - "v[0-9].*[0-9].x" + pull_request: types: - opened @@ -18,105 +21,39 @@ on: - ready_for_review paths: # Keep the list in sync with the paths defined in the `tests_skipper.yml` workflow - - "haystack-experimental/**/*.py" + - "haystack_experimental/**/*.py" - "test/**/*.py" - "pyproject.toml" env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - CORE_AZURE_CS_ENDPOINT: ${{ secrets.CORE_AZURE_CS_ENDPOINT }} - CORE_AZURE_CS_API_KEY: ${{ secrets.CORE_AZURE_CS_API_KEY }} - AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} - AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HF_API_TOKEN: ${{ secrets.HUGGINGFACE_API_KEY }} PYTHON_VERSION: "3.8" - HATCH_VERSION: "1.9.3" + HATCH_VERSION: "1.9.4" jobs: - black: + linting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - name: Install Hatch run: pip install hatch==${{ env.HATCH_VERSION }} - - name: Check status - run: hatch run default:format-check + - name: Check code format + run: hatch fmt - - name: Calculate alert data - id: calculator - shell: bash - if: (success() || failure()) && github.ref_name == 'main' - run: | - if [ "${{ job.status }}" = "success" ]; then - echo "alert_type=success" >> "$GITHUB_OUTPUT"; - else - echo "alert_type=error" >> "$GITHUB_OUTPUT"; - fi + - name: Linting + run: hatch run test:lint - - name: Send event to Datadog - if: (success() || failure()) && github.ref_name == 'main' - uses: masci/datadog@v1 - with: - api-key: ${{ secrets.CORE_DATADOG_API_KEY }} - api-url: https://api.datadoghq.eu - events: | - - title: "${{ github.workflow }} workflow" - text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" - alert_type: "${{ steps.calculator.outputs.alert_type }}" - source_type_name: "Github" - host: ${{ github.repository_owner }} - tags: - - "project:${{ github.repository }}" - - "job:${{ github.job }}" - - "run_id:${{ github.run_id }}" - - "workflow:${{ github.workflow }}" - - "branch:${{ github.ref_name }}" - - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - - install-dependencies: - name: Install and cache ${{ matrix.os }} dependencies - needs: black - strategy: - matrix: - os: [ubuntu-latest, macos-12, windows-latest] - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - - name: Install Hatch - run: pip install hatch==${{ env.HATCH_VERSION }} - - - name: Install dependencies - # To actually install and sync the dependencies - run: hatch run test:pip list - - - uses: actions/cache@v4 - with: - path: ${{ env.pythonLocation }} - key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} + - name: Typing + run: hatch run test:typing unit-tests: name: Unit / ${{ matrix.os }} - needs: install-dependencies strategy: fail-fast: false matrix: os: - ubuntu-latest - windows-latest - - macos-12 + - macos-latest runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -125,14 +62,11 @@ jobs: with: python-version: "${{ env.PYTHON_VERSION }}" - - name: Restore Python dependencies - uses: actions/cache/restore@v4 - with: - path: ${{ env.pythonLocation }} - key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} - name: Run - run: hatch run test:unit + run: hatch run test:cov - name: Coveralls # We upload only coverage for ubuntu as handling both os @@ -142,234 +76,9 @@ jobs: with: path-to-lcov: coverage.xml - - name: Calculate alert data - id: calculator - shell: bash - if: (success() || failure()) && github.ref_name == 'main' - run: | - if [ "${{ job.status }}" = "success" ]; then - echo "alert_type=success" >> "$GITHUB_OUTPUT"; - else - echo "alert_type=error" >> "$GITHUB_OUTPUT"; - fi - - - name: Send event to Datadog - if: (success() || failure()) && github.ref_name == 'main' - uses: masci/datadog@v1 - with: - api-key: ${{ secrets.CORE_DATADOG_API_KEY }} - api-url: https://api.datadoghq.eu - events: | - - title: "${{ github.workflow }} workflow" - text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" - alert_type: "${{ steps.calculator.outputs.alert_type }}" - source_type_name: "Github" - host: ${{ github.repository_owner }} - tags: - - "project:${{ github.repository }}" - - "job:${{ github.job }}" - - "run_id:${{ github.run_id }}" - - "workflow:${{ github.workflow }}" - - "branch:${{ github.ref_name }}" - - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - - name: Nightly - run unit tests with Haystack main branch if: github.event_name == 'schedule' id: nightly-haystack-main run: | hatch run pip install git+https://github.com/deepset-ai/haystack.git hatch run test:unit - - - name: Send event to Datadog for nightly failures - if: failure() && github.event_name == 'schedule' - uses: ./.github/actions/send_failure - with: - title: | - core-integrations failure: - ${{ (steps.tests.conclusion == 'nightly-haystack-main') && 'nightly-haystack-main' || 'tests' }} - - ${{ github.workflow }} - api-key: ${{ secrets.CORE_DATADOG_API_KEY }} - - integration-tests-linux: - name: Integration / ubuntu-latest - needs: unit-tests - runs-on: ubuntu-latest - services: - tika: - image: apache/tika:2.9.0.0 - ports: - - 9998:9998 - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - - name: Install dependencies - run: | - sudo apt update - sudo apt install ffmpeg # for local Whisper tests - - - name: Restore Python dependencies - uses: actions/cache/restore@v4 - with: - path: ${{ env.pythonLocation }} - key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} - - - name: Run - run: hatch run test:integration - - - name: Calculate alert data - id: calculator - shell: bash - if: (success() || failure()) && github.ref_name == 'main' - run: | - if [ "${{ job.status }}" = "success" ]; then - echo "alert_type=success" >> "$GITHUB_OUTPUT"; - else - echo "alert_type=error" >> "$GITHUB_OUTPUT"; - fi - - - name: Send event to Datadog - if: (success() || failure()) && github.ref_name == 'main' - uses: masci/datadog@v1 - with: - api-key: ${{ secrets.CORE_DATADOG_API_KEY }} - api-url: https://api.datadoghq.eu - events: | - - title: "${{ github.workflow }} workflow" - text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" - alert_type: "${{ steps.calculator.outputs.alert_type }}" - source_type_name: "Github" - host: ${{ github.repository_owner }} - tags: - - "project:${{ github.repository }}" - - "job:${{ github.job }}" - - "run_id:${{ github.run_id }}" - - "workflow:${{ github.workflow }}" - - "branch:${{ github.ref_name }}" - - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - - integration-tests-macos: - name: Integration / macos-12 - needs: unit-tests - runs-on: macos-12 - env: - HAYSTACK_MPS_ENABLED: false - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - - name: Install dependencies - run: | - brew install ffmpeg # for local Whisper tests - - - name: Restore Python dependencies - uses: actions/cache/restore@v4 - with: - path: ${{ env.pythonLocation }} - key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} - - - name: Run - run: hatch run test:integration-mac - - - name: Calculate alert data - id: calculator - shell: bash - if: (success() || failure()) && github.ref_name == 'main' - run: | - if [ "${{ job.status }}" = "success" ]; then - echo "alert_type=success" >> "$GITHUB_OUTPUT"; - else - echo "alert_type=error" >> "$GITHUB_OUTPUT"; - fi - - - name: Send event to Datadog - if: (success() || failure()) && github.ref_name == 'main' - uses: masci/datadog@v1 - with: - api-key: ${{ secrets.CORE_DATADOG_API_KEY }} - api-url: https://api.datadoghq.eu - events: | - - title: "${{ github.workflow }} workflow" - text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" - alert_type: "${{ steps.calculator.outputs.alert_type }}" - source_type_name: "Github" - host: ${{ github.repository_owner }} - tags: - - "project:${{ github.repository }}" - - "job:${{ github.job }}" - - "run_id:${{ github.run_id }}" - - "workflow:${{ github.workflow }}" - - "branch:${{ github.ref_name }}" - - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - - integration-tests-windows: - name: Integration / windows-latest - needs: unit-tests - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "${{ env.PYTHON_VERSION }}" - - - name: Restore Python dependencies - uses: actions/cache/restore@v4 - with: - path: ${{ env.pythonLocation }} - key: pip-${{ runner.os }}-${{ github.run_id }}-${{ hashFiles('pyproject.toml') }} - - - name: Run - run: hatch run test:integration-windows - - - name: Calculate alert data - id: calculator - shell: bash - if: (success() || failure()) && github.ref_name == 'main' - run: | - if [ "${{ job.status }}" = "success" ]; then - echo "alert_type=success" >> "$GITHUB_OUTPUT"; - else - echo "alert_type=error" >> "$GITHUB_OUTPUT"; - fi - - - name: Send event to Datadog - if: (success() || failure()) && github.ref_name == 'main' - uses: masci/datadog@v1 - with: - api-key: ${{ secrets.CORE_DATADOG_API_KEY }} - api-url: https://api.datadoghq.eu - events: | - - title: "${{ github.workflow }} workflow" - text: "Job ${{ github.job }} in branch ${{ github.ref_name }}" - alert_type: "${{ steps.calculator.outputs.alert_type }}" - source_type_name: "Github" - host: ${{ github.repository_owner }} - tags: - - "project:${{ github.repository }}" - - "job:${{ github.job }}" - - "run_id:${{ github.run_id }}" - - "workflow:${{ github.workflow }}" - - "branch:${{ github.ref_name }}" - - "url:https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - - trigger-catch-all: - name: Tests completed - # This job will be executed only after all the other tests - # are successful. - # This way we'll be able to mark only this test as required - # and skip it accordingly. - needs: - - integration-tests-linux - - integration-tests-macos - - integration-tests-windows - uses: ./.github/workflows/tests_skipper_workflow.yml - with: - tests_were_skipped: false diff --git a/.github/workflows/tests_skipper_trigger.yml b/.github/workflows/tests_skipper_trigger.yml deleted file mode 100644 index f492d9e9..00000000 --- a/.github/workflows/tests_skipper_trigger.yml +++ /dev/null @@ -1,46 +0,0 @@ -# If you change this name also do it in tests.yml and ci_metrics.yml -name: Tests - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - paths-ignore: - # we skip the tests unless the code changes. The problem is that GitHub will run the check anyway if any other - # file outside the code changed (e.g. the release notes). Hence, we need a second filter down below. - # keep the list in sync with the paths defined in the `tests.yml` workflow - - "haystack-experimental/**/*.py" - - "test/**/*.py" - -jobs: - check_if_changed: - name: Check if changed - runs-on: ubuntu-latest - permissions: - pull-requests: read - outputs: - code_changes: ${{ steps.changes.outputs.code_changes }} - steps: - - uses: actions/checkout@v4 - - name: Check for changed code - id: changes - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 - with: - # keep the list in sync with the paths defined in the `tests.yml` workflow - filters: | - code_changes: - - haystack-experimental/**/*.py - - test/**/*.py - - "pyproject.toml" - - trigger-catch-all: - name: Tests completed - # Don't run this check if the PR contains both code and non-code changes (e.g. release notes) - needs: check_if_changed - if: needs.check_if_changed.outputs.code_changes == 'false' - uses: ./.github/workflows/tests_skipper_workflow.yml - with: - tests_were_skipped: true diff --git a/.github/workflows/tests_skipper_workflow.yml b/.github/workflows/tests_skipper_workflow.yml deleted file mode 100644 index 4554c827..00000000 --- a/.github/workflows/tests_skipper_workflow.yml +++ /dev/null @@ -1,24 +0,0 @@ -# If you change this name also do it in tests.yml and ci_metrics.yml -# We use a separate workflow to skip the tests if the PR contains both code and non-code changes (e.g. release notes). -# Skipping the job unfortunately doesn't work because GitHub will treat these jobs as successful even if they are -# skipped. Hence, we need to revert to a separate workflow. -name: Tests -on: - workflow_call: - inputs: - tests_were_skipped: - type: boolean - required: true - -jobs: - catch-all: - # Don't run this check if the PR contains both code and non-code changes (e.g. release notes) - name: Mark tests as completed - runs-on: ubuntu-latest - steps: - - name: Skip tests - if: ${{ github.event.inputs.tests_were_skipped }} - run: echo "Skipped!" - - name: Tests completed successfully - if: ${{ !github.event.inputs.tests_were_skipped }} - run: echo "Tests completed!" diff --git a/haystack_experimental/__init__.py b/haystack_experimental/__init__.py new file mode 100644 index 00000000..c1764a6e --- /dev/null +++ b/haystack_experimental/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2022-present deepset GmbH +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/haystack_experimental/version.py b/haystack_experimental/version.py index 8b18fc69..a4a8d183 100644 --- a/haystack_experimental/version.py +++ b/haystack_experimental/version.py @@ -2,9 +2,4 @@ # # SPDX-License-Identifier: Apache-2.0 -from importlib import metadata - -try: - __version__ = str(metadata.version("haystack-experimental")) -except metadata.PackageNotFoundError: - __version__ = "main" +__version__ = "0.0.0" diff --git a/pyproject.toml b/pyproject.toml index 47bdb0ae..be67eed0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,9 +7,9 @@ name = "haystack-experimental" dynamic = ["version"] description = "Experimental components and features for the Haystack LLM framework." readme = "README.md" -license = "Apache-2.0" +license = {text = "Apache-2.0"} requires-python = ">=3.8" -authors = [{ name = "deepset.ai", email = "malte.pietsch@deepset.ai" }] +authors = [{ name = "deepset.ai", email = "info@deepset.ai" }] classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", @@ -21,81 +21,64 @@ classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering :: Artificial Intelligence", ] -dependencies = ["haystack-ai"] +dependencies = [ + "haystack-ai", +] +[project.urls] +"CI: GitHub" = "https://github.com/deepset-ai/haystack-experimental/actions" +"GitHub: issues" = "https://github.com/deepset-ai/haystack-experimental/issues" +"GitHub: repo" = "https://github.com/deepset-ai/haystack-experimental" +Homepage = "https://github.com/deepset-ai/haystack-experimental" [tool.hatch.envs.default] dependencies = [ - "pre-commit", # Type check "mypy", # Test "pytest", "pytest-cov", - "pytest-custom_exit_code", # used in the CI - "pytest-asyncio", - "pytest-rerunfailures", - "responses", - "tox", - "coverage", - "python-multipart", - "psutil", # Linting "pylint", "ruff", - # Documentation - "toml", - "reno", - # dulwich is a reno dependency, they pin it at >=0.15.0 so pip takes ton of time to resolve the dependency tree. - # We pin it here to avoid taking too much time. - # https://opendev.org/openstack/reno/src/branch/master/requirements.txt#L7 - "dulwich>=0.21.0,<1.0.0", - # Version specified following Black stability policy: - # https://black.readthedocs.io/en/stable/the_black_code_style/index.html#stability-policy - "black[jupyter]~=23.0", ] -[tool.hatch.envs.default.scripts] -format = "black ." -format-check = "black --check ." - [tool.hatch.envs.test] -extra-dependencies = [] +extra-dependencies = [ + # List here dependencies behind lazy-import +] [tool.hatch.envs.test.scripts] -e2e = "pytest e2e" unit = 'pytest --cov-report xml:coverage.xml --cov="haystack-experimental" -m "not integration" {args:test}' integration = 'pytest --maxfail=5 -m "integration" {args:test}' -integration-mac = 'pytest --maxfail=5 -m "integration" -k "not tika" {args:test}' -integration-windows = 'pytest --maxfail=5 -m "integration" -k "not tika" {args:test}' -types = "mypy --install-types --non-interactive --cache-dir=.mypy_cache/ {args:haystack-experimental}" +typing = "mypy --install-types --non-interactive {args:haystack_experimental}" lint = [ - "ruff check {args:haystack-experimental}", - "pylint -ry -j 0 {args:haystack-experimental}", + "ruff check {args:haystack_experimental}", + "pylint -ry -j 0 {args:haystack_experimental}", +] +test-cov = "coverage run -m pytest {args:test}" +cov-report = [ + "- coverage combine", + "coverage report", +] +cov = [ + "test-cov", + "cov-report", ] -lint-fix = ["black .", "ruff check {args:haystack-experimental} --fix"] [tool.hatch.envs.readme] -detached = true # To avoid installing the dependencies from the default environment +detached = true # To avoid installing the dependencies from the default environment dependencies = ["haystack-pydoc-tools"] [tool.hatch.envs.readme.scripts] sync = "./.github/utils/pydoc-markdown.sh" delete-outdated = "python ./.github/utils/delete_outdated_docs.py {args}" -[tool.hatch.envs.snippets] -extra-dependencies = ["torch", "pydantic"] - -[project.urls] -"CI: GitHub" = "https://github.com/deepset-ai/haystack-experimental/actions" -"GitHub: issues" = "https://github.com/deepset-ai/haystack-experimental/issues" -"GitHub: repo" = "https://github.com/deepset-ai/haystack-experimental" -Homepage = "https://github.com/deepset-ai/haystack-experimental" - [tool.hatch.version] -path = "VERSION.txt" -pattern = "(?P.+)" +path = "haystack_experimental/version.py" [tool.hatch.metadata] allow-direct-references = true @@ -106,97 +89,24 @@ include = ["/haystack-experimental", "/VERSION.txt"] [tool.hatch.build.targets.wheel] packages = ["haystack-experimental"] -[tool.black] -line-length = 120 -skip_magic_trailing_comma = true # For compatibility with pydoc>=4.6, check if still needed. - [tool.codespell] ignore-words-list = "ans,astroid,nd,ned,nin,ue,rouge,ist" quiet-level = 3 skip = "test/nodes/*,test/others/*,test/samples/*,e2e/*" +[tool.pylint] +ignore-paths = [ + "haystack_experimental/__init__.py", + "haystack_experimental/version.py", +] [tool.pylint.'MESSAGES CONTROL'] max-line-length = 120 -disable = [ - - # To keep - "fixme", - "c-extension-no-member", - - # To review: - "missing-docstring", - "unused-argument", - "no-member", - "line-too-long", - "protected-access", - "too-few-public-methods", - "raise-missing-from", - "invalid-name", - "duplicate-code", - "arguments-differ", - "consider-using-f-string", - "no-else-return", - "attribute-defined-outside-init", - "super-with-arguments", - "redefined-builtin", - "abstract-method", - "unspecified-encoding", - "unidiomatic-typecheck", - "no-name-in-module", - "consider-using-with", - "redefined-outer-name", - "arguments-renamed", - "unnecessary-pass", - "broad-except", - "unnecessary-comprehension", - "subprocess-run-check", - "singleton-comparison", - "consider-iterating-dictionary", - "undefined-loop-variable", - "consider-using-in", - "bare-except", - "unexpected-keyword-arg", - "simplifiable-if-expression", - "use-list-literal", - "broad-exception-raised", - - # To review later - "cyclic-import", - "import-outside-toplevel", - "deprecated-method", -] -[tool.pylint.'DESIGN'] -max-args = 38 # Default is 5 -max-attributes = 28 # Default is 7 -max-branches = 34 # Default is 12 -max-locals = 45 # Default is 15 -max-module-lines = 2468 # Default is 1000 -max-nested-blocks = 9 # Default is 5 -max-statements = 206 # Default is 50 -[tool.pylint.'SIMILARITIES'] -min-similarity-lines = 6 [tool.pytest.ini_options] minversion = "6.0" addopts = "--strict-markers" markers = [ - "unit: unit tests", "integration: integration tests", - - "generator: generator tests", - "summarizer: summarizer tests", - "embedding_dim: uses a document store with non-default embedding dimension (e.g @pytest.mark.embedding_dim(128))", - - "tika: requires Tika container", - "parsr: requires Parsr container", - "ocr: requires Tesseract", - - "elasticsearch: requires Elasticsearch container", - "weaviate: requires Weaviate container", - "pinecone: requires Pinecone credentials", - "faiss: uses FAISS", - "opensearch", - "document_store", ] log_cli = true @@ -206,11 +116,10 @@ warn_unused_configs = true ignore_missing_imports = true [tool.ruff] -line-length = 301 +line-length = 120 target-version = "py38" exclude = ["test"] - [tool.ruff.lint] select = [ "ASYNC", # flake8-async @@ -259,13 +168,3 @@ ignore = [ [tool.ruff.lint.mccabe] max-complexity = 28 - -[tool.ruff.lint.per-file-ignores] - -[tool.ruff.lint.pylint] -allow-magic-value-types = ["float", "int", "str"] -max-args = 14 # Default is 5 -max-branches = 21 # Default is 12 -max-public-methods = 20 # Default is 20 -max-returns = 7 # Default is 6 -max-statements = 60 # Default is 50 diff --git a/releasenotes/config.yaml b/releasenotes/config.yaml deleted file mode 100644 index 1becbe28..00000000 --- a/releasenotes/config.yaml +++ /dev/null @@ -1,47 +0,0 @@ -default_branch: main -collapse_pre_releases: true -pre_release_tag_re: (?P-(?:[ab]|rc)+\d*)$ -prelude_section_name: highlights -template: | - --- - highlights: > - Replace this text with content to appear at the top of the section for this - release. The highlights might repeat some details that are also present in other notes - from the same release, that's ok. Not every release note requires highlights, - use this section only to describe major features or notable changes. - upgrade: - - | - List upgrade notes here, or remove this section. - Upgrade notes should be rare: only list known/potential breaking changes, - or major changes that require user action before the upgrade. - Notes here must include steps that users can follow to 1. know if they're - affected and 2. handle the change gracefully on their end. - features: - - | - List new features here, or remove this section. - enhancements: - - | - List new behavior that is too small to be - considered a new feature, or remove this section. - issues: - - | - List known issues here, or remove this section. For example, if some change is experimental or known to not work in some cases, it should be mentioned here. - deprecations: - - | - List deprecations notes here, or remove this section. Deprecations should not be used for something that is removed in the release, use upgrade section instead. Deprecation should allow time for users to make necessary changes for the removal to happen in a future release. - security: - - | - Add security notes here, or remove this section. - fixes: - - | - Add normal bug fixes here, or remove this section. - -sections: - # The prelude section is implicitly included. - - [upgrade, ⬆️ Upgrade Notes] - - [features, 🚀 New Features] - - [enhancements, ⚡️ Enhancement Notes] - - [issues, Known Issues] - - [deprecations, ⚠️ Deprecation Notes] - - [security, Security Notes] - - [fixes, 🐛 Bug Fixes] diff --git a/test/test_experimental.py b/test/test_experimental.py new file mode 100644 index 00000000..f1748238 --- /dev/null +++ b/test/test_experimental.py @@ -0,0 +1,2 @@ +def test(): + pass From 09c78dd26f9c6fe018bb86c65e185b1422953e63 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Wed, 22 May 2024 08:53:57 +0200 Subject: [PATCH 3/4] fix coverage report --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index be67eed0..547d69d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ lint = [ test-cov = "coverage run -m pytest {args:test}" cov-report = [ "- coverage combine", - "coverage report", + "coverage xml", ] cov = [ "test-cov", From b78621c4901074d92cb85e553c6abf5bda5060c9 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Wed, 22 May 2024 08:54:29 +0200 Subject: [PATCH 4/4] clone repo --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 35bced01..484b3dee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,6 +33,8 @@ jobs: linting: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + - name: Install Hatch run: pip install hatch==${{ env.HATCH_VERSION }}