Skip to content

Commit

Permalink
chore: move webhooks folder outside api folder (#5493)
Browse files Browse the repository at this point in the history
# Description

As discussed this PR is moving `webhooks` folder outside `api` folder.
Now that we have specific schemas for webhooks it does not have much
sense to have this code inside the `api` folder.

Refs #1836 

**Type of change**

- Refactor (change restructuring the codebase without changing
functionality)

**How Has This Been Tested**

- [x] Running test suite.

**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
- I confirm My changes generate no new warnings
- I have added tests that prove my fix is effective or that my feature
works
- I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)
  • Loading branch information
jfcalvo committed Sep 16, 2024
1 parent 48a0dfe commit 3fb3d66
Show file tree
Hide file tree
Showing 23 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from argilla_server.database import get_async_db
from argilla_server.api.policies.v1 import WebhookPolicy, authorize
from argilla_server.api.webhooks.v1.ping import notify_ping_event
from argilla_server.webhooks.v1.ping import notify_ping_event
from argilla_server.security import auth
from argilla_server.models import User
from argilla_server.api.schemas.v1.webhooks import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import List, Optional
from uuid import UUID

from argilla_server.api.webhooks.v1.enums import WebhookEvent
from argilla_server.webhooks.v1.enums import WebhookEvent
from argilla_server.api.schemas.v1.commons import UpdateSchema
from argilla_server.pydantic_v1 import BaseModel, Field, HttpUrl

Expand Down
4 changes: 2 additions & 2 deletions argilla-server/src/argilla_server/bulk/records_bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
)
from argilla_server.api.schemas.v1.responses import UserResponseCreate
from argilla_server.api.schemas.v1.suggestions import SuggestionCreate
from argilla_server.api.webhooks.v1.enums import RecordEvent
from argilla_server.api.webhooks.v1.records import notify_record_event as notify_record_event_v1
from argilla_server.webhooks.v1.enums import RecordEvent
from argilla_server.webhooks.v1.records import notify_record_event as notify_record_event_v1
from argilla_server.contexts import distribution
from argilla_server.contexts.accounts import fetch_users_by_ids_as_dict
from argilla_server.contexts.records import (
Expand Down
8 changes: 4 additions & 4 deletions argilla-server/src/argilla_server/contexts/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
VectorSettingsCreate,
)
from argilla_server.api.schemas.v1.vectors import Vector as VectorSchema
from argilla_server.api.webhooks.v1.enums import DatasetEvent, ResponseEvent, RecordEvent
from argilla_server.api.webhooks.v1.records import notify_record_event as notify_record_event_v1
from argilla_server.api.webhooks.v1.responses import notify_response_event as notify_response_event_v1
from argilla_server.api.webhooks.v1.datasets import notify_dataset_event as notify_dataset_event_v1
from argilla_server.webhooks.v1.enums import DatasetEvent, ResponseEvent, RecordEvent
from argilla_server.webhooks.v1.records import notify_record_event as notify_record_event_v1
from argilla_server.webhooks.v1.responses import notify_response_event as notify_response_event_v1
from argilla_server.webhooks.v1.datasets import notify_dataset_event as notify_dataset_event_v1
from argilla_server.contexts import accounts, distribution
from argilla_server.database import get_async_db
from argilla_server.enums import DatasetStatus, UserRole, RecordStatus
Expand Down
4 changes: 2 additions & 2 deletions argilla-server/src/argilla_server/contexts/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from sqlalchemy.orm import selectinload
from sqlalchemy.ext.asyncio import AsyncSession

from argilla_server.api.webhooks.v1.enums import RecordEvent
from argilla_server.api.webhooks.v1.records import notify_record_event as notify_record_event_v1
from argilla_server.webhooks.v1.enums import RecordEvent
from argilla_server.webhooks.v1.records import notify_record_event as notify_record_event_v1
from argilla_server.enums import DatasetDistributionStrategy, RecordStatus
from argilla_server.models import Record
from argilla_server.search_engine.base import SearchEngine
Expand Down
2 changes: 1 addition & 1 deletion argilla-server/src/argilla_server/jobs/webhook_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from sqlalchemy.ext.asyncio import AsyncSession
from fastapi.encoders import jsonable_encoder

