Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move Record and Response schemas to his own file and unify canonical schemas for them #4482

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ These are the section headers that we use:
- Restore filters from feedback dataset settings ([#4461])(https://github.com/argilla-io/argilla/pull/4461)
- Warning on feedback dataset settings when leaving page with unsaved changes ([#4461])(https://github.com/argilla-io/argilla/pull/4461)
- Added pydantic v2 support using the python SDK ([#4459](https://github.com/argilla-io/argilla/pull/4459))
- API v1 responses returning `Record` schema now always include `dataset_id` as attribute. ([#4482](https://github.com/argilla-io/argilla/pull/4482))
- API v1 responses returning `Response` schema now always include `record_id` as attribute. ([#4482](https://github.com/argilla-io/argilla/pull/4482))

## Changed
### Changed

- Module `argilla.cli.server` definitions have been moved to `argilla.server.cli` module. ([#4472](https://github.com/argilla-io/argilla/pull/4472))

Expand Down
4 changes: 2 additions & 2 deletions src/argilla/server/apis/v1/handlers/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from argilla.server.schemas.v1.datasets import (
Dataset,
DatasetCreate,
DatasetMetrics,
Datasets,
DatasetUpdate,
Field,
Expand All @@ -35,7 +36,6 @@
MetadataProperties,
MetadataProperty,
MetadataPropertyCreate,
Metrics,
Question,
QuestionCreate,
Questions,
Expand Down Expand Up @@ -175,7 +175,7 @@ async def get_dataset(
return dataset


@router.get("/me/datasets/{dataset_id}/metrics", response_model=Metrics)
@router.get("/me/datasets/{dataset_id}/metrics", response_model=DatasetMetrics)
async def get_current_user_dataset_metrics(
*, db: AsyncSession = Depends(get_async_db), dataset_id: UUID, current_user: User = Security(auth.get_current_user)
):
Expand Down
16 changes: 9 additions & 7 deletions src/argilla/server/apis/v1/handlers/datasets/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
MetadataQueryParams,
Order,
RangeFilter,
RecordFilterScope,
RecordIncludeParam,
Records,
RecordsCreate,
RecordsUpdate,
ResponseFilterScope,
SearchRecord,
SearchRecordsQuery,
SearchRecordsResult,
Expand All @@ -53,9 +47,17 @@
TermsFilter,
VectorSettings,
)
from argilla.server.schemas.v1.datasets import (
from argilla.server.schemas.v1.records import (
Record as RecordSchema,
frascuchon marked this conversation as resolved.
Show resolved Hide resolved
)
from argilla.server.schemas.v1.records import (
RecordFilterScope,
RecordIncludeParam,
Records,
RecordsCreate,
RecordsUpdate,
)
frascuchon marked this conversation as resolved.
Show resolved Hide resolved
from argilla.server.schemas.v1.responses import ResponseFilterScope
from argilla.server.search_engine import (
AndFilter,
FloatMetadataFilter,
Expand Down
12 changes: 5 additions & 7 deletions src/argilla/server/apis/v1/handlers/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@

from argilla.server.contexts import datasets
from argilla.server.database import get_async_db
from argilla.server.models import User
from argilla.server.models import Record, User
from argilla.server.policies import RecordPolicyV1, authorize
from argilla.server.schemas.v1.datasets import Record as RecordSchema
from argilla.server.schemas.v1.records import RecordUpdate, Response, ResponseCreate
from argilla.server.schemas.v1.records import Record as RecordSchema
from argilla.server.schemas.v1.records import RecordUpdate
from argilla.server.schemas.v1.responses import Response, ResponseCreate
from argilla.server.schemas.v1.suggestions import Suggestion, SuggestionCreate, Suggestions
from argilla.server.search_engine import SearchEngine, get_search_engine
from argilla.server.security import auth
from argilla.server.utils import parse_uuids

if TYPE_CHECKING:
from argilla.server.models import Record

DELETE_RECORD_SUGGESTIONS_LIMIT = 100

router = APIRouter(tags=["records"])
Expand All @@ -44,7 +42,7 @@ async def _get_record(
with_dataset: bool = False,
with_suggestions: bool = False,
with_vectors: bool = False,
) -> "Record":
) -> Record:
record = await datasets.get_record_by_id(db, record_id, with_dataset, with_suggestions, with_vectors)
if not record:
raise HTTPException(
Expand Down
20 changes: 13 additions & 7 deletions src/argilla/server/contexts/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,25 @@
FieldCreate,
MetadataPropertyCreate,
QuestionCreate,
)
from argilla.server.schemas.v1.datasets import (
VectorSettings as VectorSettingsSchema,
)
from argilla.server.schemas.v1.metadata_properties import MetadataPropertyUpdate
from argilla.server.schemas.v1.records import (
RecordCreate,
RecordIncludeParam,
RecordsCreate,
RecordsUpdate,
RecordUpdateWithId,
ResponseValueCreate,
)
from argilla.server.schemas.v1.datasets import (
VectorSettings as VectorSettingsSchema,
from argilla.server.schemas.v1.responses import (
ResponseCreate,
ResponseUpdate,
ResponseUpsert,
ResponseValueCreate,
ResponseValueUpdate,
)
from argilla.server.schemas.v1.metadata_properties import MetadataPropertyUpdate
from argilla.server.schemas.v1.records import ResponseCreate
from argilla.server.schemas.v1.responses import ResponseUpdate, ResponseUpsert, ResponseValueUpdate
from argilla.server.schemas.v1.vectors import Vector as VectorSchema
from argilla.server.search_engine import SearchEngine
from argilla.server.security.model import User
Expand All @@ -77,7 +84,6 @@

from argilla.server.schemas.v1.datasets import (
DatasetUpdate,
RecordsUpdate,
VectorSettingsCreate,
)
from argilla.server.schemas.v1.fields import FieldUpdate
Expand Down
4 changes: 2 additions & 2 deletions src/argilla/server/contexts/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
from argilla.server.schemas.v1.datasets import (
FilterScope,
MetadataFilterScope,
RecordFilterScope,
ResponseFilterScope,
SearchRecordsQuery,
SuggestionFilterScope,
)
from argilla.server.schemas.v1.records import RecordFilterScope
from argilla.server.schemas.v1.responses import ResponseFilterScope


class SearchRecordsQueryValidator:
Expand Down
Loading