-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add XCom tab to Grid * Combine showLogs and showXcom logic evaluation to isIndividualTaskInstance * Remove link to /xcom page from UI grid view * Use consistent naming to distinguish XcomCollection and XcomEntry * Refactor boolean vars (cherry picked from commit 77c0103)
- Loading branch information
1 parent
beba3b8
commit be86dd3
Showing
7 changed files
with
329 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*! | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import type { API } from "src/types"; | ||
import { getMetaValue } from "src/utils"; | ||
import { useQuery } from "react-query"; | ||
import axios, { AxiosResponse } from "axios"; | ||
|
||
// tryNumber is not required to get XCom keys or values but is used | ||
// in query key so refetch will occur if new tries are available | ||
interface TaskXcomCollectionProps extends API.GetXcomEntriesVariables { | ||
tryNumber: number; | ||
} | ||
interface TaskXcomProps extends API.GetXcomEntryVariables { | ||
tryNumber: number; | ||
} | ||
|
||
export const useTaskXcomCollection = ({ | ||
dagId, | ||
dagRunId, | ||
taskId, | ||
mapIndex, | ||
tryNumber, | ||
}: TaskXcomCollectionProps) => | ||
useQuery(["taskXcoms", dagId, dagRunId, taskId, mapIndex, tryNumber], () => | ||
axios.get<AxiosResponse, API.XComCollection>( | ||
getMetaValue("task_xcom_entries_api") | ||
.replace("_DAG_RUN_ID_", dagRunId) | ||
.replace("_TASK_ID_", taskId), | ||
{ params: { map_index: mapIndex } } | ||
) | ||
); | ||
|
||
export const useTaskXcomEntry = ({ | ||
dagId, | ||
dagRunId, | ||
taskId, | ||
mapIndex, | ||
xcomKey, | ||
tryNumber, | ||
}: TaskXcomProps) => | ||
useQuery( | ||
["taskXcom", dagId, dagRunId, taskId, mapIndex, xcomKey, tryNumber], | ||
() => | ||
axios.get<AxiosResponse, API.XCom>( | ||
getMetaValue("task_xcom_entry_api") | ||
.replace("_DAG_RUN_ID_", dagRunId) | ||
.replace("_TASK_ID_", taskId) | ||
.replace("_XCOM_KEY_", xcomKey), | ||
{ params: { map_index: mapIndex } } | ||
), | ||
{ | ||
enabled: !!xcomKey, | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
airflow/www/static/js/dag/details/taskInstance/Xcom/XcomEntry.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*! | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { Alert, AlertIcon, Spinner, Td, Text, Tr } from "@chakra-ui/react"; | ||
import React from "react"; | ||
import { useTaskXcomEntry } from "src/api"; | ||
import type { Dag, DagRun, TaskInstance } from "src/types"; | ||
|
||
interface Props { | ||
dagId: Dag["id"]; | ||
dagRunId: DagRun["runId"]; | ||
taskId: TaskInstance["taskId"]; | ||
mapIndex?: TaskInstance["mapIndex"]; | ||
xcomKey: string; | ||
tryNumber: TaskInstance["tryNumber"]; | ||
} | ||
|
||
const XcomEntry = ({ | ||
dagId, | ||
dagRunId, | ||
taskId, | ||
mapIndex, | ||
xcomKey, | ||
tryNumber, | ||
}: Props) => { | ||
const { | ||
data: xcom, | ||
isLoading, | ||
error, | ||
} = useTaskXcomEntry({ | ||
dagId, | ||
dagRunId, | ||
taskId, | ||
mapIndex, | ||
xcomKey, | ||
tryNumber: tryNumber || 1, | ||
}); | ||
|
||
let content = <Text fontFamily="monospace">{xcom?.value}</Text>; | ||
if (isLoading) { | ||
content = <Spinner />; | ||
} else if (error) { | ||
content = ( | ||
<Alert status="error"> | ||
<AlertIcon /> | ||
Error loading XCom entry | ||
</Alert> | ||
); | ||
} else if (!xcom) { | ||
content = ( | ||
<Alert status="info"> | ||
<AlertIcon /> | ||
No value found for XCom key | ||
</Alert> | ||
); | ||
} | ||
|
||
return ( | ||
<Tr> | ||
<Td>{xcomKey}</Td> | ||
<Td>{content}</Td> | ||
</Tr> | ||
); | ||
}; | ||
|
||
export default XcomEntry; |
Oops, something went wrong.