modal 0.3.20 → 0.3.21

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/index.cjs CHANGED
@@ -6520,6 +6520,104 @@ var AutoscalerSettings = {
6520
6520
  return message;
6521
6521
  }
6522
6522
  };
6523
+ function createBaseAutoscalingMetrics() {
6524
+ return { cpuUsagePercent: 0, memoryUsagePercent: 0, concurrentRequests: 0, timestamp: 0 };
6525
+ }
6526
+ var AutoscalingMetrics = {
6527
+ encode(message, writer = new BinaryWriter()) {
6528
+ if (message.cpuUsagePercent !== 0) {
6529
+ writer.uint32(9).double(message.cpuUsagePercent);
6530
+ }
6531
+ if (message.memoryUsagePercent !== 0) {
6532
+ writer.uint32(17).double(message.memoryUsagePercent);
6533
+ }
6534
+ if (message.concurrentRequests !== 0) {
6535
+ writer.uint32(24).uint32(message.concurrentRequests);
6536
+ }
6537
+ if (message.timestamp !== 0) {
6538
+ writer.uint32(33).double(message.timestamp);
6539
+ }
6540
+ return writer;
6541
+ },
6542
+ decode(input, length) {
6543
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6544
+ let end = length === void 0 ? reader.len : reader.pos + length;
6545
+ const message = createBaseAutoscalingMetrics();
6546
+ while (reader.pos < end) {
6547
+ const tag = reader.uint32();
6548
+ switch (tag >>> 3) {
6549
+ case 1: {
6550
+ if (tag !== 9) {
6551
+ break;
6552
+ }
6553
+ message.cpuUsagePercent = reader.double();
6554
+ continue;
6555
+ }
6556
+ case 2: {
6557
+ if (tag !== 17) {
6558
+ break;
6559
+ }
6560
+ message.memoryUsagePercent = reader.double();
6561
+ continue;
6562
+ }
6563
+ case 3: {
6564
+ if (tag !== 24) {
6565
+ break;
6566
+ }
6567
+ message.concurrentRequests = reader.uint32();
6568
+ continue;
6569
+ }
6570
+ case 4: {
6571
+ if (tag !== 33) {
6572
+ break;
6573
+ }
6574
+ message.timestamp = reader.double();
6575
+ continue;
6576
+ }
6577
+ }
6578
+ if ((tag & 7) === 4 || tag === 0) {
6579
+ break;
6580
+ }
6581
+ reader.skip(tag & 7);
6582
+ }
6583
+ return message;
6584
+ },
6585
+ fromJSON(object) {
6586
+ return {
6587
+ cpuUsagePercent: isSet3(object.cpuUsagePercent) ? globalThis.Number(object.cpuUsagePercent) : 0,
6588
+ memoryUsagePercent: isSet3(object.memoryUsagePercent) ? globalThis.Number(object.memoryUsagePercent) : 0,
6589
+ concurrentRequests: isSet3(object.concurrentRequests) ? globalThis.Number(object.concurrentRequests) : 0,
6590
+ timestamp: isSet3(object.timestamp) ? globalThis.Number(object.timestamp) : 0
6591
+ };
6592
+ },
6593
+ toJSON(message) {
6594
+ const obj = {};
6595
+ if (message.cpuUsagePercent !== 0) {
6596
+ obj.cpuUsagePercent = message.cpuUsagePercent;
6597
+ }
6598
+ if (message.memoryUsagePercent !== 0) {
6599
+ obj.memoryUsagePercent = message.memoryUsagePercent;
6600
+ }
6601
+ if (message.concurrentRequests !== 0) {
6602
+ obj.concurrentRequests = Math.round(message.concurrentRequests);
6603
+ }
6604
+ if (message.timestamp !== 0) {
6605
+ obj.timestamp = message.timestamp;
6606
+ }
6607
+ return obj;
6608
+ },
6609
+ create(base) {
6610
+ return AutoscalingMetrics.fromPartial(base ?? {});
6611
+ },
6612
+ fromPartial(object) {
6613
+ const message = createBaseAutoscalingMetrics();
6614
+ message.cpuUsagePercent = object.cpuUsagePercent ?? 0;
6615
+ message.memoryUsagePercent = object.memoryUsagePercent ?? 0;
6616
+ message.concurrentRequests = object.concurrentRequests ?? 0;
6617
+ message.timestamp = object.timestamp ?? 0;
6618
+ return message;
6619
+ }
6620
+ };
6523
6621
  function createBaseBaseImage() {
6524
6622
  return { imageId: "", dockerTag: "" };
6525
6623
  }
