Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

storage inspector fixes & code gen update (#8566)

Shahmir Varqha59d8c9e24e90
diff --git a/frontend/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap b/frontend/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap
index 30a3843442..bb47f0d5ea 100644
--- a/frontend/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap
+++ b/frontend/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap
@@ -29,6 +29,43 @@ store = AzureStore("my-container",
)"
`;
+exports[`generateStorageCode > CoreWeave > basic connection with all fields 1`] = `
+"from obstore.store import S3Store
+
+store = S3Store("operator-bucket",
+ region="US-EAST-04A",
+ access_key_id="AKIAIOSFODNN7EXAMPLE",
+ secret_access_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
+ endpoint="https://operator-bucket.cwobject.com",
+ virtual_hosted_style_request=True,
+)"
+`;
+
+exports[`generateStorageCode > CoreWeave > minimal connection (bucket and region only) 1`] = `
+"from obstore.store import S3Store
+
+store = S3Store("operator-bucket",
+ region="US-EAST-04A",
+ endpoint="https://operator-bucket.cwobject.com",
+ virtual_hosted_style_request=True,
+)"
+`;
+
+exports[`generateStorageCode > CoreWeave > with secrets 1`] = `
+"from obstore.store import S3Store
+import os
+
+_access_key_id = os.environ.get("COREWEAVE_OBJECT_STORAGE_KEY")
+_secret_access_key = os.environ.get("COREWEAVE_OBJECT_STORAGE_SECRET")
+store = S3Store("operator-bucket",
+ region="US-EAST-04A",
+ access_key_id=_access_key_id,
+ secret_access_key=_secret_access_key,
+ endpoint="https://operator-bucket.cwobject.com",
+ virtual_hosted_style_request=True,
+)"
+`;
+
exports[`generateStorageCode > GCS > with service account key 1`] = `
"from obstore.store import GCSStore
import json
diff --git a/frontend/src/components/editor/connections/storage/__tests__/as-code.test.ts b/frontend/src/components/editor/connections/storage/__tests__/as-code.test.ts
index 26dacb3db0..f61a6f266a 100644
--- a/frontend/src/components/editor/connections/storage/__tests__/as-code.test.ts
+++ b/frontend/src/components/editor/connections/storage/__tests__/as-code.test.ts
@@ -27,6 +27,14 @@ describe("generateStorageCode", () => {
account_key: "base64accountkey==",
};
+ const baseCoreWeave: StorageConnection = {
+ type: "coreweave",
+ bucket: "operator-bucket",
+ region: "US-EAST-04A",
+ access_key_id: "AKIAIOSFODNN7EXAMPLE",
+ secret_access_key: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
+ };
+
const baseGDrive: StorageConnection = {
type: "gdrive",
credentials_json:
@@ -105,6 +113,32 @@ describe("generateStorageCode", () => {
});
});
+ describe("CoreWeave", () => {
+ it("basic connection with all fields", () => {
+ expect(generateStorageCode(baseCoreWeave, "obstore")).toMatchSnapshot();
+ });
+
+ it("minimal connection (bucket and region only)", () => {
+ const conn: StorageConnection = {
+ type: "coreweave",
+ bucket: "operator-bucket",
+ region: "US-EAST-04A",
+ };
+ expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
+ });
+
+ it("with secrets", () => {
+ const conn: StorageConnection = {
+ type: "coreweave",
+ bucket: "operator-bucket",
+ region: "US-EAST-04A",
+ access_key_id: prefixSecret("COREWEAVE_OBJECT_STORAGE_KEY"),
+ secret_access_key: prefixSecret("COREWEAVE_OBJECT_STORAGE_SECRET"),
+ };
+ expect(generateStorageCode(conn, "obstore")).toMatchSnapshot();
+ });
+ });
+
describe("Google Drive", () => {
it("with service account credentials", () => {
expect(generateStorageCode(baseGDrive, "fsspec")).toMatchSnapshot();
@@ -162,5 +196,31 @@ describe("generateStorageCode", () => {
),
).toThrow();
});
+
+ it("throws for empty CoreWeave bucket", () => {
+ expect(() =>
+ generateStorageCode(
+ {
+ type: "coreweave",
+ bucket: "",
+ region: "US-EAST-04A",
+ } as StorageConnection,
+ "obstore",
+ ),
+ ).toThrow();
+ });
+
+ it("throws for empty CoreWeave region", () => {
+ expect(() =>
+ generateStorageCode(
+ {
+ type: "coreweave",
+ bucket: "operator-bucket",
+ region: "",
+ } as StorageConnection,
+ "obstore",
+ ),
+ ).toThrow();
+ });
});
});
diff --git a/frontend/src/components/editor/connections/storage/add-storage-form.tsx b/frontend/src/components/editor/connections/storage/add-storage-form.tsx
index 26337dc1ac..ec1cc1ba13 100644
--- a/frontend/src/components/editor/connections/storage/add-storage-form.tsx
+++ b/frontend/src/components/editor/connections/storage/add-storage-form.tsx
@@ -4,6 +4,7 @@ import { useState } from "react";
import type { FieldValues } from "react-hook-form";
import type { z } from "zod";
import { ProtocolIcon } from "@/components/storage/components";
+import type { KnownStorageProtocol } from "@/core/storage/types";
import { ConnectionForm, SelectorButton, SelectorGrid } from "../components";
import {
generateStorageCode,
@@ -12,6 +13,7 @@ import {
} from "./as-code";
import {
AzureStorageSchema,
+ CoreWeaveStorageSchema,
GCSStorageSchema,
GoogleDriveStorageSchema,
S3StorageSchema,
@@ -21,7 +23,6 @@ import {
interface StorageProviderSchema {
name: string;
schema: z.ZodType<StorageConnection, FieldValues>;
- color: string;
protocol: string;
storageLibraries: {
libraries: StorageLibrary[];
@@ -29,11 +30,12 @@ interface StorageProviderSchema {
};
}
+const BACKGROUND_COLOR = "#232F3E";
+
const STORAGE_PROVIDERS = [
{
name: "Amazon S3",
schema: S3StorageSchema,
- color: "#232F3E",
protocol: "s3",
storageLibraries: {
libraries: ["obstore"],
@@ -43,7 +45,6 @@ const STORAGE_PROVIDERS = [
{
name: "Google Cloud Storage",
schema: GCSStorageSchema,
- color: "#4285F4",
protocol: "gcs",
storageLibraries: {
libraries: ["obstore"],
@@ -53,17 +54,24 @@ const STORAGE_PROVIDERS = [
{
name: "Azure Blob Storage",
schema: AzureStorageSchema,
- color: "#0062AD",
protocol: "azure",
storageLibraries: {
libraries: ["obstore"],
preferred: "obstore",
},
},
+ {
+ name: "CoreWeave",
+ schema: CoreWeaveStorageSchema,
+ protocol: "coreweave",
+ storageLibraries: {
+ libraries: ["obstore"],
+ preferred: "obstore",
+ },
+ },
{
name: "Google Drive",
schema: GoogleDriveStorageSchema,
- color: "#177834",
protocol: "gdrive",
storageLibraries: {
libraries: ["fsspec"],
@@ -77,18 +85,17 @@ const StorageProviderSelector: React.FC<{
}> = ({ onSelect }) => {
return (
<SelectorGrid>
- {STORAGE_PROVIDERS.map(({ name, schema, color, protocol }) => (
+ {STORAGE_PROVIDERS.map(({ name, schema, protocol }) => (
<SelectorButton
key={name}
name={name}
- color={color}
+ color={BACKGROUND_COLOR}
icon={
- <span className="w-8 h-8 flex items-center justify-center">
- <ProtocolIcon
- protocol={protocol}
- className="w-7 h-7 brightness-0 invert"
- />
- </span>
+ <ProtocolIcon
+ protocol={protocol as KnownStorageProtocol}
+ forceDark={true}
+ className="w-7.5 h-7.5"
+ />
}
onSelect={() => onSelect(schema)}
/>
diff --git a/frontend/src/components/editor/connections/storage/as-code.ts b/frontend/src/components/editor/connections/storage/as-code.ts
index 907ed87eeb..bf3190bf98 100644
--- a/frontend/src/components/editor/connections/storage/as-code.ts
+++ b/frontend/src/components/editor/connections/storage/as-code.ts
@@ -125,6 +125,40 @@ function generateAzureCode(
return { imports, code };
}
+function generateCoreWeaveCode(
+ connection: Extract<StorageConnection, { type: "coreweave" }>,
+ secrets: SecretContainer,
+): { imports: Set<string>; code: string } {
+ const bucket = secrets.print("bucket", connection.bucket);
+ const imports = new Set(["from obstore.store import S3Store"]);
+ const params: string[] = [
+ ` region=${secrets.print("region", connection.region)},`,
+ ];
+
+ if (connection.access_key_id) {
+ params.push(
+ ` access_key_id=${secrets.print("access_key_id", connection.access_key_id)},`,
+ );
+ }
+ if (connection.secret_access_key) {
+ params.push(
+ ` secret_access_key=${secrets.print("secret_access_key", connection.secret_access_key)},`,
+ );
+ }
+
+ params.push(
+ ` endpoint="https://${connection.bucket}.cwobject.com",`,
+ " virtual_hosted_style_request=True,",
+ );
+
+ const paramsStr = `\n${params.join("\n")}\n`;
+
+ const code = dedent(`
+ store = S3Store(${bucket},${paramsStr})
+ `);
+ return { imports, code };
+}
+
function generateGDriveCode(
connection: Extract<StorageConnection, { type: "gdrive" }>,
secrets: SecretContainer,
@@ -169,6 +203,9 @@ export function generateStorageCode(
case "azure":
result = generateAzureCode(connection, secrets);
break;
+ case "coreweave":
+ result = generateCoreWeaveCode(connection, secrets);
+ break;
case "gdrive":
result = generateGDriveCode(connection, secrets);
break;
diff --git a/frontend/src/components/editor/connections/storage/schemas.ts b/frontend/src/components/editor/connections/storage/schemas.ts
index 5da0603789..ac98fd3c5f 100644
--- a/frontend/src/components/editor/connections/storage/schemas.ts
+++ b/frontend/src/components/editor/connections/storage/schemas.ts
@@ -21,7 +21,6 @@ export const S3StorageSchema = z
FieldOptions.of({
label: "Region",
placeholder: "us-east-1",
- optionRegex: ".*region.*",
}),
),
access_key_id: z
@@ -115,6 +114,50 @@ export const AzureStorageSchema = z
})
.describe(FieldOptions.of({ direction: "two-columns" }));
+export const CoreWeaveStorageSchema = z
+ .object({
+ type: z.literal("coreweave"),
+ bucket: z
+ .string()
+ .nonempty()
+ .describe(
+ FieldOptions.of({
+ label: "Bucket",
+ placeholder: "bucket-name",
+ }),
+ ),
+ region: z
+ .string()
+ .nonempty()
+ .describe(
+ FieldOptions.of({
+ label: "Region",
+ placeholder: "US-EAST-04A",
+ }),
+ ),
+ access_key_id: z
+ .string()
+ .optional()
+ .describe(
+ FieldOptions.of({
+ label: "Access Key ID",
+ inputType: "password",
+ optionRegex: ".*object_storage_key.*",
+ }),
+ ),
+ secret_access_key: z
+ .string()
+ .optional()
+ .describe(
+ FieldOptions.of({
+ label: "Secret Access Key",
+ inputType: "password",
+ optionRegex: ".*object_storage_secret.*",
+ }),
+ ),
+ })
+ .describe(FieldOptions.of({ direction: "two-columns" }));
+
export const GoogleDriveStorageSchema = z
.object({
type: z.literal("gdrive"),
@@ -135,6 +178,7 @@ export const StorageConnectionSchema = z.discriminatedUnion("type", [
S3StorageSchema,
GCSStorageSchema,
AzureStorageSchema,
+ CoreWeaveStorageSchema,
GoogleDriveStorageSchema,
]);
diff --git a/frontend/src/components/storage/components.tsx b/frontend/src/components/storage/components.tsx
index b37d0018d9..6d71448fb2 100644
--- a/frontend/src/components/storage/components.tsx
+++ b/frontend/src/components/storage/components.tsx
@@ -75,15 +75,19 @@ const PROTOCOL_ICONS: Record<KnownStorageProtocol, IconEntry> = {
export const ProtocolIcon: React.FC<{
protocol: KnownStorageProtocol | (string & {});
+ forceDark?: boolean;
className?: string;
-}> = ({ protocol, className }) => {
+}> = ({ protocol, forceDark, className }) => {
const { theme } = useTheme();
const entry =
PROTOCOL_ICONS[protocol.toLowerCase() as KnownStorageProtocol] ??
HardDriveIcon;
if ("src" in entry) {
- const src = theme === "dark" && entry.dark ? entry.dark : entry.src;
+ let src = entry.src;
+ if (entry.dark && (forceDark || theme === "dark")) {
+ src = entry.dark;
+ }
return (
<img src={src} alt={protocol} className={cn("h-3.5 w-3.5", className)} />
);
diff --git a/marimo/_data/_external_storage/storage.py b/marimo/_data/_external_storage/storage.py
index c08e1d3b2d..bc0a3e5001 100644
--- a/marimo/_data/_external_storage/storage.py
+++ b/marimo/_data/_external_storage/storage.py
@@ -54,6 +54,12 @@ class Obstore(StorageBackend["ObjectStore"]):
# Objects are actual files/objects at this level
for entry in result["objects"]:
+ # Skip zero-byte folder marker objects that some S3 clients
+ # create as directory placeholders (e.g., "folder" with size 0)
+ path = entry.get("path", "")
+ size = entry.get("size", 0)
+ if size == 0 and prefix and path == prefix.rstrip("/"):
+ continue
storage_entries.append(self._create_storage_entry(entry))
if len(storage_entries) > limit:
diff --git a/tests/_data/_external_storage/test_storage_models.py b/tests/_data/_external_storage/test_storage_models.py
index 09c3971c02..d0e17b59a5 100644
--- a/tests/_data/_external_storage/test_storage_models.py
+++ b/tests/_data/_external_storage/test_storage_models.py
@@ -87,6 +87,43 @@ class TestObstore:
]
)
+ def test_list_entries_skips_zero_byte_folder_marker(self) -> None:
+ now = datetime.now(tz=timezone.utc)
+ mock_store = MagicMock()
+ mock_store.list_with_delimiter.return_value = {
+ "common_prefixes": [],
+ "objects": [
+ {
+ "path": "folder",
+ "size": 0,
+ "last_modified": now,
+ "e_tag": "abcde",
+ "version": None,
+ },
+ {
+ "path": "folder/order_details.csv",
+ "size": 5426089,
+ "last_modified": now,
+ "e_tag": "fghij",
+ "version": None,
+ },
+ ],
+ }
+
+ backend = self._make_backend(mock_store)
+ result = backend.list_entries(prefix="folder")
+
+ assert result == [
+ StorageEntry(
+ path="folder/order_details.csv",
+ kind="object",
+ size=5426089,
+ last_modified=now.timestamp(),
+ metadata={"e_tag": "fghij"},
+ mime_type="text/csv",
+ ),
+ ]
+
def test_list_entries_empty(self) -> None:
mock_store = MagicMock()
mock_store.list_with_delimiter.return_value = {