From f569e8d4985526453e2fdda7a3de2f6858cf028a Mon Sep 17 00:00:00 2001 From: Paco Aranda Date: Fri, 14 Jun 2024 14:30:14 +0200 Subject: [PATCH] [CHORE] Review and fix commit hooks (#5027) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description Review and improve the pre-commit hooks configuration. **Type of change** (Please delete options that are not relevant. Remember to title the PR according to the type of change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Refactor (change restructuring the codebase without changing functionality) - [ ] Improvement (change adding some improvement to an existing functionality) **How Has This Been Tested** (Please describe the tests that you ran to verify your changes. And ideally, reference `tests`) - [ ] Test A - [ ] Test B **Checklist** - [ ] I added relevant documentation - [ ] I followed the style guidelines of this project - [ ] I did a self-review of my code - [ ] I made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK) (see text above) - [ ] I have added relevant notes to the `CHANGELOG.md` file (See https://keepachangelog.com/) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../actions/generate-credentials/app/main.py | 4 +- .../slack-post-credentials/app/main.py | 16 +++-- .pre-commit-config.yaml | 58 ++++++++++++++----- argilla-server/.pre-commit-config.yaml | 47 --------------- LICENSE => argilla-server/LICENSE | 0 .../LICENSE_HEADER | 0 argilla-server/src/argilla_server/_app.py | 1 - .../src/argilla_server/alembic/env.py | 2 +- ...913727_fix_suggestions_type_enum_values.py | 1 - .../api/handlers/v1/datasets/datasets.py | 5 +- .../api/handlers/v1/datasets/records.py | 1 - .../argilla_server/api/handlers/v1/fields.py | 2 +- .../api/handlers/v1/metadata_properties.py | 2 +- .../argilla_server/api/handlers/v1/oauth2.py | 2 +- .../api/handlers/v1/questions.py | 2 +- .../argilla_server/api/handlers/v1/records.py | 3 +- .../api/handlers/v1/responses.py | 2 +- .../api/handlers/v1/suggestions.py | 2 +- .../argilla_server/api/handlers/v1/users.py | 2 - .../api/handlers/v1/vectors_settings.py | 2 +- .../api/handlers/v1/workspaces.py | 2 +- .../argilla_server/api/policies/v1/commons.py | 3 +- .../api/schemas/v1/metadata_properties.py | 2 +- .../api/schemas/v1/questions.py | 2 +- .../argilla_server/api/schemas/v1/settings.py | 2 +- .../api/schemas/v1/suggestions.py | 2 +- .../src/argilla_server/bulk/records_bulk.py | 5 -- argilla-server/src/argilla_server/cli/rich.py | 2 +- .../cli/search_engine/reindex.py | 2 +- .../src/argilla_server/contexts/accounts.py | 2 +- .../src/argilla_server/contexts/datasets.py | 4 +- .../src/argilla_server/contexts/questions.py | 6 +- .../src/argilla_server/contexts/records.py | 8 +-- .../src/argilla_server/contexts/settings.py | 2 +- .../src/argilla_server/errors/__init__.py | 2 +- argilla-server/src/argilla_server/helpers.py | 1 - .../src/argilla_server/models/__init__.py | 6 +- .../argilla_server/search_engine/__init__.py | 3 +- .../argilla_server/search_engine/commons.py | 2 +- .../src/argilla_server/security/settings.py | 2 +- argilla-server/src/argilla_server/utils.py | 2 +- .../validators/response_values.py | 2 +- .../argilla_server/validators/responses.py | 2 +- .../v1/authentication/test_create_token.py | 1 - .../records_bulk/test_dataset_records_bulk.py | 1 - ...est_dataset_records_bulk_with_responses.py | 6 +- ...t_dataset_records_bulk_with_suggestions.py | 9 ++- .../test_dataset_records_bulk_with_vectors.py | 1 - .../records/test_update_dataset_records.py | 4 +- .../v1/questions/test_update_question.py | 2 - .../v1/records/test_create_record_response.py | 2 +- .../v1/records/test_upsert_suggestion.py | 2 +- ...test_create_current_user_responses_bulk.py | 2 +- .../handlers/v1/test_metadata_properties.py | 1 - .../unit/api/handlers/v1/test_records.py | 2 +- .../tests/unit/api/handlers/v1/test_users.py | 2 +- .../api/handlers/v1/users/test_create_user.py | 1 - .../api/handlers/v1/users/test_delete_user.py | 1 - .../tests/unit/cli/search_engine/conftest.py | 1 - .../tests/unit/search_engine/test_commons.py | 2 +- .../unit/search_engine/test_elastisearch.py | 3 +- .../unit/search_engine/test_opensearch.py | 2 +- .../tests/unit/security/test_model.py | 3 +- .../unit/validators/test_records_bulk.py | 1 - .../src/argilla_v1/cli/training/__main__.py | 1 - .../src/argilla_v1/cli/workspaces/add_user.py | 1 - .../src/argilla_v1/cli/workspaces/create.py | 2 +- .../argilla_v1/client/feedback/constants.py | 4 +- .../client/feedback/schemas/metadata.py | 1 - .../client/feedback/schemas/responses.py | 3 +- .../src/argilla_v1/client/sdk/client.py | 1 - .../src/argilla_v1/client/sdk/commons/api.py | 4 +- .../src/argilla_v1/client/sdk/datasets/api.py | 2 +- .../client/sdk/text_classification/api.py | 4 +- .../client/sdk/v1/vectors_settings/api.py | 2 +- argilla-v1/src/argilla_v1/client/users.py | 2 +- .../src/argilla_v1/client/workspaces.py | 2 +- .../text_classification/label_errors.py | 1 - .../labeling/text_classification/rule.py | 1 - argilla-v1/src/argilla_v1/utils/telemetry.py | 6 +- argilla-v1/src/argilla_v1/utils/utils.py | 1 - .../integration/client/feedback/conftest.py | 5 +- .../feedback/dataset/remote/test_dataset.py | 2 +- .../remote/test_working_with_vectors.py | 2 +- .../feedback/schemas/remote/test_metadata.py | 2 +- .../client/sdk/api/test_commons.py | 6 +- .../tests/integration/client/sdk/conftest.py | 2 - .../client/sdk/v1/test_datasets.py | 4 -- .../integration/client/sdk/v1/test_records.py | 8 +-- .../integration/client/test_client_errors.py | 2 - .../client/test_scan_raw_records.py | 1 - .../labeling/text_classification/test_rule.py | 2 +- .../integration/listeners/test_listener.py | 1 - .../metrics/test_common_metrics.py | 1 - .../metrics/test_text_classification.py | 1 - .../metrics/test_token_classification.py | 1 - .../test_log_for_token_classification.py | 1 - .../tests/unit/cli/users/test_delete.py | 2 +- argilla-v1/tests/unit/cli/users/test_list.py | 3 - .../tests/unit/cli/workspaces/test_create.py | 3 - .../feedback/dataset/remote/test_dataset.py | 1 - .../client/feedback/schemas/test_responses.py | 3 - .../feedback/schemas/test_suggestions.py | 2 +- .../client/feedback/utils/test_assignment.py | 1 - .../client/feedback/utils/test_html_utils.py | 2 - .../unit/client/sdk/v1/test_search_records.py | 2 +- .../tests/unit/utils/test_dependency.py | 2 +- argilla/.pre-commit-config.yaml | 36 ------------ argilla/README.md | 4 +- argilla/docs/how_to_guides/record.md | 2 +- .../argilla/datasets/dataset_records.md | 32 +++++----- .../docs/reference/argilla/records/records.md | 2 +- argilla/mkdocs.yml | 37 ++++++------ .../src/argilla/_models/_record/__init__.py | 1 - .../src/argilla/_models/_settings/__init__.py | 1 - argilla/src/argilla/records/_search.py | 4 +- argilla/src/argilla/responses.py | 6 +- argilla/src/argilla/settings/_question.py | 16 ++--- docs/_source/conf.py | 16 ++--- 119 files changed, 196 insertions(+), 330 deletions(-) delete mode 100644 argilla-server/.pre-commit-config.yaml rename LICENSE => argilla-server/LICENSE (100%) rename license_header.txt => argilla-server/LICENSE_HEADER (100%) delete mode 100644 argilla/.pre-commit-config.yaml diff --git a/.github/actions/generate-credentials/app/main.py b/.github/actions/generate-credentials/app/main.py index cad56b4f4b..e3bacb355c 100644 --- a/.github/actions/generate-credentials/app/main.py +++ b/.github/actions/generate-credentials/app/main.py @@ -33,7 +33,9 @@ def generate_credentials() -> Dict[str, Any]: credentials = {} for user in ["owner", "admin", "annotator"]: logging.info(f"Generating random credential for user '{user}'") - password = generate_password_from_secret(secret=SECRET, salt=f"{GITHUB_REF}/{user}", length=32) + password = generate_password_from_secret( + secret=SECRET, salt=f"{GITHUB_REF}/{user}", length=32 + ) credentials[user] = password return credentials diff --git a/.github/actions/slack-post-credentials/app/main.py b/.github/actions/slack-post-credentials/app/main.py index 806eeea609..7665dc9759 100644 --- a/.github/actions/slack-post-credentials/app/main.py +++ b/.github/actions/slack-post-credentials/app/main.py @@ -74,7 +74,9 @@ def get_slack_channel_id(client: WebClient) -> Union[str, None]: for channel in result["channels"]: if channel["name"] == SLACK_CHANNEL_NAME: channel_id = channel["id"] - logging.info(f"Found channel id for '{SLACK_CHANNEL_NAME}' channel: '{channel_id}'") + logging.info( + f"Found channel id for '{SLACK_CHANNEL_NAME}' channel: '{channel_id}'" + ) return channel_id @@ -87,7 +89,9 @@ def get_pr_url(pr_number: int) -> str: return f"https://github.com/argilla-io/argilla/pull/{pr_number}" -def get_thread_ts_pr_message(client: WebClient, channel_id: str, pr_number: int) -> Union[str, None]: +def get_thread_ts_pr_message( + client: WebClient, channel_id: str, pr_number: int +) -> Union[str, None]: response = client.conversations_history(channel=channel_id, limit=1000) response.validate() @@ -119,7 +123,9 @@ def bot_already_replied(client: WebClient, channel_id: str, thread_ts: str) -> b return False -def reply_thread_with_credentials(client: WebClient, channel_id: str, thread_ts: str) -> None: +def reply_thread_with_credentials( + client: WebClient, channel_id: str, thread_ts: str +) -> None: client.chat_postMessage( channel=channel_id, text=f"Credentials for PR deployed environment (use as password and API key):\n- URL: {URL}\n- owner: '{OWNER}'\n- admin: '{ADMIN}'\n- annotator: '{ANNOTATOR}'", @@ -153,7 +159,9 @@ def reply_thread_with_credentials(client: WebClient, channel_id: str, thread_ts: pr_number = get_pull_request_number() if pr_number is None: logging.error(f"Could not parse `GITHUB_REF` ({GITHUB_REF}) to get PR number") - raise ValueError(f"Could not parse `GITHUB_REF` ({GITHUB_REF}) to get PR number") + raise ValueError( + f"Could not parse `GITHUB_REF` ({GITHUB_REF}) to get PR number" + ) client = get_slack_client() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b621526819..9e8df894e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,32 +1,43 @@ repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + exclude_types: [text, jupyter] + - id: trailing-whitespace + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.1.4 + hooks: + - id: ruff-format + ############################################################################## # argilla specific hooks ############################################################################## + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.1.4 + hooks: + - id: ruff + files: 'argilla/src/.*\.py$' + args: + - --fix - repo: https://github.com/Lucas-C/pre-commit-hooks rev: v1.5.4 hooks: - id: insert-license name: "Insert license header in Python source files" - files: '^argilla-sdk/.*\.py$' - exclude: ^argilla-sdk/docs/snippets/ + files: '^argilla/.*\.py$' + exclude: ^argilla/docs/snippets/ args: - --license-filepath - - argilla-sdk/LICENSE_HEADER + - argilla/LICENSE_HEADER - --fuzzy-match-generates-todo - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.4 - hooks: - - id: ruff - files: '^argilla-sdk/.*\.py$' - args: - - --fix - - id: ruff-format - files: '^argilla-sdk/.*\.py$' - repo: https://github.com/kynan/nbstripout rev: 0.7.1 hooks: - id: nbstripout - files: '^argilla-sdk/.*\.ipynb$' + files: '^argilla/.*\.ipynb$' args: - --keep-count - --keep-output @@ -37,6 +48,27 @@ repos: # - --keep-execution-count # - --keep-metadata # - --keep-version + ############################################################################## + # argilla-server specific hooks + ############################################################################## + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.1.4 + hooks: + - id: ruff + files: 'argila-server/src/.*\.py$' + args: + - --fix + + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: insert-license + name: "Insert license header in Python source files" + files: '^argilla-server/.*\.py$' + args: + - --license-filepath + - argilla-server/LICENSE_HEADER + - --fuzzy-match-generates-todo ci: autofix_commit_msg: | diff --git a/argilla-server/.pre-commit-config.yaml b/argilla-server/.pre-commit-config.yaml deleted file mode 100644 index d8898694ec..0000000000 --- a/argilla-server/.pre-commit-config.yaml +++ /dev/null @@ -1,47 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 - hooks: - - id: check-yaml - - id: end-of-file-fixer - exclude_types: [text, jupyter] - - id: trailing-whitespace - - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.5 - hooks: - - id: insert-license - name: "Insert license header in Python source files" - files: \.py$ - args: - - --license-filepath - - license_header.txt - - --fuzzy-match-generates-todo - # - --remove-header - - - repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black - additional_dependencies: ["typer==0.7.0"] - args: [--line-length=120] - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.3 - hooks: - # Simulate isort via (the much faster) ruff - - id: ruff - args: - - --select=I - - --fix - -ci: - autofix_commit_msg: | - [pre-commit.ci] auto fixes from pre-commit.com hooks - for more information, see https://pre-commit.ci - autofix_prs: true - autoupdate_branch: "" - autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" - autoupdate_schedule: weekly - skip: [] - submodules: false diff --git a/LICENSE b/argilla-server/LICENSE similarity index 100% rename from LICENSE rename to argilla-server/LICENSE diff --git a/license_header.txt b/argilla-server/LICENSE_HEADER similarity index 100% rename from license_header.txt rename to argilla-server/LICENSE_HEADER diff --git a/argilla-server/src/argilla_server/_app.py b/argilla-server/src/argilla_server/_app.py index 5a58596096..f0184003ab 100644 --- a/argilla-server/src/argilla_server/_app.py +++ b/argilla-server/src/argilla_server/_app.py @@ -35,7 +35,6 @@ from argilla_server.database import get_async_db from argilla_server.logging import configure_logging from argilla_server.models import User -from argilla_server.pydantic_v1.errors import ConfigError from argilla_server.search_engine import get_search_engine from argilla_server.security import auth from argilla_server.settings import settings diff --git a/argilla-server/src/argilla_server/alembic/env.py b/argilla-server/src/argilla_server/alembic/env.py index 2716507f04..2329429173 100644 --- a/argilla-server/src/argilla_server/alembic/env.py +++ b/argilla-server/src/argilla_server/alembic/env.py @@ -17,7 +17,7 @@ from alembic import context from argilla_server.database import database_url_sync from argilla_server.models.base import DatabaseModel -from argilla_server.models.database import * # noqa: I001 +from argilla_server.models.database import * # noqa from sqlalchemy import engine_from_config, pool # this is the Alembic Config object, which provides diff --git a/argilla-server/src/argilla_server/alembic/versions/1e629a913727_fix_suggestions_type_enum_values.py b/argilla-server/src/argilla_server/alembic/versions/1e629a913727_fix_suggestions_type_enum_values.py index c5b55b2300..b9706106ea 100644 --- a/argilla-server/src/argilla_server/alembic/versions/1e629a913727_fix_suggestions_type_enum_values.py +++ b/argilla-server/src/argilla_server/alembic/versions/1e629a913727_fix_suggestions_type_enum_values.py @@ -19,7 +19,6 @@ Create Date: 2023-07-24 12:47:11.715011 """ -import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. diff --git a/argilla-server/src/argilla_server/api/handlers/v1/datasets/datasets.py b/argilla-server/src/argilla_server/api/handlers/v1/datasets/datasets.py index d1b1a4ce8f..63f95391e1 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/datasets/datasets.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/datasets/datasets.py @@ -19,7 +19,6 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import selectinload -from argilla_server import models from argilla_server.api.policies.v1 import DatasetPolicy, MetadataPropertyPolicy, authorize, is_authorized from argilla_server.api.schemas.v1.datasets import ( Dataset as DatasetSchema, @@ -38,10 +37,10 @@ MetadataPropertyCreate, ) from argilla_server.api.schemas.v1.vector_settings import VectorSettings, VectorSettingsCreate, VectorsSettings -from argilla_server.contexts import accounts, datasets +from argilla_server.contexts import datasets from argilla_server.database import get_async_db from argilla_server.enums import ResponseStatus -from argilla_server.models import Dataset, User, Workspace +from argilla_server.models import Dataset, User from argilla_server.search_engine import ( SearchEngine, get_search_engine, diff --git a/argilla-server/src/argilla_server/api/handlers/v1/datasets/records.py b/argilla-server/src/argilla_server/api/handlers/v1/datasets/records.py index f8560b362e..e032aa7037 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/datasets/records.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/datasets/records.py @@ -23,7 +23,6 @@ import argilla_server.search_engine as search_engine from argilla_server.api.policies.v1 import DatasetPolicy, RecordPolicy, authorize, is_authorized -from argilla_server.api.schemas.v1.datasets import Dataset as DatasetSchema from argilla_server.api.schemas.v1.records import ( Filters, FilterScope, diff --git a/argilla-server/src/argilla_server/api/handlers/v1/fields.py b/argilla-server/src/argilla_server/api/handlers/v1/fields.py index 87f983f255..a62c7dbcde 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/fields.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/fields.py @@ -14,7 +14,7 @@ from uuid import UUID -from fastapi import APIRouter, Depends, Security, status +from fastapi import APIRouter, Depends, Security from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import selectinload diff --git a/argilla-server/src/argilla_server/api/handlers/v1/metadata_properties.py b/argilla-server/src/argilla_server/api/handlers/v1/metadata_properties.py index 2034505df2..ae0392bfb0 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/metadata_properties.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/metadata_properties.py @@ -14,7 +14,7 @@ from uuid import UUID -from fastapi import APIRouter, Depends, Security, status +from fastapi import APIRouter, Depends, Security from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import selectinload diff --git a/argilla-server/src/argilla_server/api/handlers/v1/oauth2.py b/argilla-server/src/argilla_server/api/handlers/v1/oauth2.py index fd6b30bb24..96f5912492 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/oauth2.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/oauth2.py @@ -92,7 +92,7 @@ def _check_oauth_enabled_or_raise() -> None: def _get_provider_by_name_or_raise(provider_name: str) -> OAuth2ClientProvider: - if not provider_name in settings.oauth.providers: + if provider_name not in settings.oauth.providers: raise HTTPException(status_code=404, detail=f"Provider '{provider_name}' not found") return settings.oauth.providers[provider_name] diff --git a/argilla-server/src/argilla_server/api/handlers/v1/questions.py b/argilla-server/src/argilla_server/api/handlers/v1/questions.py index b5dd662f23..27d8cedf85 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/questions.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/questions.py @@ -14,7 +14,7 @@ from uuid import UUID -from fastapi import APIRouter, Depends, Security, status +from fastapi import APIRouter, Depends, Security from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import selectinload diff --git a/argilla-server/src/argilla_server/api/handlers/v1/records.py b/argilla-server/src/argilla_server/api/handlers/v1/records.py index a47ef4632b..3778921ee2 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/records.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/records.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING from uuid import UUID from fastapi import APIRouter, Depends, Query, Security, status @@ -26,7 +25,7 @@ from argilla_server.api.schemas.v1.responses import Response, ResponseCreate from argilla_server.api.schemas.v1.suggestions import Suggestion as SuggestionSchema from argilla_server.api.schemas.v1.suggestions import SuggestionCreate, Suggestions -from argilla_server.contexts import datasets, questions +from argilla_server.contexts import datasets from argilla_server.database import get_async_db from argilla_server.errors.future.base_errors import NotFoundError, UnprocessableEntityError from argilla_server.models import Dataset, Question, Record, Suggestion, User diff --git a/argilla-server/src/argilla_server/api/handlers/v1/responses.py b/argilla-server/src/argilla_server/api/handlers/v1/responses.py index 58a6222a00..56cb695c95 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/responses.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/responses.py @@ -14,7 +14,7 @@ from uuid import UUID -from fastapi import APIRouter, Depends, Security, status +from fastapi import APIRouter, Depends, Security from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import selectinload diff --git a/argilla-server/src/argilla_server/api/handlers/v1/suggestions.py b/argilla-server/src/argilla_server/api/handlers/v1/suggestions.py index 2c700aab75..1257545749 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/suggestions.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/suggestions.py @@ -14,7 +14,7 @@ from uuid import UUID -from fastapi import APIRouter, Depends, Security, status +from fastapi import APIRouter, Depends, Security from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import selectinload diff --git a/argilla-server/src/argilla_server/api/handlers/v1/users.py b/argilla-server/src/argilla_server/api/handlers/v1/users.py index 3e40816393..98d4ffcd3d 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/users.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/users.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import List from uuid import UUID from fastapi import APIRouter, Depends, Request, Security, status @@ -25,7 +24,6 @@ from argilla_server.api.schemas.v1.workspaces import Workspaces from argilla_server.contexts import accounts from argilla_server.database import get_async_db -from argilla_server.errors.future import NotUniqueError from argilla_server.models import User from argilla_server.security import auth diff --git a/argilla-server/src/argilla_server/api/handlers/v1/vectors_settings.py b/argilla-server/src/argilla_server/api/handlers/v1/vectors_settings.py index 115ca4935b..511e9a5b99 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/vectors_settings.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/vectors_settings.py @@ -14,7 +14,7 @@ from uuid import UUID -from fastapi import APIRouter, Depends, Security, status +from fastapi import APIRouter, Depends, Security from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import selectinload diff --git a/argilla-server/src/argilla_server/api/handlers/v1/workspaces.py b/argilla-server/src/argilla_server/api/handlers/v1/workspaces.py index 48f1c70319..1636998ea4 100644 --- a/argilla-server/src/argilla_server/api/handlers/v1/workspaces.py +++ b/argilla-server/src/argilla_server/api/handlers/v1/workspaces.py @@ -28,7 +28,7 @@ Workspaces, WorkspaceUserCreate, ) -from argilla_server.contexts import accounts, datasets +from argilla_server.contexts import accounts from argilla_server.database import get_async_db from argilla_server.errors.future import NotFoundError, UnprocessableEntityError from argilla_server.models import User, Workspace, WorkspaceUser diff --git a/argilla-server/src/argilla_server/api/policies/v1/commons.py b/argilla-server/src/argilla_server/api/policies/v1/commons.py index 6d87b058c1..d9326c7fc2 100644 --- a/argilla-server/src/argilla_server/api/policies/v1/commons.py +++ b/argilla-server/src/argilla_server/api/policies/v1/commons.py @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Awaitable, Callable, Optional -from uuid import UUID +from typing import Awaitable, Callable from argilla_server.errors import ForbiddenOperationError from argilla_server.models import User diff --git a/argilla-server/src/argilla_server/api/schemas/v1/metadata_properties.py b/argilla-server/src/argilla_server/api/schemas/v1/metadata_properties.py index 60ae6a063e..da8265f95a 100644 --- a/argilla-server/src/argilla_server/api/schemas/v1/metadata_properties.py +++ b/argilla-server/src/argilla_server/api/schemas/v1/metadata_properties.py @@ -13,7 +13,7 @@ # limitations under the License. from datetime import datetime -from typing import Annotated, Any, Dict, Generic, List, Literal, Optional, TypeVar, Union +from typing import Any, Dict, Generic, List, Literal, Optional, TypeVar, Union from uuid import UUID from argilla_server.api.schemas.v1.commons import UpdateSchema diff --git a/argilla-server/src/argilla_server/api/schemas/v1/questions.py b/argilla-server/src/argilla_server/api/schemas/v1/questions.py index 022bde0337..93106e7730 100644 --- a/argilla-server/src/argilla_server/api/schemas/v1/questions.py +++ b/argilla-server/src/argilla_server/api/schemas/v1/questions.py @@ -19,7 +19,7 @@ from argilla_server.api.schemas.v1.commons import UpdateSchema from argilla_server.api.schemas.v1.fields import FieldName from argilla_server.enums import OptionsOrder, QuestionType -from argilla_server.pydantic_v1 import BaseModel, Field, conlist, constr, root_validator, validator +from argilla_server.pydantic_v1 import BaseModel, Field, conlist, constr, root_validator from argilla_server.settings import settings try: diff --git a/argilla-server/src/argilla_server/api/schemas/v1/settings.py b/argilla-server/src/argilla_server/api/schemas/v1/settings.py index 89bad9bfeb..62df486aef 100644 --- a/argilla-server/src/argilla_server/api/schemas/v1/settings.py +++ b/argilla-server/src/argilla_server/api/schemas/v1/settings.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Dict, Optional +from typing import Optional from argilla_server.pydantic_v1 import BaseModel, BaseSettings, Field diff --git a/argilla-server/src/argilla_server/api/schemas/v1/suggestions.py b/argilla-server/src/argilla_server/api/schemas/v1/suggestions.py index 370c3702d2..9a98d6536b 100644 --- a/argilla-server/src/argilla_server/api/schemas/v1/suggestions.py +++ b/argilla-server/src/argilla_server/api/schemas/v1/suggestions.py @@ -13,7 +13,7 @@ # limitations under the License. from datetime import datetime -from typing import Annotated, Any, Dict, List, Literal, Optional, Union +from typing import Any, List, Literal, Optional, Union from uuid import UUID from argilla_server.api.schemas.v1.questions import QuestionName diff --git a/argilla-server/src/argilla_server/bulk/records_bulk.py b/argilla-server/src/argilla_server/bulk/records_bulk.py index 1a310a8e24..1719b124e4 100644 --- a/argilla-server/src/argilla_server/bulk/records_bulk.py +++ b/argilla-server/src/argilla_server/bulk/records_bulk.py @@ -74,7 +74,6 @@ async def create_records_bulk(self, dataset: Dataset, bulk_create: RecordsBulkCr return RecordsBulk(items=records) async def _upsert_records_relationships(self, records: List[Record], records_create: List[RecordCreate]) -> None: - records_and_suggestions = list(zip(records, [r.suggestions for r in records_create])) records_and_responses = list(zip(records, [r.responses for r in records_create])) records_and_vectors = list(zip(records, [r.vectors for r in records_create])) @@ -88,7 +87,6 @@ async def _upsert_records_relationships(self, records: List[Record], records_cre async def _upsert_records_suggestions( self, records_and_suggestions: List[Tuple[Record, List[SuggestionCreate]]] ) -> List[Suggestion]: - upsert_many_suggestions = [] for idx, (record, suggestions) in enumerate(records_and_suggestions): try: @@ -121,7 +119,6 @@ async def _upsert_records_suggestions( async def _upsert_records_responses( self, records_and_responses: List[Tuple[Record, List[UserResponseCreate]]] ) -> List[Response]: - user_ids = [response.user_id for _, responses in records_and_responses for response in responses or []] users_by_id = await fetch_users_by_ids_as_dict(self._db, user_ids) @@ -152,7 +149,6 @@ async def _upsert_records_responses( async def _upsert_records_vectors( self, records_and_vectors: List[Tuple[Record, Dict[str, List[float]]]] ) -> List[Vector]: - upsert_many_vectors = [] for idx, (record, vectors) in enumerate(records_and_vectors): try: @@ -225,7 +221,6 @@ async def _fetch_existing_dataset_records( dataset: Dataset, records_upsert: List[RecordUpsert], ) -> Dict[Union[str, UUID], Record]: - records_by_external_id = await fetch_records_by_external_ids_as_dict( self._db, dataset, [r.external_id for r in records_upsert] ) diff --git a/argilla-server/src/argilla_server/cli/rich.py b/argilla-server/src/argilla_server/cli/rich.py index 9c30a07ae3..aff4be5434 100644 --- a/argilla-server/src/argilla_server/cli/rich.py +++ b/argilla-server/src/argilla_server/cli/rich.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING, Any +from typing import Any from rich.console import Console, RenderableType from rich.panel import Panel diff --git a/argilla-server/src/argilla_server/cli/search_engine/reindex.py b/argilla-server/src/argilla_server/cli/search_engine/reindex.py index eb26548387..76e4395557 100644 --- a/argilla-server/src/argilla_server/cli/search_engine/reindex.py +++ b/argilla-server/src/argilla_server/cli/search_engine/reindex.py @@ -124,7 +124,7 @@ async def _reindex_dataset(db: AsyncSession, search_engine: SearchEngine, progre async def _reindex_datasets(db: AsyncSession, search_engine: SearchEngine, progress: Progress) -> None: - task = progress.add_task(f"reindexing feedback datasets...", total=await Reindexer.count_datasets(db)) + task = progress.add_task("reindexing feedback datasets...", total=await Reindexer.count_datasets(db)) async for dataset in Reindexer.reindex_datasets(db, search_engine): await _reindex_dataset_records(db, search_engine, progress, dataset) diff --git a/argilla-server/src/argilla_server/contexts/accounts.py b/argilla-server/src/argilla_server/contexts/accounts.py index 3fedcdbf93..21fe752082 100644 --- a/argilla-server/src/argilla_server/contexts/accounts.py +++ b/argilla-server/src/argilla_server/contexts/accounts.py @@ -18,7 +18,7 @@ from passlib.context import CryptContext from sqlalchemy import exists, select from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.orm import Session, selectinload +from sqlalchemy.orm import selectinload from argilla_server.contexts import datasets from argilla_server.enums import UserRole diff --git a/argilla-server/src/argilla_server/contexts/datasets.py b/argilla-server/src/argilla_server/contexts/datasets.py index 2dbc62a717..34468c2b18 100644 --- a/argilla-server/src/argilla_server/contexts/datasets.py +++ b/argilla-server/src/argilla_server/contexts/datasets.py @@ -63,9 +63,9 @@ VectorSettingsCreate, ) from argilla_server.api.schemas.v1.vectors import Vector as VectorSchema -from argilla_server.contexts import accounts, questions +from argilla_server.contexts import accounts from argilla_server.enums import DatasetStatus, RecordInclude, UserRole -from argilla_server.errors.future import NotFoundError, NotUniqueError, UnprocessableEntityError +from argilla_server.errors.future import NotUniqueError, UnprocessableEntityError from argilla_server.models import ( Dataset, Field, diff --git a/argilla-server/src/argilla_server/contexts/questions.py b/argilla-server/src/argilla_server/contexts/questions.py index a7cc0dfd68..fe05acc038 100644 --- a/argilla-server/src/argilla_server/contexts/questions.py +++ b/argilla-server/src/argilla_server/contexts/questions.py @@ -12,19 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Union -from uuid import UUID -from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.orm import selectinload import argilla_server.errors.future as errors from argilla_server.api.schemas.v1.questions import ( QuestionCreate, QuestionUpdate, ) -from argilla_server.models import Dataset, Question, User +from argilla_server.models import Dataset, Question from argilla_server.validators.questions import ( QuestionCreateValidator, QuestionDeleteValidator, diff --git a/argilla-server/src/argilla_server/contexts/records.py b/argilla-server/src/argilla_server/contexts/records.py index def76d9ecb..c2b0f20bb9 100644 --- a/argilla-server/src/argilla_server/contexts/records.py +++ b/argilla-server/src/argilla_server/contexts/records.py @@ -12,20 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Dict, Iterable, Sequence +from typing import Dict, Sequence from uuid import UUID -from sqlalchemy import select, sql +from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import selectinload -from argilla_server.models import Dataset, Record, Suggestion +from argilla_server.models import Dataset, Record async def list_dataset_records_by_ids( db: AsyncSession, dataset_id: UUID, record_ids: Sequence[UUID] ) -> Sequence[Record]: - query = select(Record).filter(Record.id.in_(record_ids), Record.dataset_id == dataset_id) return (await db.execute(query)).unique().scalars().all() @@ -33,7 +32,6 @@ async def list_dataset_records_by_ids( async def list_dataset_records_by_external_ids( db: AsyncSession, dataset_id: UUID, external_ids: Sequence[str] ) -> Sequence[Record]: - query = ( select(Record) .filter(Record.external_id.in_(external_ids), Record.dataset_id == dataset_id) diff --git a/argilla-server/src/argilla_server/contexts/settings.py b/argilla-server/src/argilla_server/contexts/settings.py index a471e37e18..d2f483a185 100644 --- a/argilla-server/src/argilla_server/contexts/settings.py +++ b/argilla-server/src/argilla_server/contexts/settings.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Dict, Union +from typing import Union from argilla_server.api.schemas.v1.settings import ArgillaSettings, HuggingfaceSettings, Settings from argilla_server.settings import settings diff --git a/argilla-server/src/argilla_server/errors/__init__.py b/argilla-server/src/argilla_server/errors/__init__.py index 2f784920b4..779340a32c 100644 --- a/argilla-server/src/argilla_server/errors/__init__.py +++ b/argilla-server/src/argilla_server/errors/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .base_errors import * +from .base_errors import * # noqa diff --git a/argilla-server/src/argilla_server/helpers.py b/argilla-server/src/argilla_server/helpers.py index 4ce970f131..30cd43d945 100644 --- a/argilla-server/src/argilla_server/helpers.py +++ b/argilla-server/src/argilla_server/helpers.py @@ -17,7 +17,6 @@ Common helper functions """ import logging -from typing import Any, Dict, List, Optional _LOGGER = logging.getLogger("argilla_server") diff --git a/argilla-server/src/argilla_server/models/__init__.py b/argilla-server/src/argilla_server/models/__init__.py index 52cb08924f..1fe3f724cc 100644 --- a/argilla-server/src/argilla_server/models/__init__.py +++ b/argilla-server/src/argilla_server/models/__init__.py @@ -15,6 +15,6 @@ # This line is included here since some enums are already imported from `argilla_server.models`. # We need to review and avoid this. This is only a workaround to not change everything right now -from argilla_server.enums import * # noqa: I001 -from .database import * # noqa: I001 -from .metadata_properties import * # noqa: I001 +from argilla_server.enums import * # noqa +from .database import * # noqa +from .metadata_properties import * # noqa diff --git a/argilla-server/src/argilla_server/search_engine/__init__.py b/argilla-server/src/argilla_server/search_engine/__init__.py index 7d9d1ce773..aef23c4884 100644 --- a/argilla-server/src/argilla_server/search_engine/__init__.py +++ b/argilla-server/src/argilla_server/search_engine/__init__.py @@ -15,7 +15,8 @@ from typing import AsyncGenerator from ..settings import settings -from .base import * +from .base import * # noqa +from .base import SearchEngine from .elasticsearch import ElasticSearchEngine from .opensearch import OpenSearchEngine diff --git a/argilla-server/src/argilla_server/search_engine/commons.py b/argilla-server/src/argilla_server/search_engine/commons.py index 22af1f12fa..2030b59ae5 100644 --- a/argilla-server/src/argilla_server/search_engine/commons.py +++ b/argilla-server/src/argilla_server/search_engine/commons.py @@ -832,7 +832,7 @@ async def __value_count_aggregation(self, index_name: str, field_name: str, quer async def __stats_aggregation(self, index_name: str, field_name: str, query: dict) -> dict: # See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html - aggregation_name = f"numeric_stats" + aggregation_name = "numeric_stats" stats_agg = {aggregation_name: {"stats": {"field": field_name}}} diff --git a/argilla-server/src/argilla_server/security/settings.py b/argilla-server/src/argilla_server/security/settings.py index f006b0c450..2715b9b3b5 100644 --- a/argilla-server/src/argilla_server/security/settings.py +++ b/argilla-server/src/argilla_server/security/settings.py @@ -16,7 +16,7 @@ from typing import TYPE_CHECKING, Optional from uuid import uuid4 -from argilla_server.pydantic_v1 import BaseSettings, PrivateAttr, validator +from argilla_server.pydantic_v1 import BaseSettings, PrivateAttr if TYPE_CHECKING: from argilla_server.security.authentication.oauth2 import OAuth2Settings diff --git a/argilla-server/src/argilla_server/utils.py b/argilla-server/src/argilla_server/utils.py index 12396175e8..5bb02e7d02 100644 --- a/argilla-server/src/argilla_server/utils.py +++ b/argilla-server/src/argilla_server/utils.py @@ -14,7 +14,7 @@ import re from collections import defaultdict -from typing import Any, Callable, Dict, List, Optional, Set, Type, TypeVar, Union +from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union from uuid import UUID from fastapi import HTTPException, Query diff --git a/argilla-server/src/argilla_server/validators/response_values.py b/argilla-server/src/argilla_server/validators/response_values.py index 4ba64f1c4e..eaeacd6aad 100644 --- a/argilla-server/src/argilla_server/validators/response_values.py +++ b/argilla-server/src/argilla_server/validators/response_values.py @@ -260,7 +260,7 @@ def _validate_labels_are_available_at_question_settings(self, span_question_sett available_labels = [option.value for option in span_question_settings.options] for value_item in self._response_value: - if not value_item.label in available_labels: + if value_item.label not in available_labels: raise UnprocessableEntityError( f"undefined label '{value_item.label}' for span question.\nValid labels are: {available_labels!r}" ) diff --git a/argilla-server/src/argilla_server/validators/responses.py b/argilla-server/src/argilla_server/validators/responses.py index 63d23adc08..ef98bd0fd1 100644 --- a/argilla-server/src/argilla_server/validators/responses.py +++ b/argilla-server/src/argilla_server/validators/responses.py @@ -15,7 +15,7 @@ from typing import Union from argilla_server.api.schemas.v1.responses import ResponseCreate, ResponseUpdate, ResponseUpsert -from argilla_server.enums import QuestionType, ResponseStatus +from argilla_server.enums import ResponseStatus from argilla_server.errors.future import UnprocessableEntityError from argilla_server.models import Record from argilla_server.validators.response_values import ResponseValueValidator diff --git a/argilla-server/tests/unit/api/handlers/v1/authentication/test_create_token.py b/argilla-server/tests/unit/api/handlers/v1/authentication/test_create_token.py index 38e835aa43..7bd8867293 100644 --- a/argilla-server/tests/unit/api/handlers/v1/authentication/test_create_token.py +++ b/argilla-server/tests/unit/api/handlers/v1/authentication/test_create_token.py @@ -13,7 +13,6 @@ # limitations under the License. import pytest -from argilla_server.models import User from httpx import AsyncClient from tests.factories import UserFactory diff --git a/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk.py b/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk.py index ae730d7e99..bfbd65102e 100644 --- a/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk.py +++ b/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk.py @@ -31,7 +31,6 @@ @pytest.mark.asyncio class TestDatasetRecordsBulk: - def url(self, dataset_id: UUID) -> str: return f"/api/v1/datasets/{dataset_id}/records/bulk" diff --git a/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_responses.py b/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_responses.py index ccaf8598c6..2ee3bb11df 100644 --- a/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_responses.py +++ b/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_responses.py @@ -34,7 +34,6 @@ @pytest.mark.asyncio class TestDatasetRecordsBulkWithResponses: - def url(self, dataset_id: UUID) -> str: return f"/api/v1/datasets/{dataset_id}/records/bulk" @@ -318,7 +317,7 @@ async def test_create_record_with_with_wrong_response_question( assert response.status_code == 422, response.json() assert response.json() == { - "detail": f"Record at position 0 does not have valid responses because " + "detail": "Record at position 0 does not have valid responses because " "found response value for non configured question with name='other-question'" } @@ -349,7 +348,7 @@ async def test_update_record_with_wrong_responses_values(self, async_client: Asy assert response.status_code == 422, response.json() assert response.json() == { - "detail": f"Record at position 0 does not have valid responses because 'wrong-label' " + "detail": "Record at position 0 does not have valid responses because 'wrong-label' " "is not a valid label for label selection question.\n" "Valid labels are: ['label-a', 'label-b']" } @@ -361,7 +360,6 @@ async def _configure_dataset_fields(self, dataset: Dataset): await dataset.awaitable_attrs.fields async def _configure_dataset_questions(self, dataset: Dataset): - await LabelSelectionQuestionFactory.create( dataset=dataset, name="label", diff --git a/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_suggestions.py b/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_suggestions.py index c6028a4871..84413b4c2b 100644 --- a/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_suggestions.py +++ b/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_suggestions.py @@ -33,7 +33,6 @@ @pytest.mark.asyncio class TestDatasetRecordsBulkWithSuggestions: - def url(self, dataset_id: UUID) -> str: return f"/api/v1/datasets/{dataset_id}/records/bulk" @@ -329,8 +328,8 @@ async def test_create_record_with_wrong_suggestion_value_in_bulk( assert response.status_code == 422, response.json() assert response.json() == { - "detail": f"Record at position 0 does not have valid suggestions because suggestion for question name=label " - f"is not valid: 'wrong-label' is not a valid label for label selection question.\n" + "detail": "Record at position 0 does not have valid suggestions because suggestion for question name=label " + "is not valid: 'wrong-label' is not a valid label for label selection question.\n" "Valid labels are: ['label-a', 'label-b']" } @@ -389,8 +388,8 @@ async def test_update_record_with_wrong_suggestion_value_in_bulk( assert response.status_code == 422, response.json() assert response.json() == { - "detail": f"Record at position 0 does not have valid suggestions because suggestion for question name=label " - f"is not valid: 'wrong-label' is not a valid label for label selection question.\n" + "detail": "Record at position 0 does not have valid suggestions because suggestion for question name=label " + "is not valid: 'wrong-label' is not a valid label for label selection question.\n" "Valid labels are: ['label-a', 'label-b']" } diff --git a/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_vectors.py b/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_vectors.py index 37ed298866..dee8f9d194 100644 --- a/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_vectors.py +++ b/argilla-server/tests/unit/api/handlers/v1/datasets/records/records_bulk/test_dataset_records_bulk_with_vectors.py @@ -31,7 +31,6 @@ @pytest.mark.asyncio class TestDatasetRecordsBulkWithVectors: - def url(self, dataset_id: UUID) -> str: return f"/api/v1/datasets/{dataset_id}/records/bulk" diff --git a/argilla-server/tests/unit/api/handlers/v1/datasets/records/test_update_dataset_records.py b/argilla-server/tests/unit/api/handlers/v1/datasets/records/test_update_dataset_records.py index 4349035bfe..cf9fa909e9 100644 --- a/argilla-server/tests/unit/api/handlers/v1/datasets/records/test_update_dataset_records.py +++ b/argilla-server/tests/unit/api/handlers/v1/datasets/records/test_update_dataset_records.py @@ -15,8 +15,8 @@ from uuid import UUID import pytest -from argilla_server.enums import DatasetStatus, QuestionType, ResponseStatus, SuggestionType -from argilla_server.models.database import Record, Response, Suggestion, User +from argilla_server.enums import DatasetStatus, QuestionType, SuggestionType +from argilla_server.models.database import Record, Suggestion, User from httpx import AsyncClient from sqlalchemy import func, select from sqlalchemy.ext.asyncio import AsyncSession diff --git a/argilla-server/tests/unit/api/handlers/v1/questions/test_update_question.py b/argilla-server/tests/unit/api/handlers/v1/questions/test_update_question.py index 949811284c..ba66886963 100644 --- a/argilla-server/tests/unit/api/handlers/v1/questions/test_update_question.py +++ b/argilla-server/tests/unit/api/handlers/v1/questions/test_update_question.py @@ -16,9 +16,7 @@ import pytest from argilla_server.enums import OptionsOrder, QuestionType -from argilla_server.models import Question from httpx import AsyncClient -from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession from tests.factories import LabelSelectionQuestionFactory, QuestionFactory, SpanQuestionFactory, TextQuestionFactory diff --git a/argilla-server/tests/unit/api/handlers/v1/records/test_create_record_response.py b/argilla-server/tests/unit/api/handlers/v1/records/test_create_record_response.py index 50c901d196..98b3a864b9 100644 --- a/argilla-server/tests/unit/api/handlers/v1/records/test_create_record_response.py +++ b/argilla-server/tests/unit/api/handlers/v1/records/test_create_record_response.py @@ -16,7 +16,7 @@ from uuid import UUID import pytest -from argilla_server.enums import QuestionType, ResponseStatusFilter +from argilla_server.enums import ResponseStatusFilter from argilla_server.models import Response, User from httpx import AsyncClient from sqlalchemy import func, select diff --git a/argilla-server/tests/unit/api/handlers/v1/records/test_upsert_suggestion.py b/argilla-server/tests/unit/api/handlers/v1/records/test_upsert_suggestion.py index 46ab36c2ef..1e9586322c 100644 --- a/argilla-server/tests/unit/api/handlers/v1/records/test_upsert_suggestion.py +++ b/argilla-server/tests/unit/api/handlers/v1/records/test_upsert_suggestion.py @@ -13,7 +13,7 @@ # limitations under the License. from datetime import datetime -from typing import Any, List +from typing import List from uuid import UUID, uuid4 import pytest diff --git a/argilla-server/tests/unit/api/handlers/v1/responses/test_create_current_user_responses_bulk.py b/argilla-server/tests/unit/api/handlers/v1/responses/test_create_current_user_responses_bulk.py index 721c263e45..009cec7d2e 100644 --- a/argilla-server/tests/unit/api/handlers/v1/responses/test_create_current_user_responses_bulk.py +++ b/argilla-server/tests/unit/api/handlers/v1/responses/test_create_current_user_responses_bulk.py @@ -39,7 +39,7 @@ @pytest.mark.asyncio class TestCreateCurrentUserResponsesBulk: def url(self) -> str: - return f"/api/v1/me/responses/bulk" + return "/api/v1/me/responses/bulk" def bulk_max_items(self) -> int: return 100 diff --git a/argilla-server/tests/unit/api/handlers/v1/test_metadata_properties.py b/argilla-server/tests/unit/api/handlers/v1/test_metadata_properties.py index ae9b32c873..9c77ac6765 100644 --- a/argilla-server/tests/unit/api/handlers/v1/test_metadata_properties.py +++ b/argilla-server/tests/unit/api/handlers/v1/test_metadata_properties.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid from typing import TYPE_CHECKING, Type from uuid import uuid4 diff --git a/argilla-server/tests/unit/api/handlers/v1/test_records.py b/argilla-server/tests/unit/api/handlers/v1/test_records.py index e48a2d33f2..ed7d9f8cc2 100644 --- a/argilla-server/tests/unit/api/handlers/v1/test_records.py +++ b/argilla-server/tests/unit/api/handlers/v1/test_records.py @@ -21,7 +21,7 @@ from argilla_server.constants import API_KEY_HEADER_NAME from argilla_server.enums import ResponseStatus from argilla_server.models import Dataset, Record, Response, Suggestion, User, UserRole -from argilla_server.search_engine import SearchEngine, SearchResponseItem, SearchResponses +from argilla_server.search_engine import SearchEngine from sqlalchemy import func, select from sqlalchemy.orm import Session diff --git a/argilla-server/tests/unit/api/handlers/v1/test_users.py b/argilla-server/tests/unit/api/handlers/v1/test_users.py index eb5298c7c7..03851897d5 100644 --- a/argilla-server/tests/unit/api/handlers/v1/test_users.py +++ b/argilla-server/tests/unit/api/handlers/v1/test_users.py @@ -22,7 +22,7 @@ from tests.factories import UserFactory, WorkspaceFactory if TYPE_CHECKING: - from fastapi.testclient import TestClient + pass @pytest.mark.asyncio diff --git a/argilla-server/tests/unit/api/handlers/v1/users/test_create_user.py b/argilla-server/tests/unit/api/handlers/v1/users/test_create_user.py index 90eebbf0c2..059f863830 100644 --- a/argilla-server/tests/unit/api/handlers/v1/users/test_create_user.py +++ b/argilla-server/tests/unit/api/handlers/v1/users/test_create_user.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from uuid import UUID import pytest from argilla_server.constants import API_KEY_HEADER_NAME diff --git a/argilla-server/tests/unit/api/handlers/v1/users/test_delete_user.py b/argilla-server/tests/unit/api/handlers/v1/users/test_delete_user.py index 0c3b6b58c6..9d3341a252 100644 --- a/argilla-server/tests/unit/api/handlers/v1/users/test_delete_user.py +++ b/argilla-server/tests/unit/api/handlers/v1/users/test_delete_user.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from datetime import datetime from uuid import UUID, uuid4 import pytest diff --git a/argilla-server/tests/unit/cli/search_engine/conftest.py b/argilla-server/tests/unit/cli/search_engine/conftest.py index 52032b0b83..f73159fe6d 100644 --- a/argilla-server/tests/unit/cli/search_engine/conftest.py +++ b/argilla-server/tests/unit/cli/search_engine/conftest.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING import pytest from pytest_mock import MockerFixture diff --git a/argilla-server/tests/unit/search_engine/test_commons.py b/argilla-server/tests/unit/search_engine/test_commons.py index 0c0f673ff7..ecba3232a6 100644 --- a/argilla-server/tests/unit/search_engine/test_commons.py +++ b/argilla-server/tests/unit/search_engine/test_commons.py @@ -277,7 +277,7 @@ def _expected_value_for_question(question: Question) -> Dict[str, Any]: @pytest.mark.asyncio @pytest.mark.skipif( - not server_settings.search_engine in ["elasticsearch", "opensearch"], + server_settings.search_engine not in ["elasticsearch", "opensearch"], reason="Running on elasticsearch/opensearch engine", ) class TestBaseElasticAndOpenSearchEngine: diff --git a/argilla-server/tests/unit/search_engine/test_elastisearch.py b/argilla-server/tests/unit/search_engine/test_elastisearch.py index 9dfb6091ad..2e51f06844 100644 --- a/argilla-server/tests/unit/search_engine/test_elastisearch.py +++ b/argilla-server/tests/unit/search_engine/test_elastisearch.py @@ -14,10 +14,9 @@ import pytest from argilla_server.search_engine import ElasticSearchEngine -from argilla_server.search_engine.commons import ALL_RESPONSES_STATUSES_FIELD, es_index_name_for_dataset +from argilla_server.search_engine.commons import es_index_name_for_dataset from argilla_server.settings import settings from opensearchpy import OpenSearch -from sqlalchemy.ext.asyncio import AsyncSession from tests.factories import DatasetFactory, VectorSettingsFactory from tests.unit.search_engine.test_commons import refresh_dataset diff --git a/argilla-server/tests/unit/search_engine/test_opensearch.py b/argilla-server/tests/unit/search_engine/test_opensearch.py index f5a4ea80a1..7d090e5d39 100644 --- a/argilla-server/tests/unit/search_engine/test_opensearch.py +++ b/argilla-server/tests/unit/search_engine/test_opensearch.py @@ -14,7 +14,7 @@ import pytest from argilla_server.search_engine import OpenSearchEngine -from argilla_server.search_engine.commons import ALL_RESPONSES_STATUSES_FIELD, es_index_name_for_dataset +from argilla_server.search_engine.commons import es_index_name_for_dataset from argilla_server.settings import settings from opensearchpy import OpenSearch, RequestError from sqlalchemy.ext.asyncio import AsyncSession diff --git a/argilla-server/tests/unit/security/test_model.py b/argilla-server/tests/unit/security/test_model.py index 1254e1f539..1b3e7a875c 100644 --- a/argilla-server/tests/unit/security/test_model.py +++ b/argilla-server/tests/unit/security/test_model.py @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Union import pytest from argilla_server.api.schemas.v1.users import User, UserCreate from argilla_server.api.schemas.v1.workspaces import WorkspaceCreate -from tests.factories import UserFactory, WorkspaceFactory +from tests.factories import UserFactory from tests.pydantic_v1 import ValidationError diff --git a/argilla-server/tests/unit/validators/test_records_bulk.py b/argilla-server/tests/unit/validators/test_records_bulk.py index 7abaa57d41..9f876f4e0f 100644 --- a/argilla-server/tests/unit/validators/test_records_bulk.py +++ b/argilla-server/tests/unit/validators/test_records_bulk.py @@ -25,7 +25,6 @@ @pytest.mark.asyncio class TestRecordsBulkValidators: - async def configure_dataset(self) -> Dataset: dataset = await DatasetFactory.create(status="ready") diff --git a/argilla-v1/src/argilla_v1/cli/training/__main__.py b/argilla-v1/src/argilla_v1/cli/training/__main__.py index ae25356b1a..1c6527b4ec 100644 --- a/argilla-v1/src/argilla_v1/cli/training/__main__.py +++ b/argilla-v1/src/argilla_v1/cli/training/__main__.py @@ -44,7 +44,6 @@ def train( import json from argilla_v1.cli.callback import init_callback - from argilla_v1.client.singleton import init from argilla_v1.training import ArgillaTrainer init_callback() diff --git a/argilla-v1/src/argilla_v1/cli/workspaces/add_user.py b/argilla-v1/src/argilla_v1/cli/workspaces/add_user.py index 26fb961666..a7820b4625 100644 --- a/argilla-v1/src/argilla_v1/cli/workspaces/add_user.py +++ b/argilla-v1/src/argilla_v1/cli/workspaces/add_user.py @@ -26,7 +26,6 @@ def add_user( ) -> None: from argilla_v1.cli.rich import echo_in_panel from argilla_v1.cli.workspaces.utils import get_user - from argilla_v1.client.users import User workspace: "Workspace" = ctx.obj diff --git a/argilla-v1/src/argilla_v1/cli/workspaces/create.py b/argilla-v1/src/argilla_v1/cli/workspaces/create.py index fe56fe40d1..fddf4076e9 100644 --- a/argilla-v1/src/argilla_v1/cli/workspaces/create.py +++ b/argilla-v1/src/argilla_v1/cli/workspaces/create.py @@ -21,7 +21,7 @@ def create_workspace( name: str = typer.Argument( ..., help="The name of the workspace to be created", - ) + ), ) -> None: """Creates a workspace for the logged user in Argilla""" from argilla_v1.cli.rich import echo_in_panel diff --git a/argilla-v1/src/argilla_v1/client/feedback/constants.py b/argilla-v1/src/argilla_v1/client/feedback/constants.py index bf87ba570e..2dd46139f8 100644 --- a/argilla-v1/src/argilla_v1/client/feedback/constants.py +++ b/argilla-v1/src/argilla_v1/client/feedback/constants.py @@ -11,10 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import List, Union -from argilla_v1.client.feedback.schemas.enums import FieldTypes, MetadataPropertyTypes -from argilla_v1.pydantic_v1 import StrictFloat, StrictInt, StrictStr +from argilla_v1.client.feedback.schemas.enums import FieldTypes FETCHING_BATCH_SIZE = 250 PUSHING_BATCH_SIZE = 32 diff --git a/argilla-v1/src/argilla_v1/client/feedback/schemas/metadata.py b/argilla-v1/src/argilla_v1/client/feedback/schemas/metadata.py index 9da479fe55..8201f9b7ea 100644 --- a/argilla-v1/src/argilla_v1/client/feedback/schemas/metadata.py +++ b/argilla-v1/src/argilla_v1/client/feedback/schemas/metadata.py @@ -11,7 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import math from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union diff --git a/argilla-v1/src/argilla_v1/client/feedback/schemas/responses.py b/argilla-v1/src/argilla_v1/client/feedback/schemas/responses.py index 91c196b1bb..8336fa7f80 100644 --- a/argilla-v1/src/argilla_v1/client/feedback/schemas/responses.py +++ b/argilla-v1/src/argilla_v1/client/feedback/schemas/responses.py @@ -20,12 +20,11 @@ from argilla_v1.client.feedback.schemas.response_values import ( ResponseValue, normalize_response_value, - parse_value_response_for_question, ) from argilla_v1.pydantic_v1 import BaseModel, Extra, validator if TYPE_CHECKING: - from argilla_v1.client.feedback.schemas.questions import QuestionSchema + pass class ValueSchema(BaseModel): diff --git a/argilla-v1/src/argilla_v1/client/sdk/client.py b/argilla-v1/src/argilla_v1/client/sdk/client.py index 758b1b2143..88c7e252c9 100644 --- a/argilla-v1/src/argilla_v1/client/sdk/client.py +++ b/argilla-v1/src/argilla_v1/client/sdk/client.py @@ -15,7 +15,6 @@ import dataclasses import datetime import functools -import inspect import json import uuid from json import JSONEncoder diff --git a/argilla-v1/src/argilla_v1/client/sdk/commons/api.py b/argilla-v1/src/argilla_v1/client/sdk/commons/api.py index 1a7f20583f..e2893fc94f 100644 --- a/argilla-v1/src/argilla_v1/client/sdk/commons/api.py +++ b/argilla-v1/src/argilla_v1/client/sdk/commons/api.py @@ -25,13 +25,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import json -from typing import Any, Dict, List, Optional, Type, TypeVar, Union +from typing import List, Type, TypeVar, Union import httpx from argilla_v1.client.sdk.client import AuthenticatedClient -from argilla_v1.client.sdk.commons.errors import GenericApiError from argilla_v1.client.sdk.commons.errors_handler import handle_response_error from argilla_v1.client.sdk.commons.models import BulkResponse, ErrorMessage, HTTPValidationError, Response from argilla_v1.client.sdk.text2text.models import Text2TextBulkData diff --git a/argilla-v1/src/argilla_v1/client/sdk/datasets/api.py b/argilla-v1/src/argilla_v1/client/sdk/datasets/api.py index 074ab22561..cc8c51ef9c 100644 --- a/argilla-v1/src/argilla_v1/client/sdk/datasets/api.py +++ b/argilla-v1/src/argilla_v1/client/sdk/datasets/api.py @@ -14,7 +14,7 @@ # limitations under the License. from functools import lru_cache -from typing import List, Optional, Union +from typing import List, Optional import httpx diff --git a/argilla-v1/src/argilla_v1/client/sdk/text_classification/api.py b/argilla-v1/src/argilla_v1/client/sdk/text_classification/api.py index 47086af46d..055ef136a7 100644 --- a/argilla-v1/src/argilla_v1/client/sdk/text_classification/api.py +++ b/argilla-v1/src/argilla_v1/client/sdk/text_classification/api.py @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import List, Optional, Union +from typing import List, Union import httpx @@ -23,8 +23,6 @@ from argilla_v1.client.sdk.text_classification.models import ( LabelingRule, LabelingRuleMetricsSummary, - TextClassificationQuery, - TextClassificationRecord, ) diff --git a/argilla-v1/src/argilla_v1/client/sdk/v1/vectors_settings/api.py b/argilla-v1/src/argilla_v1/client/sdk/v1/vectors_settings/api.py index 781505c3b9..bbbd9125b9 100644 --- a/argilla-v1/src/argilla_v1/client/sdk/v1/vectors_settings/api.py +++ b/argilla-v1/src/argilla_v1/client/sdk/v1/vectors_settings/api.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, Union from argilla_v1.client.sdk.commons.errors_handler import handle_response_error from argilla_v1.client.sdk.commons.models import Response diff --git a/argilla-v1/src/argilla_v1/client/users.py b/argilla-v1/src/argilla_v1/client/users.py index ac238b53f0..8d236d469b 100644 --- a/argilla-v1/src/argilla_v1/client/users.py +++ b/argilla-v1/src/argilla_v1/client/users.py @@ -165,7 +165,7 @@ def __active_client(httpx: bool = True) -> Union["httpx.Client", "AuthenticatedC client = client.httpx return client except Exception as e: - raise RuntimeError(f"The `rg.active_client()` is not available or not responding.") from e + raise RuntimeError("The `rg.active_client()` is not available or not responding.") from e @allowed_for_roles(roles=[UserRole.owner]) def delete(self) -> None: diff --git a/argilla-v1/src/argilla_v1/client/workspaces.py b/argilla-v1/src/argilla_v1/client/workspaces.py index 3e176b373d..119097452d 100644 --- a/argilla-v1/src/argilla_v1/client/workspaces.py +++ b/argilla-v1/src/argilla_v1/client/workspaces.py @@ -259,7 +259,7 @@ def __active_client() -> "httpx.Client": try: return active_client().http_client.httpx except Exception as e: - raise RuntimeError(f"The `rg.active_client()` is not available or not responding.") from e + raise RuntimeError("The `rg.active_client()` is not available or not responding.") from e @classmethod def _new_instance( diff --git a/argilla-v1/src/argilla_v1/labeling/text_classification/label_errors.py b/argilla-v1/src/argilla_v1/labeling/text_classification/label_errors.py index 20f719f71c..2d86a3004e 100644 --- a/argilla-v1/src/argilla_v1/labeling/text_classification/label_errors.py +++ b/argilla-v1/src/argilla_v1/labeling/text_classification/label_errors.py @@ -12,7 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import logging import warnings from enum import Enum from typing import Dict, List, Optional, Tuple, Union diff --git a/argilla-v1/src/argilla_v1/labeling/text_classification/rule.py b/argilla-v1/src/argilla_v1/labeling/text_classification/rule.py index b4a6bd7060..37b3f376a2 100644 --- a/argilla-v1/src/argilla_v1/labeling/text_classification/rule.py +++ b/argilla-v1/src/argilla_v1/labeling/text_classification/rule.py @@ -14,7 +14,6 @@ # limitations under the License. from typing import Dict, List, Optional, Union -import argilla_v1 as rg from argilla_v1.client import singleton from argilla_v1.client.api import load from argilla_v1.client.models import TextClassificationRecord diff --git a/argilla-v1/src/argilla_v1/utils/telemetry.py b/argilla-v1/src/argilla_v1/utils/telemetry.py index a7ba0a14f1..cdd3cb6479 100644 --- a/argilla-v1/src/argilla_v1/utils/telemetry.py +++ b/argilla-v1/src/argilla_v1/utils/telemetry.py @@ -16,7 +16,7 @@ import logging import platform import uuid -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import Any, Dict, Optional from argilla_v1.pydantic_v1 import BaseSettings @@ -115,11 +115,11 @@ def get_current_filename() -> Optional[str]: try: # Should work if we are running from python return Path(__file__).stem - except NameError as e: + except NameError: # This should work if we are running a notebook from vscode globals_ = globals() return Path(globals_["__vsc_ipynb_file__"]).stem - except KeyError as e: + except KeyError: # This should work for notebooks running locally or using google colab import urllib.parse diff --git a/argilla-v1/src/argilla_v1/utils/utils.py b/argilla-v1/src/argilla_v1/utils/utils.py index 459cacdfe3..902d440eca 100644 --- a/argilla-v1/src/argilla_v1/utils/utils.py +++ b/argilla-v1/src/argilla_v1/utils/utils.py @@ -15,7 +15,6 @@ import asyncio import importlib import os -import sys import threading import warnings from itertools import chain diff --git a/argilla-v1/tests/integration/client/feedback/conftest.py b/argilla-v1/tests/integration/client/feedback/conftest.py index 1c375f69e1..f89d6746ee 100644 --- a/argilla-v1/tests/integration/client/feedback/conftest.py +++ b/argilla-v1/tests/integration/client/feedback/conftest.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING, Any, List +from typing import TYPE_CHECKING, List import pytest from argilla_v1.client import singleton @@ -23,10 +23,7 @@ TermsMetadataProperty, ) from argilla_v1.client.feedback.schemas.records import FeedbackRecord -from argilla_v1.client.feedback.schemas.remote.records import RemoteFeedbackRecord -from argilla_v1.client.models import Framework from argilla_v1.client.workspaces import Workspace -from argilla_v1.feedback import TrainingTask if TYPE_CHECKING: from argilla_v1.client.feedback.schemas.types import AllowedFieldTypes, AllowedQuestionTypes diff --git a/argilla-v1/tests/integration/client/feedback/dataset/remote/test_dataset.py b/argilla-v1/tests/integration/client/feedback/dataset/remote/test_dataset.py index 6f2a381c5a..1bb605dd23 100644 --- a/argilla-v1/tests/integration/client/feedback/dataset/remote/test_dataset.py +++ b/argilla-v1/tests/integration/client/feedback/dataset/remote/test_dataset.py @@ -21,7 +21,7 @@ import pytest from argilla_server.models import User as ServerUser from argilla_server.settings import settings -from argilla_v1 import FeedbackRecord, SuggestionSchema +from argilla_v1 import FeedbackRecord from argilla_v1.client.feedback.dataset import FeedbackDataset from argilla_v1.client.feedback.dataset.remote.dataset import RemoteFeedbackDataset from argilla_v1.client.feedback.schemas.fields import TextField diff --git a/argilla-v1/tests/integration/client/feedback/dataset/remote/test_working_with_vectors.py b/argilla-v1/tests/integration/client/feedback/dataset/remote/test_working_with_vectors.py index 818e5db9b2..60b27925b5 100644 --- a/argilla-v1/tests/integration/client/feedback/dataset/remote/test_working_with_vectors.py +++ b/argilla-v1/tests/integration/client/feedback/dataset/remote/test_working_with_vectors.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, List, Union +from typing import List, Union import argilla_v1.client.singleton as rg import pytest diff --git a/argilla-v1/tests/integration/client/feedback/schemas/remote/test_metadata.py b/argilla-v1/tests/integration/client/feedback/schemas/remote/test_metadata.py index cec51fbcba..76a6a4df6d 100644 --- a/argilla-v1/tests/integration/client/feedback/schemas/remote/test_metadata.py +++ b/argilla-v1/tests/integration/client/feedback/schemas/remote/test_metadata.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING, List, Type, Union +from typing import TYPE_CHECKING, List import argilla_v1 as rg import argilla_v1.client.singleton diff --git a/argilla-v1/tests/integration/client/sdk/api/test_commons.py b/argilla-v1/tests/integration/client/sdk/api/test_commons.py index 7488627f88..0977c7488e 100644 --- a/argilla-v1/tests/integration/client/sdk/api/test_commons.py +++ b/argilla-v1/tests/integration/client/sdk/api/test_commons.py @@ -27,7 +27,7 @@ def test_text2text_bulk(sdk_client, mocked_client, bulk_text2text_data, monkeypa dataset_name = "test_dataset" mocked_client.delete(f"/api/datasets/{dataset_name}") - mocked_client.post(f"/api/datasets", json={"name": dataset_name, "task": TaskType.text2text}) + mocked_client.post("/api/datasets", json={"name": dataset_name, "task": TaskType.text2text}) response = bulk(sdk_client, name=dataset_name, json_body=bulk_text2text_data) assert isinstance(response, BulkResponse) @@ -38,7 +38,7 @@ def test_textclass_bulk(sdk_client, mocked_client, bulk_textclass_data, monkeypa dataset_name = "test_dataset" mocked_client.delete(f"/api/datasets/{dataset_name}") - mocked_client.post(f"/api/datasets", json={"name": dataset_name, "task": TaskType.text_classification}) + mocked_client.post("/api/datasets", json={"name": dataset_name, "task": TaskType.text_classification}) response = bulk(sdk_client, name=dataset_name, json_body=bulk_textclass_data) assert isinstance(response, BulkResponse) @@ -49,7 +49,7 @@ def test_tokenclass_bulk(sdk_client, mocked_client, bulk_tokenclass_data, monkey dataset_name = "test_dataset" mocked_client.delete(f"/api/datasets/{dataset_name}") - mocked_client.post(f"/api/datasets", json={"name": dataset_name, "task": TaskType.token_classification}) + mocked_client.post("/api/datasets", json={"name": dataset_name, "task": TaskType.token_classification}) response = bulk(sdk_client, name=dataset_name, json_body=bulk_tokenclass_data) assert isinstance(response, BulkResponse) diff --git a/argilla-v1/tests/integration/client/sdk/conftest.py b/argilla-v1/tests/integration/client/sdk/conftest.py index 318589b095..07e9c12bc6 100644 --- a/argilla-v1/tests/integration/client/sdk/conftest.py +++ b/argilla-v1/tests/integration/client/sdk/conftest.py @@ -14,9 +14,7 @@ # limitations under the License. import logging from datetime import datetime -from typing import Any, Dict, List -import argilla_v1 as rg import pytest from argilla_v1._constants import DEFAULT_API_KEY from argilla_v1.client.models import ( diff --git a/argilla-v1/tests/integration/client/sdk/v1/test_datasets.py b/argilla-v1/tests/integration/client/sdk/v1/test_datasets.py index d261475e3d..0a679e196b 100644 --- a/argilla-v1/tests/integration/client/sdk/v1/test_datasets.py +++ b/argilla-v1/tests/integration/client/sdk/v1/test_datasets.py @@ -41,7 +41,6 @@ get_records, list_datasets, publish_dataset, - search_records, update_records, ) from argilla_v1.client.sdk.v1.datasets.models import ( @@ -51,10 +50,7 @@ FeedbackMetadataPropertyModel, FeedbackMetricsModel, FeedbackQuestionModel, - FeedbackRecordSearchModel, FeedbackRecordsModel, - FeedbackRecordsSearchModel, - FeedbackRecordsSearchVectorQuery, FeedbackSuggestionModel, ) from argilla_v1.client.sdk.v1.records.api import set_suggestion diff --git a/argilla-v1/tests/integration/client/sdk/v1/test_records.py b/argilla-v1/tests/integration/client/sdk/v1/test_records.py index beec661517..63e00a552b 100644 --- a/argilla-v1/tests/integration/client/sdk/v1/test_records.py +++ b/argilla-v1/tests/integration/client/sdk/v1/test_records.py @@ -33,10 +33,6 @@ from argilla_v1.client.sdk.v1.records.models import FeedbackItemModel from tests.factories import ( - DatasetFactory, - RatingQuestionFactory, - RecordFactory, - SuggestionFactory, UserFactory, WorkspaceFactory, ) @@ -62,7 +58,7 @@ class TestRecordsSDK: def test_update_record_with_vectors(self, owner: User, role: UserRole) -> None: argilla_v1.client.singleton.init(api_key=owner.api_key) - workspace = Workspace.create(f"workspace") + workspace = Workspace.create("workspace") user = User.create(username="user", role=role, password="password", workspaces=[workspace.name]) feedback_dataset = FeedbackDataset( @@ -103,7 +99,7 @@ def test_update_record_with_vectors(self, owner: User, role: UserRole) -> None: @pytest.mark.parametrize("role", [UserRole.owner, UserRole.admin]) def test_update_record_with_vectors(self, owner: ServerUser, role: UserRole) -> None: argilla_v1.client.singleton.init(api_key=owner.api_key) - workspace = Workspace.create(f"workspace") + workspace = Workspace.create("workspace") user = User.create(username="user", role=role, password="password", workspaces=[workspace.name]) feedback_dataset = FeedbackDataset( diff --git a/argilla-v1/tests/integration/client/test_client_errors.py b/argilla-v1/tests/integration/client/test_client_errors.py index 668a71df75..57a64570ed 100644 --- a/argilla-v1/tests/integration/client/test_client_errors.py +++ b/argilla-v1/tests/integration/client/test_client_errors.py @@ -19,6 +19,4 @@ def test_unauthorized_response_error(mocked_client): with pytest.raises(UnauthorizedApiError, match="Could not validate credentials"): - import argilla_v1 as rg - init(api_key="wrong-api-key") diff --git a/argilla-v1/tests/integration/client/test_scan_raw_records.py b/argilla-v1/tests/integration/client/test_scan_raw_records.py index 46f865e2ac..f7a3768dc1 100644 --- a/argilla-v1/tests/integration/client/test_scan_raw_records.py +++ b/argilla-v1/tests/integration/client/test_scan_raw_records.py @@ -23,7 +23,6 @@ argvalues=(set(), {"text"}, {"tokens"}), ) def test_scan_records(gutenberg_spacy_ner, fields): - import argilla_v1 as rg import pandas as pd data = active_api().datasets.scan( diff --git a/argilla-v1/tests/integration/labeling/text_classification/test_rule.py b/argilla-v1/tests/integration/labeling/text_classification/test_rule.py index 659dfc222c..237a3e336e 100644 --- a/argilla-v1/tests/integration/labeling/text_classification/test_rule.py +++ b/argilla-v1/tests/integration/labeling/text_classification/test_rule.py @@ -16,7 +16,7 @@ import pytest from argilla_server.errors import EntityNotFoundError from argilla_v1 import User -from argilla_v1.client.api import copy, delete, load +from argilla_v1.client.api import copy, load from argilla_v1.client.models import TextClassificationRecord from argilla_v1.client.sdk.datasets.models import TaskType from argilla_v1.client.sdk.text_classification.models import ( diff --git a/argilla-v1/tests/integration/listeners/test_listener.py b/argilla-v1/tests/integration/listeners/test_listener.py index 82bc46f5bc..ec443ac881 100644 --- a/argilla-v1/tests/integration/listeners/test_listener.py +++ b/argilla-v1/tests/integration/listeners/test_listener.py @@ -15,7 +15,6 @@ import time from typing import List -import argilla_v1 as rg import pytest from argilla_v1 import RGListenerContext, listener from argilla_v1.client.api import delete, log diff --git a/argilla-v1/tests/integration/metrics/test_common_metrics.py b/argilla-v1/tests/integration/metrics/test_common_metrics.py index c2404fd5e0..8dd97cc9ff 100644 --- a/argilla-v1/tests/integration/metrics/test_common_metrics.py +++ b/argilla-v1/tests/integration/metrics/test_common_metrics.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import argilla_v1 -import argilla_v1 as rg import argilla_v1.client.singleton import pytest from argilla_v1.client.api import log diff --git a/argilla-v1/tests/integration/metrics/test_text_classification.py b/argilla-v1/tests/integration/metrics/test_text_classification.py index 90a7311187..ddfe02cd9e 100644 --- a/argilla-v1/tests/integration/metrics/test_text_classification.py +++ b/argilla-v1/tests/integration/metrics/test_text_classification.py @@ -12,7 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import argilla_v1 as rg from argilla_v1.client import singleton from argilla_v1.client.api import log from argilla_v1.client.models import TextClassificationRecord diff --git a/argilla-v1/tests/integration/metrics/test_token_classification.py b/argilla-v1/tests/integration/metrics/test_token_classification.py index c01d5ae044..4f7c410136 100644 --- a/argilla-v1/tests/integration/metrics/test_token_classification.py +++ b/argilla-v1/tests/integration/metrics/test_token_classification.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import argilla_v1 import pytest from argilla_v1.client.api import load, log from argilla_v1.client.models import TokenClassificationRecord diff --git a/argilla-v1/tests/integration/test_log_for_token_classification.py b/argilla-v1/tests/integration/test_log_for_token_classification.py index be5211c166..927b59df0d 100644 --- a/argilla-v1/tests/integration/test_log_for_token_classification.py +++ b/argilla-v1/tests/integration/test_log_for_token_classification.py @@ -14,7 +14,6 @@ import argilla_v1 import pytest from argilla_v1 import TokenClassificationRecord -from argilla_v1.client import api from argilla_v1.client.client import Argilla from argilla_v1.client.sdk.commons.errors import NotFoundApiError from argilla_v1.client.singleton import ArgillaSingleton diff --git a/argilla-v1/tests/unit/cli/users/test_delete.py b/argilla-v1/tests/unit/cli/users/test_delete.py index 6e3c278dfc..5fd699bd5a 100644 --- a/argilla-v1/tests/unit/cli/users/test_delete.py +++ b/argilla-v1/tests/unit/cli/users/test_delete.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING, Type +from typing import TYPE_CHECKING import pytest diff --git a/argilla-v1/tests/unit/cli/users/test_list.py b/argilla-v1/tests/unit/cli/users/test_list.py index ef783e6e4d..16909894eb 100644 --- a/argilla-v1/tests/unit/cli/users/test_list.py +++ b/argilla-v1/tests/unit/cli/users/test_list.py @@ -12,13 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from datetime import datetime from typing import TYPE_CHECKING from unittest.mock import ANY -from uuid import uuid4 import pytest -from argilla_v1.client.sdk.v1.workspaces.models import WorkspaceModel from rich.table import Table if TYPE_CHECKING: diff --git a/argilla-v1/tests/unit/cli/workspaces/test_create.py b/argilla-v1/tests/unit/cli/workspaces/test_create.py index b3ec0d90fe..c75cfeeefe 100644 --- a/argilla-v1/tests/unit/cli/workspaces/test_create.py +++ b/argilla-v1/tests/unit/cli/workspaces/test_create.py @@ -13,7 +13,6 @@ # limitations under the License. from typing import TYPE_CHECKING -from unittest.mock import ANY import pytest @@ -22,8 +21,6 @@ from pytest_mock import MockerFixture from typer import Typer -from argilla_v1.client.workspaces import Workspace - @pytest.mark.usefixtures("login_mock") class TestSuiteWorkspaceCreateCommand: diff --git a/argilla-v1/tests/unit/client/feedback/dataset/remote/test_dataset.py b/argilla-v1/tests/unit/client/feedback/dataset/remote/test_dataset.py index 6b553bb50e..c8aaf51bb3 100644 --- a/argilla-v1/tests/unit/client/feedback/dataset/remote/test_dataset.py +++ b/argilla-v1/tests/unit/client/feedback/dataset/remote/test_dataset.py @@ -14,7 +14,6 @@ from datetime import datetime from typing import Dict -from unittest import mock from uuid import uuid4 import httpx diff --git a/argilla-v1/tests/unit/client/feedback/schemas/test_responses.py b/argilla-v1/tests/unit/client/feedback/schemas/test_responses.py index 61ef9b8220..41fc2f81f9 100644 --- a/argilla-v1/tests/unit/client/feedback/schemas/test_responses.py +++ b/argilla-v1/tests/unit/client/feedback/schemas/test_responses.py @@ -11,16 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from uuid import uuid4 import pytest from argilla_v1.feedback import ( - FeedbackDataset, ResponseSchema, ResponseStatus, SpanValueSchema, TextQuestion, - ValueSchema, ) diff --git a/argilla-v1/tests/unit/client/feedback/schemas/test_suggestions.py b/argilla-v1/tests/unit/client/feedback/schemas/test_suggestions.py index ee522bde31..935e9463f8 100644 --- a/argilla-v1/tests/unit/client/feedback/schemas/test_suggestions.py +++ b/argilla-v1/tests/unit/client/feedback/schemas/test_suggestions.py @@ -13,7 +13,7 @@ # limitations under the License. import pytest -from argilla_v1.feedback import SuggestionSchema, TextQuestion +from argilla_v1.feedback import TextQuestion def test_create_suggestion(): diff --git a/argilla-v1/tests/unit/client/feedback/utils/test_assignment.py b/argilla-v1/tests/unit/client/feedback/utils/test_assignment.py index cf87604f5b..c6400dd629 100644 --- a/argilla-v1/tests/unit/client/feedback/utils/test_assignment.py +++ b/argilla-v1/tests/unit/client/feedback/utils/test_assignment.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings from unittest.mock import Mock, patch import pytest diff --git a/argilla-v1/tests/unit/client/feedback/utils/test_html_utils.py b/argilla-v1/tests/unit/client/feedback/utils/test_html_utils.py index 9ab9e37c2c..08866d76d4 100644 --- a/argilla-v1/tests/unit/client/feedback/utils/test_html_utils.py +++ b/argilla-v1/tests/unit/client/feedback/utils/test_html_utils.py @@ -22,10 +22,8 @@ create_token_highlights, get_file_data, image_to_html, - is_valid_dimension, media_to_html, pdf_to_html, - validate_media_type, video_to_html, ) diff --git a/argilla-v1/tests/unit/client/sdk/v1/test_search_records.py b/argilla-v1/tests/unit/client/sdk/v1/test_search_records.py index 3550825a1f..ba0fbee0ad 100644 --- a/argilla-v1/tests/unit/client/sdk/v1/test_search_records.py +++ b/argilla-v1/tests/unit/client/sdk/v1/test_search_records.py @@ -16,7 +16,7 @@ import httpx import pytest -from argilla_v1.client.sdk.commons.errors import ArApiResponseError, BadRequestApiError +from argilla_v1.client.sdk.commons.errors import ArApiResponseError from argilla_v1.client.sdk.v1.datasets.api import search_records from argilla_v1.client.sdk.v1.datasets.models import FeedbackRecordsSearchVectorQuery diff --git a/argilla-v1/tests/unit/utils/test_dependency.py b/argilla-v1/tests/unit/utils/test_dependency.py index 347302f5d4..88b028086c 100644 --- a/argilla-v1/tests/unit/utils/test_dependency.py +++ b/argilla-v1/tests/unit/utils/test_dependency.py @@ -79,7 +79,7 @@ def test_inner(): # This method should fail, as our dependencies require a higher version of datasets with pytest.raises( ImportError, - match=f"but found datasets==.*?You can install a supported version of 'datasets' with this command: `pip install -U datasets<1.0.0`", + match="but found datasets==.*?You can install a supported version of 'datasets' with this command: `pip install -U datasets<1.0.0`", ): test_inner() diff --git a/argilla/.pre-commit-config.yaml b/argilla/.pre-commit-config.yaml deleted file mode 100644 index 5bc2b29a18..0000000000 --- a/argilla/.pre-commit-config.yaml +++ /dev/null @@ -1,36 +0,0 @@ -repos: - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.4 - hooks: - - id: insert-license - name: "Insert license header in Python source files" - files: \.py$ - exclude: ^docs/snippets/ - args: - - --license-filepath - - LICENSE_HEADER - - --fuzzy-match-generates-todo - - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.4 - hooks: - - id: ruff - args: - - --fix - - id: ruff-format - - - repo: https://github.com/kynan/nbstripout - rev: 0.7.1 - hooks: - - id: nbstripout - files: \.ipynb$ - args: - - --keep-count - - --keep-output - # - --keep-prompt-number - # - --keep-cell-ids - # - --keep-markdown - # - --keep-output-timestamp - # - --keep-execution-count - # - --keep-metadata - # - --keep-version diff --git a/argilla/README.md b/argilla/README.md index ed5dc5f036..c0ad40dfc4 100644 --- a/argilla/README.md +++ b/argilla/README.md @@ -1,4 +1,4 @@ -## `argilla-sdk` +## `argilla-sdk` The argilla-sdk is an experimental project to rebuild Argilla's python client in a simpler and friendlier way. The goal is to have a minimal set of core features that are easy to use and understand, but also contribute to feedback task that build quality data. @@ -51,6 +51,6 @@ To generate the docs you will need to install the development dependencies, and mkdocs serve ``` -You will find the built documentation in `http://localhost:8000/argilla-python/`. +You will find the built documentation in `http://localhost:8000/argilla-python/`. The docs will be deployed for pull request branches automatically. diff --git a/argilla/docs/how_to_guides/record.md b/argilla/docs/how_to_guides/record.md index b5077a7048..21792c8373 100644 --- a/argilla/docs/how_to_guides/record.md +++ b/argilla/docs/how_to_guides/record.md @@ -84,7 +84,7 @@ You can add records to a dataset in two different ways: either by using a dictio We illustrate this python dictionaries that represent your data, but we would not advise you to to define dictionaries. Instead use the `Record` object for instatiating records. - ```python + ```python import argilla as rg client = rg.Argilla(api_url="", api_key="") diff --git a/argilla/docs/reference/argilla/datasets/dataset_records.md b/argilla/docs/reference/argilla/datasets/dataset_records.md index 919e7eb0f8..9ade4d146a 100644 --- a/argilla/docs/reference/argilla/datasets/dataset_records.md +++ b/argilla/docs/reference/argilla/datasets/dataset_records.md @@ -12,7 +12,7 @@ dataset.records ``` !!! note "For user familiar with legacy approaches" - 1. `Dataset.records` object is used to interact with the records in a dataset. It interactively fetches records from the server in batches without using a local copy of the records. + 1. `Dataset.records` object is used to interact with the records in a dataset. It interactively fetches records from the server in batches without using a local copy of the records. 2. The `log` method of `Dataset.records` is used to both add and update records in a dataset. If the record includes a known `id` field, the record will be updated. If the record does not include a known `id` field, the record will be added. @@ -24,7 +24,7 @@ To add records to a dataset, use the `log` method. Records can be added as dicti You can also add records to a dataset by initializing a `Record` object directly. - ```python + ```python records = [ rg.Record( @@ -44,11 +44,11 @@ To add records to a dataset, use the `log` method. Records can be added as dicti dataset.records.log(records) ``` - 1. This is an illustration of a definition. In a real world scenario, you would iterate over a data structure and create `Record` objects for each iteration. + 1. This is an illustration of a definition. In a real world scenario, you would iterate over a data structure and create `Record` objects for each iteration. === "From a data structure" - ```python + ```python data = [ { @@ -64,7 +64,7 @@ To add records to a dataset, use the `log` method. Records can be added as dicti dataset.records.log(data) ``` - 1. The data structure's keys must match the fields or questions in the Argilla dataset. In this case, there are fields named `question` and `answer`. + 1. The data structure's keys must match the fields or questions in the Argilla dataset. In this case, there are fields named `question` and `answer`. === "From a data structure with a mapping" @@ -80,21 +80,21 @@ To add records to a dataset, use the `log` method. Records can be added as dicti }, ] # (1) dataset.records.log( - records=data, + records=data, mapping={"query": "question", "response": "answer"} # (2) ) ``` - 1. The data structure's keys must match the fields or questions in the Argilla dataset. In this case, there are fields named `question` and `answer`. + 1. The data structure's keys must match the fields or questions in the Argilla dataset. In this case, there are fields named `question` and `answer`. 2. The data structure has keys `query` and `response` and the Argilla dataset has `question` and `answer`. You can use the `mapping` parameter to map the keys in the data structure to the fields in the Argilla dataset. === "From a Hugging Face dataset" You can also add records to a dataset using a Hugging Face dataset. This is useful when you want to use a dataset from the Hugging Face Hub and add it to your Argilla dataset. - You can add the dataset where the column names correspond to the names of fields, questions, metadata or vectors in the Argilla dataset. - + You can add the dataset where the column names correspond to the names of fields, questions, metadata or vectors in the Argilla dataset. + If the dataset's schema does not correspond to your Argilla dataset names, you can use a `mapping` to indicate which columns in the dataset correspond to the Argilla dataset fields. ```python @@ -103,18 +103,18 @@ To add records to a dataset, use the `log` method. Records can be added as dicti hf_dataset = load_dataset("imdb", split="train[:100]") # (1) dataset.records.log(records=hf_dataset) - ``` + ``` 1. In this example, the Hugging Face dataset matches the Argilla dataset schema. If that is not the case, you could use the `.map` of the `datasets` library to prepare the data before adding it to the Argilla dataset. Here we use the `mapping` parameter to specify the relationship between the Hugging Face dataset and the Argilla dataset. - + ```python dataset.records.log(records=hf_dataset, mapping={"txt": "text", "y": "label"}) # (1) ``` 1. In this case, the `txt` key in the Hugging Face dataset corresponds to the `text` field in the Argilla dataset, and the `y` key in the Hugging Face dataset corresponds to the `label` field in the Argilla dataset. - + ### Updating records in a dataset @@ -124,7 +124,7 @@ Records can also be updated using the `log` method with records that contain an You can update records in a dataset by initializing a `Record` object directly and providing the `id` field. - ```python + ```python records = [ rg.Record( @@ -142,7 +142,7 @@ Records can also be updated using the `log` method with records that contain an You can also update records in a dataset by providing the `id` field in the data structure. - ```python + ```python data = [ { @@ -170,7 +170,7 @@ Records can also be updated using the `log` method with records that contain an ] dataset.records.log( - records=data, + records=data, mapping={"my_id": "id"} # (2) ) @@ -188,7 +188,7 @@ Records can also be updated using the `log` method with records that contain an hf_dataset = load_dataset("imdb", split="train[:100]") # (1) dataset.records.log(records=hf_dataset, mapping={"uuid": "id"}) # (2) - ``` + ``` 1. In this example, the Hugging Face dataset matches the Argilla dataset schema. 2. The `uuid` key in the Hugging Face dataset corresponds to the `id` field in the Argilla dataset. diff --git a/argilla/docs/reference/argilla/records/records.md b/argilla/docs/reference/argilla/records/records.md index 59f22aed85..24bd474083 100644 --- a/argilla/docs/reference/argilla/records/records.md +++ b/argilla/docs/reference/argilla/records/records.md @@ -9,7 +9,7 @@ The `Record` object is used to represent a single record in Argilla. It contains ### Creating a Record -To create records, you can use the `Record` class and pass it to the `Dataset.records.log` method. The `Record` class requires a `fields` parameter, which is a dictionary of field names and values. The field names must match the field names in the dataset's `Settings` object to be accepted. +To create records, you can use the `Record` class and pass it to the `Dataset.records.log` method. The `Record` class requires a `fields` parameter, which is a dictionary of field names and values. The field names must match the field names in the dataset's `Settings` object to be accepted. ```python dataset.records.add( diff --git a/argilla/mkdocs.yml b/argilla/mkdocs.yml index af610ba924..3a891141e9 100644 --- a/argilla/mkdocs.yml +++ b/argilla/mkdocs.yml @@ -91,13 +91,12 @@ markdown_extensions: - footnotes - tables - pymdownx.emoji: - emoji_index: !!python/name:material.extensions.emoji.twemoji - emoji_generator: !!python/name:material.extensions.emoji.to_svg + emoji_index: "!!python/name:material.extensions.emoji.twemoji" + emoji_generator: "!!python/name:material.extensions.emoji.to_svg" # activating permalink: true makes the anchor link works in the notebooks - toc: permalink: true - plugins: - search - open-in-new-tab @@ -130,23 +129,23 @@ plugins: nav: - Argilla: index.md - Getting started: - - Quickstart: getting_started/quickstart.md - - Installation: getting_started/installation.md - - FAQ: getting_started/faq.md + - Quickstart: getting_started/quickstart.md + - Installation: getting_started/installation.md + - FAQ: getting_started/faq.md - How-to guides: - - how_to_guides/index.md - - Manage users and credentials: how_to_guides/user.md - - Manage workspaces: how_to_guides/workspace.md - - Manage and create datasets: how_to_guides/dataset.md - - Add, update, and delete records: how_to_guides/record.md - - Query, filter, and export records: how_to_guides/query_export.md - - Migrate your legacy datasets to Argilla V2: how_to_guides/migrate_from_legacy_datasets.md + - how_to_guides/index.md + - Manage users and credentials: how_to_guides/user.md + - Manage workspaces: how_to_guides/workspace.md + - Manage and create datasets: how_to_guides/dataset.md + - Add, update, and delete records: how_to_guides/record.md + - Query, filter, and export records: how_to_guides/query_export.md + - Migrate your legacy datasets to Argilla V2: how_to_guides/migrate_from_legacy_datasets.md - API Reference: - - Python SDK: reference/argilla/ + - Python SDK: reference/argilla/ - Community: - - community/index.md - - How to contribute?: community/contributor.md - - Issue dashboard: community/popular_issues.md - - Changelog: community/changelog.md + - community/index.md + - How to contribute?: community/contributor.md + - Issue dashboard: community/popular_issues.md + - Changelog: community/changelog.md - UI Demo ↗: - - https://demo.argilla.io/sign-in?auth=ZGVtbzoxMjM0NTY3OA== \ No newline at end of file + - https://demo.argilla.io/sign-in?auth=ZGVtbzoxMjM0NTY3OA== diff --git a/argilla/src/argilla/_models/_record/__init__.py b/argilla/src/argilla/_models/_record/__init__.py index 749d13b87d..20542d78f0 100644 --- a/argilla/src/argilla/_models/_record/__init__.py +++ b/argilla/src/argilla/_models/_record/__init__.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/argilla/src/argilla/_models/_settings/__init__.py b/argilla/src/argilla/_models/_settings/__init__.py index 749d13b87d..20542d78f0 100644 --- a/argilla/src/argilla/_models/_settings/__init__.py +++ b/argilla/src/argilla/_models/_settings/__init__.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/argilla/src/argilla/records/_search.py b/argilla/src/argilla/records/_search.py index 18666d4261..adc56b5750 100644 --- a/argilla/src/argilla/records/_search.py +++ b/argilla/src/argilla/records/_search.py @@ -78,13 +78,13 @@ class Filter: def __init__(self, conditions: Union[List[Tuple[str, str, Any]], Tuple[str, str, Any], None] = None): """ Create a filter object for use in Argilla search requests. - + Parameters: conditions (Union[List[Tuple[str, str, Any]], Tuple[str, str, Any], None], optional): \ The conditions that will be used to filter the search results. \ The conditions should be a list of tuples where each tuple contains \ the field, operator, and value. For example `("label", "in", ["positive","happy"])`.\ - + """ if isinstance(conditions, tuple): diff --git a/argilla/src/argilla/responses.py b/argilla/src/argilla/responses.py index ebe494923b..d27c1c0f5b 100644 --- a/argilla/src/argilla/responses.py +++ b/argilla/src/argilla/responses.py @@ -71,12 +71,12 @@ def __init__( def serialize(self) -> dict[str, Any]: """Serializes the Response to a dictionary. This is principally used for sending the response to the API, \ but can be used for data wrangling or manual export. - + Returns: dict[str, Any]: The serialized response as a dictionary with keys `question_name`, `value`, and `user_id`. - + Examples: - + ```python response = rg.Response("label", "negative", user_id=user.id) response.serialize() diff --git a/argilla/src/argilla/settings/_question.py b/argilla/src/argilla/settings/_question.py index 8edca4b765..77592976c9 100644 --- a/argilla/src/argilla/settings/_question.py +++ b/argilla/src/argilla/settings/_question.py @@ -87,10 +87,10 @@ def __init__( """ Define a new label question for `Settings` of a `Dataset`. A label \ question is a question where the user can select one label from \ a list of available labels. - + Parameters: name: str: The name of the question to be used as a reference. - labels: Union[List[str], Dict[str, str]]: The list of available labels for the question, + labels: Union[List[str], Dict[str, str]]: The list of available labels for the question, or a dictionary of key-value pairs where the key is the label and the value is the label text in the UI. title: Optional[str]: The title of the question to be shown in the UI. description: Optional[str]: The description of the question to be shown in the UI. @@ -159,7 +159,7 @@ def __init__( """Create a new multilabel question for `Settings` of a `Dataset`. A \ multilabel question is a question where the user can select multiple \ labels from a list of available labels. - + Parameters: name: str: The name of the question to be used as a reference. labels: List[str]: The list of available labels for the question. @@ -169,7 +169,7 @@ def __init__( description: Optional[str]: The description of the question to be shown in the UI. required: bool: If the question is required for a record to be valid. visible_labels: Optional[int]: The number of visible labels for the question. - labels_order: str: The order of the labels in the UI. Can be either "natural" or "suggestion". Default is "natural". + labels_order: str: The order of the labels in the UI. Can be either "natural" or "suggestion". Default is "natural". """ self._model = MultiLabelQuestionModel( name=name, @@ -213,7 +213,7 @@ def __init__( ) -> None: """Create a new text question for `Settings` of a `Dataset`. A text question \ is a question where the user can input text. - + Parameters: name: str: The name of the question to be used as a reference. title: Optional[str]: The title of the question to be shown in the UI. @@ -263,7 +263,7 @@ def __init__( ) -> None: """Create a new rating question for `Settings` of a `Dataset`. A rating question \ is a question where the user can select a value from a sequential list of options. - + Parameters: name: str: The name of the question to be used as a reference. values: List[int]: The list of available values for the question. @@ -314,7 +314,7 @@ def __init__( ) -> None: """Create a new ranking question for `Settings` of a `Dataset`. A ranking question \ is a question where the user can rank a list of options. - + Parameters: name: str: The name of the question to be used as a reference. values: List[str]: The list of available values for the question. @@ -368,7 +368,7 @@ def __init__( """ Create a new span question for `Settings` of a `Dataset`. A span question \ is a question where the user can select a section of text within a text field \ and assign it a label. - + Parameters: name: str: The name of the question to be used as a reference. field: str: The name of the text field to apply the span question to. diff --git a/docs/_source/conf.py b/docs/_source/conf.py index 2d77f7d298..48dbbe3cc6 100644 --- a/docs/_source/conf.py +++ b/docs/_source/conf.py @@ -83,8 +83,7 @@ "pipversion": "" if "dev" in release else "==" + release, "dockertag": "master" if "dev" in release else "v" + release, } -myst_substitutions["dockercomposeyaml"] = ( - """```yaml +myst_substitutions["dockercomposeyaml"] = """```yaml # docker-compose.yaml version: "3" @@ -97,12 +96,8 @@ ARGILLA_ELASTICSEARCH: ARGILLA_AUTH_SECRET_KEY: Please generate a 32 character random string with: openssl rand -hex 32 restart: unless-stopped -```""".format( - myst_substitutions["dockertag"] - ) -) -myst_substitutions["dockercomposeuseryaml"] = ( - """```yaml +```""".format(myst_substitutions["dockertag"]) +myst_substitutions["dockercomposeuseryaml"] = """```yaml # docker-compose.yaml services: argilla: @@ -118,10 +113,7 @@ # We mount the local file .users.yaml in remote container in path /config/.users.yaml - ${}/.users.yaml:/config/.users.yaml ... -```""".format( - myst_substitutions["dockertag"], "PWD" - ) -) +```""".format(myst_substitutions["dockertag"], "PWD") # Do not execute the notebooks when building the docs nbsphinx_execute = "never"