Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions client/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export default defineConfig([
"src/features/dataConnectorsV2/api/data-connectors.api.ts",
"src/features/dataConnectorsV2/api/doiResolver.generated-api.ts",
"src/features/notifications/api/notifications.generated-api.ts",
"src/features/persistedLogs/api/persistedLogs.generated-api.ts",
"src/features/platform/api/platform.generated-api.ts",
"src/features/projectsV2/api/projectV2.api.ts",
"src/features/searchV2/api/searchV2Api.generated-api.ts",
Expand Down
12 changes: 11 additions & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"generate-api:sessionLaunchersV2": "rtk-query-codegen-openapi src/features/sessionsV2/api/sessionLaunchersV2.api-config.ts",
"generate-api:sessionsV2": "rtk-query-codegen-openapi src/features/sessionsV2/api/sessionsV2.api-config.ts",
"generate-api:users": "rtk-query-codegen-openapi src/features/usersV2/api/users.api-config.ts",
"generate-api:persistedLogs": "rtk-query-codegen-openapi src/features/persistedLogs/api/persistedLogs.api-config.ts",
"update-api": "node scripts/update_api_spec.js computeResources connectedServices dataConnectors namespaceV2 notifications platform projectCloudStorage projectV2 repositories searchV2 sessionLaunchersV2 sessionsV2 users",
"update-api:computeResources": "node scripts/update_api_spec.js computeResources",
"update-api:connectedServices": "node scripts/update_api_spec.js connectedServices",
Expand All @@ -49,7 +50,8 @@
"update-api:searchV2": "node scripts/update_api_spec.js searchV2",
"update-api:sessionLaunchersV2": "node scripts/update_api_spec.js sessionLaunchersV2",
"update-api:sessionsV2": "node scripts/update_api_spec.js sessionsV2",
"update-api:users": "node scripts/update_api_spec.js users"
"update-api:users": "node scripts/update_api_spec.js users",
"update-api:persistedLogs": "node scripts/update_api_spec.js persistedLogs"
},
"type": "module",
"dependencies": {
Expand Down Expand Up @@ -103,7 +105,8 @@
"remark-gemoji": "^8.0.0",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"sass": "^1.64.1"
"sass": "^1.64.1",
"ulid": "^3.0.2"
},
"devDependencies": {
"@eslint/compat": "^2.0.2",
Expand Down
11 changes: 10 additions & 1 deletion client/scripts/update_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { parseDocument } from "yaml";

const GH_BASE_URL = "https://raw.githubusercontent.com";
const DATA_SERVICES_REPO = "SwissDataScienceCenter/renku-data-services";
const DATA_SERVICES_RELEASE = "main";
const DATA_SERVICES_RELEASE = "leafty/feat-peristed-logs";

async function main() {
argv.forEach((arg) => {
Expand Down Expand Up @@ -54,6 +54,8 @@ async function main() {
updateSessionsV2Api();
} else if (arg.trim() === "users") {
updateUsersApi();
} else if (arg.trim() === "persistedLogs") {
updatePersistedLogsApi();
}
});
}
Expand Down Expand Up @@ -150,6 +152,13 @@ async function updateUsersApi() {
});
}

async function updatePersistedLogsApi() {
updateApiFiles({
specFile: "components/renku_data_services/persisted_logs/api.spec.yaml",
destFile: "src/features/persistedLogs/api/persistedLogs.openapi.json",
});
}

