eladkal commented on code in PR #70088:
URL: https://github.com/apache/airflow/pull/70088#discussion_r3729517906


##########
providers/databricks/tests/unit/databricks/operators/test_databricks_warehouse.py:
##########


Review Comment:
   same comment about file name



##########
providers/databricks/src/airflow/providers/databricks/operators/databricks_warehouse.py:
##########


Review Comment:
   About file name. I know this is following what we have now in the provider 
but this doesn't align with project conventions.
   it should be `warehouse.py`
   
   I will raise followup PR to fix the other files soon



##########
providers/databricks/src/airflow/providers/databricks/hooks/databricks.py:
##########
@@ -267,6 +268,53 @@ def from_json(cls, data: str) -> SQLStatementState:
         return SQLStatementState(**json.loads(data))
 
 
+class WarehouseState:
+    """Utility class for the state of a Databricks SQL warehouse."""
+
+    WAREHOUSE_STATES = ["STARTING", "RUNNING", "STOPPING", "STOPPED", 
"DELETING", "DELETED"]
+
+    def __init__(self, state: str = "", *args, **kwargs) -> None:
+        if state not in self.WAREHOUSE_STATES:
+            raise ValueError(
+                f"Unexpected warehouse state: {state}: If the state has been 
introduced recently, "
+                "please check the Databricks user guide for troubleshooting 
information"
+            )
+        self.state = state
+
+    @property
+    def is_running(self) -> bool:
+        """Return whether the warehouse is running."""
+        return self.state == "RUNNING"
+
+    @property
+    def is_stopped(self) -> bool:
+        """Return whether the warehouse is stopped."""
+        return self.state == "STOPPED"
+
+    @property
+    def is_deleted(self) -> bool:
+        """Return whether the warehouse is deleting or deleted."""
+        return self.state in ("DELETING", "DELETED")
+
+    def __eq__(self, other: object) -> bool:
+        if not isinstance(other, WarehouseState):
+            return NotImplemented
+        return self.state == other.state
+
+    def __hash__(self):
+        return hash(self.state)
+
+    def __repr__(self) -> str:
+        return str(self.__dict__)
+
+    def to_json(self) -> str:
+        return json.dumps(self.__dict__)
+
+    @classmethod
+    def from_json(cls, data: str) -> WarehouseState:
+        return WarehouseState(**json.loads(data))

Review Comment:
   I don't see any core using these. What are they for?



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