uranusjr commented on code in PR #73015:
URL: https://github.com/apache/airflow/pull/73015#discussion_r4491122623


##########
providers/amazon/src/airflow/providers/amazon/aws/bundles/s3.py:
##########
@@ -163,7 +150,215 @@ def view_url_template(self) -> str | None:
         if self.s3_hook.region_name:
             url += f".{self.s3_hook.region_name}"
         url += ".amazonaws.com"
-        if self.prefix:
-            url += f"/{self.prefix}"
+        key = self._view_url_key()
+        if key:
+            url += f"/{key}"
 
         return url
+
+    def _reject_version_refresh(self) -> None:
+        if self.version:
+            raise AirflowException("Refreshing a specific version is not 
supported")

Review Comment:
   I think we can make the base class implement a template `refresh` that 
implement the common “shape” that looks like this:
   
   ```python
   def refresh(...
       if self.version:
           raise ...
       with self.lock():
           self._refresh_locked()
   ```
   
   Now each subclass only needs to implement exactly what they do differently, 
instead of having to repeat the ceremony.



##########
providers/amazon/src/airflow/providers/amazon/aws/bundles/s3.py:
##########
@@ -163,7 +150,215 @@ def view_url_template(self) -> str | None:
         if self.s3_hook.region_name:
             url += f".{self.s3_hook.region_name}"
         url += ".amazonaws.com"
-        if self.prefix:
-            url += f"/{self.prefix}"
+        key = self._view_url_key()
+        if key:
+            url += f"/{key}"
 
         return url
+
+    def _reject_version_refresh(self) -> None:
+        if self.version:
+            raise AirflowException("Refreshing a specific version is not 
supported")

Review Comment:
   I think we can make the base class implement a template `refresh` that 
implement the common “shape” that looks like this:
   
   ```python
   def refresh(...
       if self.version:
           raise ...
       with self.lock():
           self._refresh_locked()  # abstract
   ```
   
   Now each subclass only needs to implement exactly what they do differently, 
instead of having to repeat the ceremony.



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