Skip to content

Commit

Permalink
Merge pull request #60 from vlm-run/sh/add-dataset
Browse files Browse the repository at this point in the history
fix: fs issue in web env
  • Loading branch information
shahrear33 authored Feb 20, 2025
2 parents f054afb + 5734955 commit b78aaae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vlmrun",
"version": "0.2.7",
"version": "0.2.8",
"description": "The official TypeScript library for the VlmRun API",
"author": "VlmRun <[email protected]>",
"main": "dist/index.js",
Expand Down
8 changes: 6 additions & 2 deletions src/client/datasets.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Client, APIRequestor } from "./base_requestor";
import { DatasetResponse, DatasetCreateParams, DatasetListParams } from "./types";
import { createArchive } from "../utils";
import * as fs from "fs";
import * as path from "path";
import { Files } from "../index";

export class Datasets {
Expand All @@ -26,12 +24,18 @@ export class Datasets {
*/
async create(params: DatasetCreateParams): Promise<DatasetResponse> {
const validTypes = ["images", "videos", "documents"];

if (typeof window !== "undefined") {
throw new Error("createArchive is not supported in a browser environment.");
}

if (!validTypes.includes(params.datasetType)) {
throw new Error("dataset_type must be one of: images, videos, documents");
}

// Create tar.gz archive of the dataset directory.
const tarPath = await createArchive(params.datasetDirectory, params.datasetName);
const fs = require('fs');
const tarSizeMB = (fs.statSync(tarPath).size / 1024 / 1024).toFixed(2);
console.debug(`Created tar.gz file [path=${tarPath}, size=${tarSizeMB} MB]`);

Expand Down

0 comments on commit b78aaae

Please sign in to comment.