rambleraptor commented on code in PR #4598:
URL: https://github.com/apache/iceberg-python/pull/4598#discussion_r4812878378


##########
dev/provision.py:
##########
@@ -15,13 +15,67 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from typing import Any
+
+import requests
 from pyspark.sql import SparkSession
 from pyspark.sql.functions import current_date, date_add, expr
 
 from pyiceberg.catalog import load_catalog
 from pyiceberg.schema import Schema
 from pyiceberg.types import FixedType, NestedField, UUIDType
 
+LAKEKEEPER_MANAGEMENT_URI = "http://localhost:8182/management/v1";
+LAKEKEEPER_WAREHOUSE = "lakekeeper"
+
+
+def _lakekeeper(method: str, path: str, json: dict[str, Any] | None = None) -> 
requests.Response:
+    response = requests.request(method, f"{LAKEKEEPER_MANAGEMENT_URI}/{path}", 
json=json)
+    if not response.ok:
+        raise RuntimeError(f"Lakekeeper {method} {path} failed with 
{response.status_code}: {response.text}")
+    return response
+
+
+def provision_lakekeeper() -> None:
+    """Bootstrap Lakekeeper and create a warehouse that only allows access 
through remote signing."""
+    if not _lakekeeper("GET", "info").json()["bootstrapped"]:
+        _lakekeeper("POST", "bootstrap", json={"accept-terms-of-use": True})
+
+    warehouses = _lakekeeper("GET", "warehouse").json()["warehouses"]
+    if any(warehouse["name"] == LAKEKEEPER_WAREHOUSE for warehouse in 
warehouses):
+        return

Review Comment:
   Could you leave a comment on this? I think the intention here is to avoid 
double bootstrapping Lakekeeper, but that's not clear here. 



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to