From 55c95bd31b37b68bb06163dc831810ed3c039048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Mart=C3=ADn=20Bl=C3=A1zquez?= Date: Wed, 16 Oct 2024 09:10:58 +0200 Subject: [PATCH 1/2] Fix not handling list of all primitive types in `SignatureMixin` (#1037) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- examples/arena_hard.py | 3 ++- examples/deepseek_prover.py | 7 ++++--- examples/structured_generation_with_instructor.py | 3 ++- examples/structured_generation_with_outlines.py | 5 +++-- src/distilabel/__init__.py | 2 +- src/distilabel/mixins/signature.py | 4 ++-- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/arena_hard.py b/examples/arena_hard.py index 4f6f0c05ca..b193bc2347 100644 --- a/examples/arena_hard.py +++ b/examples/arena_hard.py @@ -15,11 +15,12 @@ import re from typing import Any, Dict, List, Optional, Union +from typing_extensions import override + from distilabel.steps import GlobalStep, StepInput from distilabel.steps.tasks.base import Task from distilabel.steps.tasks.typing import ChatType from distilabel.steps.typing import StepOutput -from typing_extensions import override class ArenaHard(Task): diff --git a/examples/deepseek_prover.py b/examples/deepseek_prover.py index b61f1c6836..07b0509646 100644 --- a/examples/deepseek_prover.py +++ b/examples/deepseek_prover.py @@ -17,14 +17,15 @@ from textwrap import dedent from typing import Any, Dict, List, Optional, Union +from jinja2 import Template +from pydantic import PrivateAttr +from typing_extensions import override + from distilabel.llms import InferenceEndpointsLLM from distilabel.pipeline import Pipeline from distilabel.steps import LoadDataFromHub from distilabel.steps.tasks.base import Task from distilabel.steps.tasks.typing import ChatType -from jinja2 import Template -from pydantic import PrivateAttr -from typing_extensions import override _PARSE_DEEPSEEK_PROVER_AUTOFORMAL_REGEX = r"```lean4(.*?)```" diff --git a/examples/structured_generation_with_instructor.py b/examples/structured_generation_with_instructor.py index 48082886f4..0808e56cac 100644 --- a/examples/structured_generation_with_instructor.py +++ b/examples/structured_generation_with_instructor.py @@ -14,11 +14,12 @@ from typing import List +from pydantic import BaseModel, Field + from distilabel.llms import MistralLLM from distilabel.pipeline import Pipeline from distilabel.steps import LoadDataFromDicts from distilabel.steps.tasks import TextGeneration -from pydantic import BaseModel, Field class Node(BaseModel): diff --git a/examples/structured_generation_with_outlines.py b/examples/structured_generation_with_outlines.py index 98ee59ed6e..b92cb6082f 100644 --- a/examples/structured_generation_with_outlines.py +++ b/examples/structured_generation_with_outlines.py @@ -15,12 +15,13 @@ from enum import Enum from pathlib import Path +from pydantic import BaseModel, StringConstraints, conint +from typing_extensions import Annotated + from distilabel.llms import LlamaCppLLM from distilabel.pipeline import Pipeline from distilabel.steps import LoadDataFromDicts from distilabel.steps.tasks import TextGeneration -from pydantic import BaseModel, StringConstraints, conint -from typing_extensions import Annotated class Weapon(str, Enum): diff --git a/src/distilabel/__init__.py b/src/distilabel/__init__.py index bafff914bf..f6ca72cd10 100644 --- a/src/distilabel/__init__.py +++ b/src/distilabel/__init__.py @@ -14,6 +14,6 @@ from rich import traceback as rich_traceback -__version__ = "1.4.0" +__version__ = "1.4.1" rich_traceback.install(show_locals=True) diff --git a/src/distilabel/mixins/signature.py b/src/distilabel/mixins/signature.py index b014f03e90..34ec873bd3 100644 --- a/src/distilabel/mixins/signature.py +++ b/src/distilabel/mixins/signature.py @@ -67,8 +67,8 @@ def flatten_dump(d: Any, parent_key: str = "", sep: str = "_") -> List: elif isinstance(v, list): if len(v) == 0: items.append((new_key, "")) - elif isinstance(v[0], str): - items.append((new_key, "-".join(v))) + elif isinstance(v[0], (str, float, int, bool)): + items.append((new_key, "-".join(map(str, v)))) else: for i, x in enumerate(v): items.extend(flatten_dump(x, f"{new_key}-{i}", sep=sep)) From 844165f25c1674076a8286d54cfe96d52c33a24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Mart=C3=ADn=20Bl=C3=A1zquez?= Date: Thu, 10 Oct 2024 15:57:17 +0200 Subject: [PATCH 2/2] Update `docs` workflows to use `uv` (#1032) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/codspeed.yml | 8 ++++---- .github/workflows/docs-pr-close.yml | 6 +++--- .github/workflows/docs-pr.yml | 12 ++++-------- .github/workflows/docs.yml | 12 ++++-------- scripts/install_docs_dependencies.sh | 9 +++++++++ 5 files changed, 24 insertions(+), 23 deletions(-) create mode 100755 scripts/install_docs_dependencies.sh diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index 12830c9d5d..ba6baa1ea2 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -13,12 +13,12 @@ concurrency: jobs: benchmarks: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.12" # Looks like it's not working very well for other people: @@ -26,7 +26,7 @@ jobs: # cache: "pip" # cache-dependency-path: pyproject.toml - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: cache with: path: ${{ env.pythonLocation }} @@ -37,7 +37,7 @@ jobs: run: ./scripts/install_dependencies.sh - name: Run benchmarks - uses: CodSpeedHQ/action@v2 + uses: CodSpeedHQ/action@v3 with: token: ${{ secrets.CODSPEED_TOKEN }} run: pytest tests/ --codspeed diff --git a/.github/workflows/docs-pr-close.yml b/.github/workflows/docs-pr-close.yml index 4f9a307b8a..71f4e5ff93 100644 --- a/.github/workflows/docs-pr-close.yml +++ b/.github/workflows/docs-pr-close.yml @@ -19,12 +19,12 @@ jobs: fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: "3.11" - name: Install dependencies - run: pip install -e .[docs] + run: ./scripts/install_docs_dependencies.sh - name: Set git credentials run: | diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index 306af85ea4..48c7236a58 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -22,15 +22,11 @@ jobs: - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} - # Looks like it's not working very well for other people: - # https://github.com/actions/setup-python/issues/436 - # cache: "pip" - # cache-dependency-path: pyproject.toml + python-version: "3.11" - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: cache with: path: ${{ env.pythonLocation }} @@ -38,7 +34,7 @@ jobs: - name: Install dependencies if: steps.cache.outputs.cache-hit != 'true' - run: pip install -e .[docs] + run: ./scripts/install_docs_dependencies.sh - name: Set git credentials run: | diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 374bd7ed4d..dd59a5129d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,15 +24,11 @@ jobs: - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} - # Looks like it's not working very well for other people: - # https://github.com/actions/setup-python/issues/436 - # cache: "pip" - # cache-dependency-path: pyproject.toml + python-version: "3.11" - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: cache with: path: ${{ env.pythonLocation }} @@ -40,7 +36,7 @@ jobs: - name: Install dependencies if: steps.cache.outputs.cache-hit != 'true' - run: pip install -e .[docs] + run: ./scripts/install_docs_dependencies.sh - name: Check no warnings run: mkdocs build --strict diff --git a/scripts/install_docs_dependencies.sh b/scripts/install_docs_dependencies.sh new file mode 100755 index 0000000000..c768b2295c --- /dev/null +++ b/scripts/install_docs_dependencies.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +python_version=$(python -c "import sys; print(sys.version_info[:2])") + +python -m pip install uv + +uv pip install --system -e ".[docs]"