fix obstore config panic: use AWS_ env vars, fix duplicate import
Some checks failed
ci/woodpecker/push/infra-ci Pipeline was successful
ci/woodpecker/push/deploy Pipeline failed
coverage 99% coverage
ci/woodpecker/push/ci Pipeline was successful

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:
kert
2026-03-21 21:23:29 -04:00
parent 9c71794ee4
commit 5564d01c66
3 changed files with 27 additions and 30 deletions

View File

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

View File

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

View File

@@ -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()
env = {
"RUSTFS_ENDPOINT": "http://test:9000",
"RUSTFS_ACCESS_KEY": "ak",
"RUSTFS_SECRET_KEY": "sk",
}
with patch("conf.connect.cfg") as mock_cfg: with patch("conf.connect.cfg") as mock_cfg:
mock_cfg.s3.endpoint = "http://rustfs:9000" mock_cfg.s3.endpoint = "http://rustfs:9000"
with patch.dict( with patch.dict("os.environ", env, clear=False):
"os.environ",
{
"RUSTFS_ENDPOINT": "http://test:9000",
"RUSTFS_ACCESS_KEY": "ak",
"RUSTFS_SECRET_KEY": "sk",
},
):
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()