pankajkoti commented on code in PR #45334:
URL: https://github.com/apache/airflow/pull/45334#discussion_r1900676677


##########
providers/src/airflow/providers/databricks/operators/databricks.py:
##########
@@ -242,7 +243,35 @@ def get_link(
         *,
         ti_key: TaskInstanceKey,
     ) -> str:
-        return XCom.get_value(key=XCOM_RUN_PAGE_URL_KEY, ti_key=ti_key)
+        # Retrieve the value from XCom
+        value = XCom.get_value(key=XCOM_RUN_PAGE_URL_KEY, ti_key=ti_key)
+
+        # Check if the value is an S3 URL
+        if value and value.startswith("s3://"):
+            try:
+                # Parse the S3 URL and extract job information
+                return self.construct_databricks_url(value)
+            except Exception:
+                # Return a placeholder link in case of an error
+                return "#"
+
+        # Return the value directly if it's not an S3 URL
+        return value
+
+    @staticmethod
+    def construct_databricks_url(s3_url: str) -> str:
+        """
+        Convert an S3 URL to a Databricks workspace URL.
+
+        Assumes the S3 URL points to a JSON file that contains job details.
+        """
+        parsed = urlparse(s3_url)
+
+        # Example logic: Extract the job run ID from the path
+        job_details = parsed.path.split("/")[-1].replace(".json", "")
+        databricks_workspace_url = 
f"https://<your-databricks-workspace-url>/#job/{job_details}/run"

Review Comment:
   how does this <your-databricks-workspace-url> in the URL work? 
   
   Also, can you provide an example of how the XCOM value looks like?



##########
providers/tests/databricks/operators/test_databricks.py:
##########
@@ -2343,3 +2344,95 @@ def test_user_databricks_task_key(self):
         expected_task_key = "test_task_key"
 
         assert expected_task_key == operator.databricks_task_key
+
+
+def test_get_link_with_valid_s3_url():

Review Comment:
   this test is doing a lot of mocking and does not seem to test much.



-- 
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