From 8a38ce24261aab58cf49dbc00289f6e078e86a5a Mon Sep 17 00:00:00 2001 From: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com> Date: Mon, 31 Mar 2025 17:31:22 +0200 Subject: [PATCH] chore: update Poetry to version 2.1.2 across workflows and remove restrictions in pyrpoject.toml --- .github/workflows/_test.yml | 2 +- .github/workflows/docs-build.yaml | 272 ++++++++++----------- .github/workflows/test-and-build-wheel.yml | 4 +- .gitlab-ci.yml | 2 +- CONTRIBUTING.md | 2 +- Dockerfile | 3 +- pyproject.toml | 4 +- qa/Dockerfile.qa | 3 +- 8 files changed, 145 insertions(+), 147 deletions(-) diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 38469e8c4..2f146fa42 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -28,7 +28,7 @@ defaults: run: shell: bash env: - POETRY_VERSION: 1.8.2 + POETRY_VERSION: 2.1.2 jobs: tests: diff --git a/.github/workflows/docs-build.yaml b/.github/workflows/docs-build.yaml index 1d09b610f..0629a35fa 100644 --- a/.github/workflows/docs-build.yaml +++ b/.github/workflows/docs-build.yaml @@ -1,148 +1,148 @@ name: docs-build on: - pull_request: - branches: [develop] - types: [opened, synchronize] - paths: - - "docs/**" - - "**/*.md" - - "**/*.rst" - push: - branches: [develop] - tags: - - docs-v* - - v* - workflow_dispatch: + pull_request: + branches: [develop] + types: [opened, synchronize] + paths: + - "docs/**" + - "**/*.md" + - "**/*.rst" + push: + branches: [develop] + tags: + - docs-v* + - v* + workflow_dispatch: defaults: - run: - shell: bash + run: + shell: bash env: - PYTHON_VERSION: "3.10" - POETRY_VERSION: "1.8.2" + PYTHON_VERSION: "3.10" + POETRY_VERSION: "2.1.2" concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: - build-docs: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Bootstrap poetry (Linux and macOS) - run: | - curl -sSL https://install.python-poetry.org | POETRY_VERSION=${{ env.POETRY_VERSION }} python - - - name: Update PATH - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - name: Configure poetry - run: poetry config virtualenvs.in-project true - - name: Install dependencies - run: poetry install --only docs - - name: Build documentation - run: make docs - - name: Delete unnecessary files - run: | - sudo find _build -name .doctrees -prune -exec rm -rf {} \; - sudo find _build -name .buildinfo -exec rm {} \; - - name: Upload HTML - uses: actions/upload-artifact@v4 - with: - name: html-build-artifact - path: _build/docs - if-no-files-found: error - retention-days: 1 - - name: Store PR information - if: github.event_name == 'pull_request' - run: | - mkdir ./pr - echo ${{ github.event.number }} > ./pr/pr.txt - echo ${{ github.event.pull_request.merged }} > ./pr/merged.txt - echo ${{ github.event.action }} > ./pr/action.txt - - name: Upload PR information - if: github.event_name == 'pull_request' - uses: actions/upload-artifact@v4 - with: - name: pr - path: pr/ + build-docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Bootstrap poetry (Linux and macOS) + run: | + curl -sSL https://install.python-poetry.org | POETRY_VERSION=${{ env.POETRY_VERSION }} python - + - name: Update PATH + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Configure poetry + run: poetry config virtualenvs.in-project true + - name: Install dependencies + run: poetry install --only docs + - name: Build documentation + run: make docs + - name: Delete unnecessary files + run: | + sudo find _build -name .doctrees -prune -exec rm -rf {} \; + sudo find _build -name .buildinfo -exec rm {} \; + - name: Upload HTML + uses: actions/upload-artifact@v4 + with: + name: html-build-artifact + path: _build/docs + if-no-files-found: error + retention-days: 1 + - name: Store PR information + if: github.event_name == 'pull_request' + run: | + mkdir ./pr + echo ${{ github.event.number }} > ./pr/pr.txt + echo ${{ github.event.pull_request.merged }} > ./pr/merged.txt + echo ${{ github.event.action }} > ./pr/action.txt + - name: Upload PR information + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: pr + path: pr/ - store-html: - if: github.event_name == 'push' && github.repository_owner == 'NVIDIA' - needs: [build-docs] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: "gh-pages" - - name: Initialize Git configuration - run: | - git config user.name docs-build - git config user.email do-not-send@github.com - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: html-build-artifact - path: ${{ github.ref_name }} - - name: Copy HTML directories - run: | - ls -asl - for i in `ls -d *` - do - echo "Git adding ${i}" - git add "${i}" - done - - name: Check or create dot-no-jekyll file - run: | - if [ -f ".nojekyll" ]; then - echo "The dot-no-jekyll file already exists." - exit 0 - fi - touch .nojekyll - git add .nojekyll - - name: Check or create redirect page - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - resp=$(grep 'http-equiv="refresh"' index.html 2>/dev/null) || true - if [ -n "${resp}" ]; then - echo "The redirect file already exists." - exit 0 - fi - # If any of these commands fail, fail the build. - def_branch=$(gh api "repos/${GITHUB_REPOSITORY}" --jq ".default_branch") - html_url=$(gh api "repos/${GITHUB_REPOSITORY}/pages" --jq ".html_url") - # Beware ugly quotation mark avoidance in the foll lines. - echo '' > index.html - echo '' >> index.html - echo ' ' >> index.html - echo ' Redirect to documentation' >> index.html - echo ' ' >> index.html - echo ' ' >> index.html - echo ' ' >> index.html - echo ' ' >> index.html - echo ' ' >> index.html - echo ' ' >> index.html - echo '

