Skip to content

Commit

Permalink
feat: support for nextflow 24
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustDev committed Jul 9, 2024
1 parent edcc061 commit 1dd14e7
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 156 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
"eslint-config-next": "13.4.19",
"moment": "^2.29.4",
"nanoid": "^4.0.2",
"next": "13.5.2",
"next": "^14.2.3",
"next-logger": "^3.0.2",
"plotly.js": "^2.26.0",
"postcss": "8.4.27",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-icons": "^4.10.1",
"react-infinite-scroll-component": "^6.1.0",
Expand Down
2 changes: 2 additions & 0 deletions prisma/migrations/20240709192350_sample/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Workflow" ALTER COLUMN "stats" DROP NOT NULL;
2 changes: 2 additions & 0 deletions prisma/migrations/20240709192801_container_opt/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Workflow" ALTER COLUMN "container" DROP NOT NULL;
4 changes: 2 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ model Workflow {
profile String
homeDir String
workDir String
container String
container String?
commitId String?
errorMessage String?
repository String?
Expand All @@ -40,7 +40,7 @@ model Workflow {
/// [Nextflow]
nextflow Json
/// [Stats]
stats Json
stats Json?
resume Boolean
success Boolean
projectName String
Expand Down
34 changes: 17 additions & 17 deletions src/app/api/trace/[id]/begin/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function PUT(request: NextRequest, { params }: any) {
profile: requestJson.workflow.profile,
homeDir: requestJson.workflow.homeDir,
workDir: requestJson.workflow.workDir,
container: requestJson.workflow.container,
container: requestJson.workflow.container ?? "",
commitId: requestJson.workflow.commitId,
errorMessage: requestJson.workflow.errorMessage,
repository: requestJson.workflow.repository,
Expand All @@ -53,7 +53,7 @@ export async function PUT(request: NextRequest, { params }: any) {
commandLine: requestJson.workflow.commandLine,
stubRun: requestJson.workflow.stubRun,
nextflow: requestJson.workflow.nextflow,
stats: requestJson.workflow.workflowStats,
// stats: requestJson.workflow.workflowStats,
resume: requestJson.workflow.resume,
success: requestJson.workflow.success,
projectName: requestJson.workflow.projectName,
Expand All @@ -73,21 +73,20 @@ export async function PUT(request: NextRequest, { params }: any) {
progress: {
create: {
id: id,
pending: requestJson.workflow.workflowStats.pendingCount,
ignored: requestJson.workflow.workflowStats.ignoredCount,
loadCpus: requestJson.workflow.workflowStats.loadCpus,
loadMemory: requestJson.workflow.workflowStats.loadMemory,
processes: requestJson.workflow.workflowStats.processes,
aborted: requestJson.workflow.workflowStats.abortedCount,
succeeded: requestJson.workflow.workflowStats.succeededCount,
peakMemory: requestJson.workflow.workflowStats.peakMemory,
peakCpus: requestJson.workflow.workflowStats.peakCpus,
failed: requestJson.workflow.workflowStats.failedCount,
running: requestJson.workflow.workflowStats.runningCount,
retries: requestJson.workflow.workflowStats.retriesCount,
peakRunning: requestJson.workflow.workflowStats.peakRunning,
cached: requestJson.workflow.workflowStats.cachedCount,
submitted: requestJson.workflow.workflowStats.submittedCount,
pending: 0,
ignored: 0,
loadCpus: 0,
loadMemory: 0,
aborted: 0,
succeeded: 0,
peakMemory: 0,
peakCpus: 0,
failed: 0,
running: 0,
retries: 0,
peakRunning: 0,
cached: 0,
submitted: 0,
},
},
},
Expand All @@ -100,6 +99,7 @@ export async function PUT(request: NextRequest, { params }: any) {
watchUrl: `${baseUrl}/runs/${id}`,
})
} catch (e: any) {
console.error(e)
return NextResponse.json({ error: e }, { status: 500 })
}
}
39 changes: 22 additions & 17 deletions src/app/api/trace/[id]/complete/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,31 @@ export async function PUT(request: Request, { params }: any) {
},
})

const settings = await GetSettings()
if (
settings.slack_notifications_enabled &&
settings.slack_webhook_url &&
settings.slack_notification_events.includes("run_completed")
) {
const tags = requestJson.workflow?.params["tags"]?.split(",").map((e: string) => e.trim()) ?? []
const duration = formatDuration(requestJson.workflow.duration / 1000)
const slackWebhookOpts: RunCompletedOptions = {
id: id,
baseUrl: settings.base_url ?? "",
name: requestJson.workflow.manifest.description,
runName: requestJson.workflow.runName,
duration: duration,
tags: tags,
status: requestJson.workflow.success,
try {
const settings = await GetSettings()
if (
settings.slack_notifications_enabled &&
settings.slack_webhook_url &&
settings.slack_notification_events.includes("run_completed")
) {
const tags = requestJson.workflow?.params["tags"]?.split(",").map((e: string) => e.trim()) ?? []
const duration = formatDuration(requestJson.workflow.duration / 1000)
const slackWebhookOpts: RunCompletedOptions = {
id: id,
baseUrl: settings.base_url ?? "",
name: requestJson.workflow.manifest.description,
runName: requestJson.workflow.runName,
duration: duration,
tags: tags,
status: requestJson.workflow.success,
}
RunCompletedWebhook(settings.slack_webhook_url, slackWebhookOpts)
}
RunCompletedWebhook(settings.slack_webhook_url, slackWebhookOpts)
} catch (error) {
console.error("Error sending slack notification", error)
}
} catch (e: any) {
console.error(e)
return NextResponse.json({ error: e }, { status: 500 })
}

Expand Down
6 changes: 5 additions & 1 deletion src/app/runs/[id]/components/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ export const MainRun = (props: PageProps) => {
<div className="md:grid md:grid-cols-2 md:gap-4 pt-8 grid-cols-1">
<div>{progress && <Processes processes={progress.processes} />}</div>
<div>
<Utilisation tasks={tasks} peakCpus={workflow.stats.peakCpus} loadCpus={workflow.stats.loadCpus} />
<Utilisation
tasks={tasks}
peakCpus={workflow?.stats?.peakCpus ?? 0}
loadCpus={workflow?.stats?.loadCpus ?? 0}
/>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/services/prisma/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PrismaClient } from "@prisma/client"

const prismaClientSingleton = () => {
return new PrismaClient()
return new PrismaClient()
}

type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientSingleton | undefined
prisma: PrismaClientSingleton | undefined
}

export const prisma = globalForPrisma.prisma ?? prismaClientSingleton()
Expand Down
Loading

0 comments on commit 1dd14e7

Please sign in to comment.