trajectories-sh 1.11.0 → 1.12.0
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/dist/cli.js
CHANGED
|
@@ -81,7 +81,7 @@ async function uploadTrajectoryAction(directory, opts) {
|
|
|
81
81
|
Uploading trajectory ${directory} \u2192 ${chalk.cyan(slug)}
|
|
82
82
|
`));
|
|
83
83
|
try {
|
|
84
|
-
const { uploadJob } = await import("./upload-
|
|
84
|
+
const { uploadJob } = await import("./upload-CDNIKYW3.js");
|
|
85
85
|
const result = await uploadJob(directory, {
|
|
86
86
|
slug,
|
|
87
87
|
name: opts.name,
|
|
@@ -92,8 +92,11 @@ async function uploadTrajectoryAction(directory, opts) {
|
|
|
92
92
|
if (result.meanReward != null) {
|
|
93
93
|
console.log(` Pass rate: ${(result.meanReward * 100).toFixed(0)}%`);
|
|
94
94
|
}
|
|
95
|
-
console.log(` Viewer:
|
|
96
|
-
|
|
95
|
+
console.log(` Viewer: ${result.viewerUrl}`);
|
|
96
|
+
if (result.existingDuplicateUrl) {
|
|
97
|
+
console.log(` Earlier copy: ${result.existingDuplicateUrl}`);
|
|
98
|
+
}
|
|
99
|
+
console.log("");
|
|
97
100
|
} catch (e) {
|
|
98
101
|
console.error(chalk.red(`
|
|
99
102
|
\u2717 ${e.message}
|
|
@@ -345,14 +345,18 @@ async function uploadJob(dir, opts) {
|
|
|
345
345
|
}
|
|
346
346
|
const initResp = await apiPost("/api/cli/push/init", { slug, name, visibility, estimated_bytes: totalSize, content_hash: contentHash });
|
|
347
347
|
if (!initResp.ok) {
|
|
348
|
-
if (initResp.status === 409) {
|
|
349
|
-
const err = await initResp.json().catch(() => ({ detail: "Duplicate trajectory" }));
|
|
350
|
-
throw new Error(err.detail);
|
|
351
|
-
}
|
|
352
348
|
throw new Error(`Init failed: ${await initResp.text()}`);
|
|
353
349
|
}
|
|
354
|
-
const
|
|
350
|
+
const initBody = await initResp.json();
|
|
351
|
+
const jobId = initBody.job_id;
|
|
355
352
|
console.log(` Job ID: ${jobId}`);
|
|
353
|
+
const apiUrlEarly = getApiUrl();
|
|
354
|
+
const siteUrlEarly = apiUrlEarly.includes("localhost") ? "http://localhost:3000" : apiUrlEarly.replace("api.", "").replace(/\/$/, "");
|
|
355
|
+
const existingDuplicateUrl = initBody.existing_duplicate ? `${siteUrlEarly}/t/${initBody.existing_duplicate.job_id}` : void 0;
|
|
356
|
+
if (existingDuplicateUrl) {
|
|
357
|
+
console.log(` \u24D8 This content was already uploaded as '${initBody.existing_duplicate.slug}' \u2014 uploading anyway.`);
|
|
358
|
+
console.log(` Existing: ${existingDuplicateUrl}`);
|
|
359
|
+
}
|
|
356
360
|
await uploadDirect(jobId, files);
|
|
357
361
|
console.log(" Finalizing...");
|
|
358
362
|
const finalResp = await apiPost(`/api/cli/push/${jobId}/finalize`, {});
|
|
@@ -381,7 +385,8 @@ async function uploadJob(dir, opts) {
|
|
|
381
385
|
slug: result.slug,
|
|
382
386
|
nTrials: result.n_trials,
|
|
383
387
|
meanReward: result.mean_reward,
|
|
384
|
-
viewerUrl: `${siteUrl}/t/${jobId}
|
|
388
|
+
viewerUrl: `${siteUrl}/t/${jobId}`,
|
|
389
|
+
existingDuplicateUrl
|
|
385
390
|
};
|
|
386
391
|
}
|
|
387
392
|
async function uploadDirect(jobId, files) {
|