Skip to content

Commit

Permalink
Merge branch 'feat/unified-notifications-v2' of github.com:Zipstack/u…
Browse files Browse the repository at this point in the history
…nstract into feat/unified-notifications-v2
  • Loading branch information
tahierhussain committed Jan 24, 2025
2 parents 53b95bd + 993a133 commit 0266676
Show file tree
Hide file tree
Showing 38 changed files with 1,026 additions and 98 deletions.
2 changes: 2 additions & 0 deletions backend/api_v2/api_deployment_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def post(
include_metadata = serializer.validated_data.get(ApiExecution.INCLUDE_METADATA)
include_metrics = serializer.validated_data.get(ApiExecution.INCLUDE_METRICS)
use_file_history = serializer.validated_data.get(ApiExecution.USE_FILE_HISTORY)
tag_names = serializer.validated_data.get(ApiExecution.TAGS)
if not file_objs or len(file_objs) == 0:
raise InvalidAPIRequest("File shouldn't be empty")
response = DeploymentHelper.execute_workflow(
Expand All @@ -64,6 +65,7 @@ def post(
include_metadata=include_metadata,
include_metrics=include_metrics,
use_file_history=use_file_history,
tag_names=tag_names,
)
if "error" in response and response["error"]:
return Response(
Expand Down
1 change: 1 addition & 0 deletions backend/api_v2/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ class ApiExecution:
INCLUDE_METRICS: str = "include_metrics"
USE_FILE_HISTORY: str = "use_file_history" # Undocumented parameter
EXECUTION_ID: str = "execution_id"
TAGS: str = "tags"
5 changes: 5 additions & 0 deletions backend/api_v2/deployment_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from rest_framework.request import Request
from rest_framework.serializers import Serializer
from rest_framework.utils.serializer_helpers import ReturnDict
from tags.models import Tag
from utils.constants import Account, CeleryQueue
from utils.local_context import StateStore
from workflow_manager.endpoint_v2.destination import DestinationConnector
Expand Down Expand Up @@ -138,6 +139,7 @@ def execute_workflow(
include_metadata: bool = False,
include_metrics: bool = False,
use_file_history: bool = False,
tag_names: list[str] = [],
) -> ReturnDict:
"""Execute workflow by api.
Expand All @@ -147,16 +149,19 @@ def execute_workflow(
file_obj (UploadedFile): input file
use_file_history (bool): Use FileHistory table to return results on already
processed files. Defaults to False
tag_names (list(str)): list of tag names
Returns:
ReturnDict: execution status/ result
"""
workflow_id = api.workflow.id
pipeline_id = api.id
tags = Tag.bulk_get_or_create(tag_names=tag_names)
workflow_execution = WorkflowExecutionServiceHelper.create_workflow_execution(
workflow_id=workflow_id,
pipeline_id=pipeline_id,
mode=WorkflowExecution.Mode.QUEUE,
tags=tags,
)
execution_id = workflow_execution.id

Expand Down
5 changes: 4 additions & 1 deletion backend/api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Serializer,
ValidationError,
)
from tags.serializers import TagParamsSerializer
from utils.serializer.integrity_error_mixin import IntegrityErrorMixin
from workflow_manager.workflow_v2.exceptions import ExecutionDoesNotExistError
from workflow_manager.workflow_v2.models.execution import WorkflowExecution
Expand Down Expand Up @@ -99,7 +100,7 @@ def to_representation(self, instance: APIKey) -> OrderedDict[str, Any]:
return representation


class ExecutionRequestSerializer(Serializer):
class ExecutionRequestSerializer(TagParamsSerializer):
"""Execution request serializer.
Attributes:
Expand All @@ -110,6 +111,8 @@ class ExecutionRequestSerializer(Serializer):
use_file_history (bool): Flag to use FileHistory to save and retrieve
responses quickly. This is undocumented to the user and can be
helpful for demos.
tags (str): Comma-separated List of tags to associate with the execution.
e.g:'tag1,tag2-name,tag3_name'
"""

timeout = IntegerField(
Expand Down
9 changes: 6 additions & 3 deletions backend/backend/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def get_required_setting(
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.admindocs",
"django_filters",
# Third party apps should go below this line,
"rest_framework",
# Connector OAuth
Expand All @@ -229,8 +230,6 @@ def get_required_setting(
"commands",
# health checks
"health",
)
v2_apps = (
"migrating.v2",
"connector_auth_v2",
"tenant_account_v2",
Expand All @@ -253,8 +252,8 @@ def get_required_setting(
"prompt_studio.prompt_studio_output_manager_v2",
"prompt_studio.prompt_studio_document_manager_v2",
"prompt_studio.prompt_studio_index_manager_v2",
"tags",
)
SHARED_APPS += v2_apps
TENANT_APPS = []

INSTALLED_APPS = list(SHARED_APPS) + [
Expand Down Expand Up @@ -435,6 +434,10 @@ def get_required_setting(
"DEFAULT_PERMISSION_CLASSES": [], # TODO: Update once auth is figured
"TEST_REQUEST_DEFAULT_FORMAT": "json",
"EXCEPTION_HANDLER": "middleware.exception.drf_logging_exc_handler",
"DEFAULT_FILTER_BACKENDS": [
"django_filters.rest_framework.DjangoFilterBackend",
"rest_framework.filters.OrderingFilter",
],
}

# These paths will work without authentication
Expand Down
1 change: 1 addition & 0 deletions backend/backend/urls_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@
UrlPathConstants.PROMPT_STUDIO,
include("prompt_studio.prompt_studio_index_manager_v2.urls"),
),
path("tags/", include("tags.urls")),
]
Loading

0 comments on commit 0266676

Please sign in to comment.