Skip to content

ENG 3008 Fix registered with no run workflows #1374

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

Merged
merged 11 commits into from
May 30, 2023
55 changes: 52 additions & 3 deletions src/ui/common/src/components/pages/workflows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useDispatch } from 'react-redux';
import {
useDagGetQuery,
useDagResultsGetQuery,
useDagsGetQuery,
useWorkflowsGetQuery,
} from '../../../handlers/AqueductApi';
import { AppDispatch } from '../../../stores/store';
Expand Down Expand Up @@ -148,13 +149,25 @@ const WorkflowsPage: React.FC<Props> = ({ user, Layout = DefaultLayout }) => {
apiKey: user.apiKey,
workflowId: workflowId,
});

const {
data: dags,
error: dagsError,
isLoading: dagsLoading,
} = useDagsGetQuery({
apiKey: user.apiKey,
workflowId: workflowId,
});

let status = ExecutionStatus.Unknown;

if (!dagResultsLoading && !dagResultsError && dagResults.length > 0) {
const latestDagResult = getLatestDagResult(dagResults);
if (latestDagResult) {
status = latestDagResult.exec_state.status;
}
} else if (!dagsLoading && !dagsError && dags.length > 0) {
status = ExecutionStatus.Registered;
}

return <ExecutionStatusLink name={row.name} url={url} status={status} />;
Expand All @@ -172,10 +185,21 @@ const WorkflowsPage: React.FC<Props> = ({ user, Layout = DefaultLayout }) => {
workflowId: workflowId,
});

const {
data: dags,
error: dagsError,
isLoading: dagsLoading,
} = useDagsGetQuery({
apiKey: user.apiKey,
workflowId: workflowId,
});

let latestDagId;
if (!dagResultsLoading && !dagResultsError && dagResults.length > 0) {
const latestDagResult = getLatestDagResult(dagResults);
latestDagId = latestDagResult.dag_id;
} else if (!dagsLoading && !dagsError && dags.length > 0) {
latestDagId = dags[0].id;
}
const {
data: dag,
Expand All @@ -191,7 +215,6 @@ const WorkflowsPage: React.FC<Props> = ({ user, Layout = DefaultLayout }) => {
skip: dagResultsLoading && latestDagId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this is probably wrong as it will not skip if dagResultsLoading is false but latestDagId is empty. I'd just use skip: !latestDagId to load dag whenever the ID is available.

}
);

const nodes = useWorkflowNodes(user.apiKey, workflowId, latestDagId);

let engines = ['Unknown'];
Expand Down Expand Up @@ -227,12 +250,23 @@ const WorkflowsPage: React.FC<Props> = ({ user, Layout = DefaultLayout }) => {
workflowId: workflowId,
});

const {
data: dags,
error: dagsError,
isLoading: dagsLoading,
} = useDagsGetQuery({
apiKey: user.apiKey,
workflowId: workflowId,
});

let latestDagResultId;
let latestDagId;
if (!dagResultsLoading && !dagResultsError && dagResults.length > 0) {
const latestDagResult = getLatestDagResult(dagResults);
latestDagResultId = latestDagResult.id;
latestDagId = latestDagResult.dag_id;
} else if (!dagsLoading && !dagsError && dags.length > 0) {
latestDagId = dags[0].id;
}

const nodes = useWorkflowNodes(user.apiKey, workflowId, latestDagId);
Expand All @@ -250,7 +284,9 @@ const WorkflowsPage: React.FC<Props> = ({ user, Layout = DefaultLayout }) => {
metricId: op.id,
name: op.name,
value: nodesResults.artifacts[artifactId]?.content_serialized,
status: nodesResults.artifacts[artifactId]?.exec_state?.status,
status:
nodesResults.artifacts[artifactId]?.exec_state?.status ??
ExecutionStatus.Registered,
};
});
return <MetricItem metrics={metricNodes} />;
Expand All @@ -267,12 +303,23 @@ const WorkflowsPage: React.FC<Props> = ({ user, Layout = DefaultLayout }) => {
workflowId: workflowId,
});

const {
data: dags,
error: dagsError,
isLoading: dagsLoading,
} = useDagsGetQuery({
apiKey: user.apiKey,
workflowId: workflowId,
});

let latestDagResultId;
let latestDagId;
if (!dagResultsLoading && !dagResultsError && dagResults.length > 0) {
const latestDagResult = getLatestDagResult(dagResults);
latestDagResultId = latestDagResult.id;
latestDagId = latestDagResult.dag_id;
} else if (!dagsLoading && !dagsError && dags.length > 0) {
latestDagId = dags[0].id;
}

const nodes = useWorkflowNodes(user.apiKey, workflowId, latestDagId);
Expand All @@ -289,7 +336,9 @@ const WorkflowsPage: React.FC<Props> = ({ user, Layout = DefaultLayout }) => {
return {
checkId: op.id,
name: op.name,
status: nodesResults.artifacts[artifactId]?.exec_state?.status,
status:
nodesResults.artifacts[artifactId]?.exec_state?.status ??
ExecutionStatus.Registered,
level: op.spec.check.level,
value: nodesResults.artifacts[artifactId]?.content_serialized,
timestamp:
Expand Down