async function updateApiFiles({ specFile, destFile }) {
const API_SPEC_FILE = specFile;
const DEST_FILE = destFile;
Expand Down
13 changes: 6 additions & 7 deletions client/src/features/logsDisplay/BuildLogsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import { skipToken } from "@reduxjs/toolkit/query";
import { useCallback, useMemo } from "react";

import {
sessionLaunchersV2Api,
useGetBuildsByBuildIdLogsQuery as useGetBuildLogsQuery,
persistedLogsApi,
useGetPersistedBuildLogsForModalQuery,
} from "../persistedLogs/api/persistedLogs.api";
import {
type Build,
type BuildList,
} from "../sessionsV2/api/sessionLaunchersV2.api";
import LogsModal from "./LogsModal";

const BUILD_LOGS_MAX_LINES = 250;

interface BuildLogsModalProps {
builds: BuildList | undefined;
isOpen: boolean;
Expand Down Expand Up @@ -74,17 +74,16 @@ function BuildLogsModalInner({
isOpen,
toggle,
}: BuildLogsModalInnerProps) {
const query = useGetBuildLogsQuery(
const query = useGetPersistedBuildLogsForModalQuery(
isOpen
? {
buildId: build.id,
maxLines: BUILD_LOGS_MAX_LINES,
}
: skipToken,
);

const [trigger] =
sessionLaunchersV2Api.endpoints.getBuildsByBuildIdLogs.useLazyQuery();
persistedLogsApi.endpoints.getPersistedBuildLogsForModal.useLazyQuery();
const downloadQueryTrigger = useCallback(
() => trigger({ buildId: build.id }),
[build.id, trigger],
Expand Down
4 changes: 2 additions & 2 deletions client/src/features/logsDisplay/LogsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default function LogsModal({

type LogsModalBodyProps = LogsQuery & Pick<LogsModalModalProps, "defaultTab">;

function LogsModalBody({
export function LogsModalBody({
data,
error,
isFetching,
Expand Down Expand Up @@ -355,7 +355,7 @@ function ModalFooterButtons({
*
* NOTE: will download with maxLines = 250, so the logs will be incomplete
*/
function useDownloadLogs(
export function useDownloadLogs(
name: string,
refetch: LogsQuery["refetch"],
downloadQueryTrigger: DownloadLogsLazyQueryTrigger | undefined | null,
Expand Down
88 changes: 88 additions & 0 deletions client/src/features/logsDisplay/SessionLogsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import { skipToken } from "@reduxjs/toolkit/query";
import { useCallback } from "react";

import {
persistedLogsApi,
useGetPersistedLogsForModalQuery,
} from "../persistedLogs/api/persistedLogs.api";
import {
SessionResponse,
sessionsV2Api,
useGetSessionsBySessionIdLogsQuery,
useGetSessionsBySessionIdQuery,
Expand All @@ -43,6 +48,37 @@ export default function SessionLogsModal({
sessionName ? { sessionId: sessionName } : skipToken,
);

if (session?.session_type === "non-interactive") {
return (
<PersistedLogsModal
isOpen={isOpen}
session={session}
sessionName={sessionName}
toggle={toggle}
/>
);
}

return (
<KubernetesLogsModal
isOpen={isOpen}
session={session}
sessionName={sessionName}
toggle={toggle}
/>
);
}

interface KubernetesLogsModalProps extends SessionLogsModalProps {
session: SessionResponse | undefined;
}

function KubernetesLogsModal({
isOpen,
session,
sessionName,
toggle,
}: KubernetesLogsModalProps) {
const query = useGetSessionsBySessionIdLogsQuery(
isOpen
? {
Expand Down Expand Up @@ -78,3 +114,55 @@ export default function SessionLogsModal({
/>
);
}

interface PersistedLogsModalProps extends SessionLogsModalProps {
session: SessionResponse;
}

function PersistedLogsModal({
isOpen,
session,
sessionName,
toggle,
}: PersistedLogsModalProps) {
const query = useGetPersistedLogsForModalQuery(
isOpen
? {
launcherId: session.launcher_id,
params: {
submission_id: session.submission_id,
},
}
: skipToken,
);

const [trigger] =
persistedLogsApi.endpoints.getPersistedLogsForModal.useLazyQuery();
const downloadQueryTrigger = useCallback(
() =>
trigger({
launcherId: session.launcher_id,
params: { submission_id: session.submission_id },
}),
[session.launcher_id, session.submission_id, trigger],
);

return (
<LogsModal
isOpen={isOpen}
name={sessionName}
query={query}
downloadQueryTrigger={downloadQueryTrigger}
title={"Logs"}
toggle={toggle}
sessionState={session?.status?.state}
sessionError={
session?.status?.state === "failed"
? session?.status?.message
: undefined
}
// eslint-disable-next-line spellcheck/spell-checker
defaultTab="amalthea-session"
/>
);
}
Loading
Loading