Skip to content
Merged
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
905 changes: 454 additions & 451 deletions api/v1/api.gen.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions api/v1/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8473,6 +8473,9 @@ components:
finishedAt:
type: string
description: "RFC 3339 timestamp when the DAG-run finished"
artifactsAvailable:
type: boolean
description: "Whether artifact files are available for this DAG-run"
params:
type: string
description: "Runtime parameters passed to the DAG-run in JSON format"
Expand All @@ -8499,6 +8502,7 @@ components:
- statusLabel
- startedAt
- finishedAt
- artifactsAvailable
- autoRetryCount

DAGRunDetails:
Expand Down Expand Up @@ -8526,9 +8530,6 @@ components:
log:
type: string
description: "Path to the log file"
artifactsAvailable:
type: boolean
description: "Whether artifact endpoints are available for this DAG-run"
nodes:
type: array
description: "Status of individual steps within the DAG-run"
Expand Down Expand Up @@ -8557,7 +8558,6 @@ components:
- rootDAGRunName
- rootDAGRunId
- log
- artifactsAvailable
- nodes

ArtifactNodeType:
Expand Down
61 changes: 45 additions & 16 deletions internal/service/frontend/api/v1/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
package api

import (
"os"

"github.com/dagucloud/dagu/api/v1"
"github.com/dagucloud/dagu/internal/cmn/fileutil"
"github.com/dagucloud/dagu/internal/core"
"github.com/dagucloud/dagu/internal/core/exec"
)
Expand Down Expand Up @@ -190,23 +193,25 @@ func toDAGRunSummary(s exec.DAGRunStatus) api.DAGRunSummary {
if s.AutoRetryLimit > 0 {
autoRetryLimit = ptrOf(s.AutoRetryLimit)
}
artifactsAvailable := hasArtifactEntries(s.ArchiveDir)

return api.DAGRunSummary{
Name: s.Name,
DagRunId: s.DAGRunID,
Params: ptrOf(s.Params),
QueuedAt: ptrOf(s.QueuedAt),
AutoRetryCount: s.AutoRetryCount,
AutoRetryLimit: autoRetryLimit,
ScheduleTime: ptrOf(s.ScheduleTime),
StartedAt: s.StartedAt,
FinishedAt: s.FinishedAt,
Status: api.Status(s.Status),
StatusLabel: api.StatusLabel(s.Status.String()),
WorkerId: ptrOf(s.WorkerID),
TriggerType: toTriggerType(s.TriggerType),
Labels: &s.Labels,
Tags: &s.Labels,
Name: s.Name,
DagRunId: s.DAGRunID,
Params: ptrOf(s.Params),
QueuedAt: ptrOf(s.QueuedAt),
AutoRetryCount: s.AutoRetryCount,
AutoRetryLimit: autoRetryLimit,
ScheduleTime: ptrOf(s.ScheduleTime),
StartedAt: s.StartedAt,
FinishedAt: s.FinishedAt,
ArtifactsAvailable: artifactsAvailable,
Status: api.Status(s.Status),
StatusLabel: api.StatusLabel(s.Status.String()),
WorkerId: ptrOf(s.WorkerID),
TriggerType: toTriggerType(s.TriggerType),
Labels: &s.Labels,
Tags: &s.Labels,
}
}
Comment thread
yottahmd marked this conversation as resolved.

