diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c20275b34..9978f5609e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ These are the section headers that we use: ## Changed - Module `argilla.cli.server` definitions have been moved to `argilla.server.cli` module. ([#4472](https://github.com/argilla-io/argilla/pull/4472)) +- The constant definition `ES_INDEX_REGEX_PATTERN` in module `argilla._constants` is now private. ([#4472](https://github.com/argilla-io/argilla/pull/4474)) ### Deprecated diff --git a/src/argilla/_constants.py b/src/argilla/_constants.py index 9a8e7a15da..e8cf15a9ee 100644 --- a/src/argilla/_constants.py +++ b/src/argilla/_constants.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +_ES_INDEX_REGEX_PATTERN = r"^(?!-|_)[a-z0-9-_]+$" + API_KEY_HEADER_NAME = "X-Argilla-Api-Key" WORKSPACE_HEADER_NAME = "X-Argilla-Workspace" @@ -21,17 +23,12 @@ DEFAULT_API_URL = "http://localhost:6900" DEFAULT_API_KEY = "argilla.apikey" DEFAULT_MAX_KEYWORD_LENGTH = 128 -DEFAULT_TELEMETRY_KEY = "C6FkcaoCbt78rACAgvyBxGBcMB3dM3nn" - -# The metadata field name prefix defined for protected (non-searchable) values -PROTECTED_METADATA_FIELD_PREFIX = "_" -ES_INDEX_REGEX_PATTERN = r"^(?!-|_)[a-z0-9-_]+$" +DATASET_NAME_REGEX_PATTERN = _ES_INDEX_REGEX_PATTERN +WORKSPACE_NAME_REGEX_PATTERN = _ES_INDEX_REGEX_PATTERN # constants for prepare_for_training(framework="openai") OPENAI_SEPARATOR = "\n\n###\n\n" OPENAI_END_TOKEN = " END" OPENAI_WHITESPACE = " " OPENAI_LEGACY_MODELS = ["babbage", "davinci", "curie", "ada"] - -_JS_MAX_SAFE_INTEGER = 9007199254740991 diff --git a/src/argilla/client/client.py b/src/argilla/client/client.py index e9cad1af72..59adc45e73 100644 --- a/src/argilla/client/client.py +++ b/src/argilla/client/client.py @@ -26,11 +26,12 @@ from rich.progress import Progress from argilla._constants import ( + DATASET_NAME_REGEX_PATTERN, DEFAULT_API_KEY, DEFAULT_API_URL, DEFAULT_USERNAME, - ES_INDEX_REGEX_PATTERN, WORKSPACE_HEADER_NAME, + WORKSPACE_NAME_REGEX_PATTERN, ) from argilla.client.apis.datasets import Datasets from argilla.client.apis.metrics import MetricsAPI @@ -58,8 +59,13 @@ from argilla.client.sdk.datasets.models import Dataset as DatasetModel from argilla.client.sdk.metrics import api as metrics_api from argilla.client.sdk.metrics.models import MetricInfo -from argilla.client.sdk.text2text.models import CreationText2TextRecord, Text2TextBulkData -from argilla.client.sdk.text2text.models import Text2TextRecord as SdkText2TextRecord +from argilla.client.sdk.text2text.models import ( + CreationText2TextRecord, + Text2TextBulkData, +) +from argilla.client.sdk.text2text.models import ( + Text2TextRecord as SdkText2TextRecord, +) from argilla.client.sdk.text_classification import api as text_classification_api from argilla.client.sdk.text_classification.models import ( CreationTextClassificationRecord, @@ -67,12 +73,16 @@ LabelingRuleMetricsSummary, TextClassificationBulkData, ) -from argilla.client.sdk.text_classification.models import TextClassificationRecord as SdkTextClassificationRecord +from argilla.client.sdk.text_classification.models import ( + TextClassificationRecord as SdkTextClassificationRecord, +) from argilla.client.sdk.token_classification.models import ( CreationTokenClassificationRecord, TokenClassificationBulkData, ) -from argilla.client.sdk.token_classification.models import TokenClassificationRecord as SdkTokenClassificationRecord +from argilla.client.sdk.token_classification.models import ( + TokenClassificationRecord as SdkTokenClassificationRecord, +) from argilla.client.sdk.users import api as users_api from argilla.client.sdk.v1.workspaces import api as workspaces_api_v1 from argilla.client.sdk.v1.workspaces.models import WorkspaceModel @@ -238,10 +248,10 @@ def set_workspace(self, workspace: str): if not workspace: raise Exception("Must provide a workspace") - if not re.match(ES_INDEX_REGEX_PATTERN, workspace): + if not re.match(WORKSPACE_NAME_REGEX_PATTERN, workspace): raise InputValueError( f"Provided workspace name {workspace} does not match the pattern" - f" {ES_INDEX_REGEX_PATTERN}. Please, use a valid name for your" + f" {WORKSPACE_NAME_REGEX_PATTERN}. Please, use a valid name for your" " workspace. This limitation is caused by naming conventions for indexes" " in Elasticsearch. If applicable, you can try to lowercase the name of your workspace." " https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html" @@ -392,10 +402,10 @@ def log( if not name: raise InputValueError("Empty dataset name has been passed as argument.") - if not re.match(ES_INDEX_REGEX_PATTERN, name): + if not re.match(DATASET_NAME_REGEX_PATTERN, name): raise InputValueError( f"Provided dataset name {name} does not match the pattern" - f" {ES_INDEX_REGEX_PATTERN}. Please, use a valid name for your" + f" {DATASET_NAME_REGEX_PATTERN}. Please, use a valid name for your" " dataset. This limitation is caused by naming conventions for indexes" " in Elasticsearch." " https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html" diff --git a/src/argilla/client/models.py b/src/argilla/client/models.py index 8e7773b2dd..ba54417e6b 100644 --- a/src/argilla/client/models.py +++ b/src/argilla/client/models.py @@ -27,7 +27,7 @@ from deprecated import deprecated from argilla import _messages -from argilla._constants import _JS_MAX_SAFE_INTEGER, DEFAULT_MAX_KEYWORD_LENGTH, PROTECTED_METADATA_FIELD_PREFIX +from argilla._constants import DEFAULT_MAX_KEYWORD_LENGTH from argilla.pydantic_v1 import BaseModel, Field, PrivateAttr, root_validator, validator from argilla.utils.span_utils import SpanUtils @@ -91,6 +91,11 @@ def __str__(self) -> str: class _Validators(BaseModel): """Base class for our record models that takes care of general validations""" + # The metadata field name prefix defined for protected (non-searchable) values + _PROTECTED_METADATA_FIELD_PREFIX = "_" + + _JS_MAX_SAFE_INTEGER = 9007199254740991 + @validator("metadata", check_fields=False) def _check_value_length(cls, metadata): """Checks metadata values length and warn message for large values""" @@ -99,7 +104,7 @@ def _check_value_length(cls, metadata): default_length_exceeded = False for k, v in metadata.items(): - if k.startswith(PROTECTED_METADATA_FIELD_PREFIX): + if k.startswith(cls._PROTECTED_METADATA_FIELD_PREFIX): continue if isinstance(v, str) and len(v) > DEFAULT_MAX_KEYWORD_LENGTH: default_length_exceeded = True @@ -134,7 +139,7 @@ def _normalize_id(cls, v): ) warnings.warn(message, DeprecationWarning, stacklevel=2) # See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER - if v > _JS_MAX_SAFE_INTEGER: + if v > cls._JS_MAX_SAFE_INTEGER: message = ( "You've provided a big integer value. Use a string instead, otherwise you may experience some " "problems using the UI. See " diff --git a/src/argilla/server/apis/v0/models/commons/params.py b/src/argilla/server/apis/v0/models/commons/params.py index 4596339472..09f44875e5 100644 --- a/src/argilla/server/apis/v0/models/commons/params.py +++ b/src/argilla/server/apis/v0/models/commons/params.py @@ -16,7 +16,7 @@ from fastapi import Header, Path, Query -from argilla._constants import ES_INDEX_REGEX_PATTERN, WORKSPACE_HEADER_NAME +from argilla.server.constants import ES_INDEX_REGEX_PATTERN, WORKSPACE_HEADER_NAME from argilla.server.errors import BadRequestError, MissingInputParamError DATASET_NAME_PATH_PARAM = Path(..., regex=ES_INDEX_REGEX_PATTERN, description="The dataset name") diff --git a/src/argilla/server/app.py b/src/argilla/server/app.py index bf9b414b39..4d1abdf9cb 100644 --- a/src/argilla/server/app.py +++ b/src/argilla/server/app.py @@ -29,9 +29,9 @@ from starlette.responses import RedirectResponse from argilla import __version__ as argilla_version -from argilla._constants import DEFAULT_API_KEY, DEFAULT_PASSWORD, DEFAULT_USERNAME from argilla.logging import configure_logging from argilla.server import helpers +from argilla.server.constants import DEFAULT_API_KEY, DEFAULT_PASSWORD, DEFAULT_USERNAME from argilla.server.contexts import accounts from argilla.server.daos.backend import GenericElasticEngineBackend from argilla.server.daos.backend.base import GenericSearchError diff --git a/src/argilla/server/constants.py b/src/argilla/server/constants.py new file mode 100644 index 0000000000..97425cd532 --- /dev/null +++ b/src/argilla/server/constants.py @@ -0,0 +1,30 @@ +# Copyright 2021-present, the Recognai S.L. team. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +API_KEY_HEADER_NAME = "X-Argilla-Api-Key" +WORKSPACE_HEADER_NAME = "X-Argilla-Workspace" + +DEFAULT_USERNAME = "argilla" +DEFAULT_PASSWORD = "1234" +DEFAULT_API_KEY = "argilla.apikey" + +DEFAULT_MAX_KEYWORD_LENGTH = 128 +DEFAULT_TELEMETRY_KEY = "C6FkcaoCbt78rACAgvyBxGBcMB3dM3nn" + +# The metadata field name prefix defined for protected (non-searchable) values +PROTECTED_METADATA_FIELD_PREFIX = "_" + +ES_INDEX_REGEX_PATTERN = r"^(?!-|_)[a-z0-9-_]+$" + +JS_MAX_SAFE_INTEGER = 9007199254740991 diff --git a/src/argilla/server/daos/backend/generic_elastic.py b/src/argilla/server/daos/backend/generic_elastic.py index 410eec922c..c9c53a6f30 100644 --- a/src/argilla/server/daos/backend/generic_elastic.py +++ b/src/argilla/server/daos/backend/generic_elastic.py @@ -14,9 +14,9 @@ from typing import Any, Dict, Iterable, List, Optional, Tuple -from argilla._constants import PROTECTED_METADATA_FIELD_PREFIX from argilla.logging import LoggingMixin from argilla.server.commons.models import TaskType +from argilla.server.constants import PROTECTED_METADATA_FIELD_PREFIX from argilla.server.daos.backend.base import IndexNotFoundError, InvalidSearchError from argilla.server.daos.backend.client_adapters.base import IClientAdapter from argilla.server.daos.backend.client_adapters.factory import ClientAdapterFactory diff --git a/src/argilla/server/daos/models/datasets.py b/src/argilla/server/daos/models/datasets.py index b26f77dce5..5836b29cbf 100644 --- a/src/argilla/server/daos/models/datasets.py +++ b/src/argilla/server/daos/models/datasets.py @@ -15,8 +15,8 @@ from datetime import datetime from typing import Any, Dict, Optional, TypeVar, Union -from argilla._constants import ES_INDEX_REGEX_PATTERN from argilla.server.commons.models import TaskType +from argilla.server.constants import ES_INDEX_REGEX_PATTERN from argilla.server.pydantic_v1 import BaseModel, Field, root_validator diff --git a/src/argilla/server/daos/models/records.py b/src/argilla/server/daos/models/records.py index b5aaf1f133..fa9b58d982 100644 --- a/src/argilla/server/daos/models/records.py +++ b/src/argilla/server/daos/models/records.py @@ -19,8 +19,8 @@ from typing import Any, Dict, Generic, List, Optional, TypeVar, Union from argilla import _messages -from argilla._constants import _JS_MAX_SAFE_INTEGER, PROTECTED_METADATA_FIELD_PREFIX from argilla.server.commons.models import PredictionStatus, TaskStatus, TaskType +from argilla.server.constants import JS_MAX_SAFE_INTEGER, PROTECTED_METADATA_FIELD_PREFIX from argilla.server.daos.backend.search.model import BaseRecordsQuery, SortConfig from argilla.server.helpers import flatten_dict from argilla.server.pydantic_v1 import BaseModel, Field, conint, constr, root_validator, validator @@ -127,7 +127,7 @@ def _normalize_id(cls, v): ) warnings.warn(message, DeprecationWarning) # See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER - if v > _JS_MAX_SAFE_INTEGER: + if v > JS_MAX_SAFE_INTEGER: message = ( "You've provided a big integer value. Use a string instead, otherwise you may experience some " "problems using the UI. See " diff --git a/src/argilla/server/schemas/v0/datasets.py b/src/argilla/server/schemas/v0/datasets.py index 49db6276c8..8a2294020b 100644 --- a/src/argilla/server/schemas/v0/datasets.py +++ b/src/argilla/server/schemas/v0/datasets.py @@ -20,8 +20,8 @@ from typing import Any, Dict, Optional, Union from uuid import UUID -from argilla._constants import ES_INDEX_REGEX_PATTERN from argilla.server.commons.models import TaskType +from argilla.server.constants import ES_INDEX_REGEX_PATTERN from argilla.server.pydantic_v1 import BaseModel, Field diff --git a/src/argilla/server/security/auth_provider/base.py b/src/argilla/server/security/auth_provider/base.py index 3ae97637bd..becb31b81b 100644 --- a/src/argilla/server/security/auth_provider/base.py +++ b/src/argilla/server/security/auth_provider/base.py @@ -18,7 +18,7 @@ from fastapi import Depends, FastAPI, Request from fastapi.security import APIKeyHeader, SecurityScopes -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User api_key_header = APIKeyHeader(name=API_KEY_HEADER_NAME, auto_error=False) diff --git a/src/argilla/server/security/model.py b/src/argilla/server/security/model.py index 05a2408774..84c7779a59 100644 --- a/src/argilla/server/security/model.py +++ b/src/argilla/server/security/model.py @@ -16,7 +16,7 @@ from typing import Any, List, Optional from uuid import UUID -from argilla._constants import ES_INDEX_REGEX_PATTERN +from argilla.server.constants import ES_INDEX_REGEX_PATTERN from argilla.server.models import UserRole from argilla.server.pydantic_v1 import BaseModel, Field, constr from argilla.server.pydantic_v1.utils import GetterDict diff --git a/src/argilla/server/services/tasks/text_classification/model.py b/src/argilla/server/services/tasks/text_classification/model.py index d4495d3717..dad087ab6c 100644 --- a/src/argilla/server/services/tasks/text_classification/model.py +++ b/src/argilla/server/services/tasks/text_classification/model.py @@ -16,8 +16,8 @@ from datetime import datetime from typing import Any, ClassVar, Dict, List, Optional, Union -from argilla._constants import DEFAULT_MAX_KEYWORD_LENGTH from argilla.server.commons.models import PredictionStatus, TaskStatus, TaskType +from argilla.server.constants import DEFAULT_MAX_KEYWORD_LENGTH from argilla.server.helpers import flatten_dict from argilla.server.pydantic_v1 import BaseModel, Field, root_validator, validator from argilla.server.services.datasets import ServiceBaseDataset diff --git a/src/argilla/server/services/tasks/token_classification/model.py b/src/argilla/server/services/tasks/token_classification/model.py index 5cd594b91b..95a84aead1 100644 --- a/src/argilla/server/services/tasks/token_classification/model.py +++ b/src/argilla/server/services/tasks/token_classification/model.py @@ -15,8 +15,8 @@ from typing import Dict, List, Optional, Set, Tuple -from argilla._constants import DEFAULT_MAX_KEYWORD_LENGTH from argilla.server.commons.models import PredictionStatus, TaskType +from argilla.server.constants import DEFAULT_MAX_KEYWORD_LENGTH from argilla.server.pydantic_v1 import BaseModel, Field, validator from argilla.server.services.search.model import ServiceBaseRecordsQuery, ServiceScoreRange from argilla.server.services.tasks.commons import ServiceBaseAnnotation, ServiceBaseRecord diff --git a/src/argilla/server/settings.py b/src/argilla/server/settings.py index 7f56b21879..3ad05a4df7 100644 --- a/src/argilla/server/settings.py +++ b/src/argilla/server/settings.py @@ -24,7 +24,7 @@ from typing import List, Optional from urllib.parse import urlparse -from argilla._constants import DEFAULT_MAX_KEYWORD_LENGTH, DEFAULT_TELEMETRY_KEY +from argilla.server.constants import DEFAULT_MAX_KEYWORD_LENGTH, DEFAULT_TELEMETRY_KEY from argilla.server.pydantic_v1 import BaseSettings, Field, root_validator, validator diff --git a/src/argilla/utils/telemetry.py b/src/argilla/utils/telemetry.py index 8ade83f0a2..7e7a228ace 100644 --- a/src/argilla/utils/telemetry.py +++ b/src/argilla/utils/telemetry.py @@ -18,7 +18,6 @@ import uuid from typing import TYPE_CHECKING, Any, Dict, Optional -from argilla._constants import DEFAULT_TELEMETRY_KEY from argilla.pydantic_v1 import BaseSettings if TYPE_CHECKING: @@ -27,6 +26,9 @@ from argilla.server.commons.models import TaskType +_DEFAULT_TELEMETRY_KEY = "C6FkcaoCbt78rACAgvyBxGBcMB3dM3nn" + + class TelemetrySettings(BaseSettings): """ Telemetry settings @@ -35,7 +37,7 @@ class TelemetrySettings(BaseSettings): """ enable_telemetry: bool = True - telemetry_key: str = DEFAULT_TELEMETRY_KEY + telemetry_key: str = _DEFAULT_TELEMETRY_KEY class Config: env_prefix = "ARGILLA_" diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index 50c64d167e..227c8e0f4e 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -14,8 +14,6 @@ from argilla._constants import ( API_KEY_HEADER_NAME, - DEFAULT_API_KEY, - DEFAULT_USERNAME, WORKSPACE_HEADER_NAME, ) from argilla.server.models import User diff --git a/tests/unit/server/api/v0/test_datasets.py b/tests/unit/server/api/v0/test_datasets.py index 22b0f7744d..730b8e9842 100644 --- a/tests/unit/server/api/v0/test_datasets.py +++ b/tests/unit/server/api/v0/test_datasets.py @@ -15,9 +15,9 @@ from typing import Any, Dict, List import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v0.models.text_classification import TextClassificationBulkRequest from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import UserRole from argilla.server.schemas.v0.datasets import Dataset diff --git a/tests/unit/server/api/v0/test_metrics.py b/tests/unit/server/api/v0/test_metrics.py index 58d689a9c7..343804e27d 100644 --- a/tests/unit/server/api/v0/test_metrics.py +++ b/tests/unit/server/api/v0/test_metrics.py @@ -15,7 +15,6 @@ from typing import TYPE_CHECKING import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v0.models.text2text import ( Text2TextBulkRequest, Text2TextRecord, @@ -29,6 +28,7 @@ TokenClassificationRecord, ) from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User, UserRole from argilla.server.services.metrics.models import CommonTasksMetrics from argilla.server.services.tasks.text_classification.metrics import TextClassificationMetrics diff --git a/tests/unit/server/api/v0/test_records_update.py b/tests/unit/server/api/v0/test_records_update.py index b8da692448..8d93aefca2 100644 --- a/tests/unit/server/api/v0/test_records_update.py +++ b/tests/unit/server/api/v0/test_records_update.py @@ -14,11 +14,11 @@ from typing import TYPE_CHECKING import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v0.models.text2text import Text2TextBulkRequest, Text2TextRecord, Text2TextRecordInputs from argilla.server.apis.v0.models.text_classification import TextClassificationBulkRequest, TextClassificationRecord from argilla.server.apis.v0.models.token_classification import TokenClassificationBulkRequest, TokenClassificationRecord from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User, UserRole from tests.factories import UserFactory, WorkspaceFactory diff --git a/tests/unit/server/api/v0/test_text2text.py b/tests/unit/server/api/v0/test_text2text.py index 6ea6ab84ca..4adbcb74e6 100644 --- a/tests/unit/server/api/v0/test_text2text.py +++ b/tests/unit/server/api/v0/test_text2text.py @@ -14,7 +14,6 @@ from typing import TYPE_CHECKING, List, Optional import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v0.models.commons.model import BulkResponse from argilla.server.apis.v0.models.text2text import ( Text2TextBulkRequest, @@ -22,6 +21,7 @@ Text2TextSearchResults, ) from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User if TYPE_CHECKING: diff --git a/tests/unit/server/api/v0/test_text_classification.py b/tests/unit/server/api/v0/test_text_classification.py index c4024aa0f9..2694ba6bd4 100644 --- a/tests/unit/server/api/v0/test_text_classification.py +++ b/tests/unit/server/api/v0/test_text_classification.py @@ -17,7 +17,6 @@ from typing import TYPE_CHECKING import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v0.models.commons.model import BulkResponse from argilla.server.apis.v0.models.text_classification import ( TextClassificationAnnotation, @@ -28,6 +27,7 @@ TextClassificationSearchResults, ) from argilla.server.commons.models import PredictionStatus, TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User from argilla.server.schemas.v0.datasets import Dataset diff --git a/tests/unit/server/api/v0/test_text_classification_api_rules.py b/tests/unit/server/api/v0/test_text_classification_api_rules.py index cddebb11a6..68dcb757e8 100644 --- a/tests/unit/server/api/v0/test_text_classification_api_rules.py +++ b/tests/unit/server/api/v0/test_text_classification_api_rules.py @@ -14,7 +14,6 @@ from typing import TYPE_CHECKING import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v0.models.text_classification import ( CreateLabelingRule, LabelingRule, @@ -23,6 +22,7 @@ TextClassificationRecord, ) from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User if TYPE_CHECKING: diff --git a/tests/unit/server/api/v0/test_text_classification_dataset_settings.py b/tests/unit/server/api/v0/test_text_classification_dataset_settings.py index 3b054d24a5..5ca999a9fa 100644 --- a/tests/unit/server/api/v0/test_text_classification_dataset_settings.py +++ b/tests/unit/server/api/v0/test_text_classification_dataset_settings.py @@ -14,8 +14,8 @@ from typing import TYPE_CHECKING, Any, Optional import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User from tests.factories import AnnotatorFactory, WorkspaceFactory diff --git a/tests/unit/server/api/v0/test_token_classification.py b/tests/unit/server/api/v0/test_token_classification.py index 56f4605b84..8d42a4a0fd 100644 --- a/tests/unit/server/api/v0/test_token_classification.py +++ b/tests/unit/server/api/v0/test_token_classification.py @@ -16,7 +16,6 @@ import pytest from argilla import User -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v0.models.commons.model import BulkResponse, SortableField from argilla.server.apis.v0.models.token_classification import ( TokenClassificationBulkRequest, @@ -26,6 +25,7 @@ TokenClassificationSearchResults, ) from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME @pytest.mark.asyncio diff --git a/tests/unit/server/api/v0/test_token_classification_dataset_settings.py b/tests/unit/server/api/v0/test_token_classification_dataset_settings.py index 206b960612..aff1ca4e6c 100644 --- a/tests/unit/server/api/v0/test_token_classification_dataset_settings.py +++ b/tests/unit/server/api/v0/test_token_classification_dataset_settings.py @@ -14,9 +14,9 @@ from typing import TYPE_CHECKING, Optional import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.client.api import delete from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User if TYPE_CHECKING: diff --git a/tests/unit/server/api/v0/test_users.py b/tests/unit/server/api/v0/test_users.py index 73327e25a7..ae34b61124 100644 --- a/tests/unit/server/api/v0/test_users.py +++ b/tests/unit/server/api/v0/test_users.py @@ -16,7 +16,7 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User, UserRole from fastapi.testclient import TestClient from sqlalchemy import func, select diff --git a/tests/unit/server/api/v0/test_workspaces.py b/tests/unit/server/api/v0/test_workspaces.py index 57109d5390..27ca96ee25 100644 --- a/tests/unit/server/api/v0/test_workspaces.py +++ b/tests/unit/server/api/v0/test_workspaces.py @@ -16,7 +16,7 @@ from uuid import UUID, uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import User, Workspace, WorkspaceUser from fastapi.testclient import TestClient from sqlalchemy import func, select diff --git a/tests/unit/server/api/v1/datasets/test_list_dataset_records_search_suggestions_options.py b/tests/unit/server/api/v1/datasets/test_list_dataset_records_search_suggestions_options.py index 51cac75ec1..e96dfa0c5b 100644 --- a/tests/unit/server/api/v1/datasets/test_list_dataset_records_search_suggestions_options.py +++ b/tests/unit/server/api/v1/datasets/test_list_dataset_records_search_suggestions_options.py @@ -15,7 +15,7 @@ from uuid import UUID, uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from httpx import AsyncClient from tests.factories import ( diff --git a/tests/unit/server/api/v1/datasets/test_search_dataset_records.py b/tests/unit/server/api/v1/datasets/test_search_dataset_records.py index 8efb72708e..754491c237 100644 --- a/tests/unit/server/api/v1/datasets/test_search_dataset_records.py +++ b/tests/unit/server/api/v1/datasets/test_search_dataset_records.py @@ -15,8 +15,8 @@ from uuid import UUID, uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v1.handlers.datasets.records import LIST_DATASET_RECORDS_LIMIT_LE +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.enums import RecordInclude, SortOrder from argilla.server.search_engine import ( AndFilter, diff --git a/tests/unit/server/api/v1/responses/test_create_current_user_responses_bulk.py b/tests/unit/server/api/v1/responses/test_create_current_user_responses_bulk.py index 578a50dd7c..7713923460 100644 --- a/tests/unit/server/api/v1/responses/test_create_current_user_responses_bulk.py +++ b/tests/unit/server/api/v1/responses/test_create_current_user_responses_bulk.py @@ -17,7 +17,7 @@ from uuid import UUID, uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.enums import ResponseStatus from argilla.server.models import Response, User from argilla.server.search_engine import SearchEngine diff --git a/tests/unit/server/api/v1/test_datasets.py b/tests/unit/server/api/v1/test_datasets.py index c3bf220040..e6afb432bc 100644 --- a/tests/unit/server/api/v1/test_datasets.py +++ b/tests/unit/server/api/v1/test_datasets.py @@ -18,8 +18,8 @@ from uuid import UUID, uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v1.handlers.datasets.records import LIST_DATASET_RECORDS_LIMIT_DEFAULT +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.enums import ( DatasetStatus, RecordInclude, diff --git a/tests/unit/server/api/v1/test_fields.py b/tests/unit/server/api/v1/test_fields.py index d70e32ca3b..ae0e36ec0b 100644 --- a/tests/unit/server/api/v1/test_fields.py +++ b/tests/unit/server/api/v1/test_fields.py @@ -17,7 +17,7 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import DatasetStatus, Field, UserRole from argilla.server.schemas.v1.datasets import FIELD_CREATE_TITLE_MAX_LENGTH from sqlalchemy import func, select diff --git a/tests/unit/server/api/v1/test_list_dataset_records.py b/tests/unit/server/api/v1/test_list_dataset_records.py index 674f2416f3..80f4d57567 100644 --- a/tests/unit/server/api/v1/test_list_dataset_records.py +++ b/tests/unit/server/api/v1/test_list_dataset_records.py @@ -16,8 +16,8 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.apis.v1.handlers.datasets.records import LIST_DATASET_RECORDS_LIMIT_DEFAULT +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.enums import RecordInclude, RecordSortField, ResponseStatus, UserRole from argilla.server.models import Dataset, Question, Record, Response, Suggestion, User, Workspace from argilla.server.search_engine import ( diff --git a/tests/unit/server/api/v1/test_metadata_properties.py b/tests/unit/server/api/v1/test_metadata_properties.py index 89b79d35e5..216bb1269f 100644 --- a/tests/unit/server/api/v1/test_metadata_properties.py +++ b/tests/unit/server/api/v1/test_metadata_properties.py @@ -17,7 +17,7 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.enums import MetadataPropertyType, UserRole from argilla.server.models import MetadataProperty, UserRole from argilla.server.schemas.v1.datasets import METADATA_PROPERTY_CREATE_TITLE_MAX_LENGTH diff --git a/tests/unit/server/api/v1/test_questions.py b/tests/unit/server/api/v1/test_questions.py index e7ba614c0f..2be2c6b668 100644 --- a/tests/unit/server/api/v1/test_questions.py +++ b/tests/unit/server/api/v1/test_questions.py @@ -16,7 +16,7 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import DatasetStatus, Question, UserRole from argilla.server.schemas.v1.datasets import QUESTION_CREATE_DESCRIPTION_MAX_LENGTH, QUESTION_CREATE_TITLE_MAX_LENGTH from sqlalchemy import func, select diff --git a/tests/unit/server/api/v1/test_records.py b/tests/unit/server/api/v1/test_records.py index 2a031afbcc..9c0c27db2e 100644 --- a/tests/unit/server/api/v1/test_records.py +++ b/tests/unit/server/api/v1/test_records.py @@ -18,7 +18,7 @@ from uuid import UUID, uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +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 diff --git a/tests/unit/server/api/v1/test_responses.py b/tests/unit/server/api/v1/test_responses.py index 85e6efa998..d9db537ead 100644 --- a/tests/unit/server/api/v1/test_responses.py +++ b/tests/unit/server/api/v1/test_responses.py @@ -17,7 +17,7 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import DatasetStatus, Response, ResponseStatus, UserRole from argilla.server.search_engine import SearchEngine from sqlalchemy import func, select diff --git a/tests/unit/server/api/v1/test_suggestions.py b/tests/unit/server/api/v1/test_suggestions.py index e2f33020e1..d65e5715b0 100644 --- a/tests/unit/server/api/v1/test_suggestions.py +++ b/tests/unit/server/api/v1/test_suggestions.py @@ -16,7 +16,7 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import Suggestion, UserRole from argilla.server.search_engine import SearchEngine from sqlalchemy import func, select diff --git a/tests/unit/server/api/v1/test_users.py b/tests/unit/server/api/v1/test_users.py index 38766a8dc7..687dfbf566 100644 --- a/tests/unit/server/api/v1/test_users.py +++ b/tests/unit/server/api/v1/test_users.py @@ -16,7 +16,7 @@ from typing import TYPE_CHECKING import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import UserRole from tests.factories import UserFactory, WorkspaceFactory diff --git a/tests/unit/server/api/v1/test_vectors_settings.py b/tests/unit/server/api/v1/test_vectors_settings.py index 638a1b073a..0ee34ef238 100644 --- a/tests/unit/server/api/v1/test_vectors_settings.py +++ b/tests/unit/server/api/v1/test_vectors_settings.py @@ -16,7 +16,7 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.enums import UserRole from argilla.server.schemas.v1.datasets import VECTOR_SETTINGS_CREATE_TITLE_MAX_LENGTH diff --git a/tests/unit/server/api/v1/test_workspaces.py b/tests/unit/server/api/v1/test_workspaces.py index 278a88d08b..4b53296009 100644 --- a/tests/unit/server/api/v1/test_workspaces.py +++ b/tests/unit/server/api/v1/test_workspaces.py @@ -15,8 +15,8 @@ from uuid import uuid4 import pytest -from argilla._constants import API_KEY_HEADER_NAME from argilla.server.commons.models import TaskType +from argilla.server.constants import API_KEY_HEADER_NAME from argilla.server.models import UserRole from tests.factories import AnnotatorFactory, DatasetFactory, UserFactory, WorkspaceFactory diff --git a/tests/unit/server/cli/database/users/test_create_default.py b/tests/unit/server/cli/database/users/test_create_default.py index 5682e1dc7a..df7fade0d9 100644 --- a/tests/unit/server/cli/database/users/test_create_default.py +++ b/tests/unit/server/cli/database/users/test_create_default.py @@ -13,7 +13,7 @@ # limitations under the License. from typing import TYPE_CHECKING -from argilla._constants import DEFAULT_API_KEY, DEFAULT_PASSWORD, DEFAULT_USERNAME +from argilla.server.constants import DEFAULT_API_KEY, DEFAULT_PASSWORD, DEFAULT_USERNAME from argilla.server.contexts import accounts from argilla.server.models import User, UserRole diff --git a/tests/unit/server/conftest.py b/tests/unit/server/conftest.py index 60614ce3ec..8537008721 100644 --- a/tests/unit/server/conftest.py +++ b/tests/unit/server/conftest.py @@ -17,7 +17,7 @@ import pytest import pytest_asyncio -from argilla._constants import API_KEY_HEADER_NAME, DEFAULT_API_KEY +from argilla.server.constants import API_KEY_HEADER_NAME, DEFAULT_API_KEY from argilla.server.daos.backend import GenericElasticEngineBackend from argilla.server.daos.datasets import DatasetsDAO from argilla.server.daos.records import DatasetRecordsDAO diff --git a/tests/unit/server/models/old_models/test_text_classification.py b/tests/unit/server/models/old_models/test_text_classification.py index d6812a4187..12b56e5f9d 100644 --- a/tests/unit/server/models/old_models/test_text_classification.py +++ b/tests/unit/server/models/old_models/test_text_classification.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import pytest -from argilla._constants import DEFAULT_MAX_KEYWORD_LENGTH from argilla.server.apis.v0.models.text_classification import ( TextClassificationAnnotation, TextClassificationQuery, @@ -156,7 +155,7 @@ def test_too_long_metadata(): } ) - assert len(record.metadata["too_long"]) == DEFAULT_MAX_KEYWORD_LENGTH + assert len(record.metadata["too_long"]) == 128 def test_too_long_label(): diff --git a/tests/unit/server/models/old_models/test_token_classification.py b/tests/unit/server/models/old_models/test_token_classification.py index 8cd7e751a4..64c0062d36 100644 --- a/tests/unit/server/models/old_models/test_token_classification.py +++ b/tests/unit/server/models/old_models/test_token_classification.py @@ -14,7 +14,6 @@ # limitations under the License. import pytest -from argilla._constants import DEFAULT_MAX_KEYWORD_LENGTH from argilla.server.apis.v0.models.token_classification import ( TokenClassificationAnnotation, TokenClassificationQuery, @@ -151,7 +150,7 @@ def test_too_long_metadata(): } ) - assert len(record.metadata["too_long"]) == DEFAULT_MAX_KEYWORD_LENGTH + assert len(record.metadata["too_long"]) == 128 def test_entity_label_too_long(): diff --git a/tests/unit/server/security/test_provider.py b/tests/unit/server/security/test_provider.py index 7cd7a589bb..9b8020b4a0 100644 --- a/tests/unit/server/security/test_provider.py +++ b/tests/unit/server/security/test_provider.py @@ -15,7 +15,7 @@ from typing import TYPE_CHECKING import pytest -from argilla._constants import DEFAULT_API_KEY +from argilla.server.constants import DEFAULT_API_KEY from argilla.server.security.auth_provider.db import DBAuthProvider from fastapi.security import SecurityScopes