hduong-mwam commented on code in PR #35719:
URL: https://github.com/apache/airflow/pull/35719#discussion_r1412787254


##########
airflow/www/static/js/dag/details/taskInstance/Xcom/XcomEntry.tsx:
##########
@@ -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 { useTaskXcom } 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,
+  } = useTaskXcom({
+    dagId,
+    dagRunId,
+    taskId,
+    mapIndex,
+    xcomKey,
+    tryNumber: tryNumber || 1,
+  });
+
+  let content = <Text fontFamily="monospace">{xcom?.value}</Text>;

Review Comment:
   Sorry I am afraid I am not following. In my test, I just have a task which 
returns this dict `{"long_string": "Lorem..."}`. This results in two XCom 
entries:
   - The key `long_string`: `Lorem...`
   - And the full `return_value`: `{"long_string": "Lorem..."}`
   
   Do you mean check that the entry value is a valid JSON and format that? I 
personally haven't have a use-case that I return an entry that is a JSON but 
instead if the task returns a dict then I can access the attributes as keys (if 
that makes sense)
   
   Keyed portion
   
![image](https://github.com/apache/airflow/assets/148540755/4514a27e-51e6-4b8d-bced-cf2a34303d32)
   
   Full return_value portion
   
![image](https://github.com/apache/airflow/assets/148540755/a671eb65-4a91-4a63-9128-eb2d0f47fb0a)
   
![image](https://github.com/apache/airflow/assets/148540755/010618c1-efac-483e-b071-5cd437a273e7)
   
   (Apologies for the handwriting 😄) Here is an example of shorter XCom but 
with many keys to illustrate my point
   
![image](https://github.com/apache/airflow/assets/148540755/ecfb282f-47a8-477b-a4a7-c66336c23893)
   



##########
airflow/www/static/js/dag/details/taskInstance/Xcom/XcomEntry.tsx:
##########
@@ -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 { useTaskXcom } 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,
+  } = useTaskXcom({
+    dagId,
+    dagRunId,
+    taskId,
+    mapIndex,
+    xcomKey,
+    tryNumber: tryNumber || 1,
+  });
+
+  let content = <Text fontFamily="monospace">{xcom?.value}</Text>;

Review Comment:
   Sorry I am afraid I am not following. In my test, I just have a task which 
returns this dict `{"long_string": "Lorem..."}`. This results in two XCom 
entries:
   - The key `long_string`: `Lorem...`
   - And the full `return_value`: `{"long_string": "Lorem..."}`
   
   Do you mean check that the entry value is a valid JSON and format that? I 
personally haven't have a use-case that I return an entry that is a JSON but 
instead if the task returns a dict then I can access the attributes as keys (if 
that makes sense)
   
   Keyed portion
   
![image](https://github.com/apache/airflow/assets/148540755/4514a27e-51e6-4b8d-bced-cf2a34303d32)
   
   Full return_value portion
   
![image](https://github.com/apache/airflow/assets/148540755/a671eb65-4a91-4a63-9128-eb2d0f47fb0a)
   
![image](https://github.com/apache/airflow/assets/148540755/010618c1-efac-483e-b071-5cd437a273e7)
   
   (Apologies for the handwriting 😄) Here is an example of shorter XCom but 
with many keys to illustrate my point
   
![image](https://github.com/apache/airflow/assets/148540755/ecfb282f-47a8-477b-a4a7-c66336c23893)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to