Please follow the link to the ' >> index.html - echo ${def_branch}' branch documentation.

' >> index.html - echo ' ' >> index.html - echo '' >> index.html - git add index.html - - name: Commit changes to the GitHub Pages branch - run: | - git status - if git commit -m 'Pushing changes to GitHub Pages.'; then - git push -f - else - echo "Nothing changed." - fi + store-html: + if: github.event_name == 'push' && github.repository_owner == 'NVIDIA' + needs: [build-docs] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: "gh-pages" + - name: Initialize Git configuration + run: | + git config user.name docs-build + git config user.email do-not-send@github.com + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: html-build-artifact + path: ${{ github.ref_name }} + - name: Copy HTML directories + run: | + ls -asl + for i in `ls -d *` + do + echo "Git adding ${i}" + git add "${i}" + done + - name: Check or create dot-no-jekyll file + run: | + if [ -f ".nojekyll" ]; then + echo "The dot-no-jekyll file already exists." + exit 0 + fi + touch .nojekyll + git add .nojekyll + - name: Check or create redirect page + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + resp=$(grep 'http-equiv="refresh"' index.html 2>/dev/null) || true + if [ -n "${resp}" ]; then + echo "The redirect file already exists." + exit 0 + fi + # If any of these commands fail, fail the build. + def_branch=$(gh api "repos/${GITHUB_REPOSITORY}" --jq ".default_branch") + html_url=$(gh api "repos/${GITHUB_REPOSITORY}/pages" --jq ".html_url") + # Beware ugly quotation mark avoidance in the foll lines. + echo '' > index.html + echo '' >> index.html + echo ' ' >> index.html + echo ' Redirect to documentation' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo ' ' >> index.html + echo '

Please follow the link to the ' >> index.html + echo ${def_branch}' branch documentation.

' >> index.html + echo ' ' >> index.html + echo '' >> index.html + git add index.html + - name: Commit changes to the GitHub Pages branch + run: | + git status + if git commit -m 'Pushing changes to GitHub Pages.'; then + git push -f + else + echo "Nothing changed." + fi diff --git a/.github/workflows/test-and-build-wheel.yml b/.github/workflows/test-and-build-wheel.yml index f5a3ed16d..23123ceac 100644 --- a/.github/workflows/test-and-build-wheel.yml +++ b/.github/workflows/test-and-build-wheel.yml @@ -15,7 +15,7 @@ jobs: build-wheel: runs-on: ubuntu-latest env: - POETRY_VERSION: "1.8.2" + POETRY_VERSION: "2.1.2" PYTHON_VERSION: "3.11" outputs: artifact_name: ${{ steps.set-artifact-name.outputs.artifact_name }} @@ -104,7 +104,7 @@ jobs: - name: Install Wheel run: | pip install --upgrade pip - pip install poetry==1.8.2 + pip install poetry==2.1.2 pip install ./*.whl - name: Start server in the background diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 34386d4c2..893ffd042 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ include: variables: PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.cache/pip" - POETRY_VERSION: "1.8.2" + POETRY_VERSION: "2.1.2" IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG LATEST_TAG: $CI_REGISTRY_IMAGE:latest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ce93049d..74f371c60 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -180,7 +180,7 @@ To get started quickly, follow the steps below. This will run the test suite to ensure everything is set up correctly. -> **Note**: You should use `poetry run` to run commands within the virtual environment. If you want to avoid prefixing commands with `poetry run`, you can activate the environment using `poetry shell`. This will start a new shell with the virtual environment activated, allowing you to run commands directly. +> **Note**: You should use `poetry run` to run commands within the virtual environment. If you want to avoid prefixing commands with `poetry run`, you can activate the environment using `poetry shell` or follow the docs here if you are using poetry >2 . ForThis will start a new shell with the virtual environment activated, allowing you to run commands directly. ### Contribution Workflow diff --git a/Dockerfile b/Dockerfile index aff152e3a..f924d20a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ - # syntax=docker/dockerfile:experimental # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. @@ -21,7 +20,7 @@ FROM python:3.10 RUN apt-get update && apt-get install -y git gcc g++ # Set POETRY_VERSION environment variable -ENV POETRY_VERSION=1.8.2 +ARG POETRY_VERSION=2.1.2 RUN if [ "$(uname -m)" = "x86_64" ]; then \ export ANNOY_COMPILER_ARGS="-D_CRT_SECURE_NO_WARNINGS,-DANNOYLIB_MULTITHREADED_BUILD,-march=x86-64"; \ diff --git a/pyproject.toml b/pyproject.toml index aa0d9fe6c..8737b137f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ description = "NeMo Guardrails is an open-source toolkit for easily adding progr authors = ["NVIDIA "] license = "LICENSE.md" readme = "README.md" -version = "0.13.0" +version = "0.14.0-rc1" packages = [{ include = "nemoguardrails" }] @@ -163,5 +163,5 @@ log-level = "DEBUG" log_cli = "False" [build-system] -requires = ["poetry-core>=1.0.0,<2.0.0"] +requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" diff --git a/qa/Dockerfile.qa b/qa/Dockerfile.qa index 68607e2bf..f7d0acb4e 100644 --- a/qa/Dockerfile.qa +++ b/qa/Dockerfile.qa @@ -1,4 +1,3 @@ - # syntax=docker/dockerfile:experimental # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. @@ -21,7 +20,7 @@ FROM python:3.10 RUN apt-get update && apt-get install -y git gcc g++ # Set POETRY_VERSION environment variable -ENV POETRY_VERSION=1.8.2 +ARG POETRY_VERSION=2.1.2 ENV ANNOY_COMPILER_ARGS="-D_CRT_SECURE_NO_WARNINGS,-DANNOYLIB_MULTITHREADED_BUILD,-march=x86-64"