dabla commented on code in PR #68510:
URL: https://github.com/apache/airflow/pull/68510#discussion_r3459899424


##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/log/wasb_task_handler.py:
##########
@@ -84,6 +85,33 @@ def hook(self):
             )
             return None
 
+    def _build_log_source_url(self, blob_name: str) -> str:
+        legacy_url = 
f"https://{self.wasb_container}.blob.core.windows.net/{blob_name}";

Review Comment:
   I would extract a method named _build_legacy_url:
   
   ```
   def _build_legacy_url(self, blob_name: str) -> str:
           return 
f"https://{self.wasb_container}.blob.core.windows.net/{blob_name}";
   ```
   
   Then in _build_log_source_url I would do as follow (hook is a cached 
propery):
   
   ```
   if not self.hook:
           return self._build_legacy_url(blob_name)
   ```
   
   Then do same call at then end of the `_build_log_source_url `method if no 
other condition was met.



##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/log/wasb_task_handler.py:
##########
@@ -100,7 +128,7 @@ def read(self, relative_path, ti: RuntimeTI) -> 
tuple[LogSourceInfo, LogMessages
             self.log.exception("can't list blobs")
 
         if blob_names:

Review Comment:
   Think this can be optimized like this:
   
   ```
   if blob_names:
       uris = (self._build_log_source_url(b) for b in blob_names)
   
       if AIRFLOW_V_3_0_PLUS:
           messages = list(uris)
       else:
           messages.extend(
               ["Found remote logs:",
                *[f"  * {x}" for x in sorted(uris)]]
           )
   else:
       return messages, None
   ```



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