tensorlake 0.5.1 → 0.5.3

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.
@@ -1 +1 @@
1
- export { z as CreateSandboxImageOptions, B as DockerfileBuildPlan, E as DockerfileInstruction, T as SandboxImageSource, Y as createSandboxImage, _ as defaultRegisteredName, $ as loadDockerfilePlan, a0 as loadImagePlan, a1 as logicalDockerfileLines, a2 as runCreateSandboxImageCli } from './sandbox-image-CEGsGg4V.cjs';
1
+ export { z as CreateSandboxImageOptions, B as DockerfileBuildPlan, E as DockerfileInstruction, T as SandboxImageSource, Y as createSandboxImage, _ as defaultRegisteredName, $ as loadDockerfilePlan, a0 as loadImagePlan, a1 as logicalDockerfileLines, a2 as runCreateSandboxImageCli } from './sandbox-image-B0WMhyoM.cjs';
@@ -1 +1 @@
1
- export { z as CreateSandboxImageOptions, B as DockerfileBuildPlan, E as DockerfileInstruction, T as SandboxImageSource, Y as createSandboxImage, _ as defaultRegisteredName, $ as loadDockerfilePlan, a0 as loadImagePlan, a1 as logicalDockerfileLines, a2 as runCreateSandboxImageCli } from './sandbox-image-CEGsGg4V.js';
1
+ export { z as CreateSandboxImageOptions, B as DockerfileBuildPlan, E as DockerfileInstruction, T as SandboxImageSource, Y as createSandboxImage, _ as defaultRegisteredName, $ as loadDockerfilePlan, a0 as loadImagePlan, a1 as logicalDockerfileLines, a2 as runCreateSandboxImageCli } from './sandbox-image-B0WMhyoM.js';
@@ -3642,6 +3642,38 @@ __export(client_exports, {
3642
3642
  function sleep2(ms) {
3643
3643
  return new Promise((resolve) => setTimeout(resolve, ms));
3644
3644
  }
3645
+ function formatStartupFailureMessage(sandboxId, status, options) {
3646
+ const prefix = status === "terminated" /* TERMINATED */ ? `Sandbox ${sandboxId} terminated during startup` : `Sandbox ${sandboxId} became ${status} during startup`;
3647
+ const detail = formatErrorDetails(options.errorDetails);
3648
+ if (detail) {
3649
+ return `${prefix}: ${detail}`;
3650
+ }
3651
+ if (options.terminationReason) {
3652
+ return `${prefix}: termination reason: ${options.terminationReason}`;
3653
+ }
3654
+ return prefix;
3655
+ }
3656
+ function formatErrorDetails(errorDetails) {
3657
+ if (errorDetails == null) return void 0;
3658
+ if (typeof errorDetails === "string") {
3659
+ const detail = errorDetails.trim();
3660
+ return detail || void 0;
3661
+ }
3662
+ if (Array.isArray(errorDetails)) {
3663
+ const parts = errorDetails.map((item) => formatErrorDetails(item)).filter((item) => Boolean(item));
3664
+ return parts.length > 0 ? parts.join("; ") : JSON.stringify(errorDetails);
3665
+ }
3666
+ if (typeof errorDetails === "object") {
3667
+ for (const key of ["message", "detail", "error", "reason"]) {
3668
+ const value = errorDetails[key];
3669
+ if (typeof value === "string" && value.trim()) {
3670
+ return value.trim();
3671
+ }
3672
+ }
3673
+ return JSON.stringify(errorDetails);
3674
+ }
3675
+ return String(errorDetails);
3676
+ }
3645
3677
  function normalizeUserPorts(ports) {
3646
3678
  return dedupeAndSortPorts(ports.map(validateUserPort));
3647
3679
  }
@@ -4092,15 +4124,26 @@ var init_client = __esm({
4092
4124
  if (result.status === "running" /* RUNNING */) {
4093
4125
  return finishConnect(result.routingHint, result.name);
4094
4126
  }
4127
+ if (result.status === "suspended" /* SUSPENDED */ || result.status === "terminated" /* TERMINATED */) {
4128
+ throw new SandboxError(
4129
+ formatStartupFailureMessage(result.sandboxId, result.status, {
4130
+ errorDetails: result.errorDetails,
4131
+ terminationReason: result.terminationReason
4132
+ })
4133
+ );
4134
+ }
4095
4135
  const deadline = Date.now() + startupTimeout * 1e3;
4096
4136
  while (Date.now() < deadline) {
4097
4137
  const info = await this.get(result.sandboxId);
4098
4138
  if (info.status === "running" /* RUNNING */) {
4099
4139
  return finishConnect(info.routingHint, info.name);
4100
4140
  }
4101
- if (info.status === "terminated" /* TERMINATED */) {
4141
+ if (info.status === "suspended" /* SUSPENDED */ || info.status === "terminated" /* TERMINATED */) {
4102
4142
  throw new SandboxError(
4103
- `Sandbox ${result.sandboxId} terminated during startup`
4143
+ formatStartupFailureMessage(result.sandboxId, info.status, {
4144
+ errorDetails: info.errorDetails,
4145
+ terminationReason: info.terminationReason
4146
+ })
4104
4147
  );
4105
4148
  }
4106
4149
  await sleep2(500);
@@ -4777,7 +4820,7 @@ async function executeDockerfilePlan(sandbox, plan, emit, sleep3) {
4777
4820
  );
4778
4821
  }
4779
4822
  }
4780
- async function registerImage(context, name, dockerfile, snapshotId, snapshotUri, isPublic) {
4823
+ async function registerImage(context, name, dockerfile, snapshotId, snapshotSandboxId, snapshotUri, snapshotSizeBytes, rootfsDiskBytes, isPublic) {
4781
4824
  if (!context.organizationId || !context.projectId) {
4782
4825
  throw new Error(
4783
4826
  "Organization ID and Project ID are required. Run 'tl login' and 'tl init'."
@@ -4804,8 +4847,11 @@ async function registerImage(context, name, dockerfile, snapshotId, snapshotUri,
4804
4847
  name,
4805
4848
  dockerfile,
4806
4849
  snapshotId,
4850
+ snapshotSandboxId,
4807
4851
  snapshotUri,
4808
- isPublic
4852
+ snapshotSizeBytes,
4853
+ rootfsDiskBytes,
4854
+ public: isPublic
4809
4855
  })
4810
4856
  });
4811
4857
  if (!response.ok) {
@@ -4856,6 +4902,16 @@ async function createSandboxImage(source, options = {}, deps = {}) {
4856
4902
  `Snapshot ${snapshot.snapshotId} is missing snapshotUri and cannot be registered as a sandbox image.`
4857
4903
  );
4858
4904
  }
4905
+ if (snapshot.sizeBytes == null) {
4906
+ throw new Error(
4907
+ `Snapshot ${snapshot.snapshotId} is missing sizeBytes and cannot be registered as a sandbox image.`
4908
+ );
4909
+ }
4910
+ if (snapshot.rootfsDiskBytes == null) {
4911
+ throw new Error(
4912
+ `Snapshot ${snapshot.snapshotId} is missing rootfsDiskBytes and cannot be registered as a sandbox image.`
4913
+ );
4914
+ }
4859
4915
  emit({
4860
4916
  type: "status",
4861
4917
  message: `Registering image '${plan.registeredName}'...`
@@ -4865,7 +4921,10 @@ async function createSandboxImage(source, options = {}, deps = {}) {
4865
4921
  plan.registeredName,
4866
4922
  plan.dockerfileText,
4867
4923
  snapshot.snapshotId,
4924
+ snapshot.sandboxId,
4868
4925
  snapshot.snapshotUri,
4926
+ snapshot.sizeBytes,
4927
+ snapshot.rootfsDiskBytes,
4869
4928
  options.isPublic ?? false
4870
4929
  );
4871
4930
  emit({
@@ -4893,25 +4952,25 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
4893
4952
  name: { type: "string", short: "n" },
4894
4953
  cpus: { type: "string" },
4895
4954
  memory: { type: "string" },
4896
- disk: { type: "string" },
4955
+ disk_mb: { type: "string" },
4897
4956
  public: { type: "boolean", default: false }
4898
4957
  }
4899
4958
  });
4900
4959
  const dockerfilePath = parsed.positionals[0];
4901
4960
  if (!dockerfilePath) {
4902
- throw new Error("Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MB] [--disk GB] [--public]");
4961
+ throw new Error("Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MB] [--disk_mb MB] [--public]");
4903
4962
  }
4904
4963
  const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
4905
4964
  const memoryMb = parsed.values.memory != null ? Number(parsed.values.memory) : void 0;
4906
- const diskGb = parsed.values.disk != null ? Number(parsed.values.disk) : void 0;
4965
+ const diskMb = parsed.values.disk_mb != null ? Number(parsed.values.disk_mb) : void 0;
4907
4966
  if (cpus != null && !Number.isFinite(cpus)) {
4908
4967
  throw new Error(`Invalid --cpus value: ${parsed.values.cpus}`);
4909
4968
  }
4910
4969
  if (memoryMb != null && !Number.isInteger(memoryMb)) {
4911
4970
  throw new Error(`Invalid --memory value: ${parsed.values.memory}`);
4912
4971
  }
4913
- if (diskGb != null && !Number.isInteger(diskGb)) {
4914
- throw new Error(`Invalid --disk value: ${parsed.values.disk}`);
4972
+ if (diskMb != null && !Number.isInteger(diskMb)) {
4973
+ throw new Error(`Invalid --disk_mb value: ${parsed.values.disk_mb}`);
4915
4974
  }
4916
4975
  await createSandboxImage(
4917
4976
  dockerfilePath,
@@ -4919,7 +4978,7 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
4919
4978
  registeredName: parsed.values.name,
4920
4979
  cpus,
4921
4980
  memoryMb,
4922
- diskMb: diskGb != null ? diskGb * 1024 : void 0,
4981
+ diskMb,
4923
4982
  isPublic: parsed.values.public
4924
4983
  },
4925
4984
  { emit: ndjsonStdoutEmit }