@@ -35073,6 +35171,108 @@ var TaskCurrentInputsResponse = {
35073
35171
  return message;
35074
35172
  }
35075
35173
  };
35174
+ function createBaseTaskGetAutoscalingMetricsRequest() {
35175
+ return { taskId: "" };
35176
+ }
35177
+ var TaskGetAutoscalingMetricsRequest = {
35178
+ encode(message, writer = new BinaryWriter()) {
35179
+ if (message.taskId !== "") {
35180
+ writer.uint32(10).string(message.taskId);
35181
+ }
35182
+ return writer;
35183
+ },
35184
+ decode(input, length) {
35185
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
35186
+ let end = length === void 0 ? reader.len : reader.pos + length;
35187
+ const message = createBaseTaskGetAutoscalingMetricsRequest();
35188
+ while (reader.pos < end) {
35189
+ const tag = reader.uint32();
35190
+ switch (tag >>> 3) {
35191
+ case 1: {
35192
+ if (tag !== 10) {
35193
+ break;
35194
+ }
35195
+ message.taskId = reader.string();
35196
+ continue;
35197
+ }
35198
+ }
35199
+ if ((tag & 7) === 4 || tag === 0) {
35200
+ break;
35201
+ }
35202
+ reader.skip(tag & 7);
35203
+ }
35204
+ return message;
35205
+ },
35206
+ fromJSON(object) {
35207
+ return { taskId: isSet3(object.taskId) ? globalThis.String(object.taskId) : "" };
35208
+ },
35209
+ toJSON(message) {
35210
+ const obj = {};
35211
+ if (message.taskId !== "") {
35212
+ obj.taskId = message.taskId;
35213
+ }
35214
+ return obj;
35215
+ },
35216
+ create(base) {
35217
+ return TaskGetAutoscalingMetricsRequest.fromPartial(base ?? {});
35218
+ },
35219
+ fromPartial(object) {
35220
+ const message = createBaseTaskGetAutoscalingMetricsRequest();
35221
+ message.taskId = object.taskId ?? "";
35222
+ return message;
35223
+ }
35224
+ };
35225
+ function createBaseTaskGetAutoscalingMetricsResponse() {
35226
+ return { metrics: void 0 };
35227
+ }
35228
+ var TaskGetAutoscalingMetricsResponse = {
35229
+ encode(message, writer = new BinaryWriter()) {
35230
+ if (message.metrics !== void 0) {
35231
+ AutoscalingMetrics.encode(message.metrics, writer.uint32(10).fork()).join();
35232
+ }
35233
+ return writer;
35234
+ },
35235
+ decode(input, length) {
35236
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
35237
+ let end = length === void 0 ? reader.len : reader.pos + length;
35238
+ const message = createBaseTaskGetAutoscalingMetricsResponse();
35239
+ while (reader.pos < end) {
35240
+ const tag = reader.uint32();
35241
+ switch (tag >>> 3) {
35242
+ case 1: {
35243
+ if (tag !== 10) {
35244
+ break;
35245
+ }
35246
+ message.metrics = AutoscalingMetrics.decode(reader, reader.uint32());
35247
+ continue;
35248
+ }
35249
+ }
35250
+ if ((tag & 7) === 4 || tag === 0) {
35251
+ break;
35252
+ }
35253
+ reader.skip(tag & 7);
35254
+ }
35255
+ return message;
35256
+ },
35257
+ fromJSON(object) {
35258
+ return { metrics: isSet3(object.metrics) ? AutoscalingMetrics.fromJSON(object.metrics) : void 0 };
35259
+ },
35260
+ toJSON(message) {
35261
+ const obj = {};
35262
+ if (message.metrics !== void 0) {
35263
+ obj.metrics = AutoscalingMetrics.toJSON(message.metrics);
35264
+ }
35265
+ return obj;
35266
+ },
35267
+ create(base) {
35268
+ return TaskGetAutoscalingMetricsResponse.fromPartial(base ?? {});
35269
+ },
35270
+ fromPartial(object) {
35271
+ const message = createBaseTaskGetAutoscalingMetricsResponse();
35272
+ message.metrics = object.metrics !== void 0 && object.metrics !== null ? AutoscalingMetrics.fromPartial(object.metrics) : void 0;
35273
+ return message;
35274
+ }
35275
+ };
35076
35276
  function createBaseTaskInfo() {
35077
35277
  return {
35078
35278
  id: "",
@@ -40979,6 +41179,15 @@ var ModalClientDefinition = {
40979
41179
  responseStream: false,
40980
41180
  options: {}
40981
41181
  },
41182
+ /** Used for flash autoscaling */
41183
+ taskGetAutoscalingMetrics: {
41184
+ name: "TaskGetAutoscalingMetrics",
41185
+ requestType: TaskGetAutoscalingMetricsRequest,
41186
+ requestStream: false,
41187
+ responseType: TaskGetAutoscalingMetricsResponse,
41188
+ responseStream: false,
41189
+ options: {}
41190
+ },
40982
41191
  taskList: {
40983
41192
  name: "TaskList",
40984
41193
  requestType: TaskListRequest,
@@ -42491,7 +42700,12 @@ var App = class _App {
42491
42700
  const gpuConfig = parseGpuConfig(options.gpu);
42492
42701
  if (options.timeout && options.timeout % 1e3 !== 0) {
42493
42702
  throw new Error(
42494
- `Timeout must be a multiple of 1000ms, got ${options.timeout}`
42703
+ `timeout must be a multiple of 1000ms, got ${options.timeout}`
42704
+ );
42705
+ }
42706
+ if (options.idleTimeout && options.idleTimeout % 1e3 !== 0) {
42707
+ throw new Error(
42708
+ `idleTimeout must be a multiple of 1000ms, got ${options.idleTimeout}`
42495
42709
  );
42496
42710
  }
42497
42711
  await image.build(this);
@@ -42570,6 +42784,7 @@ var App = class _App {
42570
42784
  entrypointArgs: options.command ?? ["sleep", "48h"],
42571
42785
  imageId: image.imageId,
42572
42786
  timeoutSecs: options.timeout != void 0 ? options.timeout / 1e3 : 600,
42787
+ idleTimeoutSecs: options.idleTimeout != void 0 ? options.idleTimeout / 1e3 : void 0,
42573
42788
  workdir: options.workdir ?? void 0,
42574
42789
  networkAccess,
42575
42790
  resources: {
package/dist/index.d.cts CHANGED
@@ -418,6 +418,8 @@ type SandboxCreateOptions = {
418
418
  gpu?: string;
419
419
  /** Timeout of the Sandbox container, defaults to 10 minutes. */
420
420
  timeout?: number;
421
+ /** The amount of time in milliseconds that a sandbox can be idle before being terminated. */
422
+ idleTimeout?: number;
421
423
  /** Working directory of the Sandbox. */
422
424
  workdir?: string;
423
425
  /**
package/dist/index.d.ts CHANGED
@@ -418,6 +418,8 @@ type SandboxCreateOptions = {
418
418
  gpu?: string;
419
419
  /** Timeout of the Sandbox container, defaults to 10 minutes. */
420
420
  timeout?: number;
421
+ /** The amount of time in milliseconds that a sandbox can be idle before being terminated. */
422
+ idleTimeout?: number;
421
423
  /** Working directory of the Sandbox. */
422
424
  workdir?: string;
423
425
  /**
package/dist/index.js CHANGED
@@ -6460,6 +6460,104 @@ var AutoscalerSettings = {
6460
6460
  return message;
6461
6461
  }
6462
6462
  };
6463
+ function createBaseAutoscalingMetrics() {
6464
+ return { cpuUsagePercent: 0, memoryUsagePercent: 0, concurrentRequests: 0, timestamp: 0 };
6465
+ }
6466
+ var AutoscalingMetrics = {
6467
+ encode(message, writer = new BinaryWriter()) {
6468
+ if (message.cpuUsagePercent !== 0) {
6469
+ writer.uint32(9).double(message.cpuUsagePercent);
6470
+ }
6471
+ if (message.memoryUsagePercent !== 0) {
6472
+ writer.uint32(17).double(message.memoryUsagePercent);
6473
+ }
6474
+ if (message.concurrentRequests !== 0) {
6475
+ writer.uint32(24).uint32(message.concurrentRequests);
6476
+ }
6477
+ if (message.timestamp !== 0) {
6478
+ writer.uint32(33).double(message.timestamp);
6479
+ }
6480
+ return writer;
6481
+ },
6482
+ decode(input, length) {
6483
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
6484
+ let end = length === void 0 ? reader.len : reader.pos + length;
6485
+ const message = createBaseAutoscalingMetrics();
6486
+ while (reader.pos < end) {
6487
+ const tag = reader.uint32();
6488
+ switch (tag >>> 3) {
6489
+ case 1: {
6490
+ if (tag !== 9) {
6491
+ break;
6492
+ }
6493
+ message.cpuUsagePercent = reader.double();
6494
+ continue;
6495
+ }
6496
+ case 2: {
6497
+ if (tag !== 17) {
6498
+ break;
6499
+ }
6500
+ message.memoryUsagePercent = reader.double();
6501
+ continue;
6502
+ }
6503
+ case 3: {
6504
+ if (tag !== 24) {
6505
+ break;
6506
+ }
6507
+ message.concurrentRequests = reader.uint32();
6508
+ continue;
6509
+ }
6510
+ case 4: {
6511
+ if (tag !== 33) {
6512
+ break;
6513
+ }
6514
+ message.timestamp = reader.double();
6515
+ continue;
6516
+ }
6517
+ }
6518
+ if ((tag & 7) === 4 || tag === 0) {
6519
+ break;
6520
+ }
6521
+ reader.skip(tag & 7);
6522
+ }
6523
+ return message;
6524
+ },
6525
+ fromJSON(object) {
6526
+ return {
6527
+ cpuUsagePercent: isSet3(object.cpuUsagePercent) ? globalThis.Number(object.cpuUsagePercent) : 0,
6528
+ memoryUsagePercent: isSet3(object.memoryUsagePercent) ? globalThis.Number(object.memoryUsagePercent) : 0,
6529
+ concurrentRequests: isSet3(object.concurrentRequests) ? globalThis.Number(object.concurrentRequests) : 0,
6530
+ timestamp: isSet3(object.timestamp) ? globalThis.Number(object.timestamp) : 0
6531
+ };
6532
+ },
6533
+ toJSON(message) {
6534
+ const obj = {};
6535
+ if (message.cpuUsagePercent !== 0) {
6536
+ obj.cpuUsagePercent = message.cpuUsagePercent;
6537
+ }
6538
+ if (message.memoryUsagePercent !== 0) {
6539
+ obj.memoryUsagePercent = message.memoryUsagePercent;
6540
+ }
6541
+ if (message.concurrentRequests !== 0) {
6542
+ obj.concurrentRequests = Math.round(message.concurrentRequests);
6543
+ }
6544
+ if (message.timestamp !== 0) {
6545
+ obj.timestamp = message.timestamp;
6546
+ }
6547
+ return obj;
6548
+ },
6549
+ create(base) {
6550
+ return AutoscalingMetrics.fromPartial(base ?? {});
6551
+ },
6552
+ fromPartial(object) {
6553
+ const message = createBaseAutoscalingMetrics();
6554
+ message.cpuUsagePercent = object.cpuUsagePercent ?? 0;
6555
+ message.memoryUsagePercent = object.memoryUsagePercent ?? 0;
6556
+ message.concurrentRequests = object.concurrentRequests ?? 0;
6557
+ message.timestamp = object.timestamp ?? 0;
6558
+ return message;
6559
+ }
6560
+ };
6463
6561
  function createBaseBaseImage() {
6464
6562
  return { imageId: "", dockerTag: "" };
6465
6563
  }
@@ -35013,6 +35111,108 @@ var TaskCurrentInputsResponse = {
35013
35111
  return message;
35014
35112
  }
35015
35113
  };
35114
+ function createBaseTaskGetAutoscalingMetricsRequest() {
35115
+ return { taskId: "" };
35116
+ }
35117
+ var TaskGetAutoscalingMetricsRequest = {
35118
+ encode(message, writer = new BinaryWriter()) {
35119
+ if (message.taskId !== "") {
35120
+ writer.uint32(10).string(message.taskId);
35121
+ }
35122
+ return writer;
35123
+ },
35124
+ decode(input, length) {
35125
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
35126
+ let end = length === void 0 ? reader.len : reader.pos + length;
35127
+ const message = createBaseTaskGetAutoscalingMetricsRequest();
35128
+ while (reader.pos < end) {
35129
+ const tag = reader.uint32();
35130
+ switch (tag >>> 3) {
35131
+ case 1: {
35132
+ if (tag !== 10) {
35133
+ break;
35134
+ }
35135
+ message.taskId = reader.string();
35136
+ continue;
35137
+ }
35138
+ }
35139
+ if ((tag & 7) === 4 || tag === 0) {
35140
+ break;
35141
+ }
35142
+ reader.skip(tag & 7);
35143
+ }
35144
+ return message;
35145
+ },
35146
+ fromJSON(object) {
35147
+ return { taskId: isSet3(object.taskId) ? globalThis.String(object.taskId) : "" };
35148
+ },
35149
+ toJSON(message) {
35150
+ const obj = {};
35151
+ if (message.taskId !== "") {
35152
+ obj.taskId = message.taskId;
35153
+ }
35154
+ return obj;
35155
+ },
35156
+ create(base) {
35157
+ return TaskGetAutoscalingMetricsRequest.fromPartial(base ?? {});
35158
+ },
35159
+ fromPartial(object) {
35160
+ const message = createBaseTaskGetAutoscalingMetricsRequest();
35161
+ message.taskId = object.taskId ?? "";
35162
+ return message;
35163
+ }
35164
+ };
35165
+ function createBaseTaskGetAutoscalingMetricsResponse() {
35166
+ return { metrics: void 0 };
35167
+ }
35168
+ var TaskGetAutoscalingMetricsResponse = {
35169
+ encode(message, writer = new BinaryWriter()) {
35170
+ if (message.metrics !== void 0) {
35171
+ AutoscalingMetrics.encode(message.metrics, writer.uint32(10).fork()).join();
35172
+ }
35173
+ return writer;
35174
+ },
35175
+ decode(input, length) {
35176
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
35177
+ let end = length === void 0 ? reader.len : reader.pos + length;
35178
+ const message = createBaseTaskGetAutoscalingMetricsResponse();
35179
+ while (reader.pos < end) {
35180
+ const tag = reader.uint32();
35181
+ switch (tag >>> 3) {
35182
+ case 1: {
35183
+ if (tag !== 10) {
35184
+ break;
35185
+ }
35186
+ message.metrics = AutoscalingMetrics.decode(reader, reader.uint32());
35187
+ continue;
35188
+ }
35189
+ }
35190
+ if ((tag & 7) === 4 || tag === 0) {
35191
+ break;
35192
+ }
35193
+ reader.skip(tag & 7);
35194
+ }
35195
+ return message;
35196
+ },
35197
+ fromJSON(object) {
35198
+ return { metrics: isSet3(object.metrics) ? AutoscalingMetrics.fromJSON(object.metrics) : void 0 };
35199
+ },
35200
+ toJSON(message) {
35201
+ const obj = {};
35202
+ if (message.metrics !== void 0) {
35203
+ obj.metrics = AutoscalingMetrics.toJSON(message.metrics);
35204
+ }
35205
+ return obj;
35206
+ },
35207
+ create(base) {
35208
+ return TaskGetAutoscalingMetricsResponse.fromPartial(base ?? {});
35209
+ },
35210
+ fromPartial(object) {
35211
+ const message = createBaseTaskGetAutoscalingMetricsResponse();
35212
+ message.metrics = object.metrics !== void 0 && object.metrics !== null ? AutoscalingMetrics.fromPartial(object.metrics) : void 0;
35213
+ return message;
35214
+ }
35215
+ };
35016
35216
  function createBaseTaskInfo() {
35017
35217
  return {
35018
35218
  id: "",
@@ -40919,6 +41119,15 @@ var ModalClientDefinition = {
40919
41119
  responseStream: false,
40920
41120
  options: {}
40921
41121
  },
41122
+ /** Used for flash autoscaling */
41123
+ taskGetAutoscalingMetrics: {
41124
+ name: "TaskGetAutoscalingMetrics",
41125
+ requestType: TaskGetAutoscalingMetricsRequest,
41126
+ requestStream: false,
41127
+ responseType: TaskGetAutoscalingMetricsResponse,
41128
+ responseStream: false,
41129
+ options: {}
41130
+ },
40922
41131
  taskList: {
40923
41132
  name: "TaskList",
40924
41133
  requestType: TaskListRequest,
@@ -42437,7 +42646,12 @@ var App = class _App {
42437
42646
  const gpuConfig = parseGpuConfig(options.gpu);
42438
42647
  if (options.timeout && options.timeout % 1e3 !== 0) {
42439
42648
  throw new Error(
42440
- `Timeout must be a multiple of 1000ms, got ${options.timeout}`
42649
+ `timeout must be a multiple of 1000ms, got ${options.timeout}`
42650
+ );
42651
+ }
42652
+ if (options.idleTimeout && options.idleTimeout % 1e3 !== 0) {
42653
+ throw new Error(
42654
+ `idleTimeout must be a multiple of 1000ms, got ${options.idleTimeout}`
42441
42655
  );
42442
42656
  }
42443
42657
  await image.build(this);
@@ -42516,6 +42730,7 @@ var App = class _App {
42516
42730
  entrypointArgs: options.command ?? ["sleep", "48h"],
42517
42731
  imageId: image.imageId,
42518
42732
  timeoutSecs: options.timeout != void 0 ? options.timeout / 1e3 : 600,
42733
+ idleTimeoutSecs: options.idleTimeout != void 0 ? options.idleTimeout / 1e3 : void 0,
42519
42734
  workdir: options.workdir ?? void 0,
42520
42735
  networkAccess,
42521
42736
  resources: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modal",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "description": "Modal client library for JavaScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://modal.com/docs",