from argilla_server.api.webhooks.v1.commons import notify_event
from argilla_server.webhooks.v1.commons import notify_event
from argilla_server.database import AsyncSessionLocal
from argilla_server.jobs.queues import HIGH_QUEUE
from argilla_server.contexts import webhooks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

from argilla_server.models import Dataset
from argilla_server.jobs.webhook_jobs import enqueue_notify_events
from argilla_server.api.webhooks.v1.schemas import DatasetEventSchema
from argilla_server.api.webhooks.v1.enums import DatasetEvent
from argilla_server.webhooks.v1.schemas import DatasetEventSchema
from argilla_server.webhooks.v1.enums import DatasetEvent


async def notify_dataset_event(db: AsyncSession, dataset_event: DatasetEvent, dataset: Dataset) -> List[Job]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

from argilla_server.models import Webhook
from argilla_server.contexts import info
from argilla_server.api.webhooks.v1.commons import notify_event
from argilla_server.api.webhooks.v1.enums import WebhookEvent
from argilla_server.webhooks.v1.commons import notify_event
from argilla_server.webhooks.v1.enums import WebhookEvent


def notify_ping_event(webhook: Webhook) -> httpx.Response:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import selectinload

from argilla_server.api.webhooks.v1.enums import RecordEvent
from argilla_server.api.webhooks.v1.schemas import RecordEventSchema
from argilla_server.webhooks.v1.enums import RecordEvent
from argilla_server.webhooks.v1.schemas import RecordEventSchema
from argilla_server.jobs.webhook_jobs import enqueue_notify_events
from argilla_server.models import Record, Dataset

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

from argilla_server.models import Response, Record, Dataset
from argilla_server.jobs.webhook_jobs import enqueue_notify_events
from argilla_server.api.webhooks.v1.schemas import ResponseEventSchema
from argilla_server.api.webhooks.v1.enums import ResponseEvent
from argilla_server.webhooks.v1.schemas import ResponseEventSchema
from argilla_server.webhooks.v1.enums import ResponseEvent


async def notify_response_event(db: AsyncSession, response_event: ResponseEvent, response: Response) -> List[Job]:
Expand Down
2 changes: 1 addition & 1 deletion argilla-server/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from sqlalchemy.ext.asyncio import async_object_session

from argilla_server.enums import DatasetDistributionStrategy, FieldType, MetadataPropertyType, OptionsOrder
from argilla_server.api.webhooks.v1.enums import WebhookEvent
from argilla_server.webhooks.v1.enums import WebhookEvent
from argilla_server.models import (
Dataset,
Field,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sqlalchemy import func, select
from sqlalchemy.ext.asyncio import AsyncSession

from argilla_server.api.webhooks.v1.enums import WebhookEvent
from argilla_server.webhooks.v1.enums import WebhookEvent
from argilla_server.models import Webhook
from argilla_server.constants import API_KEY_HEADER_NAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sqlalchemy import func, select
from sqlalchemy.ext.asyncio import AsyncSession

from argilla_server.api.webhooks.v1.enums import WebhookEvent
from argilla_server.webhooks.v1.enums import WebhookEvent
from argilla_server.models import Webhook
from argilla_server.constants import API_KEY_HEADER_NAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from httpx import AsyncClient

from argilla_server.api.webhooks.v1.enums import WebhookEvent
from argilla_server.webhooks.v1.enums import WebhookEvent
from argilla_server.constants import API_KEY_HEADER_NAME

from tests.factories import AdminFactory, AnnotatorFactory, WebhookFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from httpx import AsyncClient
from typing import Any

from argilla_server.api.webhooks.v1.enums import WebhookEvent
from argilla_server.webhooks.v1.enums import WebhookEvent
from argilla_server.constants import API_KEY_HEADER_NAME

from tests.factories import AdminFactory, AnnotatorFactory, WebhookFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from httpx import Response
from standardwebhooks.webhooks import Webhook

from argilla_server.api.webhooks.v1.enums import WebhookEvent
from argilla_server.api.webhooks.v1.ping import notify_ping_event
from argilla_server.webhooks.v1.enums import WebhookEvent
from argilla_server.webhooks.v1.ping import notify_ping_event
from argilla_server.contexts import info

from tests.factories import WebhookFactory
Expand Down

0 comments on commit 3fb3d66

Please sign in to comment.