ashb commented on code in PR #54813:
URL: https://github.com/apache/airflow/pull/54813#discussion_r2304243968


##########
providers/alibaba/src/airflow/providers/alibaba/cloud/log/oss_task_handler.py:
##########
@@ -95,6 +95,9 @@ def read(self, relative_path, ti: RuntimeTI) -> 
tuple[LogSourceInfo, LogMessages
             return messages, logs
         return messages, None
 
+    def stream(self, relative_path: str, ti: RuntimeTI) -> LogResponse:
+        raise NotImplementedError

Review Comment:
   Other option would be to have two protocols (one with just read, and one 
which subclasses it that adds in stream), and then either mark it as "runtime 
checkable", or simply do something like this:
   
   ```python
           logs: LogMessages | list[RawLogStream] | None  # extra typing to 
void mypy assignment error
           if stream := getattr(remote_io, "stream"):
               # Use .stream interface if provider's RemoteIO supports it
               sources, logs = stream(path, ti)
               return sources, logs or []
           else:
               # Fallback to .read interface
               sources, logs = remote_io.read(path, ti)
               return sources, logs or []
   ```
   
   (This also has the benefit of not masking potential exceptions from inside 
the stream function itself -- for instance if the stream function was 
implemented but raised an AttributeError inside it then it would be lost and 
the read fallback path chosen instead)



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