fix obstore config panic: use AWS_ env vars, fix duplicate import
obstore 0.9.x panics on store.config with config dict keys — marimo calls store.config for the Files panel. Fix: set AWS_* env vars and create S3Store() bare. Also fix acodb_explorer: merge duplicate connect imports into one cell, remove empty cell. marimo check now passes clean. refs #81
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import marimo
|
import marimo
|
||||||
|
|
||||||
__generated_with = "0.20.2"
|
__generated_with = "0.21.1"
|
||||||
app = marimo.App(width="full")
|
app = marimo.App(width="full")
|
||||||
|
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ def _():
|
|||||||
from conf import connect
|
from conf import connect
|
||||||
|
|
||||||
connect.theme()
|
connect.theme()
|
||||||
|
_s3 = connect.obstore() # noqa: F841 — marimo auto-discovers in Files
|
||||||
|
|
||||||
from nature import PALETTE # noqa: E402 — needs theme() to add styles to path
|
from nature import PALETTE # noqa: E402 — needs theme() to add styles to path
|
||||||
|
|
||||||
|
|||||||
@@ -125,22 +125,24 @@ def obstore(*, bucket: str = "lakehouse") -> Any:
|
|||||||
|
|
||||||
Creates an ``obstore.store.S3Store`` that marimo auto-discovers
|
Creates an ``obstore.store.S3Store`` that marimo auto-discovers
|
||||||
in the Files sidebar under Remote Storage.
|
in the Files sidebar under Remote Storage.
|
||||||
|
|
||||||
|
Sets ``AWS_*`` env vars so that ``store.config`` (called by
|
||||||
|
marimo) doesn't panic — obstore 0.9.x crashes on config dict
|
||||||
|
keys but reads env vars correctly.
|
||||||
"""
|
"""
|
||||||
from obstore.store import S3Store
|
from obstore.store import S3Store
|
||||||
|
|
||||||
endpoint = os.environ.get("RUSTFS_ENDPOINT", cfg.s3.endpoint)
|
endpoint = os.environ.get("RUSTFS_ENDPOINT", cfg.s3.endpoint)
|
||||||
access_key = os.environ.get("RUSTFS_ACCESS_KEY", "")
|
access_key = os.environ.get("RUSTFS_ACCESS_KEY", "")
|
||||||
secret_key = os.environ.get("RUSTFS_SECRET_KEY", "")
|
secret_key = os.environ.get("RUSTFS_SECRET_KEY", "")
|
||||||
return S3Store(
|
|
||||||
bucket,
|
os.environ.setdefault("AWS_ENDPOINT_URL", endpoint)
|
||||||
config={
|
os.environ.setdefault("AWS_ACCESS_KEY_ID", access_key)
|
||||||
"endpoint": endpoint,
|
os.environ.setdefault("AWS_SECRET_ACCESS_KEY", secret_key)
|
||||||
"access_key_id": access_key,
|
os.environ.setdefault("AWS_DEFAULT_REGION", "us-east-1")
|
||||||
"secret_access_key": secret_key,
|
os.environ.setdefault("AWS_ALLOW_HTTP", "true")
|
||||||
"region": "us-east-1",
|
|
||||||
"allow_http": "true",
|
return S3Store(bucket)
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def theme() -> None:
|
def theme() -> None:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
@@ -135,33 +136,26 @@ class TestS3:
|
|||||||
|
|
||||||
|
|
||||||
class TestObstore:
|
class TestObstore:
|
||||||
def test_creates_s3store(self):
|
def test_creates_s3store_and_sets_env(self):
|
||||||
mock_store = MagicMock()
|
mock_store = MagicMock()
|
||||||
with patch("conf.connect.cfg") as mock_cfg:
|
env = {
|
||||||
mock_cfg.s3.endpoint = "http://rustfs:9000"
|
|
||||||
with patch.dict(
|
|
||||||
"os.environ",
|
|
||||||
{
|
|
||||||
"RUSTFS_ENDPOINT": "http://test:9000",
|
"RUSTFS_ENDPOINT": "http://test:9000",
|
||||||
"RUSTFS_ACCESS_KEY": "ak",
|
"RUSTFS_ACCESS_KEY": "ak",
|
||||||
"RUSTFS_SECRET_KEY": "sk",
|
"RUSTFS_SECRET_KEY": "sk",
|
||||||
},
|
}
|
||||||
):
|
with patch("conf.connect.cfg") as mock_cfg:
|
||||||
|
mock_cfg.s3.endpoint = "http://rustfs:9000"
|
||||||
|
with patch.dict("os.environ", env, clear=False):
|
||||||
with patch(
|
with patch(
|
||||||
"obstore.store.S3Store", return_value=mock_store
|
"obstore.store.S3Store", return_value=mock_store
|
||||||
) as mock_cls:
|
) as mock_cls:
|
||||||
result = connect.obstore(bucket="mybucket")
|
result = connect.obstore(bucket="mybucket")
|
||||||
mock_cls.assert_called_once_with(
|
mock_cls.assert_called_once_with("mybucket")
|
||||||
"mybucket",
|
|
||||||
config={
|
|
||||||
"endpoint": "http://test:9000",
|
|
||||||
"access_key_id": "ak",
|
|
||||||
"secret_access_key": "sk",
|
|
||||||
"region": "us-east-1",
|
|
||||||
"allow_http": "true",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
assert result is mock_store
|
assert result is mock_store
|
||||||
|
assert os.environ["AWS_ENDPOINT_URL"] == "http://test:9000"
|
||||||
|
assert os.environ["AWS_ACCESS_KEY_ID"] == "ak"
|
||||||
|
assert os.environ["AWS_SECRET_ACCESS_KEY"] == "sk"
|
||||||
|
assert os.environ["AWS_ALLOW_HTTP"] == "true"
|
||||||
|
|
||||||
def test_default_bucket(self):
|
def test_default_bucket(self):
|
||||||
mock_store = MagicMock()
|
mock_store = MagicMock()
|
||||||
|
|||||||
Reference in New Issue
Block a user