@lmnr-ai/lmnr 0.8.53 → 0.8.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/cli.cjs +6 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +1 -3
- package/dist/cli.d.mts +1 -3
- package/dist/cli.mjs +6 -9
- package/dist/cli.mjs.map +1 -1
- package/dist/{consts-9rSS0oeR.cjs → consts-X-pnRGD0.cjs} +2 -3
- package/dist/{consts-9rSS0oeR.cjs.map → consts-X-pnRGD0.cjs.map} +1 -1
- package/dist/{consts-CTTu3jhI.mjs → consts-r67THnT9.mjs} +2 -3
- package/dist/{consts-CTTu3jhI.mjs.map → consts-r67THnT9.mjs.map} +1 -1
- package/dist/{evaluations-BwB2JsRa.d.mts → evaluations-Bz4AjiEN.d.mts} +302 -1264
- package/dist/{evaluations-BXDpgOzM.d.cts → evaluations-CAossFsy.d.cts} +302 -1264
- package/dist/{file-utils-CyBBBeeW.cjs → file-utils-DvRb07ah.cjs} +7 -15
- package/dist/{file-utils-CyBBBeeW.cjs.map → file-utils-DvRb07ah.cjs.map} +1 -1
- package/dist/{file-utils-CwqjWMsF.mjs → file-utils-qSiXXrPa.mjs} +6 -14
- package/dist/{file-utils-CwqjWMsF.mjs.map → file-utils-qSiXXrPa.mjs.map} +1 -1
- package/dist/index.cjs +3893 -2308
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1664 -512
- package/dist/index.d.mts +1664 -512
- package/dist/index.mjs +3905 -2322
- package/dist/index.mjs.map +1 -1
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.cjs +117 -185
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.cjs.map +1 -1
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.d.cts +1 -453
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.d.mts +1 -453
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.mjs +117 -185
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.mjs.map +1 -1
- package/dist/{rolldown-runtime-Ctb5zv51.cjs → rolldown-runtime-C-fzZZTt.cjs} +2 -3
- package/dist/{rolldown-runtime-B4iAMlE-.mjs → rolldown-runtime-DYf_mQCB.mjs} +2 -3
- package/dist/{utils-DavLzQA8.mjs → utils-B7IKRw5F.mjs} +190 -55
- package/dist/utils-B7IKRw5F.mjs.map +1 -0
- package/dist/{utils-DcdjJ-4n.cjs → utils-C3QuhVGE.cjs} +245 -68
- package/dist/utils-C3QuhVGE.cjs.map +1 -0
- package/package.json +9 -8
- package/dist/utils-DavLzQA8.mjs.map +0 -1
- package/dist/utils-DcdjJ-4n.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -34,6 +34,18 @@ Laminar.initialize() must be called
|
|
|
34
34
|
- once in your application,
|
|
35
35
|
- as early as possible, but after other instrumentation libraries
|
|
36
36
|
|
|
37
|
+
### Environment variables
|
|
38
|
+
|
|
39
|
+
| Variable | Meaning |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `LMNR_PROJECT_API_KEY` | Project API key, if not passed to `initialize()` |
|
|
42
|
+
| `LMNR_BASE_URL` | Laminar API base URL (default `https://api.lmnr.ai`) |
|
|
43
|
+
| `LMNR_RELEASE` | Release (e.g. git SHA) stamped on spans; detected if unset |
|
|
44
|
+
| `LMNR_TRAJECTORY_PATH` | Write the run as a trajectory file in Harbor's ATIF format (with Laminar's `lmnr-atif` extension) at this path instead of exporting spans; no API key needed. May contain `{trace_id}` (one file per trace) and `{pid}` |
|
|
45
|
+
| `LMNR_TRAJECTORY_FORCE_EXPORT` | With `LMNR_TRAJECTORY_PATH`: also export spans to Laminar (needs an API key) |
|
|
46
|
+
|
|
47
|
+
`Laminar.initialize({ writeTrajectory: false })` ignores `LMNR_TRAJECTORY_PATH`, for a process whose environment is meant for an agent it runs.
|
|
48
|
+
|
|
37
49
|
## Instrumentation
|
|
38
50
|
|
|
39
51
|
In addition to automatic instrumentation, we provide a simple `@observe()` decorator.
|
package/dist/cli.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
3
|
-
const require_utils = require("./utils-
|
|
4
|
-
const require_file_utils = require("./file-utils-
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C-fzZZTt.cjs");
|
|
3
|
+
const require_utils = require("./utils-C3QuhVGE.cjs");
|
|
4
|
+
const require_file_utils = require("./file-utils-DvRb07ah.cjs");
|
|
5
5
|
let commander = require("commander");
|
|
6
6
|
let fs_promises = require("fs/promises");
|
|
7
7
|
fs_promises = require_rolldown_runtime.__toESM(fs_promises);
|
|
8
8
|
let esbuild = require("esbuild");
|
|
9
9
|
esbuild = require_rolldown_runtime.__toESM(esbuild);
|
|
10
|
-
|
|
10
|
+
// src/cli/datasets.ts
|
|
11
11
|
const logger$2 = require_utils.initializeLogger();
|
|
12
12
|
const DEFAULT_DATASET_PULL_BATCH_SIZE = 100;
|
|
13
13
|
const DEFAULT_DATASET_PUSH_BATCH_SIZE = 100;
|
|
@@ -160,8 +160,7 @@ const handleDatasetsCreate = async (name, paths, options) => {
|
|
|
160
160
|
logger$2.error("Failed to pull dataset after creation: " + require_utils.errorMessage(error));
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
|
-
|
|
164
|
-
//#region src/cli/evals.ts
|
|
163
|
+
// src/cli/evals.ts
|
|
165
164
|
const logger$1 = require_utils.initializeLogger();
|
|
166
165
|
const createSkipDynamicImportsPlugin = (skipModules) => ({
|
|
167
166
|
name: "skip-dynamic-imports",
|
|
@@ -259,8 +258,7 @@ async function runEvaluation(files, options) {
|
|
|
259
258
|
}
|
|
260
259
|
if (options.outputFile) await fs_promises.writeFile(options.outputFile, JSON.stringify(scores, null, 2));
|
|
261
260
|
}
|
|
262
|
-
|
|
263
|
-
//#region src/cli/index.ts
|
|
261
|
+
// src/cli/index.ts
|
|
264
262
|
const logger = require_utils.initializeLogger();
|
|
265
263
|
async function cli() {
|
|
266
264
|
const program = new commander.Command();
|
|
@@ -312,6 +310,5 @@ cli().catch((err) => {
|
|
|
312
310
|
logger.error(require_utils.errorMessage(err));
|
|
313
311
|
throw err;
|
|
314
312
|
});
|
|
315
|
-
//#endregion
|
|
316
313
|
|
|
317
314
|
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":["logger","initializeLogger","LaminarClient","errorMessage","loadFromPaths","writeToFile","logger","initializeLogger","__filename","__dirname","getDirname","fs","initializeLogger","Command","version","errorMessage"],"sources":["../src/cli/datasets.ts","../src/cli/evals.ts","../src/cli/index.ts"],"sourcesContent":["import { LaminarClient } from \"@lmnr-ai/client\";\nimport { errorMessage, type StringUUID } from \"@lmnr-ai/types\";\n\nimport { Datapoint } from \"../evaluations\";\nimport { initializeLogger } from \"../utils\";\nimport { loadFromPaths, printToConsole, writeToFile } from \"./file-utils\";\n\nconst logger = initializeLogger();\nconst DEFAULT_DATASET_PULL_BATCH_SIZE = 100;\nconst DEFAULT_DATASET_PUSH_BATCH_SIZE = 100;\n\ninterface DatasetCommandOptions {\n projectApiKey?: string;\n baseUrl?: string;\n port?: number;\n}\n\n/**\n * Pull all data from a dataset in batches.\n */\nconst pullAllData = async <D = any, T = any>(\n client: LaminarClient,\n identifier: { name?: string; id?: StringUUID },\n batchSize: number = DEFAULT_DATASET_PULL_BATCH_SIZE,\n offset: number = 0,\n limit?: number,\n): Promise<Datapoint<D, T>[]> => {\n let hasMore = true;\n let currentOffset = offset;\n const stopAt = limit !== undefined ? offset + limit : undefined;\n\n const result: Datapoint<D, T>[] = [];\n\n while (hasMore && (stopAt === undefined || currentOffset < stopAt)) {\n const data = await client.datasets.pull<D, T>({\n ...identifier,\n offset: currentOffset,\n limit: batchSize,\n });\n\n result.push(...data.items);\n\n // Stop if we received no items or fewer items than requested (end of data)\n if (data.items.length === 0 || data.items.length < batchSize) {\n hasMore = false;\n } else if (stopAt !== undefined && currentOffset + batchSize >= stopAt) {\n hasMore = false;\n } else if (\n data.totalCount !== undefined &&\n currentOffset + batchSize >= data.totalCount\n ) {\n hasMore = false;\n }\n\n currentOffset += batchSize;\n }\n\n if (limit !== undefined) {\n return result.slice(0, limit);\n }\n\n return result;\n};\n\n/**\n * Handle datasets list command.\n */\nexport const handleDatasetsList = async (\n options: DatasetCommandOptions,\n): Promise<void> => {\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n try {\n const datasets = await client.datasets.listDatasets();\n\n if (datasets.length === 0) {\n console.log(\"No datasets found.\");\n return;\n }\n\n // Print table header\n const idWidth = 36; // UUID length\n const createdAtWidth = 19; // YYYY-MM-DD HH:MM:SS format\n\n console.log(\n `\\n${\"ID\".padEnd(idWidth)} ${\"Created At\".padEnd(createdAtWidth)} Name`,\n );\n console.log(\n `${\"-\".repeat(idWidth)} ${\"-\".repeat(createdAtWidth)} ${\"-\".repeat(20)}`,\n );\n\n // Print each dataset row\n for (const dataset of datasets) {\n const createdAt = new Date(dataset.createdAt);\n const createdAtStr = createdAt\n .toISOString()\n .replace(\"T\", \" \")\n .substring(0, 19);\n console.log(\n `${dataset.id.padEnd(idWidth)} ${createdAtStr.padEnd(createdAtWidth)} ${dataset.name}`,\n );\n }\n\n console.log(`\\nTotal: ${datasets.length} dataset(s)\\n`);\n } catch (error) {\n logger.error(`Failed to list datasets: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets push command.\n */\nexport const handleDatasetsPush = async (\n paths: string[],\n options: DatasetCommandOptions & {\n name?: string;\n id?: StringUUID;\n recursive?: boolean;\n batchSize?: number;\n },\n): Promise<void> => {\n if (!options.name && !options.id) {\n logger.error(\"Either name or id must be provided\");\n return;\n }\n\n if (options.name && options.id) {\n logger.error(\"Only one of name or id must be provided\");\n return;\n }\n\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n const data = await loadFromPaths(paths, options.recursive);\n\n if (data.length === 0) {\n logger.warn(\"No data to push. Skipping\");\n return;\n }\n\n const identifier = options.name ? { name: options.name } : { id: options.id };\n\n try {\n await client.datasets.push({\n points: data,\n ...identifier,\n batchSize: options.batchSize ?? DEFAULT_DATASET_PUSH_BATCH_SIZE,\n });\n logger.info(\n `Pushed ${data.length} data points to dataset ${options.name || options.id}`,\n );\n } catch (error) {\n logger.error(`Failed to push dataset: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets pull command.\n */\nexport const handleDatasetsPull = async (\n outputPath: string | undefined,\n options: DatasetCommandOptions & {\n name?: string;\n id?: StringUUID;\n outputFormat?: \"json\" | \"csv\" | \"jsonl\";\n batchSize?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<void> => {\n if (!options.name && !options.id) {\n logger.error(\"Either name or id must be provided\");\n return;\n }\n\n if (options.name && options.id) {\n logger.error(\"Only one of name or id must be provided\");\n return;\n }\n\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n const identifier = options.name ? { name: options.name } : { id: options.id };\n\n try {\n const result = await pullAllData(\n client,\n identifier,\n options.batchSize ?? DEFAULT_DATASET_PULL_BATCH_SIZE,\n options.offset ?? 0,\n options.limit,\n );\n\n if (outputPath) {\n await writeToFile(outputPath, result, options.outputFormat);\n logger.info(\n `Successfully pulled ${result.length} data points to ${outputPath}`,\n );\n } else {\n printToConsole(result, options.outputFormat ?? \"json\");\n }\n } catch (error) {\n logger.error(`Failed to pull dataset: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets create command.\n */\nexport const handleDatasetsCreate = async (\n name: string,\n paths: string[],\n options: DatasetCommandOptions & {\n outputFile: string;\n outputFormat?: \"json\" | \"csv\" | \"jsonl\";\n recursive?: boolean;\n batchSize?: number;\n },\n): Promise<void> => {\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n // Load data from input files\n const data = await loadFromPaths(paths, options.recursive);\n\n if (data.length === 0) {\n logger.warn(\"No data to push. Skipping\");\n return;\n }\n\n // Push data to create/populate the dataset\n logger.info(`Pushing ${data.length} data points to dataset '${name}'...`);\n\n try {\n await client.datasets.push({\n points: data,\n name,\n batchSize: options.batchSize ?? DEFAULT_DATASET_PUSH_BATCH_SIZE,\n createDataset: true,\n });\n logger.info(\n `Successfully pushed ${data.length} data points to dataset '${name}'`,\n );\n } catch (error) {\n logger.error(`Failed to create dataset: ${errorMessage(error)}`);\n return;\n }\n\n // Pull data back from the dataset\n logger.info(`Pulling data from dataset '${name}'...`);\n\n try {\n const result = await pullAllData(\n client,\n { name },\n options.batchSize ?? DEFAULT_DATASET_PULL_BATCH_SIZE,\n 0,\n undefined,\n );\n\n // Save to output file\n await writeToFile(options.outputFile, result, options.outputFormat);\n\n logger.info(\n `Successfully created dataset '${name}' ` +\n `and saved ${result.length} datapoints to ${options.outputFile}`,\n );\n } catch (error) {\n logger.error(\n \"Failed to pull dataset after creation: \" + errorMessage(error),\n );\n }\n};\n","import * as esbuild from \"esbuild\";\nimport * as fs from \"fs/promises\";\n\nimport { Evaluation } from \"../evaluations\";\nimport { getDirname, initializeLogger } from \"../utils\";\n\nconst logger = initializeLogger();\n\n// esbuild plugin to skip dynamic imports\nconst createSkipDynamicImportsPlugin = (\n skipModules: string[],\n): esbuild.Plugin => ({\n name: \"skip-dynamic-imports\",\n setup(build) {\n if (!skipModules || skipModules.length === 0) return;\n\n build.onResolve({ filter: /.*/ }, (args) => {\n // Only handle dynamic imports\n if (args.kind === \"dynamic-import\" && skipModules.includes(args.path)) {\n logger.warn(`Skipping dynamic import: ${args.path}`);\n // Return a virtual module that exports an empty object\n return {\n path: args.path,\n namespace: \"lmnr-skip-dynamic-import\",\n };\n }\n });\n\n // Provide empty module content for skipped dynamic imports\n build.onLoad(\n { filter: /.*/, namespace: \"lmnr-skip-dynamic-import\" },\n (args) => ({\n contents: \"export default {};\",\n loader: \"js\",\n }),\n );\n },\n});\n\nfunction loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}): Evaluation<any, any, any>[] {\n globalThis._evaluations = [];\n globalThis._set_global_evaluation = true;\n\n const __filename = filename;\n const __dirname = getDirname();\n\n // add some arguments for proper cjs/esm interop\n\n new Function(\"require\", \"module\", \"__filename\", \"__dirname\", moduleText)(\n require,\n module,\n __filename,\n __dirname,\n );\n\n // Return the modified _evals global variable\n return globalThis._evaluations;\n}\n\nexport interface EvalCommandOptions {\n failOnError?: boolean;\n outputFile?: string;\n externalPackages?: string[];\n dynamicImportsToSkip?: string[];\n frontendPort?: number;\n}\n\nexport async function runEvaluation(\n files: string[],\n options: EvalCommandOptions,\n): Promise<void> {\n const patterns =\n files && files.length > 0\n ? files\n : // No files provided, use default pattern\n [\"evals/**/*.eval.{ts,js}\"];\n\n const evalFiles: string[] = [];\n for await (const file of fs.glob(patterns)) {\n evalFiles.push(file);\n }\n\n evalFiles.sort();\n\n if (evalFiles.length === 0) {\n logger.error(\n \"No evaluation files found. Please provide a file or \" +\n \"ensure there are eval files that are named like `*.eval.{ts,js}` in \" +\n \"the `evals` directory or its subdirectories.\",\n );\n process.exit(1);\n }\n\n if (files.length === 0) {\n logger.info(`Located ${evalFiles.length} evaluation files in evals/`);\n } else {\n logger.info(`Running ${evalFiles.length} evaluation files.`);\n }\n\n const scores: {\n file: string;\n scores: Record<string, number>;\n url: string;\n evaluationId: string;\n }[] = [];\n\n for (const file of evalFiles) {\n logger.info(`Loading ${file}...`);\n const buildOptions = {\n bundle: true,\n platform: \"node\" as esbuild.Platform,\n entryPoints: [file],\n outfile: `tmp_out_${file}.js`,\n write: false, // will be loaded in memory as a temp file\n external: [\n \"@lmnr-ai/lmnr\",\n \"@lmnr-ai/lmnr/*\",\n \"@lmnr-ai/client\",\n \"@lmnr-ai/types\",\n \"esbuild\",\n \"fsevents\",\n \"playwright\",\n \"puppeteer\",\n \"puppeteer-core\",\n \"playwright-core\",\n ...(options.externalPackages ? options.externalPackages : []),\n ],\n plugins: [\n createSkipDynamicImportsPlugin(options.dynamicImportsToSkip || []),\n ],\n treeShaking: true,\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n logger.error(\n \"Error when building: No output files found \" +\n \"it is likely that all eval files are not valid TypeScript or JavaScript files.\",\n );\n if (options.failOnError) {\n process.exit(1);\n }\n continue;\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluations = loadModule({\n filename: file,\n moduleText: outputFileText,\n });\n\n logger.info(`Loaded ${evaluations.length} evaluations from ${file}`);\n\n for (const evaluation of evaluations) {\n if (!evaluation?.run) {\n logger.error(`Evaluation ${file} does not properly call evaluate()`);\n if (options.failOnError) {\n process.exit(1);\n }\n continue;\n }\n\n if (options.frontendPort) {\n evaluation.setFrontendPort(options.frontendPort);\n }\n const evalResult = await evaluation.run();\n scores.push({\n file,\n scores: evalResult?.averageScores ?? {},\n url: evalResult?.url ?? \"\",\n evaluationId: evalResult?.evaluationId ?? \"\",\n });\n }\n }\n\n if (options.outputFile) {\n await fs.writeFile(options.outputFile, JSON.stringify(scores, null, 2));\n }\n}\n","#!/usr/bin/env node\n\nimport { errorMessage } from \"@lmnr-ai/types\";\nimport { Command } from \"commander\";\n\nimport { version } from \"../../package.json\";\nimport { Evaluation } from \"../evaluations\";\nimport { initializeLogger } from \"../utils\";\nimport {\n handleDatasetsCreate,\n handleDatasetsList,\n handleDatasetsPull,\n handleDatasetsPush,\n} from \"./datasets\";\nimport { runEvaluation } from \"./evals\";\n\nconst logger = initializeLogger();\n\ndeclare global {\n var _evaluations: Evaluation<any, any, any>[] | undefined;\n var _set_global_evaluation: boolean;\n}\n\nasync function cli() {\n const program = new Command();\n\n program\n .name(\"lmnr\")\n .description(\n \"CLI for Laminar. Use `lmnr <subcommand> --help` for more information.\",\n )\n .version(version, \"-v, --version\", \"display version number\");\n\n // Eval command\n program\n .command(\"eval\")\n .description(\"Run an evaluation\")\n .argument(\n \"[files...]\",\n \"A file or files containing the evaluation to run. If no file is provided, \" +\n \"the evaluation will run all `*.eval.ts|js` files in the `evals` directory. \" +\n \"If multiple files are provided, the evaluation will run each file in order.\",\n )\n .option(\n \"--fail-on-error\",\n \"Fail on error. If specified, will fail if encounters a file that cannot be run\",\n )\n .option(\n \"--output-file <file>\",\n \"Output file to write the results to. Outputs are written in JSON format.\",\n )\n .option(\n \"--external-packages <packages...>\",\n \"[ADVANCED] List of packages to pass as external to esbuild. This will not link \" +\n \"the packages directly into the eval file, but will instead require them at runtime. \" +\n \"Read more: https://esbuild.github.io/api/#external\",\n )\n .option(\n \"--dynamic-imports-to-skip <modules...>\",\n \"[ADVANCED] List of module names to skip when encountered as dynamic imports. \" +\n \"These dynamic imports will resolve to an empty module to prevent build failures. \" +\n \"This is meant to skip the imports that are not used in the evaluation itself.\",\n )\n .option(\n \"--frontend-port <port>\",\n \"Port for the Laminar frontend. Defaults to 5667\",\n (val) => parseInt(val, 10),\n )\n .action(async (files: string[], options) => {\n await runEvaluation(files, options);\n });\n\n const deprecatedDatasetsWarning =\n \"DeprecationWarning: `lmnr datasets` is deprecated and will be removed in a future version. \" +\n \"Use `lmnr-cli dataset` instead.\";\n\n // Datasets command with global options\n const datasetCmd = program\n .command(\"datasets\")\n .description(\n \"[DEPRECATED] Manage datasets. Use `lmnr-cli dataset` instead.\",\n )\n .option(\n \"--project-api-key <key>\",\n \"Project API key. If not provided, reads from LMNR_PROJECT_API_KEY env variable\",\n )\n .option(\n \"--base-url <url>\",\n \"Base URL for the Laminar API. Defaults to https://api.lmnr.ai or LMNR_BASE_URL env variable\",\n )\n .option(\n \"--port <port>\",\n \"Port for the Laminar API. Defaults to 443\",\n (val) => parseInt(val, 10),\n );\n\n // Datasets list command\n datasetCmd\n .command(\"list\")\n .description(\"List all datasets\")\n .action(async (options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsList({ ...parentOpts, ...options });\n });\n\n // Datasets push command\n datasetCmd\n .command(\"push\")\n .description(\"Push datapoints to an existing dataset\")\n .argument(\n \"<paths...>\",\n \"Paths to files or directories containing data to push\",\n )\n .option(\n \"-n, --name <name>\",\n \"Name of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--id <id>\",\n \"ID of the dataset (either name or id must be provided)\",\n )\n .option(\"-r, --recursive\", \"Recursively read files in directories\", false)\n .option(\n \"--batch-size <size>\",\n \"Batch size for pushing data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .action(async (paths: string[], options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsPush(paths, { ...parentOpts, ...options });\n });\n\n // Datasets pull command\n datasetCmd\n .command(\"pull\")\n .description(\"Pull data from a dataset\")\n .argument(\n \"[output-path]\",\n \"Path to save the data. If not provided, prints to console\",\n )\n .option(\n \"-n, --name <name>\",\n \"Name of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--id <id>\",\n \"ID of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--output-format <format>\",\n \"Output format (json, csv, jsonl). Inferred from file extension if not provided\",\n )\n .option(\n \"--batch-size <size>\",\n \"Batch size for pulling data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .option(\"--limit <limit>\", \"Limit number of datapoints to pull\", (val) =>\n parseInt(val, 10),\n )\n .option(\n \"--offset <offset>\",\n \"Offset for pagination\",\n (val) => parseInt(val, 10),\n 0,\n )\n .action(async (outputPath: string | undefined, options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsPull(outputPath, { ...parentOpts, ...options });\n });\n\n // Datasets create command\n datasetCmd\n .command(\"create\")\n .description(\"Create a dataset from input files\")\n .argument(\"<name>\", \"Name of the dataset to create\")\n .argument(\n \"<paths...>\",\n \"Paths to files or directories containing data to push\",\n )\n .requiredOption(\"-o, --output-file <file>\", \"Path to save the pulled data\")\n .option(\n \"--output-format <format>\",\n \"Output format (json, csv, jsonl). Inferred from file extension if not provided\",\n )\n .option(\"-r, --recursive\", \"Recursively read files in directories\", false)\n .option(\n \"--batch-size <size>\",\n \"Batch size for pushing/pulling data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .action(async (name: string, paths: string[], options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsCreate(name, paths, { ...parentOpts, ...options });\n });\n\n // If no command provided, show help\n if (!process.argv.slice(2).length) {\n program.help();\n return;\n }\n\n await program.parseAsync();\n}\n\ncli().catch((err) => {\n logger.error(errorMessage(err));\n throw err;\n});\n"],"mappings":";;;;;;;;;;AAOA,MAAMA,WAASC,cAAAA,iBAAiB;AAChC,MAAM,kCAAkC;AACxC,MAAM,kCAAkC;;;;AAWxC,MAAM,cAAc,OAClB,QACA,YACA,YAAoB,iCACpB,SAAiB,GACjB,UAC+B;CAC/B,IAAI,UAAU;CACd,IAAI,gBAAgB;CACpB,MAAM,SAAS,UAAU,KAAA,IAAY,SAAS,QAAQ,KAAA;CAEtD,MAAM,SAA4B,CAAC;CAEnC,OAAO,YAAY,WAAW,KAAA,KAAa,gBAAgB,SAAS;EAClE,MAAM,OAAO,MAAM,OAAO,SAAS,KAAW;GAC5C,GAAG;GACH,QAAQ;GACR,OAAO;EACT,CAAC;EAED,OAAO,KAAK,GAAG,KAAK,KAAK;EAGzB,IAAI,KAAK,MAAM,WAAW,KAAK,KAAK,MAAM,SAAS,WACjD,UAAU;OACL,IAAI,WAAW,KAAA,KAAa,gBAAgB,aAAa,QAC9D,UAAU;OACL,IACL,KAAK,eAAe,KAAA,KACpB,gBAAgB,aAAa,KAAK,YAElC,UAAU;EAGZ,iBAAiB;CACnB;CA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AK,EAAE,CAClB,CAAC,CACA,OACC,qBACA,0BACC,QAAQ,SAAS,KAAK,EAAE,GACzB,CACF,CAAC,CACA,OAAO,OAAO,YAAgC,SAAS,QAAQ;EAC9D,QAAQ,OAAO,MAAM,4BAA4B,IAAI;EACrD,MAAM,aAAa,IAAI,QAAQ,KAAK,KAAK,CAAC;EAC1C,MAAM,mBAAmB,YAAY;GAAE,GAAG;GAAY,GAAG;EAAQ,CAAC;CACpE,CAAC;CAGH,WACG,QAAQ,QAAQ,CAAC,CACjB,YAAY,mCAAmC,CAAC,CAChD,SAAS,UAAU,+BAA+B,CAAC,CACnD,SACC,cACA,uDACF,CAAC,CACA,eAAe,4BAA4B,8BAA8B,CAAC,CAC1E,OACC,4BACA,gFACF,CAAC,CACA,OAAO,mBAAmB,yCAAyC,KAAK,CAAC,CACzE,OACC,uBACA,wCACC,QAAQ,SAAS,KAAK,EAAE,GACzB,GACF,CAAC,CACA,OAAO,OAAO,MAAc,OAAiB,SAAS,QAAQ;EAC7D,QAAQ,OAAO,MAAM,4BAA4B,IAAI;EACrD,MAAM,aAAa,IAAI,QAAQ,KAAK,KAAK,CAAC;EAC1C,MAAM,qBAAqB,MAAM,OAAO;GAAE,GAAG;GAAY,GAAG;EAAQ,CAAC;CACvE,CAAC;CAGH,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ;EACjC,QAAQ,KAAK;EACb;CACF;CAEA,MAAM,QAAQ,WAAW;AAC3B;AAEA,IAAI,CAAC,CAAC,OAAO,QAAQ;CACnB,OAAO,MAAMC,cAAAA,aAAa,GAAG,CAAC;CAC9B,MAAM;AACR,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":["logger","initializeLogger","LaminarClient","errorMessage","loadFromPaths","writeToFile","logger","initializeLogger","__filename","__dirname","getDirname","fs","initializeLogger","Command","version","errorMessage"],"sources":["../src/cli/datasets.ts","../src/cli/evals.ts","../src/cli/index.ts"],"sourcesContent":["import { LaminarClient } from \"@lmnr-ai/client\";\nimport { errorMessage, type StringUUID } from \"@lmnr-ai/types\";\n\nimport { Datapoint } from \"../evaluations\";\nimport { initializeLogger } from \"../utils\";\nimport { loadFromPaths, printToConsole, writeToFile } from \"./file-utils\";\n\nconst logger = initializeLogger();\nconst DEFAULT_DATASET_PULL_BATCH_SIZE = 100;\nconst DEFAULT_DATASET_PUSH_BATCH_SIZE = 100;\n\ninterface DatasetCommandOptions {\n projectApiKey?: string;\n baseUrl?: string;\n port?: number;\n}\n\n/**\n * Pull all data from a dataset in batches.\n */\nconst pullAllData = async <D = any, T = any>(\n client: LaminarClient,\n identifier: { name?: string; id?: StringUUID },\n batchSize: number = DEFAULT_DATASET_PULL_BATCH_SIZE,\n offset: number = 0,\n limit?: number,\n): Promise<Datapoint<D, T>[]> => {\n let hasMore = true;\n let currentOffset = offset;\n const stopAt = limit !== undefined ? offset + limit : undefined;\n\n const result: Datapoint<D, T>[] = [];\n\n while (hasMore && (stopAt === undefined || currentOffset < stopAt)) {\n const data = await client.datasets.pull<D, T>({\n ...identifier,\n offset: currentOffset,\n limit: batchSize,\n });\n\n result.push(...data.items);\n\n // Stop if we received no items or fewer items than requested (end of data)\n if (data.items.length === 0 || data.items.length < batchSize) {\n hasMore = false;\n } else if (stopAt !== undefined && currentOffset + batchSize >= stopAt) {\n hasMore = false;\n } else if (\n data.totalCount !== undefined &&\n currentOffset + batchSize >= data.totalCount\n ) {\n hasMore = false;\n }\n\n currentOffset += batchSize;\n }\n\n if (limit !== undefined) {\n return result.slice(0, limit);\n }\n\n return result;\n};\n\n/**\n * Handle datasets list command.\n */\nexport const handleDatasetsList = async (\n options: DatasetCommandOptions,\n): Promise<void> => {\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n try {\n const datasets = await client.datasets.listDatasets();\n\n if (datasets.length === 0) {\n console.log(\"No datasets found.\");\n return;\n }\n\n // Print table header\n const idWidth = 36; // UUID length\n const createdAtWidth = 19; // YYYY-MM-DD HH:MM:SS format\n\n console.log(\n `\\n${\"ID\".padEnd(idWidth)} ${\"Created At\".padEnd(createdAtWidth)} Name`,\n );\n console.log(\n `${\"-\".repeat(idWidth)} ${\"-\".repeat(createdAtWidth)} ${\"-\".repeat(20)}`,\n );\n\n // Print each dataset row\n for (const dataset of datasets) {\n const createdAt = new Date(dataset.createdAt);\n const createdAtStr = createdAt\n .toISOString()\n .replace(\"T\", \" \")\n .substring(0, 19);\n console.log(\n `${dataset.id.padEnd(idWidth)} ${createdAtStr.padEnd(createdAtWidth)} ${dataset.name}`,\n );\n }\n\n console.log(`\\nTotal: ${datasets.length} dataset(s)\\n`);\n } catch (error) {\n logger.error(`Failed to list datasets: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets push command.\n */\nexport const handleDatasetsPush = async (\n paths: string[],\n options: DatasetCommandOptions & {\n name?: string;\n id?: StringUUID;\n recursive?: boolean;\n batchSize?: number;\n },\n): Promise<void> => {\n if (!options.name && !options.id) {\n logger.error(\"Either name or id must be provided\");\n return;\n }\n\n if (options.name && options.id) {\n logger.error(\"Only one of name or id must be provided\");\n return;\n }\n\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n const data = await loadFromPaths(paths, options.recursive);\n\n if (data.length === 0) {\n logger.warn(\"No data to push. Skipping\");\n return;\n }\n\n const identifier = options.name ? { name: options.name } : { id: options.id };\n\n try {\n await client.datasets.push({\n points: data,\n ...identifier,\n batchSize: options.batchSize ?? DEFAULT_DATASET_PUSH_BATCH_SIZE,\n });\n logger.info(\n `Pushed ${data.length} data points to dataset ${options.name || options.id}`,\n );\n } catch (error) {\n logger.error(`Failed to push dataset: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets pull command.\n */\nexport const handleDatasetsPull = async (\n outputPath: string | undefined,\n options: DatasetCommandOptions & {\n name?: string;\n id?: StringUUID;\n outputFormat?: \"json\" | \"csv\" | \"jsonl\";\n batchSize?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<void> => {\n if (!options.name && !options.id) {\n logger.error(\"Either name or id must be provided\");\n return;\n }\n\n if (options.name && options.id) {\n logger.error(\"Only one of name or id must be provided\");\n return;\n }\n\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n const identifier = options.name ? { name: options.name } : { id: options.id };\n\n try {\n const result = await pullAllData(\n client,\n identifier,\n options.batchSize ?? DEFAULT_DATASET_PULL_BATCH_SIZE,\n options.offset ?? 0,\n options.limit,\n );\n\n if (outputPath) {\n await writeToFile(outputPath, result, options.outputFormat);\n logger.info(\n `Successfully pulled ${result.length} data points to ${outputPath}`,\n );\n } else {\n printToConsole(result, options.outputFormat ?? \"json\");\n }\n } catch (error) {\n logger.error(`Failed to pull dataset: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets create command.\n */\nexport const handleDatasetsCreate = async (\n name: string,\n paths: string[],\n options: DatasetCommandOptions & {\n outputFile: string;\n outputFormat?: \"json\" | \"csv\" | \"jsonl\";\n recursive?: boolean;\n batchSize?: number;\n },\n): Promise<void> => {\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n // Load data from input files\n const data = await loadFromPaths(paths, options.recursive);\n\n if (data.length === 0) {\n logger.warn(\"No data to push. Skipping\");\n return;\n }\n\n // Push data to create/populate the dataset\n logger.info(`Pushing ${data.length} data points to dataset '${name}'...`);\n\n try {\n await client.datasets.push({\n points: data,\n name,\n batchSize: options.batchSize ?? DEFAULT_DATASET_PUSH_BATCH_SIZE,\n createDataset: true,\n });\n logger.info(\n `Successfully pushed ${data.length} data points to dataset '${name}'`,\n );\n } catch (error) {\n logger.error(`Failed to create dataset: ${errorMessage(error)}`);\n return;\n }\n\n // Pull data back from the dataset\n logger.info(`Pulling data from dataset '${name}'...`);\n\n try {\n const result = await pullAllData(\n client,\n { name },\n options.batchSize ?? DEFAULT_DATASET_PULL_BATCH_SIZE,\n 0,\n undefined,\n );\n\n // Save to output file\n await writeToFile(options.outputFile, result, options.outputFormat);\n\n logger.info(\n `Successfully created dataset '${name}' ` +\n `and saved ${result.length} datapoints to ${options.outputFile}`,\n );\n } catch (error) {\n logger.error(\n \"Failed to pull dataset after creation: \" + errorMessage(error),\n );\n }\n};\n","import * as esbuild from \"esbuild\";\nimport * as fs from \"fs/promises\";\n\nimport { Evaluation } from \"../evaluations\";\nimport { getDirname, initializeLogger } from \"../utils\";\n\nconst logger = initializeLogger();\n\n// esbuild plugin to skip dynamic imports\nconst createSkipDynamicImportsPlugin = (\n skipModules: string[],\n): esbuild.Plugin => ({\n name: \"skip-dynamic-imports\",\n setup(build) {\n if (!skipModules || skipModules.length === 0) return;\n\n build.onResolve({ filter: /.*/ }, (args) => {\n // Only handle dynamic imports\n if (args.kind === \"dynamic-import\" && skipModules.includes(args.path)) {\n logger.warn(`Skipping dynamic import: ${args.path}`);\n // Return a virtual module that exports an empty object\n return {\n path: args.path,\n namespace: \"lmnr-skip-dynamic-import\",\n };\n }\n });\n\n // Provide empty module content for skipped dynamic imports\n build.onLoad(\n { filter: /.*/, namespace: \"lmnr-skip-dynamic-import\" },\n (args) => ({\n contents: \"export default {};\",\n loader: \"js\",\n }),\n );\n },\n});\n\nfunction loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}): Evaluation<any, any, any>[] {\n globalThis._evaluations = [];\n globalThis._set_global_evaluation = true;\n\n const __filename = filename;\n const __dirname = getDirname();\n\n // add some arguments for proper cjs/esm interop\n\n new Function(\"require\", \"module\", \"__filename\", \"__dirname\", moduleText)(\n require,\n module,\n __filename,\n __dirname,\n );\n\n // Return the modified _evals global variable\n return globalThis._evaluations;\n}\n\nexport interface EvalCommandOptions {\n failOnError?: boolean;\n outputFile?: string;\n externalPackages?: string[];\n dynamicImportsToSkip?: string[];\n frontendPort?: number;\n}\n\nexport async function runEvaluation(\n files: string[],\n options: EvalCommandOptions,\n): Promise<void> {\n const patterns =\n files && files.length > 0\n ? files\n : // No files provided, use default pattern\n [\"evals/**/*.eval.{ts,js}\"];\n\n const evalFiles: string[] = [];\n for await (const file of fs.glob(patterns)) {\n evalFiles.push(file);\n }\n\n evalFiles.sort();\n\n if (evalFiles.length === 0) {\n logger.error(\n \"No evaluation files found. Please provide a file or \" +\n \"ensure there are eval files that are named like `*.eval.{ts,js}` in \" +\n \"the `evals` directory or its subdirectories.\",\n );\n process.exit(1);\n }\n\n if (files.length === 0) {\n logger.info(`Located ${evalFiles.length} evaluation files in evals/`);\n } else {\n logger.info(`Running ${evalFiles.length} evaluation files.`);\n }\n\n const scores: {\n file: string;\n scores: Record<string, number>;\n url: string;\n evaluationId: string;\n }[] = [];\n\n for (const file of evalFiles) {\n logger.info(`Loading ${file}...`);\n const buildOptions = {\n bundle: true,\n platform: \"node\" as esbuild.Platform,\n entryPoints: [file],\n outfile: `tmp_out_${file}.js`,\n write: false, // will be loaded in memory as a temp file\n external: [\n \"@lmnr-ai/lmnr\",\n \"@lmnr-ai/lmnr/*\",\n \"@lmnr-ai/client\",\n \"@lmnr-ai/types\",\n \"esbuild\",\n \"fsevents\",\n \"playwright\",\n \"puppeteer\",\n \"puppeteer-core\",\n \"playwright-core\",\n ...(options.externalPackages ? options.externalPackages : []),\n ],\n plugins: [\n createSkipDynamicImportsPlugin(options.dynamicImportsToSkip || []),\n ],\n treeShaking: true,\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n logger.error(\n \"Error when building: No output files found \" +\n \"it is likely that all eval files are not valid TypeScript or JavaScript files.\",\n );\n if (options.failOnError) {\n process.exit(1);\n }\n continue;\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluations = loadModule({\n filename: file,\n moduleText: outputFileText,\n });\n\n logger.info(`Loaded ${evaluations.length} evaluations from ${file}`);\n\n for (const evaluation of evaluations) {\n if (!evaluation?.run) {\n logger.error(`Evaluation ${file} does not properly call evaluate()`);\n if (options.failOnError) {\n process.exit(1);\n }\n continue;\n }\n\n if (options.frontendPort) {\n evaluation.setFrontendPort(options.frontendPort);\n }\n const evalResult = await evaluation.run();\n scores.push({\n file,\n scores: evalResult?.averageScores ?? {},\n url: evalResult?.url ?? \"\",\n evaluationId: evalResult?.evaluationId ?? \"\",\n });\n }\n }\n\n if (options.outputFile) {\n await fs.writeFile(options.outputFile, JSON.stringify(scores, null, 2));\n }\n}\n","#!/usr/bin/env node\n\nimport { errorMessage } from \"@lmnr-ai/types\";\nimport { Command } from \"commander\";\n\nimport { version } from \"../../package.json\";\nimport { Evaluation } from \"../evaluations\";\nimport { initializeLogger } from \"../utils\";\nimport {\n handleDatasetsCreate,\n handleDatasetsList,\n handleDatasetsPull,\n handleDatasetsPush,\n} from \"./datasets\";\nimport { runEvaluation } from \"./evals\";\n\nconst logger = initializeLogger();\n\ndeclare global {\n var _evaluations: Evaluation<any, any, any>[] | undefined;\n var _set_global_evaluation: boolean;\n}\n\nasync function cli() {\n const program = new Command();\n\n program\n .name(\"lmnr\")\n .description(\n \"CLI for Laminar. Use `lmnr <subcommand> --help` for more information.\",\n )\n .version(version, \"-v, --version\", \"display version number\");\n\n // Eval command\n program\n .command(\"eval\")\n .description(\"Run an evaluation\")\n .argument(\n \"[files...]\",\n \"A file or files containing the evaluation to run. If no file is provided, \" +\n \"the evaluation will run all `*.eval.ts|js` files in the `evals` directory. \" +\n \"If multiple files are provided, the evaluation will run each file in order.\",\n )\n .option(\n \"--fail-on-error\",\n \"Fail on error. If specified, will fail if encounters a file that cannot be run\",\n )\n .option(\n \"--output-file <file>\",\n \"Output file to write the results to. Outputs are written in JSON format.\",\n )\n .option(\n \"--external-packages <packages...>\",\n \"[ADVANCED] List of packages to pass as external to esbuild. This will not link \" +\n \"the packages directly into the eval file, but will instead require them at runtime. \" +\n \"Read more: https://esbuild.github.io/api/#external\",\n )\n .option(\n \"--dynamic-imports-to-skip <modules...>\",\n \"[ADVANCED] List of module names to skip when encountered as dynamic imports. \" +\n \"These dynamic imports will resolve to an empty module to prevent build failures. \" +\n \"This is meant to skip the imports that are not used in the evaluation itself.\",\n )\n .option(\n \"--frontend-port <port>\",\n \"Port for the Laminar frontend. Defaults to 5667\",\n (val) => parseInt(val, 10),\n )\n .action(async (files: string[], options) => {\n await runEvaluation(files, options);\n });\n\n const deprecatedDatasetsWarning =\n \"DeprecationWarning: `lmnr datasets` is deprecated and will be removed in a future version. \" +\n \"Use `lmnr-cli dataset` instead.\";\n\n // Datasets command with global options\n const datasetCmd = program\n .command(\"datasets\")\n .description(\n \"[DEPRECATED] Manage datasets. Use `lmnr-cli dataset` instead.\",\n )\n .option(\n \"--project-api-key <key>\",\n \"Project API key. If not provided, reads from LMNR_PROJECT_API_KEY env variable\",\n )\n .option(\n \"--base-url <url>\",\n \"Base URL for the Laminar API. Defaults to https://api.lmnr.ai or LMNR_BASE_URL env variable\",\n )\n .option(\n \"--port <port>\",\n \"Port for the Laminar API. Defaults to 443\",\n (val) => parseInt(val, 10),\n );\n\n // Datasets list command\n datasetCmd\n .command(\"list\")\n .description(\"List all datasets\")\n .action(async (options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsList({ ...parentOpts, ...options });\n });\n\n // Datasets push command\n datasetCmd\n .command(\"push\")\n .description(\"Push datapoints to an existing dataset\")\n .argument(\n \"<paths...>\",\n \"Paths to files or directories containing data to push\",\n )\n .option(\n \"-n, --name <name>\",\n \"Name of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--id <id>\",\n \"ID of the dataset (either name or id must be provided)\",\n )\n .option(\"-r, --recursive\", \"Recursively read files in directories\", false)\n .option(\n \"--batch-size <size>\",\n \"Batch size for pushing data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .action(async (paths: string[], options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsPush(paths, { ...parentOpts, ...options });\n });\n\n // Datasets pull command\n datasetCmd\n .command(\"pull\")\n .description(\"Pull data from a dataset\")\n .argument(\n \"[output-path]\",\n \"Path to save the data. If not provided, prints to console\",\n )\n .option(\n \"-n, --name <name>\",\n \"Name of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--id <id>\",\n \"ID of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--output-format <format>\",\n \"Output format (json, csv, jsonl). Inferred from file extension if not provided\",\n )\n .option(\n \"--batch-size <size>\",\n \"Batch size for pulling data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .option(\"--limit <limit>\", \"Limit number of datapoints to pull\", (val) =>\n parseInt(val, 10),\n )\n .option(\n \"--offset <offset>\",\n \"Offset for pagination\",\n (val) => parseInt(val, 10),\n 0,\n )\n .action(async (outputPath: string | undefined, options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsPull(outputPath, { ...parentOpts, ...options });\n });\n\n // Datasets create command\n datasetCmd\n .command(\"create\")\n .description(\"Create a dataset from input files\")\n .argument(\"<name>\", \"Name of the dataset to create\")\n .argument(\n \"<paths...>\",\n \"Paths to files or directories containing data to push\",\n )\n .requiredOption(\"-o, --output-file <file>\", \"Path to save the pulled data\")\n .option(\n \"--output-format <format>\",\n \"Output format (json, csv, jsonl). Inferred from file extension if not provided\",\n )\n .option(\"-r, --recursive\", \"Recursively read files in directories\", false)\n .option(\n \"--batch-size <size>\",\n \"Batch size for pushing/pulling data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .action(async (name: string, paths: string[], options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsCreate(name, paths, { ...parentOpts, ...options });\n });\n\n // If no command provided, show help\n if (!process.argv.slice(2).length) {\n program.help();\n return;\n }\n\n await program.parseAsync();\n}\n\ncli().catch((err) => {\n logger.error(errorMess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AQ,SAAS,KAAK,EAAE,GACzB,GACF,CAAC,CACA,OAAO,OAAO,MAAc,OAAiB,SAAS,QAAQ;EAC7D,QAAQ,OAAO,MAAM,4BAA4B,IAAI;EACrD,MAAM,aAAa,IAAI,QAAQ,KAAK,KAAK,CAAC;EAC1C,MAAM,qBAAqB,MAAM,OAAO;GAAE,GAAG;GAAY,GAAG;EAAQ,CAAC;CACvE,CAAC;CAGH,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ;EACjC,QAAQ,KAAK;EACb;CACF;CAEA,MAAM,QAAQ,WAAW;AAC3B;AAEA,IAAI,CAAC,CAAC,OAAO,QAAQ;CACnB,OAAO,MAAMC,cAAAA,aAAa,GAAG,CAAC;CAC9B,MAAM;AACR,CAAC"}
|
package/dist/cli.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { n as Evaluation } from "./evaluations-
|
|
2
|
-
//#region src/cli/index.d.ts
|
|
1
|
+
import { n as Evaluation } from "./evaluations-CAossFsy.cjs";
|
|
3
2
|
declare global {
|
|
4
3
|
var _evaluations: Evaluation<any, any, any>[] | undefined;
|
|
5
4
|
var _set_global_evaluation: boolean;
|
|
6
5
|
}
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=cli.d.cts.map
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { n as Evaluation } from "./evaluations-
|
|
2
|
-
//#region src/cli/index.d.ts
|
|
1
|
+
import { n as Evaluation } from "./evaluations-Bz4AjiEN.mjs";
|
|
3
2
|
declare global {
|
|
4
3
|
var _evaluations: Evaluation<any, any, any>[] | undefined;
|
|
5
4
|
var _set_global_evaluation: boolean;
|
|
6
5
|
}
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=cli.d.mts.map
|
package/dist/cli.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { r as __require } from "./rolldown-runtime-
|
|
3
|
-
import {
|
|
4
|
-
import { i as writeToFile, n as loadFromPaths, r as printToConsole } from "./file-utils-
|
|
2
|
+
import { r as __require } from "./rolldown-runtime-DYf_mQCB.mjs";
|
|
3
|
+
import { K as version, Z as errorMessage, i as getDirname, q as LaminarClient, s as initializeLogger } from "./utils-B7IKRw5F.mjs";
|
|
4
|
+
import { i as writeToFile, n as loadFromPaths, r as printToConsole } from "./file-utils-qSiXXrPa.mjs";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import * as fs from "fs/promises";
|
|
7
7
|
import * as esbuild from "esbuild";
|
|
8
|
-
|
|
8
|
+
// src/cli/datasets.ts
|
|
9
9
|
const logger$2 = initializeLogger();
|
|
10
10
|
const DEFAULT_DATASET_PULL_BATCH_SIZE = 100;
|
|
11
11
|
const DEFAULT_DATASET_PUSH_BATCH_SIZE = 100;
|
|
@@ -158,8 +158,7 @@ const handleDatasetsCreate = async (name, paths, options) => {
|
|
|
158
158
|
logger$2.error("Failed to pull dataset after creation: " + errorMessage(error));
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
//#region src/cli/evals.ts
|
|
161
|
+
// src/cli/evals.ts
|
|
163
162
|
const logger$1 = initializeLogger();
|
|
164
163
|
const createSkipDynamicImportsPlugin = (skipModules) => ({
|
|
165
164
|
name: "skip-dynamic-imports",
|
|
@@ -257,8 +256,7 @@ async function runEvaluation(files, options) {
|
|
|
257
256
|
}
|
|
258
257
|
if (options.outputFile) await fs.writeFile(options.outputFile, JSON.stringify(scores, null, 2));
|
|
259
258
|
}
|
|
260
|
-
|
|
261
|
-
//#region src/cli/index.ts
|
|
259
|
+
// src/cli/index.ts
|
|
262
260
|
const logger = initializeLogger();
|
|
263
261
|
async function cli() {
|
|
264
262
|
const program = new Command();
|
|
@@ -310,7 +308,6 @@ cli().catch((err) => {
|
|
|
310
308
|
logger.error(errorMessage(err));
|
|
311
309
|
throw err;
|
|
312
310
|
});
|
|
313
|
-
//#endregion
|
|
314
311
|
export {};
|
|
315
312
|
|
|
316
313
|
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":["logger","logger"],"sources":["../src/cli/datasets.ts","../src/cli/evals.ts","../src/cli/index.ts"],"sourcesContent":["import { LaminarClient } from \"@lmnr-ai/client\";\nimport { errorMessage, type StringUUID } from \"@lmnr-ai/types\";\n\nimport { Datapoint } from \"../evaluations\";\nimport { initializeLogger } from \"../utils\";\nimport { loadFromPaths, printToConsole, writeToFile } from \"./file-utils\";\n\nconst logger = initializeLogger();\nconst DEFAULT_DATASET_PULL_BATCH_SIZE = 100;\nconst DEFAULT_DATASET_PUSH_BATCH_SIZE = 100;\n\ninterface DatasetCommandOptions {\n projectApiKey?: string;\n baseUrl?: string;\n port?: number;\n}\n\n/**\n * Pull all data from a dataset in batches.\n */\nconst pullAllData = async <D = any, T = any>(\n client: LaminarClient,\n identifier: { name?: string; id?: StringUUID },\n batchSize: number = DEFAULT_DATASET_PULL_BATCH_SIZE,\n offset: number = 0,\n limit?: number,\n): Promise<Datapoint<D, T>[]> => {\n let hasMore = true;\n let currentOffset = offset;\n const stopAt = limit !== undefined ? offset + limit : undefined;\n\n const result: Datapoint<D, T>[] = [];\n\n while (hasMore && (stopAt === undefined || currentOffset < stopAt)) {\n const data = await client.datasets.pull<D, T>({\n ...identifier,\n offset: currentOffset,\n limit: batchSize,\n });\n\n result.push(...data.items);\n\n // Stop if we received no items or fewer items than requested (end of data)\n if (data.items.length === 0 || data.items.length < batchSize) {\n hasMore = false;\n } else if (stopAt !== undefined && currentOffset + batchSize >= stopAt) {\n hasMore = false;\n } else if (\n data.totalCount !== undefined &&\n currentOffset + batchSize >= data.totalCount\n ) {\n hasMore = false;\n }\n\n currentOffset += batchSize;\n }\n\n if (limit !== undefined) {\n return result.slice(0, limit);\n }\n\n return result;\n};\n\n/**\n * Handle datasets list command.\n */\nexport const handleDatasetsList = async (\n options: DatasetCommandOptions,\n): Promise<void> => {\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n try {\n const datasets = await client.datasets.listDatasets();\n\n if (datasets.length === 0) {\n console.log(\"No datasets found.\");\n return;\n }\n\n // Print table header\n const idWidth = 36; // UUID length\n const createdAtWidth = 19; // YYYY-MM-DD HH:MM:SS format\n\n console.log(\n `\\n${\"ID\".padEnd(idWidth)} ${\"Created At\".padEnd(createdAtWidth)} Name`,\n );\n console.log(\n `${\"-\".repeat(idWidth)} ${\"-\".repeat(createdAtWidth)} ${\"-\".repeat(20)}`,\n );\n\n // Print each dataset row\n for (const dataset of datasets) {\n const createdAt = new Date(dataset.createdAt);\n const createdAtStr = createdAt\n .toISOString()\n .replace(\"T\", \" \")\n .substring(0, 19);\n console.log(\n `${dataset.id.padEnd(idWidth)} ${createdAtStr.padEnd(createdAtWidth)} ${dataset.name}`,\n );\n }\n\n console.log(`\\nTotal: ${datasets.length} dataset(s)\\n`);\n } catch (error) {\n logger.error(`Failed to list datasets: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets push command.\n */\nexport const handleDatasetsPush = async (\n paths: string[],\n options: DatasetCommandOptions & {\n name?: string;\n id?: StringUUID;\n recursive?: boolean;\n batchSize?: number;\n },\n): Promise<void> => {\n if (!options.name && !options.id) {\n logger.error(\"Either name or id must be provided\");\n return;\n }\n\n if (options.name && options.id) {\n logger.error(\"Only one of name or id must be provided\");\n return;\n }\n\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n const data = await loadFromPaths(paths, options.recursive);\n\n if (data.length === 0) {\n logger.warn(\"No data to push. Skipping\");\n return;\n }\n\n const identifier = options.name ? { name: options.name } : { id: options.id };\n\n try {\n await client.datasets.push({\n points: data,\n ...identifier,\n batchSize: options.batchSize ?? DEFAULT_DATASET_PUSH_BATCH_SIZE,\n });\n logger.info(\n `Pushed ${data.length} data points to dataset ${options.name || options.id}`,\n );\n } catch (error) {\n logger.error(`Failed to push dataset: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets pull command.\n */\nexport const handleDatasetsPull = async (\n outputPath: string | undefined,\n options: DatasetCommandOptions & {\n name?: string;\n id?: StringUUID;\n outputFormat?: \"json\" | \"csv\" | \"jsonl\";\n batchSize?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<void> => {\n if (!options.name && !options.id) {\n logger.error(\"Either name or id must be provided\");\n return;\n }\n\n if (options.name && options.id) {\n logger.error(\"Only one of name or id must be provided\");\n return;\n }\n\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n const identifier = options.name ? { name: options.name } : { id: options.id };\n\n try {\n const result = await pullAllData(\n client,\n identifier,\n options.batchSize ?? DEFAULT_DATASET_PULL_BATCH_SIZE,\n options.offset ?? 0,\n options.limit,\n );\n\n if (outputPath) {\n await writeToFile(outputPath, result, options.outputFormat);\n logger.info(\n `Successfully pulled ${result.length} data points to ${outputPath}`,\n );\n } else {\n printToConsole(result, options.outputFormat ?? \"json\");\n }\n } catch (error) {\n logger.error(`Failed to pull dataset: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets create command.\n */\nexport const handleDatasetsCreate = async (\n name: string,\n paths: string[],\n options: DatasetCommandOptions & {\n outputFile: string;\n outputFormat?: \"json\" | \"csv\" | \"jsonl\";\n recursive?: boolean;\n batchSize?: number;\n },\n): Promise<void> => {\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n // Load data from input files\n const data = await loadFromPaths(paths, options.recursive);\n\n if (data.length === 0) {\n logger.warn(\"No data to push. Skipping\");\n return;\n }\n\n // Push data to create/populate the dataset\n logger.info(`Pushing ${data.length} data points to dataset '${name}'...`);\n\n try {\n await client.datasets.push({\n points: data,\n name,\n batchSize: options.batchSize ?? DEFAULT_DATASET_PUSH_BATCH_SIZE,\n createDataset: true,\n });\n logger.info(\n `Successfully pushed ${data.length} data points to dataset '${name}'`,\n );\n } catch (error) {\n logger.error(`Failed to create dataset: ${errorMessage(error)}`);\n return;\n }\n\n // Pull data back from the dataset\n logger.info(`Pulling data from dataset '${name}'...`);\n\n try {\n const result = await pullAllData(\n client,\n { name },\n options.batchSize ?? DEFAULT_DATASET_PULL_BATCH_SIZE,\n 0,\n undefined,\n );\n\n // Save to output file\n await writeToFile(options.outputFile, result, options.outputFormat);\n\n logger.info(\n `Successfully created dataset '${name}' ` +\n `and saved ${result.length} datapoints to ${options.outputFile}`,\n );\n } catch (error) {\n logger.error(\n \"Failed to pull dataset after creation: \" + errorMessage(error),\n );\n }\n};\n","import * as esbuild from \"esbuild\";\nimport * as fs from \"fs/promises\";\n\nimport { Evaluation } from \"../evaluations\";\nimport { getDirname, initializeLogger } from \"../utils\";\n\nconst logger = initializeLogger();\n\n// esbuild plugin to skip dynamic imports\nconst createSkipDynamicImportsPlugin = (\n skipModules: string[],\n): esbuild.Plugin => ({\n name: \"skip-dynamic-imports\",\n setup(build) {\n if (!skipModules || skipModules.length === 0) return;\n\n build.onResolve({ filter: /.*/ }, (args) => {\n // Only handle dynamic imports\n if (args.kind === \"dynamic-import\" && skipModules.includes(args.path)) {\n logger.warn(`Skipping dynamic import: ${args.path}`);\n // Return a virtual module that exports an empty object\n return {\n path: args.path,\n namespace: \"lmnr-skip-dynamic-import\",\n };\n }\n });\n\n // Provide empty module content for skipped dynamic imports\n build.onLoad(\n { filter: /.*/, namespace: \"lmnr-skip-dynamic-import\" },\n (args) => ({\n contents: \"export default {};\",\n loader: \"js\",\n }),\n );\n },\n});\n\nfunction loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}): Evaluation<any, any, any>[] {\n globalThis._evaluations = [];\n globalThis._set_global_evaluation = true;\n\n const __filename = filename;\n const __dirname = getDirname();\n\n // add some arguments for proper cjs/esm interop\n\n new Function(\"require\", \"module\", \"__filename\", \"__dirname\", moduleText)(\n require,\n module,\n __filename,\n __dirname,\n );\n\n // Return the modified _evals global variable\n return globalThis._evaluations;\n}\n\nexport interface EvalCommandOptions {\n failOnError?: boolean;\n outputFile?: string;\n externalPackages?: string[];\n dynamicImportsToSkip?: string[];\n frontendPort?: number;\n}\n\nexport async function runEvaluation(\n files: string[],\n options: EvalCommandOptions,\n): Promise<void> {\n const patterns =\n files && files.length > 0\n ? files\n : // No files provided, use default pattern\n [\"evals/**/*.eval.{ts,js}\"];\n\n const evalFiles: string[] = [];\n for await (const file of fs.glob(patterns)) {\n evalFiles.push(file);\n }\n\n evalFiles.sort();\n\n if (evalFiles.length === 0) {\n logger.error(\n \"No evaluation files found. Please provide a file or \" +\n \"ensure there are eval files that are named like `*.eval.{ts,js}` in \" +\n \"the `evals` directory or its subdirectories.\",\n );\n process.exit(1);\n }\n\n if (files.length === 0) {\n logger.info(`Located ${evalFiles.length} evaluation files in evals/`);\n } else {\n logger.info(`Running ${evalFiles.length} evaluation files.`);\n }\n\n const scores: {\n file: string;\n scores: Record<string, number>;\n url: string;\n evaluationId: string;\n }[] = [];\n\n for (const file of evalFiles) {\n logger.info(`Loading ${file}...`);\n const buildOptions = {\n bundle: true,\n platform: \"node\" as esbuild.Platform,\n entryPoints: [file],\n outfile: `tmp_out_${file}.js`,\n write: false, // will be loaded in memory as a temp file\n external: [\n \"@lmnr-ai/lmnr\",\n \"@lmnr-ai/lmnr/*\",\n \"@lmnr-ai/client\",\n \"@lmnr-ai/types\",\n \"esbuild\",\n \"fsevents\",\n \"playwright\",\n \"puppeteer\",\n \"puppeteer-core\",\n \"playwright-core\",\n ...(options.externalPackages ? options.externalPackages : []),\n ],\n plugins: [\n createSkipDynamicImportsPlugin(options.dynamicImportsToSkip || []),\n ],\n treeShaking: true,\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n logger.error(\n \"Error when building: No output files found \" +\n \"it is likely that all eval files are not valid TypeScript or JavaScript files.\",\n );\n if (options.failOnError) {\n process.exit(1);\n }\n continue;\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluations = loadModule({\n filename: file,\n moduleText: outputFileText,\n });\n\n logger.info(`Loaded ${evaluations.length} evaluations from ${file}`);\n\n for (const evaluation of evaluations) {\n if (!evaluation?.run) {\n logger.error(`Evaluation ${file} does not properly call evaluate()`);\n if (options.failOnError) {\n process.exit(1);\n }\n continue;\n }\n\n if (options.frontendPort) {\n evaluation.setFrontendPort(options.frontendPort);\n }\n const evalResult = await evaluation.run();\n scores.push({\n file,\n scores: evalResult?.averageScores ?? {},\n url: evalResult?.url ?? \"\",\n evaluationId: evalResult?.evaluationId ?? \"\",\n });\n }\n }\n\n if (options.outputFile) {\n await fs.writeFile(options.outputFile, JSON.stringify(scores, null, 2));\n }\n}\n","#!/usr/bin/env node\n\nimport { errorMessage } from \"@lmnr-ai/types\";\nimport { Command } from \"commander\";\n\nimport { version } from \"../../package.json\";\nimport { Evaluation } from \"../evaluations\";\nimport { initializeLogger } from \"../utils\";\nimport {\n handleDatasetsCreate,\n handleDatasetsList,\n handleDatasetsPull,\n handleDatasetsPush,\n} from \"./datasets\";\nimport { runEvaluation } from \"./evals\";\n\nconst logger = initializeLogger();\n\ndeclare global {\n var _evaluations: Evaluation<any, any, any>[] | undefined;\n var _set_global_evaluation: boolean;\n}\n\nasync function cli() {\n const program = new Command();\n\n program\n .name(\"lmnr\")\n .description(\n \"CLI for Laminar. Use `lmnr <subcommand> --help` for more information.\",\n )\n .version(version, \"-v, --version\", \"display version number\");\n\n // Eval command\n program\n .command(\"eval\")\n .description(\"Run an evaluation\")\n .argument(\n \"[files...]\",\n \"A file or files containing the evaluation to run. If no file is provided, \" +\n \"the evaluation will run all `*.eval.ts|js` files in the `evals` directory. \" +\n \"If multiple files are provided, the evaluation will run each file in order.\",\n )\n .option(\n \"--fail-on-error\",\n \"Fail on error. If specified, will fail if encounters a file that cannot be run\",\n )\n .option(\n \"--output-file <file>\",\n \"Output file to write the results to. Outputs are written in JSON format.\",\n )\n .option(\n \"--external-packages <packages...>\",\n \"[ADVANCED] List of packages to pass as external to esbuild. This will not link \" +\n \"the packages directly into the eval file, but will instead require them at runtime. \" +\n \"Read more: https://esbuild.github.io/api/#external\",\n )\n .option(\n \"--dynamic-imports-to-skip <modules...>\",\n \"[ADVANCED] List of module names to skip when encountered as dynamic imports. \" +\n \"These dynamic imports will resolve to an empty module to prevent build failures. \" +\n \"This is meant to skip the imports that are not used in the evaluation itself.\",\n )\n .option(\n \"--frontend-port <port>\",\n \"Port for the Laminar frontend. Defaults to 5667\",\n (val) => parseInt(val, 10),\n )\n .action(async (files: string[], options) => {\n await runEvaluation(files, options);\n });\n\n const deprecatedDatasetsWarning =\n \"DeprecationWarning: `lmnr datasets` is deprecated and will be removed in a future version. \" +\n \"Use `lmnr-cli dataset` instead.\";\n\n // Datasets command with global options\n const datasetCmd = program\n .command(\"datasets\")\n .description(\n \"[DEPRECATED] Manage datasets. Use `lmnr-cli dataset` instead.\",\n )\n .option(\n \"--project-api-key <key>\",\n \"Project API key. If not provided, reads from LMNR_PROJECT_API_KEY env variable\",\n )\n .option(\n \"--base-url <url>\",\n \"Base URL for the Laminar API. Defaults to https://api.lmnr.ai or LMNR_BASE_URL env variable\",\n )\n .option(\n \"--port <port>\",\n \"Port for the Laminar API. Defaults to 443\",\n (val) => parseInt(val, 10),\n );\n\n // Datasets list command\n datasetCmd\n .command(\"list\")\n .description(\"List all datasets\")\n .action(async (options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsList({ ...parentOpts, ...options });\n });\n\n // Datasets push command\n datasetCmd\n .command(\"push\")\n .description(\"Push datapoints to an existing dataset\")\n .argument(\n \"<paths...>\",\n \"Paths to files or directories containing data to push\",\n )\n .option(\n \"-n, --name <name>\",\n \"Name of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--id <id>\",\n \"ID of the dataset (either name or id must be provided)\",\n )\n .option(\"-r, --recursive\", \"Recursively read files in directories\", false)\n .option(\n \"--batch-size <size>\",\n \"Batch size for pushing data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .action(async (paths: string[], options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsPush(paths, { ...parentOpts, ...options });\n });\n\n // Datasets pull command\n datasetCmd\n .command(\"pull\")\n .description(\"Pull data from a dataset\")\n .argument(\n \"[output-path]\",\n \"Path to save the data. If not provided, prints to console\",\n )\n .option(\n \"-n, --name <name>\",\n \"Name of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--id <id>\",\n \"ID of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--output-format <format>\",\n \"Output format (json, csv, jsonl). Inferred from file extension if not provided\",\n )\n .option(\n \"--batch-size <size>\",\n \"Batch size for pulling data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .option(\"--limit <limit>\", \"Limit number of datapoints to pull\", (val) =>\n parseInt(val, 10),\n )\n .option(\n \"--offset <offset>\",\n \"Offset for pagination\",\n (val) => parseInt(val, 10),\n 0,\n )\n .action(async (outputPath: string | undefined, options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsPull(outputPath, { ...parentOpts, ...options });\n });\n\n // Datasets create command\n datasetCmd\n .command(\"create\")\n .description(\"Create a dataset from input files\")\n .argument(\"<name>\", \"Name of the dataset to create\")\n .argument(\n \"<paths...>\",\n \"Paths to files or directories containing data to push\",\n )\n .requiredOption(\"-o, --output-file <file>\", \"Path to save the pulled data\")\n .option(\n \"--output-format <format>\",\n \"Output format (json, csv, jsonl). Inferred from file extension if not provided\",\n )\n .option(\"-r, --recursive\", \"Recursively read files in directories\", false)\n .option(\n \"--batch-size <size>\",\n \"Batch size for pushing/pulling data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .action(async (name: string, paths: string[], options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsCreate(name, paths, { ...parentOpts, ...options });\n });\n\n // If no command provided, show help\n if (!process.argv.slice(2).length) {\n program.help();\n return;\n }\n\n await program.parseAsync();\n}\n\ncli().catch((err) => {\n logger.error(errorMessage(err));\n throw err;\n});\n"],"mappings":";;;;;;;;AAOA,MAAMA,WAAS,iBAAiB;AAChC,MAAM,kCAAkC;AACxC,MAAM,kCAAkC;;;;AAWxC,MAAM,cAAc,OAClB,QACA,YACA,YAAoB,iCACpB,SAAiB,GACjB,UAC+B;CAC/B,IAAI,UAAU;CACd,IAAI,gBAAgB;CACpB,MAAM,SAAS,UAAU,KAAA,IAAY,SAAS,QAAQ,KAAA;CAEtD,MAAM,SAA4B,CAAC;CAEnC,OAAO,YAAY,WAAW,KAAA,KAAa,gBAAgB,SAAS;EAClE,MAAM,OAAO,MAAM,OAAO,SAAS,KAAW;GAC5C,GAAG;GACH,QAAQ;GACR,OAAO;EACT,CAAC;EAED,OAAO,KAAK,GAAG,KAAK,KAAK;EAGzB,IAAI,KAAK,MAAM,WAAW,KAAK,KAAK,MAAM,SAAS,WACjD,UAAU;OACL,IAAI,WAAW,KAAA,KAAa,gBAAgB,aAAa,QAC9D,UAAU;OACL,IACL,KAAK,eAAe,KAAA,KACpB,gBAAgB,aAAa,KAAK,YAElC,UAAU;EAGZ,iBAAiB;CACnB;CAEA,IAAI,UAAU,KAAA,GACZ,OAAO,OAAO,MAAM,GAAG,KAAK;CAG9B,OAAO;AACT;;;;AAKA,MAAa,qBAAqB,OAChC,YACkB;CAClB,MAAM,SAAS,IAAI,cAAc;EAC/B,eAAe,QAAQ;EACvB,SAAS,QAAQ;EACjB,MAAM,QAAQ;CAChB,CAAC;CAED,IAAI;EACF,MAAM,WAAW,MAAM,OAAO,SAAS,aAAa;EAEpD,IAAI,SAAS,WAAW,GAAG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C,4BACA,gFACF,CAAC,CACA,OAAO,mBAAmB,yCAAyC,KAAK,CAAC,CACzE,OACC,uBACA,wCACC,QAAQ,SAAS,KAAK,EAAE,GACzB,GACF,CAAC,CACA,OAAO,OAAO,MAAc,OAAiB,SAAS,QAAQ;EAC7D,QAAQ,OAAO,MAAM,4BAA4B,IAAI;EACrD,MAAM,aAAa,IAAI,QAAQ,KAAK,KAAK,CAAC;EAC1C,MAAM,qBAAqB,MAAM,OAAO;GAAE,GAAG;GAAY,GAAG;EAAQ,CAAC;CACvE,CAAC;CAGH,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ;EACjC,QAAQ,KAAK;EACb;CACF;CAEA,MAAM,QAAQ,WAAW;AAC3B;AAEA,IAAI,CAAC,CAAC,OAAO,QAAQ;CACnB,OAAO,MAAM,aAAa,GAAG,CAAC;CAC9B,MAAM;AACR,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["logger","logger"],"sources":["../src/cli/datasets.ts","../src/cli/evals.ts","../src/cli/index.ts"],"sourcesContent":["import { LaminarClient } from \"@lmnr-ai/client\";\nimport { errorMessage, type StringUUID } from \"@lmnr-ai/types\";\n\nimport { Datapoint } from \"../evaluations\";\nimport { initializeLogger } from \"../utils\";\nimport { loadFromPaths, printToConsole, writeToFile } from \"./file-utils\";\n\nconst logger = initializeLogger();\nconst DEFAULT_DATASET_PULL_BATCH_SIZE = 100;\nconst DEFAULT_DATASET_PUSH_BATCH_SIZE = 100;\n\ninterface DatasetCommandOptions {\n projectApiKey?: string;\n baseUrl?: string;\n port?: number;\n}\n\n/**\n * Pull all data from a dataset in batches.\n */\nconst pullAllData = async <D = any, T = any>(\n client: LaminarClient,\n identifier: { name?: string; id?: StringUUID },\n batchSize: number = DEFAULT_DATASET_PULL_BATCH_SIZE,\n offset: number = 0,\n limit?: number,\n): Promise<Datapoint<D, T>[]> => {\n let hasMore = true;\n let currentOffset = offset;\n const stopAt = limit !== undefined ? offset + limit : undefined;\n\n const result: Datapoint<D, T>[] = [];\n\n while (hasMore && (stopAt === undefined || currentOffset < stopAt)) {\n const data = await client.datasets.pull<D, T>({\n ...identifier,\n offset: currentOffset,\n limit: batchSize,\n });\n\n result.push(...data.items);\n\n // Stop if we received no items or fewer items than requested (end of data)\n if (data.items.length === 0 || data.items.length < batchSize) {\n hasMore = false;\n } else if (stopAt !== undefined && currentOffset + batchSize >= stopAt) {\n hasMore = false;\n } else if (\n data.totalCount !== undefined &&\n currentOffset + batchSize >= data.totalCount\n ) {\n hasMore = false;\n }\n\n currentOffset += batchSize;\n }\n\n if (limit !== undefined) {\n return result.slice(0, limit);\n }\n\n return result;\n};\n\n/**\n * Handle datasets list command.\n */\nexport const handleDatasetsList = async (\n options: DatasetCommandOptions,\n): Promise<void> => {\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n try {\n const datasets = await client.datasets.listDatasets();\n\n if (datasets.length === 0) {\n console.log(\"No datasets found.\");\n return;\n }\n\n // Print table header\n const idWidth = 36; // UUID length\n const createdAtWidth = 19; // YYYY-MM-DD HH:MM:SS format\n\n console.log(\n `\\n${\"ID\".padEnd(idWidth)} ${\"Created At\".padEnd(createdAtWidth)} Name`,\n );\n console.log(\n `${\"-\".repeat(idWidth)} ${\"-\".repeat(createdAtWidth)} ${\"-\".repeat(20)}`,\n );\n\n // Print each dataset row\n for (const dataset of datasets) {\n const createdAt = new Date(dataset.createdAt);\n const createdAtStr = createdAt\n .toISOString()\n .replace(\"T\", \" \")\n .substring(0, 19);\n console.log(\n `${dataset.id.padEnd(idWidth)} ${createdAtStr.padEnd(createdAtWidth)} ${dataset.name}`,\n );\n }\n\n console.log(`\\nTotal: ${datasets.length} dataset(s)\\n`);\n } catch (error) {\n logger.error(`Failed to list datasets: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets push command.\n */\nexport const handleDatasetsPush = async (\n paths: string[],\n options: DatasetCommandOptions & {\n name?: string;\n id?: StringUUID;\n recursive?: boolean;\n batchSize?: number;\n },\n): Promise<void> => {\n if (!options.name && !options.id) {\n logger.error(\"Either name or id must be provided\");\n return;\n }\n\n if (options.name && options.id) {\n logger.error(\"Only one of name or id must be provided\");\n return;\n }\n\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n const data = await loadFromPaths(paths, options.recursive);\n\n if (data.length === 0) {\n logger.warn(\"No data to push. Skipping\");\n return;\n }\n\n const identifier = options.name ? { name: options.name } : { id: options.id };\n\n try {\n await client.datasets.push({\n points: data,\n ...identifier,\n batchSize: options.batchSize ?? DEFAULT_DATASET_PUSH_BATCH_SIZE,\n });\n logger.info(\n `Pushed ${data.length} data points to dataset ${options.name || options.id}`,\n );\n } catch (error) {\n logger.error(`Failed to push dataset: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets pull command.\n */\nexport const handleDatasetsPull = async (\n outputPath: string | undefined,\n options: DatasetCommandOptions & {\n name?: string;\n id?: StringUUID;\n outputFormat?: \"json\" | \"csv\" | \"jsonl\";\n batchSize?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<void> => {\n if (!options.name && !options.id) {\n logger.error(\"Either name or id must be provided\");\n return;\n }\n\n if (options.name && options.id) {\n logger.error(\"Only one of name or id must be provided\");\n return;\n }\n\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n const identifier = options.name ? { name: options.name } : { id: options.id };\n\n try {\n const result = await pullAllData(\n client,\n identifier,\n options.batchSize ?? DEFAULT_DATASET_PULL_BATCH_SIZE,\n options.offset ?? 0,\n options.limit,\n );\n\n if (outputPath) {\n await writeToFile(outputPath, result, options.outputFormat);\n logger.info(\n `Successfully pulled ${result.length} data points to ${outputPath}`,\n );\n } else {\n printToConsole(result, options.outputFormat ?? \"json\");\n }\n } catch (error) {\n logger.error(`Failed to pull dataset: ${errorMessage(error)}`);\n }\n};\n\n/**\n * Handle datasets create command.\n */\nexport const handleDatasetsCreate = async (\n name: string,\n paths: string[],\n options: DatasetCommandOptions & {\n outputFile: string;\n outputFormat?: \"json\" | \"csv\" | \"jsonl\";\n recursive?: boolean;\n batchSize?: number;\n },\n): Promise<void> => {\n const client = new LaminarClient({\n projectApiKey: options.projectApiKey,\n baseUrl: options.baseUrl,\n port: options.port,\n });\n\n // Load data from input files\n const data = await loadFromPaths(paths, options.recursive);\n\n if (data.length === 0) {\n logger.warn(\"No data to push. Skipping\");\n return;\n }\n\n // Push data to create/populate the dataset\n logger.info(`Pushing ${data.length} data points to dataset '${name}'...`);\n\n try {\n await client.datasets.push({\n points: data,\n name,\n batchSize: options.batchSize ?? DEFAULT_DATASET_PUSH_BATCH_SIZE,\n createDataset: true,\n });\n logger.info(\n `Successfully pushed ${data.length} data points to dataset '${name}'`,\n );\n } catch (error) {\n logger.error(`Failed to create dataset: ${errorMessage(error)}`);\n return;\n }\n\n // Pull data back from the dataset\n logger.info(`Pulling data from dataset '${name}'...`);\n\n try {\n const result = await pullAllData(\n client,\n { name },\n options.batchSize ?? DEFAULT_DATASET_PULL_BATCH_SIZE,\n 0,\n undefined,\n );\n\n // Save to output file\n await writeToFile(options.outputFile, result, options.outputFormat);\n\n logger.info(\n `Successfully created dataset '${name}' ` +\n `and saved ${result.length} datapoints to ${options.outputFile}`,\n );\n } catch (error) {\n logger.error(\n \"Failed to pull dataset after creation: \" + errorMessage(error),\n );\n }\n};\n","import * as esbuild from \"esbuild\";\nimport * as fs from \"fs/promises\";\n\nimport { Evaluation } from \"../evaluations\";\nimport { getDirname, initializeLogger } from \"../utils\";\n\nconst logger = initializeLogger();\n\n// esbuild plugin to skip dynamic imports\nconst createSkipDynamicImportsPlugin = (\n skipModules: string[],\n): esbuild.Plugin => ({\n name: \"skip-dynamic-imports\",\n setup(build) {\n if (!skipModules || skipModules.length === 0) return;\n\n build.onResolve({ filter: /.*/ }, (args) => {\n // Only handle dynamic imports\n if (args.kind === \"dynamic-import\" && skipModules.includes(args.path)) {\n logger.warn(`Skipping dynamic import: ${args.path}`);\n // Return a virtual module that exports an empty object\n return {\n path: args.path,\n namespace: \"lmnr-skip-dynamic-import\",\n };\n }\n });\n\n // Provide empty module content for skipped dynamic imports\n build.onLoad(\n { filter: /.*/, namespace: \"lmnr-skip-dynamic-import\" },\n (args) => ({\n contents: \"export default {};\",\n loader: \"js\",\n }),\n );\n },\n});\n\nfunction loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}): Evaluation<any, any, any>[] {\n globalThis._evaluations = [];\n globalThis._set_global_evaluation = true;\n\n const __filename = filename;\n const __dirname = getDirname();\n\n // add some arguments for proper cjs/esm interop\n\n new Function(\"require\", \"module\", \"__filename\", \"__dirname\", moduleText)(\n require,\n module,\n __filename,\n __dirname,\n );\n\n // Return the modified _evals global variable\n return globalThis._evaluations;\n}\n\nexport interface EvalCommandOptions {\n failOnError?: boolean;\n outputFile?: string;\n externalPackages?: string[];\n dynamicImportsToSkip?: string[];\n frontendPort?: number;\n}\n\nexport async function runEvaluation(\n files: string[],\n options: EvalCommandOptions,\n): Promise<void> {\n const patterns =\n files && files.length > 0\n ? files\n : // No files provided, use default pattern\n [\"evals/**/*.eval.{ts,js}\"];\n\n const evalFiles: string[] = [];\n for await (const file of fs.glob(patterns)) {\n evalFiles.push(file);\n }\n\n evalFiles.sort();\n\n if (evalFiles.length === 0) {\n logger.error(\n \"No evaluation files found. Please provide a file or \" +\n \"ensure there are eval files that are named like `*.eval.{ts,js}` in \" +\n \"the `evals` directory or its subdirectories.\",\n );\n process.exit(1);\n }\n\n if (files.length === 0) {\n logger.info(`Located ${evalFiles.length} evaluation files in evals/`);\n } else {\n logger.info(`Running ${evalFiles.length} evaluation files.`);\n }\n\n const scores: {\n file: string;\n scores: Record<string, number>;\n url: string;\n evaluationId: string;\n }[] = [];\n\n for (const file of evalFiles) {\n logger.info(`Loading ${file}...`);\n const buildOptions = {\n bundle: true,\n platform: \"node\" as esbuild.Platform,\n entryPoints: [file],\n outfile: `tmp_out_${file}.js`,\n write: false, // will be loaded in memory as a temp file\n external: [\n \"@lmnr-ai/lmnr\",\n \"@lmnr-ai/lmnr/*\",\n \"@lmnr-ai/client\",\n \"@lmnr-ai/types\",\n \"esbuild\",\n \"fsevents\",\n \"playwright\",\n \"puppeteer\",\n \"puppeteer-core\",\n \"playwright-core\",\n ...(options.externalPackages ? options.externalPackages : []),\n ],\n plugins: [\n createSkipDynamicImportsPlugin(options.dynamicImportsToSkip || []),\n ],\n treeShaking: true,\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n logger.error(\n \"Error when building: No output files found \" +\n \"it is likely that all eval files are not valid TypeScript or JavaScript files.\",\n );\n if (options.failOnError) {\n process.exit(1);\n }\n continue;\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluations = loadModule({\n filename: file,\n moduleText: outputFileText,\n });\n\n logger.info(`Loaded ${evaluations.length} evaluations from ${file}`);\n\n for (const evaluation of evaluations) {\n if (!evaluation?.run) {\n logger.error(`Evaluation ${file} does not properly call evaluate()`);\n if (options.failOnError) {\n process.exit(1);\n }\n continue;\n }\n\n if (options.frontendPort) {\n evaluation.setFrontendPort(options.frontendPort);\n }\n const evalResult = await evaluation.run();\n scores.push({\n file,\n scores: evalResult?.averageScores ?? {},\n url: evalResult?.url ?? \"\",\n evaluationId: evalResult?.evaluationId ?? \"\",\n });\n }\n }\n\n if (options.outputFile) {\n await fs.writeFile(options.outputFile, JSON.stringify(scores, null, 2));\n }\n}\n","#!/usr/bin/env node\n\nimport { errorMessage } from \"@lmnr-ai/types\";\nimport { Command } from \"commander\";\n\nimport { version } from \"../../package.json\";\nimport { Evaluation } from \"../evaluations\";\nimport { initializeLogger } from \"../utils\";\nimport {\n handleDatasetsCreate,\n handleDatasetsList,\n handleDatasetsPull,\n handleDatasetsPush,\n} from \"./datasets\";\nimport { runEvaluation } from \"./evals\";\n\nconst logger = initializeLogger();\n\ndeclare global {\n var _evaluations: Evaluation<any, any, any>[] | undefined;\n var _set_global_evaluation: boolean;\n}\n\nasync function cli() {\n const program = new Command();\n\n program\n .name(\"lmnr\")\n .description(\n \"CLI for Laminar. Use `lmnr <subcommand> --help` for more information.\",\n )\n .version(version, \"-v, --version\", \"display version number\");\n\n // Eval command\n program\n .command(\"eval\")\n .description(\"Run an evaluation\")\n .argument(\n \"[files...]\",\n \"A file or files containing the evaluation to run. If no file is provided, \" +\n \"the evaluation will run all `*.eval.ts|js` files in the `evals` directory. \" +\n \"If multiple files are provided, the evaluation will run each file in order.\",\n )\n .option(\n \"--fail-on-error\",\n \"Fail on error. If specified, will fail if encounters a file that cannot be run\",\n )\n .option(\n \"--output-file <file>\",\n \"Output file to write the results to. Outputs are written in JSON format.\",\n )\n .option(\n \"--external-packages <packages...>\",\n \"[ADVANCED] List of packages to pass as external to esbuild. This will not link \" +\n \"the packages directly into the eval file, but will instead require them at runtime. \" +\n \"Read more: https://esbuild.github.io/api/#external\",\n )\n .option(\n \"--dynamic-imports-to-skip <modules...>\",\n \"[ADVANCED] List of module names to skip when encountered as dynamic imports. \" +\n \"These dynamic imports will resolve to an empty module to prevent build failures. \" +\n \"This is meant to skip the imports that are not used in the evaluation itself.\",\n )\n .option(\n \"--frontend-port <port>\",\n \"Port for the Laminar frontend. Defaults to 5667\",\n (val) => parseInt(val, 10),\n )\n .action(async (files: string[], options) => {\n await runEvaluation(files, options);\n });\n\n const deprecatedDatasetsWarning =\n \"DeprecationWarning: `lmnr datasets` is deprecated and will be removed in a future version. \" +\n \"Use `lmnr-cli dataset` instead.\";\n\n // Datasets command with global options\n const datasetCmd = program\n .command(\"datasets\")\n .description(\n \"[DEPRECATED] Manage datasets. Use `lmnr-cli dataset` instead.\",\n )\n .option(\n \"--project-api-key <key>\",\n \"Project API key. If not provided, reads from LMNR_PROJECT_API_KEY env variable\",\n )\n .option(\n \"--base-url <url>\",\n \"Base URL for the Laminar API. Defaults to https://api.lmnr.ai or LMNR_BASE_URL env variable\",\n )\n .option(\n \"--port <port>\",\n \"Port for the Laminar API. Defaults to 443\",\n (val) => parseInt(val, 10),\n );\n\n // Datasets list command\n datasetCmd\n .command(\"list\")\n .description(\"List all datasets\")\n .action(async (options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsList({ ...parentOpts, ...options });\n });\n\n // Datasets push command\n datasetCmd\n .command(\"push\")\n .description(\"Push datapoints to an existing dataset\")\n .argument(\n \"<paths...>\",\n \"Paths to files or directories containing data to push\",\n )\n .option(\n \"-n, --name <name>\",\n \"Name of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--id <id>\",\n \"ID of the dataset (either name or id must be provided)\",\n )\n .option(\"-r, --recursive\", \"Recursively read files in directories\", false)\n .option(\n \"--batch-size <size>\",\n \"Batch size for pushing data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .action(async (paths: string[], options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsPush(paths, { ...parentOpts, ...options });\n });\n\n // Datasets pull command\n datasetCmd\n .command(\"pull\")\n .description(\"Pull data from a dataset\")\n .argument(\n \"[output-path]\",\n \"Path to save the data. If not provided, prints to console\",\n )\n .option(\n \"-n, --name <name>\",\n \"Name of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--id <id>\",\n \"ID of the dataset (either name or id must be provided)\",\n )\n .option(\n \"--output-format <format>\",\n \"Output format (json, csv, jsonl). Inferred from file extension if not provided\",\n )\n .option(\n \"--batch-size <size>\",\n \"Batch size for pulling data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .option(\"--limit <limit>\", \"Limit number of datapoints to pull\", (val) =>\n parseInt(val, 10),\n )\n .option(\n \"--offset <offset>\",\n \"Offset for pagination\",\n (val) => parseInt(val, 10),\n 0,\n )\n .action(async (outputPath: string | undefined, options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsPull(outputPath, { ...parentOpts, ...options });\n });\n\n // Datasets create command\n datasetCmd\n .command(\"create\")\n .description(\"Create a dataset from input files\")\n .argument(\"<name>\", \"Name of the dataset to create\")\n .argument(\n \"<paths...>\",\n \"Paths to files or directories containing data to push\",\n )\n .requiredOption(\"-o, --output-file <file>\", \"Path to save the pulled data\")\n .option(\n \"--output-format <format>\",\n \"Output format (json, csv, jsonl). Inferred from file extension if not provided\",\n )\n .option(\"-r, --recursive\", \"Recursively read files in directories\", false)\n .option(\n \"--batch-size <size>\",\n \"Batch size for pushing/pulling data\",\n (val) => parseInt(val, 10),\n 100,\n )\n .action(async (name: string, paths: string[], options, cmd) => {\n process.stderr.write(deprecatedDatasetsWarning + \"\\n\");\n const parentOpts = cmd.parent?.opts() || {};\n await handleDatasetsCreate(name, paths, { ...parentOpts, ...options });\n });\n\n // If no command provided, show help\n if (!process.argv.slice(2).length) {\n program.help();\n return;\n }\n\n await program.parseAsync();\n}\n\ncli().catch((err) => {\n logger.error(errorMessage(err));\n throw err;\n});\n"],"mappings":";;;;;;;;AAOA,MAAMA,WAAS,iBAAiB;AAChC,MAAM,kCAAkC;AACxC,MAAM,kCAAkC;;;;AAWxC,MAAM,cAAc,OAClB,QACA,YACA,YAAoB,iCACpB,SAAiB,GACjB,UAC+B;CAC/B,IAAI,UAAU;CACd,IAAI,gBAAgB;CACpB,MAAM,SAAS,UAAU,KAAA,IAAY,SAAS,QAAQ,KAAA;CAEtD,MAAM,SAA4B,CAAC;CAEnC,OAAO,YAAY,WAAW,KAAA,KAAa,gBAAgB,SAAS;EAClE,MAAM,OAAO,MAAM,OAAO,SAAS,KAAW;GAC5C,GAAG;GACH,QAAQ;GACR,OAAO;EACT,CAAC;EAED,OAAO,KAAK,GAAG,KAAK,KAAK;EAGzB,IAAI,KAAK,MAAM,WAAW,KAAK,KAAK,MAAM,SAAS,WACjD,UAAU;OACL,IAAI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CACA,OACC,qBACA,0BACC,QAAQ,SAAS,KAAK,EAAE,GACzB,CACF,CAAC,CACA,OAAO,OAAO,YAAgC,SAAS,QAAQ;EAC9D,QAAQ,OAAO,MAAM,4BAA4B,IAAI;EACrD,MAAM,aAAa,IAAI,QAAQ,KAAK,KAAK,CAAC;EAC1C,MAAM,mBAAmB,YAAY;GAAE,GAAG;GAAY,GAAG;EAAQ,CAAC;CACpE,CAAC;CAGH,WACG,QAAQ,QAAQ,CAAC,CACjB,YAAY,mCAAmC,CAAC,CAChD,SAAS,UAAU,+BAA+B,CAAC,CACnD,SACC,cACA,uDACF,CAAC,CACA,eAAe,4BAA4B,8BAA8B,CAAC,CAC1E,OACC,4BACA,gFACF,CAAC,CACA,OAAO,mBAAmB,yCAAyC,KAAK,CAAC,CACzE,OACC,uBACA,wCACC,QAAQ,SAAS,KAAK,EAAE,GACzB,GACF,CAAC,CACA,OAAO,OAAO,MAAc,OAAiB,SAAS,QAAQ;EAC7D,QAAQ,OAAO,MAAM,4BAA4B,IAAI;EACrD,MAAM,aAAa,IAAI,QAAQ,KAAK,KAAK,CAAC;EAC1C,MAAM,qBAAqB,MAAM,OAAO;GAAE,GAAG;GAAY,GAAG;EAAQ,CAAC;CACvE,CAAC;CAGH,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ;EACjC,QAAQ,KAAK;EACb;CACF;CAEA,MAAM,QAAQ,WAAW;AAC3B;AAEA,IAAI,CAAC,CAAC,OAAO,QAAQ;CACnB,OAAO,MAAM,aAAa,GAAG,CAAC;CAC9B,MAAM;AACR,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/opentelemetry-lib/instrumentation/temporal/consts.ts
|
|
2
2
|
/** Header key used to carry the serialized Laminar span context through Temporal. */
|
|
3
3
|
const LAMINAR_SPAN_CONTEXT_HEADER = "x-lmnr-span-context";
|
|
4
4
|
/**
|
|
@@ -6,7 +6,6 @@ const LAMINAR_SPAN_CONTEXT_HEADER = "x-lmnr-span-context";
|
|
|
6
6
|
* interop with non-Laminar clients/workers that understand W3C trace context.
|
|
7
7
|
*/
|
|
8
8
|
const TRACEPARENT_HEADER = "traceparent";
|
|
9
|
-
//#endregion
|
|
10
9
|
Object.defineProperty(exports, "LAMINAR_SPAN_CONTEXT_HEADER", {
|
|
11
10
|
enumerable: true,
|
|
12
11
|
get: function() {
|
|
@@ -20,4 +19,4 @@ Object.defineProperty(exports, "TRACEPARENT_HEADER", {
|
|
|
20
19
|
}
|
|
21
20
|
});
|
|
22
21
|
|
|
23
|
-
//# sourceMappingURL=consts-
|
|
22
|
+
//# sourceMappingURL=consts-X-pnRGD0.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts-
|
|
1
|
+
{"version":3,"file":"consts-X-pnRGD0.cjs","names":[],"sources":["../src/opentelemetry-lib/instrumentation/temporal/consts.ts"],"sourcesContent":["/** Header key used to carry the serialized Laminar span context through Temporal. */\nexport const LAMINAR_SPAN_CONTEXT_HEADER = \"x-lmnr-span-context\";\n\n/**\n * W3C traceparent header key — written alongside `x-lmnr-span-context` for\n * interop with non-Laminar clients/workers that understand W3C trace context.\n */\nexport const TRACEPARENT_HEADER = \"traceparent\";\n"],"mappings":";;AACA,MAAa,8BAA8B;;;;;AAM3C,MAAa,qBAAqB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/opentelemetry-lib/instrumentation/temporal/consts.ts
|
|
2
2
|
/** Header key used to carry the serialized Laminar span context through Temporal. */
|
|
3
3
|
const LAMINAR_SPAN_CONTEXT_HEADER = "x-lmnr-span-context";
|
|
4
4
|
/**
|
|
@@ -6,7 +6,6 @@ const LAMINAR_SPAN_CONTEXT_HEADER = "x-lmnr-span-context";
|
|
|
6
6
|
* interop with non-Laminar clients/workers that understand W3C trace context.
|
|
7
7
|
*/
|
|
8
8
|
const TRACEPARENT_HEADER = "traceparent";
|
|
9
|
-
//#endregion
|
|
10
9
|
export { TRACEPARENT_HEADER as n, LAMINAR_SPAN_CONTEXT_HEADER as t };
|
|
11
10
|
|
|
12
|
-
//# sourceMappingURL=consts-
|
|
11
|
+
//# sourceMappingURL=consts-r67THnT9.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts-
|
|
1
|
+
{"version":3,"file":"consts-r67THnT9.mjs","names":[],"sources":["../src/opentelemetry-lib/instrumentation/temporal/consts.ts"],"sourcesContent":["/** Header key used to carry the serialized Laminar span context through Temporal. */\nexport const LAMINAR_SPAN_CONTEXT_HEADER = \"x-lmnr-span-context\";\n\n/**\n * W3C traceparent header key — written alongside `x-lmnr-span-context` for\n * interop with non-Laminar clients/workers that understand W3C trace context.\n */\nexport const TRACEPARENT_HEADER = \"traceparent\";\n"],"mappings":";;AACA,MAAa,8BAA8B;;;;;AAM3C,MAAa,qBAAqB"}
|