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

[442] - Pagination added for logs #832

Merged
merged 11 commits into from
Sep 3, 2024
11 changes: 3 additions & 8 deletions ddpui/api/pipeline_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,11 @@ def post_run_prefect_org_deployment_task(
@pipelineapi.get("flow_runs/{flow_run_id}/logs", auth=auth.CustomAuthMiddleware())
@has_permission(["can_view_pipeline"])
def get_flow_runs_logs(
request, flow_run_id, offset: int = 0
request, flow_run_id, task_run_id = '', limit: int = 0, offset: int = 0
): # pylint: disable=unused-argument
"""return the logs from a flow-run"""
try:
result = prefect_service.get_flow_run_logs(flow_run_id, offset)
result = prefect_service.get_flow_run_logs(flow_run_id, task_run_id,limit,offset)
except Exception as error:
logger.exception(error)
raise HttpError(400, "failed to retrieve logs") from error
Expand Down Expand Up @@ -712,19 +712,14 @@ def get_prefect_flow_runs_log_history(
)
@has_permission(["can_view_pipeline"])
def get_prefect_flow_runs_log_history_v1(
request, deployment_id, limit: int = 0, fetchlogs=True, offset: int = 0
request, deployment_id, limit: int = 0, offset: int = 0
):
# pylint: disable=unused-argument
"""Fetch all flow runs for the deployment and the logs for each flow run"""
flow_runs = prefect_service.get_flow_runs_by_deployment_id_v1(
deployment_id=deployment_id, limit=limit, offset=offset
)

if fetchlogs:
for flow_run in flow_runs:
logs_dict = prefect_service.get_flow_run_logs_v2(flow_run["id"])
flow_run["runs"] = logs_dict

return flow_runs
Ishankoradia marked this conversation as resolved.
Show resolved Hide resolved


Expand Down
6 changes: 4 additions & 2 deletions ddpui/ddpprefect/prefect_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,13 @@ def get_deployment(deployment_id) -> dict:
return res


def get_flow_run_logs(flow_run_id: str, offset: int) -> dict: # pragma: no cover
def get_flow_run_logs(
flow_run_id: str, task_run_id: str, limit: int, offset: int
) -> dict: # pragma: no cover
"""retreive the logs from a flow-run from prefect"""
res = prefect_get(
f"flow_runs/logs/{flow_run_id}",
params={"offset": offset},
params={"offset": offset, "limit": limit, "task_run_id": task_run_id},
)
return {"logs": res}

Expand Down
Loading