Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/every-rockets-tie.md

This file was deleted.

6 changes: 6 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.3.0

### Minor Changes

- 8a49b7c: Support multipart uploads and use it by default for larger files

## 2.2.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mixedbread/cli",
"version": "2.2.3",
"version": "2.3.0",
"description": "CLI tool for managing the Mixedbread platform.",
"author": "Mixedbread <support@mixedbread.com>",
"license": "Apache-2.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/store/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { z } from "zod";
import { createClient } from "../../utils/client";
import { warnContextualizationDeprecated } from "../../utils/deprecation";
import { getGitInfo } from "../../utils/git";
import type { MultipartUploadOptions } from "../../utils/upload";
import {
addGlobalOptions,
extendGlobalOptions,
Expand All @@ -22,6 +21,7 @@ import {
formatChangeSummary,
} from "../../utils/sync";
import { getSyncedFiles } from "../../utils/sync-state";
import type { MultipartUploadOptions } from "../../utils/upload";

const SyncStoreSchema = extendGlobalOptions({
nameOrId: z.string().min(1, { error: '"name-or-id" is required' }),
Expand Down Expand Up @@ -87,15 +87,15 @@ export function createSyncCommand(): Command {
.option("--parallel <n>", "Number of concurrent operations (1-200)")
.option(
"--multipart-threshold <mb>",
"File size threshold in MB to trigger multipart upload",
"File size threshold in MB to trigger multipart upload"
)
.option(
"--multipart-part-size <mb>",
"Size of each part in MB for multipart upload",
"Size of each part in MB for multipart upload"
)
.option(
"--multipart-concurrency <n>",
"Number of concurrent part uploads for multipart upload",
"Number of concurrent part uploads for multipart upload"
)
);

Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/store/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ export function createUploadCommand(): Command {
.option("--manifest <file>", "Upload using manifest file")
.option(
"--multipart-threshold <mb>",
"File size threshold in MB to trigger multipart upload",
"File size threshold in MB to trigger multipart upload"
)
.option(
"--multipart-part-size <mb>",
"Size of each part in MB for multipart upload",
"Size of each part in MB for multipart upload"
)
.option(
"--multipart-concurrency <n>",
"Number of concurrent part uploads for multipart upload",
"Number of concurrent part uploads for multipart upload"
)
);

Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/utils/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ export async function executeSyncChanges(
const failedCount = results.uploads.failed.length - skippedCount;

if (uploadedOk === uploadTotal) {
uploadSpinner.stop(`Uploaded ${formatCountWithSuffix(uploadTotal, "file")}`);
uploadSpinner.stop(
`Uploaded ${formatCountWithSuffix(uploadTotal, "file")}`
);
} else {
const parts: string[] = [];
if (failedCount > 0) parts.push(`${failedCount} failed`);
Expand Down
23 changes: 17 additions & 6 deletions packages/cli/src/utils/upload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile, stat } from "node:fs/promises";
import { basename, relative } from "node:path";
import { cpus, freemem } from "node:os";
import { basename, relative } from "node:path";
import type Mixedbread from "@mixedbread/sdk";
import type { FileCreateParams } from "@mixedbread/sdk/resources/stores";
import chalk from "chalk";
Expand Down Expand Up @@ -140,8 +140,13 @@ export async function uploadFile(
filePath: string,
options: UploadFileOptions = {}
): Promise<void> {
const { metadata = {}, strategy, externalId, multipartUpload, onProgress } =
options;
const {
metadata = {},
strategy,
externalId,
multipartUpload,
onProgress,
} = options;

// Read file content
const fileContent = await readFile(filePath);
Expand Down Expand Up @@ -284,7 +289,9 @@ export async function uploadFilesInBatch(
const stats = await stat(file.path);
if (stats.size === 0) {
completed++;
uploadSpinner.message(`Uploading ${completed}/${formatCountWithSuffix(total, "file")}...`);
uploadSpinner.message(
`Uploading ${completed}/${formatCountWithSuffix(total, "file")}...`
);
results.skipped++;
return;
}
Expand Down Expand Up @@ -341,11 +348,15 @@ export async function uploadFilesInBatch(

results.successfulSize += stats.size;
completed++;
uploadSpinner.message(`Uploading ${completed}/${formatCountWithSuffix(total, "file")}...`);
uploadSpinner.message(
`Uploading ${completed}/${formatCountWithSuffix(total, "file")}...`
);
} catch (error) {
results.failed++;
completed++;
uploadSpinner.message(`Uploading ${completed}/${formatCountWithSuffix(total, "file")}...`);
uploadSpinner.message(
`Uploading ${completed}/${formatCountWithSuffix(total, "file")}...`
);
const errorMsg =
error instanceof Error ? error.message : "Unknown error";
log.error(`${relativePath} - ${errorMsg}`);
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/tests/utils/vector-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ describe("Store Utils", () => {
});

await expect(
resolveStore(
mockClient as unknown as Mixedbread,
"nonexistent-store"
)
resolveStore(mockClient as unknown as Mixedbread, "nonexistent-store")
).rejects.toThrow('Store "nonexistent-store" not found');
});

Expand Down