Expand Down Expand Up @@ -244,13 +249,14 @@ func ToDAGRunDetails(s exec.DAGRunStatus) api.DAGRunDetails {
if s.AutoRetryLimit > 0 {
autoRetryLimit = ptrOf(s.AutoRetryLimit)
}
artifactsAvailable := hasArtifactEntries(s.ArchiveDir)

return api.DAGRunDetails{
RootDAGRunName: s.Root.Name,
RootDAGRunId: s.Root.ID,
ParentDAGRunName: ptrOf(s.Parent.Name),
ParentDAGRunId: ptrOf(s.Parent.ID),
ArtifactsAvailable: s.ArchiveDir != "",
ArtifactsAvailable: artifactsAvailable,
Log: s.Log,
Name: s.Name,
Params: ptrOf(s.Params),
Expand All @@ -276,6 +282,29 @@ func ToDAGRunDetails(s exec.DAGRunStatus) api.DAGRunDetails {
}
}

func hasArtifactEntries(archiveDir string) bool {
if archiveDir == "" {
return false
}

info, err := os.Stat(archiveDir)
if err != nil || !info.IsDir() {
return false
}

entries, err := os.ReadDir(archiveDir)
if err != nil {
return false
}

for _, entry := range entries {
if !fileutil.IsSymlinkDirEntry(entry) {
return true
}
}
return false
}

func toNode(node *exec.Node) api.Node {
if node == nil {
return api.Node{}
Expand Down
17 changes: 17 additions & 0 deletions internal/service/frontend/api/v1/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package api

import (
"os"
"path/filepath"
"testing"
"time"

Expand All @@ -14,12 +16,22 @@ import (
"github.com/stretchr/testify/require"
)

func writeArtifactFile(t *testing.T) string {
t.Helper()

dir := t.TempDir()
err := os.WriteFile(filepath.Join(dir, "artifact.txt"), []byte("artifact"), 0o600)
require.NoError(t, err)
return dir
}

func TestToDAGRunSummaryIncludesScheduleTime(t *testing.T) {
status := exec.DAGRunStatus{
Name: "test-dag",
DAGRunID: "run-1",
AutoRetryCount: 2,
AutoRetryLimit: 5,
ArchiveDir: writeArtifactFile(t),
Status: core.Queued,
ScheduleTime: "2026-03-13T00:00:00Z",
}
Expand All @@ -30,6 +42,7 @@ func TestToDAGRunSummaryIncludesScheduleTime(t *testing.T) {
assert.Equal(t, status.AutoRetryCount, summary.AutoRetryCount)
require.NotNil(t, summary.AutoRetryLimit)
assert.Equal(t, status.AutoRetryLimit, *summary.AutoRetryLimit)
assert.True(t, summary.ArtifactsAvailable)
}

func TestToDAGRunDetailsIncludesScheduleTime(t *testing.T) {
Expand All @@ -38,6 +51,7 @@ func TestToDAGRunDetailsIncludesScheduleTime(t *testing.T) {
DAGRunID: "run-1",
AutoRetryCount: 3,
AutoRetryLimit: 5,
ArchiveDir: writeArtifactFile(t),
Status: core.Queued,
QueuedAt: "2026-03-13T00:01:00Z",
ScheduleTime: "2026-03-13T00:00:00Z",
Expand All @@ -51,6 +65,7 @@ func TestToDAGRunDetailsIncludesScheduleTime(t *testing.T) {
assert.Equal(t, status.AutoRetryCount, details.AutoRetryCount)
require.NotNil(t, details.AutoRetryLimit)
assert.Equal(t, status.AutoRetryLimit, *details.AutoRetryLimit)
assert.True(t, details.ArtifactsAvailable)
}

func TestToDAGRunSummaryOmitsAutoRetryLimitWhenUnconfigured(t *testing.T) {
Expand All @@ -64,6 +79,7 @@ func TestToDAGRunSummaryOmitsAutoRetryLimitWhenUnconfigured(t *testing.T) {

summary := toDAGRunSummary(status)
assert.Nil(t, summary.AutoRetryLimit)
assert.False(t, summary.ArtifactsAvailable)
}

func TestToDAGRunDetailsOmitsAutoRetryLimitWhenUnconfigured(t *testing.T) {
Expand All @@ -77,6 +93,7 @@ func TestToDAGRunDetailsOmitsAutoRetryLimitWhenUnconfigured(t *testing.T) {

details := ToDAGRunDetails(status)
assert.Nil(t, details.AutoRetryLimit)
assert.False(t, details.ArtifactsAvailable)
}

func TestToDAGDetailsIncludesParamDefDescriptions(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/api/v1/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3443,6 +3443,8 @@ export interface components {
startedAt: string;
/** @description RFC 3339 timestamp when the DAG-run finished */
finishedAt: string;
/** @description Whether artifact files are available for this DAG-run */
artifactsAvailable: boolean;
/** @description Runtime parameters passed to the DAG-run in JSON format */
params?: string;
/** @description ID of the worker that executed this DAG-run ('local' for local execution) */
Expand All @@ -3466,8 +3468,6 @@ export interface components {
parentDAGRunId?: components["schemas"]["DAGRunId"] & unknown;
/** @description Path to the log file */
log: string;
/** @description Whether artifact endpoints are available for this DAG-run */
artifactsAvailable: boolean;
/** @description Status of individual steps within the DAG-run */
nodes: components["schemas"]["Node"][];
onExit?: components["schemas"]["Node"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@

/* Inline code */
.doc-preview code {
font-family: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, 'Courier New', monospace;
font-family:
'JetBrains Mono', 'Fira Code', Menlo, Monaco, 'Courier New', monospace;
font-size: 0.85em;
color: var(--foreground);
background: var(--muted);
Expand Down
60 changes: 60 additions & 0 deletions ui/src/components/ui/doc-markdown-preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { MermaidBlock } from '@/components/ui/mermaid-block';
import { cn } from '@/lib/utils';
import { slugifyHeading } from '@/lib/text-utils';
import type { ReactElement, ReactNode } from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import './doc-markdown-preview.css';

type DocMarkdownPreviewProps = {
content: string | null | undefined;
className?: string;
};

function headingId(children: ReactNode): string {
const text =
typeof children === 'string'
? children
: Array.isArray(children)
? children
.map((child) => (typeof child === 'string' ? child : ''))
.join('')
: String(children ?? '');
return slugifyHeading(text);
}

export function DocMarkdownPreview({
content,
className,
}: DocMarkdownPreviewProps) {
return (
<div className={cn('doc-preview max-w-none', className)}>
<ReactMarkdown
remarkPlugins={[remarkGfm]}
components={{
h1: ({ children }) => <h1 id={headingId(children)}>{children}</h1>,
h2: ({ children }) => <h2 id={headingId(children)}>{children}</h2>,
h3: ({ children }) => <h3 id={headingId(children)}>{children}</h3>,
h4: ({ children }) => <h4 id={headingId(children)}>{children}</h4>,
h5: ({ children }) => <h5 id={headingId(children)}>{children}</h5>,
h6: ({ children }) => <h6 id={headingId(children)}>{children}</h6>,
code({ className: codeClassName, children }) {
if (codeClassName === 'language-mermaid') {
return <MermaidBlock code={String(children)} />;
}
return <code className={codeClassName}>{children}</code>;
},
pre({ children }) {
const child = children as ReactElement;
if (child?.type === MermaidBlock) {
return <>{children}</>;
}
return <pre>{children}</pre>;
},
}}
>
{content ?? ''}
</ReactMarkdown>
</div>
);
}
Loading