-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved execution app into workflow_manager, added API to list file exe…
…cutions for an execution with latest logs, schema migration for indexes on some columns
- Loading branch information
1 parent
0ffca6b
commit 71e8dd1
Showing
19 changed files
with
199 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from enum import Enum | ||
|
||
|
||
class ExecutionEntity(Enum): | ||
ETL = "ETL" | ||
API = "API" | ||
TASK = "TASK" | ||
WORKFLOW = "WF" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .execution import ExecutionSerializer # noqa: F401 | ||
from .file_centric import FileCentricExecutionSerializer # noqa: F401 |
22 changes: 22 additions & 0 deletions
22
backend/workflow_manager/execution/serializer/execution.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Optional | ||
|
||
from rest_framework import serializers | ||
from workflow_manager.workflow_v2.models import WorkflowExecution | ||
|
||
|
||
# TODO: Optimize with select_related / prefetch_related to reduce DB queries | ||
class ExecutionSerializer(serializers.ModelSerializer): | ||
workflow_name = serializers.SerializerMethodField() | ||
pipeline_name = serializers.SerializerMethodField() | ||
|
||
class Meta: | ||
model = WorkflowExecution | ||
exclude = ["task_id", "execution_log_id", "execution_type"] | ||
|
||
def get_workflow_name(self, obj: WorkflowExecution) -> Optional[str]: | ||
"""Fetch the workflow name using workflow_id""" | ||
return obj.workflow_name | ||
|
||
def get_pipeline_name(self, obj: WorkflowExecution) -> Optional[str]: | ||
"""Fetch the pipeline or API deployment name""" | ||
return obj.pipeline_name |
22 changes: 22 additions & 0 deletions
22
backend/workflow_manager/execution/serializer/file_centric.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Optional | ||
|
||
from rest_framework import serializers | ||
from workflow_manager.file_execution.models import ( | ||
WorkflowFileExecution as FileExecution, | ||
) | ||
|
||
|
||
class FileCentricExecutionSerializer(serializers.ModelSerializer): | ||
latest_log = serializers.SerializerMethodField() | ||
|
||
class Meta: | ||
model = FileExecution | ||
exclude = ["file_hash"] | ||
|
||
def get_latest_log(self, obj: FileExecution) -> Optional[dict[str, any]]: | ||
latest_log = ( | ||
obj.execution_logs.exclude(data__log_level__in=["DEBUG", "WARN"]) | ||
.order_by("-event_time") | ||
.first() | ||
) | ||
return latest_log.data if latest_log else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django.urls import path | ||
from rest_framework.urlpatterns import format_suffix_patterns | ||
from workflow_manager.execution.views import ( | ||
ExecutionViewSet, | ||
FileCentricExecutionViewSet, | ||
) | ||
from workflow_manager.workflow_v2.execution_log_view import ( | ||
WorkflowExecutionLogViewSet as ExecutionLogViewSet, | ||
) | ||
|
||
execution_list = ExecutionViewSet.as_view( | ||
{ | ||
"get": "list", | ||
} | ||
) | ||
file_centric_list = FileCentricExecutionViewSet.as_view({"get": "list"}) | ||
execution_log_list = ExecutionLogViewSet.as_view({"get": "list"}) | ||
|
||
urlpatterns = format_suffix_patterns( | ||
[ | ||
path("", execution_list, name="execution-list"), | ||
path("<uuid:pk>/files/", file_centric_list, name="file-centric-execution-list"), | ||
path("<uuid:pk>/logs/", execution_log_list, name="execution-log"), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .execution import ExecutionViewSet # noqa: F401 | ||
from .file_centric import FileCentricExecutionViewSet # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import logging | ||
|
||
from rest_framework import viewsets | ||
from rest_framework.filters import OrderingFilter | ||
from rest_framework.permissions import IsAuthenticated | ||
from utils.pagination import CustomPagination | ||
from workflow_manager.execution.serializer import FileCentricExecutionSerializer | ||
from workflow_manager.file_execution.models import ( | ||
WorkflowFileExecution as FileExecution, | ||
) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class FileCentricExecutionViewSet(viewsets.ReadOnlyModelViewSet): | ||
permission_classes = [IsAuthenticated] | ||
serializer_class = FileCentricExecutionSerializer | ||
pagination_class = CustomPagination | ||
filter_backends = [OrderingFilter] | ||
ordering_fields = ["created_at"] | ||
ordering = ["created_at"] | ||
|
||
def get_queryset(self): | ||
execution_id = self.kwargs.get("pk") | ||
return FileExecution.objects.filter(workflow_execution_id=execution_id) |
27 changes: 27 additions & 0 deletions
27
.../workflow_v2/migrations/0006_workflowexecution_workflow_ex_workflo_5942c9_idx_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 4.2.1 on 2025-02-04 04:12 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("workflow_v2", "0005_workflowexecution_tags"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddIndex( | ||
model_name="workflowexecution", | ||
index=models.Index( | ||
fields=["workflow_id", "-created_at"], | ||
name="workflow_ex_workflo_5942c9_idx", | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name="workflowexecution", | ||
index=models.Index( | ||
fields=["pipeline_id", "-created_at"], | ||
name="workflow_ex_pipelin_126dbf_idx", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
from .execution import WorkflowExecution # noqa: F401 | ||
# isort:skip_file | ||
|
||
# Do not change the order of the imports below to avoid circular dependency issues | ||
from .workflow import Workflow # noqa: F401 | ||
from .execution_log import ExecutionLog # noqa: F401 | ||
from .execution import WorkflowExecution # noqa: F401 | ||
from .file_history import FileHistory # noqa: F401 | ||
from .workflow import Workflow # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters