modal 0.11.1-dev.6 → 0.11.1-dev.7

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
@@ -18121,7 +18121,7 @@ var EndpointCreateRequest = {
18121
18121
  }
18122
18122
  };
18123
18123
  function createBaseEndpointCreateResponse() {
18124
- return { endpointId: "", endpointPageUrl: "", name: "" };
18124
+ return { endpointId: "", endpointPageUrl: "", name: "", modelName: "" };
18125
18125
  }
18126
18126
  var EndpointCreateResponse = {
18127
18127
  encode(message, writer = new BinaryWriter()) {
@@ -18134,6 +18134,9 @@ var EndpointCreateResponse = {
18134
18134
  if (message.name !== "") {
18135
18135
  writer.uint32(26).string(message.name);
18136
18136
  }
18137
+ if (message.modelName !== "") {
18138
+ writer.uint32(34).string(message.modelName);
18139
+ }
18137
18140
  return writer;
18138
18141
  },
18139
18142
  decode(input, length) {
@@ -18164,6 +18167,13 @@ var EndpointCreateResponse = {
18164
18167
  message.name = reader.string();
18165
18168
  continue;
18166
18169
  }
18170
+ case 4: {
18171
+ if (tag !== 34) {
18172
+ break;
18173
+ }
18174
+ message.modelName = reader.string();
18175
+ continue;
18176
+ }
18167
18177
  }
18168
18178
  if ((tag & 7) === 4 || tag === 0) {
18169
18179
  break;
@@ -18176,7 +18186,8 @@ var EndpointCreateResponse = {
18176
18186
  return {
18177
18187
  endpointId: isSet5(object.endpointId) ? globalThis.String(object.endpointId) : "",
18178
18188
  endpointPageUrl: isSet5(object.endpointPageUrl) ? globalThis.String(object.endpointPageUrl) : "",
18179
- name: isSet5(object.name) ? globalThis.String(object.name) : ""
18189
+ name: isSet5(object.name) ? globalThis.String(object.name) : "",
18190
+ modelName: isSet5(object.modelName) ? globalThis.String(object.modelName) : ""
18180
18191
  };
18181
18192
  },
18182
18193
  toJSON(message) {
@@ -18190,6 +18201,9 @@ var EndpointCreateResponse = {
18190
18201
  if (message.name !== "") {
18191
18202
  obj.name = message.name;
18192
18203
  }
18204
+ if (message.modelName !== "") {
18205
+ obj.modelName = message.modelName;
18206
+ }
18193
18207
  return obj;
18194
18208
  },
18195
18209
  create(base) {
@@ -18200,6 +18214,7 @@ var EndpointCreateResponse = {
18200
18214
  message.endpointId = object.endpointId ?? "";
18201
18215
  message.endpointPageUrl = object.endpointPageUrl ?? "";
18202
18216
  message.name = object.name ?? "";
18217
+ message.modelName = object.modelName ?? "";
18203
18218
  return message;
18204
18219
  }
18205
18220
  };
@@ -18552,7 +18567,8 @@ function createBaseEndpointGetInfoResponse_EndpointInfoSummary() {
18552
18567
  status: 0,
18553
18568
  lifecycle: void 0,
18554
18569
  volumeId: "",
18555
- modelPath: ""
18570
+ modelPath: "",
18571
+ modelName: ""
18556
18572
  };
18557
18573
  }
18558
18574
  var EndpointGetInfoResponse_EndpointInfoSummary = {
@@ -18587,6 +18603,9 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18587
18603
  if (message.modelPath !== "") {
18588
18604
  writer.uint32(98).string(message.modelPath);
18589
18605
  }
18606
+ if (message.modelName !== "") {
18607
+ writer.uint32(106).string(message.modelName);
18608
+ }
18590
18609
  return writer;
18591
18610
  },
18592
18611
  decode(input, length) {
@@ -18666,6 +18685,13 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18666
18685
  message.modelPath = reader.string();
18667
18686
  continue;
18668
18687
  }
18688
+ case 13: {
18689
+ if (tag !== 106) {
18690
+ break;
18691
+ }
18692
+ message.modelName = reader.string();
18693
+ continue;
18694
+ }
18669
18695
  }
18670
18696
  if ((tag & 7) === 4 || tag === 0) {
18671
18697
  break;
@@ -18685,7 +18711,8 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18685
18711
  status: isSet5(object.status) ? endpointGetInfoResponse_EndpointStatusFromJSON(object.status) : 0,
18686
18712
  lifecycle: isSet5(object.lifecycle) ? EndpointLifecycle.fromJSON(object.lifecycle) : void 0,
18687
18713
  volumeId: isSet5(object.volumeId) ? globalThis.String(object.volumeId) : "",
18688
- modelPath: isSet5(object.modelPath) ? globalThis.String(object.modelPath) : ""
18714
+ modelPath: isSet5(object.modelPath) ? globalThis.String(object.modelPath) : "",
18715
+ modelName: isSet5(object.modelName) ? globalThis.String(object.modelName) : ""
18689
18716
  };
18690
18717
  },
18691
18718
  toJSON(message) {
@@ -18720,6 +18747,9 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18720
18747
  if (message.modelPath !== "") {
18721
18748
  obj.modelPath = message.modelPath;
18722
18749
  }
18750
+ if (message.modelName !== "") {
18751
+ obj.modelName = message.modelName;
18752
+ }
18723
18753
  return obj;
18724
18754
  },
18725
18755
  create(base) {
@@ -18737,6 +18767,7 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18737
18767
  message.lifecycle = object.lifecycle !== void 0 && object.lifecycle !== null ? EndpointLifecycle.fromPartial(object.lifecycle) : void 0;
18738
18768
  message.volumeId = object.volumeId ?? "";
18739
18769
  message.modelPath = object.modelPath ?? "";
18770
+ message.modelName = object.modelName ?? "";
18740
18771
  return message;
18741
18772
  }
18742
18773
  };
@@ -45016,7 +45047,7 @@ var SandboxGetExitSnapshotResponse_Error = {
45016
45047
  }
45017
45048
  };
45018
45049
  function createBaseSandboxGetFromNameRequest() {
45019
- return { sandboxName: "", environmentName: "", appName: "" };
45050
+ return { sandboxName: "", environmentName: "", appName: "", includeTerminated: false };
45020
45051
  }
45021
45052
  var SandboxGetFromNameRequest = {
45022
45053
  encode(message, writer = new BinaryWriter()) {
@@ -45029,6 +45060,9 @@ var SandboxGetFromNameRequest = {
45029
45060
  if (message.appName !== "") {
45030
45061
  writer.uint32(26).string(message.appName);
45031
45062
  }
45063
+ if (message.includeTerminated !== false) {
45064
+ writer.uint32(32).bool(message.includeTerminated);
45065
+ }
45032
45066
  return writer;
45033
45067
  },
45034
45068
  decode(input, length) {
@@ -45059,6 +45093,13 @@ var SandboxGetFromNameRequest = {
45059
45093
  message.appName = reader.string();
45060
45094
  continue;
45061
45095
  }
45096
+ case 4: {
45097
+ if (tag !== 32) {
45098
+ break;
45099
+ }
45100
+ message.includeTerminated = reader.bool();
45101
+ continue;
45102
+ }
45062
45103
  }
45063
45104
  if ((tag & 7) === 4 || tag === 0) {
45064
45105
  break;
@@ -45071,7 +45112,8 @@ var SandboxGetFromNameRequest = {
45071
45112
  return {
45072
45113
  sandboxName: isSet5(object.sandboxName) ? globalThis.String(object.sandboxName) : "",
45073
45114
  environmentName: isSet5(object.environmentName) ? globalThis.String(object.environmentName) : "",
45074
- appName: isSet5(object.appName) ? globalThis.String(object.appName) : ""
45115
+ appName: isSet5(object.appName) ? globalThis.String(object.appName) : "",
45116
+ includeTerminated: isSet5(object.includeTerminated) ? globalThis.Boolean(object.includeTerminated) : false
45075
45117
  };
45076
45118
  },
45077
45119
  toJSON(message) {
@@ -45085,6 +45127,9 @@ var SandboxGetFromNameRequest = {
45085
45127
  if (message.appName !== "") {
45086
45128
  obj.appName = message.appName;
45087
45129
  }
45130
+ if (message.includeTerminated !== false) {
45131
+ obj.includeTerminated = message.includeTerminated;
45132
+ }
45088
45133
  return obj;
45089
45134
  },
45090
45135
  create(base) {
@@ -45095,6 +45140,7 @@ var SandboxGetFromNameRequest = {
45095
45140
  message.sandboxName = object.sandboxName ?? "";
45096
45141
  message.environmentName = object.environmentName ?? "";
45097
45142
  message.appName = object.appName ?? "";
45143
+ message.includeTerminated = object.includeTerminated ?? false;
45098
45144
  return message;
45099
45145
  }
45100
45146
  };
@@ -74579,7 +74625,7 @@ var AuthTokenManager = class {
74579
74625
  };
74580
74626
 
74581
74627
  // src/version.ts
74582
- var SDK_VERSION = "0.11.1-dev.6";
74628
+ var SDK_VERSION = "0.11.1-dev.7";
74583
74629
  function getSDKVersion() {
74584
74630
  return SDK_VERSION;
74585
74631
  }
@@ -76457,6 +76503,20 @@ var FunctionService = class {
76457
76503
  }
76458
76504
  }
76459
76505
  };
76506
+ function statsDistributions(stats) {
76507
+ return Object.fromEntries(
76508
+ Object.entries(stats).map(([key, distribution]) => [
76509
+ key,
76510
+ {
76511
+ unit: distribution.unit,
76512
+ percentiles: distribution.percentiles.map((p) => ({
76513
+ percentile: p.percentileBasisPoints / 100,
76514
+ value: p.value
76515
+ }))
76516
+ }
76517
+ ])
76518
+ );
76519
+ }
76460
76520
  function mergeServiceOptions(base, diff) {
76461
76521
  const filteredDiff = Object.fromEntries(
76462
76522
  Object.entries(diff).filter(([, value]) => value !== void 0)
@@ -76824,6 +76884,65 @@ var Function_ = class _Function_ {
76824
76884
  this.functionId
76825
76885
  );
76826
76886
  }
76887
+ /**
76888
+ * Return historical statistics. Defaults to the last hour; the maximum range is 7 days.
76889
+ *
76890
+ * @example Read statistics for the last hour.
76891
+ * ```ts
76892
+ * const fn = await modal.functions.fromName("libmodal-test-support", "echo_string");
76893
+ * const stats = await fn.stats();
76894
+ * console.log(stats.inputSuccessCount, stats.inputFailureCount);
76895
+ * ```
76896
+ *
76897
+ * @example Include all variants over the last 24 hours.
76898
+ * ```ts
76899
+ * const until = new Date();
76900
+ * const since = new Date(until.getTime() - 24 * 60 * 60 * 1000);
76901
+ * const variantStats = await fn.stats({ since, until, allVariants: true });
76902
+ * for (const [metric, distribution] of Object.entries(variantStats.inputPercentileStats)) {
76903
+ * console.log(metric, distribution.unit, distribution.percentiles);
76904
+ * }
76905
+ * ```
76906
+ *
76907
+ * Set `container` to a container ID to restrict statistics to that container.
76908
+ */
76909
+ async stats(params = {}) {
76910
+ const until = params.until ?? /* @__PURE__ */ new Date();
76911
+ const since = params.since ?? new Date(until.getTime() - 60 * 60 * 1e3);
76912
+ if (!Number.isFinite(since.getTime()) || !Number.isFinite(until.getTime())) {
76913
+ throw new InvalidError("`since` and `until` must be valid dates.");
76914
+ }
76915
+ if (since >= until) {
76916
+ throw new InvalidError("`since` must be before `until`.");
76917
+ }
76918
+ const allVariants = params.allVariants ?? false;
76919
+ const resp = await this.#client.cpClient.functionGetTimeRangeStats(
76920
+ FunctionGetTimeRangeStatsRequest.create({
76921
+ functionId: this.functionId,
76922
+ since,
76923
+ until,
76924
+ containerId: params.container || void 0,
76925
+ rollup: allVariants
76926
+ })
76927
+ );
76928
+ return {
76929
+ since: resp.since ?? /* @__PURE__ */ new Date(0),
76930
+ until: resp.until ?? /* @__PURE__ */ new Date(0),
76931
+ inputSuccessCount: resp.inputSuccessCount,
76932
+ inputFailureCount: resp.inputFailureCount,
76933
+ inputTimeoutCount: resp.inputTimeoutCount,
76934
+ inputRunningAtEndCount: resp.inputRunningAtEndCount,
76935
+ containerStartedCount: resp.containerStartedCount,
76936
+ containerErrorCount: resp.containerErrorCount,
76937
+ containerCreatingAtEndCount: resp.containerCreatingAtEndCount,
76938
+ variantCount: resp.variantCount,
76939
+ inputPercentileStats: statsDistributions(resp.inputPercentileStats),
76940
+ containerPercentileStats: statsDistributions(
76941
+ resp.containerPercentileStats
76942
+ ),
76943
+ allVariants
76944
+ };
76945
+ }
76827
76946
  // Returns statistics about the Function.
76828
76947
  async getCurrentStats() {
76829
76948
  const resp = await this.#client.cpClient.functionGetCurrentStats(
package/dist/index.d.cts CHANGED
@@ -1638,6 +1638,8 @@ interface EndpointCreateResponse {
1638
1638
  endpointId: string;
1639
1639
  endpointPageUrl: string;
1640
1640
  name: string;
1641
+ /** Model name to send in requests to the endpoint. */
1642
+ modelName: string;
1641
1643
  }
1642
1644
  declare const EndpointCreateResponse: MessageFns$1<EndpointCreateResponse>;
1643
1645
  interface EndpointCustomModelSource {
@@ -1677,6 +1679,8 @@ interface EndpointGetInfoResponse_EndpointInfoSummary {
1677
1679
  /** set only when the model is served from a modal volume */
1678
1680
  volumeId: string;
1679
1681
  modelPath: string;
1682
+ /** Model name to send in requests to the endpoint. */
1683
+ modelName: string;
1680
1684
  }
1681
1685
  declare const EndpointGetInfoResponse_EndpointInfoSummary: MessageFns$1<EndpointGetInfoResponse_EndpointInfoSummary>;
1682
1686
  interface EndpointGetInfoResponse_EndpointHandleMetadata {
@@ -2556,7 +2560,7 @@ interface FunctionGetTimeRangeStatsResponse {
2556
2560
  * as requirements evolve
2557
2561
  */
2558
2562
  inputPercentileStats: {
2559
- [key: string]: StatsPercentileDistribution;
2563
+ [key: string]: StatsPercentileDistribution$1;
2560
2564
  };
2561
2565
  /**
2562
2566
  * Container lifecycle counts. Started and errored containers are counted when
@@ -2571,7 +2575,7 @@ interface FunctionGetTimeRangeStatsResponse {
2571
2575
  * as requirements evolve
2572
2576
  */
2573
2577
  containerPercentileStats: {
2574
- [key: string]: StatsPercentileDistribution;
2578
+ [key: string]: StatsPercentileDistribution$1;
2575
2579
  };
2576
2580
  /**
2577
2581
  * Number of direct non-version-pinned variants included in the roll-up.
@@ -2782,13 +2786,13 @@ interface FunctionSchema {
2782
2786
  returnType: GenericPayloadType | undefined;
2783
2787
  }
2784
2788
  declare const FunctionSchema: MessageFns$1<FunctionSchema>;
2785
- interface FunctionStats {
2789
+ interface FunctionStats$1 {
2786
2790
  backlog: number;
2787
2791
  numTotalTasks: number;
2788
2792
  numRunningInputs: number;
2789
2793
  inputHeadroom: number;
2790
2794
  }
2791
- declare const FunctionStats: MessageFns$1<FunctionStats>;
2795
+ declare const FunctionStats$1: MessageFns$1<FunctionStats$1>;
2792
2796
  interface FunctionUpdateSchedulingParamsRequest {
2793
2797
  functionId: string;
2794
2798
  warmPoolSizeOverride: number;
@@ -3865,6 +3869,11 @@ interface SandboxGetFromNameRequest {
3865
3869
  sandboxName: string;
3866
3870
  environmentName: string;
3867
3871
  appName: string;
3872
+ /**
3873
+ * When set, the lookup also considers sandboxes that have already stopped and
3874
+ * returns the most recently created sandbox with the given name.
3875
+ */
3876
+ includeTerminated: boolean;
3868
3877
  }
3869
3878
  declare const SandboxGetFromNameRequest: MessageFns$1<SandboxGetFromNameRequest>;
3870
3879
  interface SandboxGetFromNameResponse {
@@ -4230,14 +4239,14 @@ interface ServerGetTimeRangeStatsResponse {
4230
4239
  requestRatePerSecond: number;
4231
4240
  /** Metrics include request_latency, subject to change as requirements evolve. */
4232
4241
  requestPercentileStats: {
4233
- [key: string]: StatsPercentileDistribution;
4242
+ [key: string]: StatsPercentileDistribution$1;
4234
4243
  };
4235
4244
  /**
4236
4245
  * Metrics include startup_time, cpu_usage, memory_usage, and
4237
4246
  * gpu_utilization, subject to change as requirements evolve.
4238
4247
  */
4239
4248
  containerPercentileStats: {
4240
- [key: string]: StatsPercentileDistribution;
4249
+ [key: string]: StatsPercentileDistribution$1;
4241
4250
  };
4242
4251
  /** Absent when the image does not contain a supported inference engine. */
4243
4252
  inference: ServerGetTimeRangeStatsResponse_ServerInferenceStats | undefined;
@@ -4261,7 +4270,7 @@ interface ServerGetTimeRangeStatsResponse_ServerInferenceStats {
4261
4270
  * end_to_end_latency, subject to change as requirements evolve.
4262
4271
  */
4263
4272
  percentileStats: {
4264
- [key: string]: StatsPercentileDistribution;
4273
+ [key: string]: StatsPercentileDistribution$1;
4265
4274
  };
4266
4275
  /**
4267
4276
  * Metrics include input_tokens_per_second, cached_input_tokens_per_second,
@@ -4402,18 +4411,18 @@ interface SharedVolumeRemoveFileRequest {
4402
4411
  recursive: boolean;
4403
4412
  }
4404
4413
  declare const SharedVolumeRemoveFileRequest: MessageFns$1<SharedVolumeRemoveFileRequest>;
4405
- interface StatsPercentile {
4414
+ interface StatsPercentile$1 {
4406
4415
  /** The percentile expressed in basis points: 5000 is p50 and 9990 is p99.9. */
4407
4416
  percentileBasisPoints: number;
4408
4417
  value: number;
4409
4418
  }
4410
- declare const StatsPercentile: MessageFns$1<StatsPercentile>;
4411
- interface StatsPercentileDistribution {
4419
+ declare const StatsPercentile$1: MessageFns$1<StatsPercentile$1>;
4420
+ interface StatsPercentileDistribution$1 {
4412
4421
  /** Unit identifier such as "seconds", "cores", "gibibytes", or "fraction". */
4413
4422
  unit: string;
4414
- percentiles: StatsPercentile[];
4423
+ percentiles: StatsPercentile$1[];
4415
4424
  }
4416
- declare const StatsPercentileDistribution: MessageFns$1<StatsPercentileDistribution>;
4425
+ declare const StatsPercentileDistribution$1: MessageFns$1<StatsPercentileDistribution$1>;
4417
4426
  interface StringMap {
4418
4427
  contents: {
4419
4428
  [key: string]: string;
@@ -5987,7 +5996,7 @@ declare const ModalClientDefinition: {
5987
5996
  readonly name: "FunctionGetCurrentStats";
5988
5997
  readonly requestType: MessageFns$1<FunctionGetCurrentStatsRequest>;
5989
5998
  readonly requestStream: false;
5990
- readonly responseType: MessageFns$1<FunctionStats>;
5999
+ readonly responseType: MessageFns$1<FunctionStats$1>;
5991
6000
  readonly responseStream: false;
5992
6001
  readonly options: {};
5993
6002
  };
@@ -7828,6 +7837,39 @@ interface FunctionCurrentStats {
7828
7837
  backlog: number;
7829
7838
  numTotalRunners: number;
7830
7839
  }
7840
+ interface StatsPercentile {
7841
+ percentile: number;
7842
+ value: number;
7843
+ }
7844
+ interface StatsPercentileDistribution {
7845
+ unit: string;
7846
+ percentiles: StatsPercentile[];
7847
+ }
7848
+ interface FunctionStats {
7849
+ since: Date;
7850
+ until: Date;
7851
+ inputSuccessCount: number;
7852
+ inputFailureCount: number;
7853
+ inputTimeoutCount: number;
7854
+ inputRunningAtEndCount: number;
7855
+ containerStartedCount: number;
7856
+ containerErrorCount: number;
7857
+ containerCreatingAtEndCount: number;
7858
+ variantCount: number;
7859
+ inputPercentileStats: Record<string, StatsPercentileDistribution>;
7860
+ containerPercentileStats: Record<string, StatsPercentileDistribution>;
7861
+ allVariants: boolean;
7862
+ }
7863
+ interface FunctionStatsParams {
7864
+ /** Inclusive start; defaults to one hour before until. */
7865
+ since?: Date;
7866
+ /** Exclusive end; defaults to the current time. */
7867
+ until?: Date;
7868
+ /** Restrict statistics to this container ID. */
7869
+ container?: string;
7870
+ /** Aggregate the base Function and its variants. Defaults to false. */
7871
+ allVariants?: boolean;
7872
+ }
7831
7873
  /** Optional parameters for {@link Function_#updateAutoscaler Function_.updateAutoscaler()}. */
7832
7874
  interface FunctionUpdateAutoscalerParams {
7833
7875
  minContainers?: number;
@@ -7906,6 +7948,29 @@ declare class Function_ {
7906
7948
  instance(): Promise<Function_>;
7907
7949
  remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
7908
7950
  spawn(args?: any[], kwargs?: Record<string, any>): Promise<FunctionCall>;
7951
+ /**
7952
+ * Return historical statistics. Defaults to the last hour; the maximum range is 7 days.
7953
+ *
7954
+ * @example Read statistics for the last hour.
7955
+ * ```ts
7956
+ * const fn = await modal.functions.fromName("libmodal-test-support", "echo_string");
7957
+ * const stats = await fn.stats();
7958
+ * console.log(stats.inputSuccessCount, stats.inputFailureCount);
7959
+ * ```
7960
+ *
7961
+ * @example Include all variants over the last 24 hours.
7962
+ * ```ts
7963
+ * const until = new Date();
7964
+ * const since = new Date(until.getTime() - 24 * 60 * 60 * 1000);
7965
+ * const variantStats = await fn.stats({ since, until, allVariants: true });
7966
+ * for (const [metric, distribution] of Object.entries(variantStats.inputPercentileStats)) {
7967
+ * console.log(metric, distribution.unit, distribution.percentiles);
7968
+ * }
7969
+ * ```
7970
+ *
7971
+ * Set `container` to a container ID to restrict statistics to that container.
7972
+ */
7973
+ stats(params?: FunctionStatsParams): Promise<FunctionStats>;
7909
7974
  getCurrentStats(): Promise<FunctionCurrentStats>;
7910
7975
  updateAutoscaler(params: FunctionUpdateAutoscalerParams): Promise<FunctionAutoscalerSettings>;
7911
7976
  /**
@@ -10208,4 +10273,4 @@ declare class ClientClosedError extends Error {
10208
10273
 
10209
10274
  declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
10210
10275
 
10211
- export { AlreadyExistsError, App, type AppFromNameParams, AppService, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionCurrentStats, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, FunctionService, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StdioBehavior, type StreamMode, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
10276
+ export { AlreadyExistsError, App, type AppFromNameParams, AppService, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionCurrentStats, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, FunctionService, type FunctionStats, type FunctionStatsParams, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StatsPercentile, type StatsPercentileDistribution, type StdioBehavior, type StreamMode, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
package/dist/index.d.ts CHANGED
@@ -1638,6 +1638,8 @@ interface EndpointCreateResponse {
1638
1638
  endpointId: string;
1639
1639
  endpointPageUrl: string;
1640
1640
  name: string;
1641
+ /** Model name to send in requests to the endpoint. */
1642
+ modelName: string;
1641
1643
  }
1642
1644
  declare const EndpointCreateResponse: MessageFns$1<EndpointCreateResponse>;
1643
1645
  interface EndpointCustomModelSource {
@@ -1677,6 +1679,8 @@ interface EndpointGetInfoResponse_EndpointInfoSummary {
1677
1679
  /** set only when the model is served from a modal volume */
1678
1680
  volumeId: string;
1679
1681
  modelPath: string;
1682
+ /** Model name to send in requests to the endpoint. */
1683
+ modelName: string;
1680
1684
  }
1681
1685
  declare const EndpointGetInfoResponse_EndpointInfoSummary: MessageFns$1<EndpointGetInfoResponse_EndpointInfoSummary>;
1682
1686
  interface EndpointGetInfoResponse_EndpointHandleMetadata {
@@ -2556,7 +2560,7 @@ interface FunctionGetTimeRangeStatsResponse {
2556
2560
  * as requirements evolve
2557
2561
  */
2558
2562
  inputPercentileStats: {
2559
- [key: string]: StatsPercentileDistribution;
2563
+ [key: string]: StatsPercentileDistribution$1;
2560
2564
  };
2561
2565
  /**
2562
2566
  * Container lifecycle counts. Started and errored containers are counted when
@@ -2571,7 +2575,7 @@ interface FunctionGetTimeRangeStatsResponse {
2571
2575
  * as requirements evolve
2572
2576
  */
2573
2577
  containerPercentileStats: {
2574
- [key: string]: StatsPercentileDistribution;
2578
+ [key: string]: StatsPercentileDistribution$1;
2575
2579
  };
2576
2580
  /**
2577
2581
  * Number of direct non-version-pinned variants included in the roll-up.
@@ -2782,13 +2786,13 @@ interface FunctionSchema {
2782
2786
  returnType: GenericPayloadType | undefined;
2783
2787
  }
2784
2788
  declare const FunctionSchema: MessageFns$1<FunctionSchema>;
2785
- interface FunctionStats {
2789
+ interface FunctionStats$1 {
2786
2790
  backlog: number;
2787
2791
  numTotalTasks: number;
2788
2792
  numRunningInputs: number;
2789
2793
  inputHeadroom: number;
2790
2794
  }
2791
- declare const FunctionStats: MessageFns$1<FunctionStats>;
2795
+ declare const FunctionStats$1: MessageFns$1<FunctionStats$1>;
2792
2796
  interface FunctionUpdateSchedulingParamsRequest {
2793
2797
  functionId: string;
2794
2798
  warmPoolSizeOverride: number;
@@ -3865,6 +3869,11 @@ interface SandboxGetFromNameRequest {
3865
3869
  sandboxName: string;
3866
3870
  environmentName: string;
3867
3871
  appName: string;
3872
+ /**
3873
+ * When set, the lookup also considers sandboxes that have already stopped and
3874
+ * returns the most recently created sandbox with the given name.
3875
+ */
3876
+ includeTerminated: boolean;
3868
3877
  }
3869
3878
  declare const SandboxGetFromNameRequest: MessageFns$1<SandboxGetFromNameRequest>;
3870
3879
  interface SandboxGetFromNameResponse {
@@ -4230,14 +4239,14 @@ interface ServerGetTimeRangeStatsResponse {
4230
4239
  requestRatePerSecond: number;
4231
4240
  /** Metrics include request_latency, subject to change as requirements evolve. */
4232
4241
  requestPercentileStats: {
4233
- [key: string]: StatsPercentileDistribution;
4242
+ [key: string]: StatsPercentileDistribution$1;
4234
4243
  };
4235
4244
  /**
4236
4245
  * Metrics include startup_time, cpu_usage, memory_usage, and
4237
4246
  * gpu_utilization, subject to change as requirements evolve.
4238
4247
  */
4239
4248
  containerPercentileStats: {
4240
- [key: string]: StatsPercentileDistribution;
4249
+ [key: string]: StatsPercentileDistribution$1;
4241
4250
  };
4242
4251
  /** Absent when the image does not contain a supported inference engine. */
4243
4252
  inference: ServerGetTimeRangeStatsResponse_ServerInferenceStats | undefined;
@@ -4261,7 +4270,7 @@ interface ServerGetTimeRangeStatsResponse_ServerInferenceStats {
4261
4270
  * end_to_end_latency, subject to change as requirements evolve.
4262
4271
  */
4263
4272
  percentileStats: {
4264
- [key: string]: StatsPercentileDistribution;
4273
+ [key: string]: StatsPercentileDistribution$1;
4265
4274
  };
4266
4275
  /**
4267
4276
  * Metrics include input_tokens_per_second, cached_input_tokens_per_second,
@@ -4402,18 +4411,18 @@ interface SharedVolumeRemoveFileRequest {
4402
4411
  recursive: boolean;
4403
4412
  }
4404
4413
  declare const SharedVolumeRemoveFileRequest: MessageFns$1<SharedVolumeRemoveFileRequest>;
4405
- interface StatsPercentile {
4414
+ interface StatsPercentile$1 {
4406
4415
  /** The percentile expressed in basis points: 5000 is p50 and 9990 is p99.9. */
4407
4416
  percentileBasisPoints: number;
4408
4417
  value: number;
4409
4418
  }
4410
- declare const StatsPercentile: MessageFns$1<StatsPercentile>;
4411
- interface StatsPercentileDistribution {
4419
+ declare const StatsPercentile$1: MessageFns$1<StatsPercentile$1>;
4420
+ interface StatsPercentileDistribution$1 {
4412
4421
  /** Unit identifier such as "seconds", "cores", "gibibytes", or "fraction". */
4413
4422
  unit: string;
4414
- percentiles: StatsPercentile[];
4423
+ percentiles: StatsPercentile$1[];
4415
4424
  }
4416
- declare const StatsPercentileDistribution: MessageFns$1<StatsPercentileDistribution>;
4425
+ declare const StatsPercentileDistribution$1: MessageFns$1<StatsPercentileDistribution$1>;
4417
4426
  interface StringMap {
4418
4427
  contents: {
4419
4428
  [key: string]: string;
@@ -5987,7 +5996,7 @@ declare const ModalClientDefinition: {
5987
5996
  readonly name: "FunctionGetCurrentStats";
5988
5997
  readonly requestType: MessageFns$1<FunctionGetCurrentStatsRequest>;
5989
5998
  readonly requestStream: false;
5990
- readonly responseType: MessageFns$1<FunctionStats>;
5999
+ readonly responseType: MessageFns$1<FunctionStats$1>;
5991
6000
  readonly responseStream: false;
5992
6001
  readonly options: {};
5993
6002
  };
@@ -7828,6 +7837,39 @@ interface FunctionCurrentStats {
7828
7837
  backlog: number;
7829
7838
  numTotalRunners: number;
7830
7839
  }
7840
+ interface StatsPercentile {
7841
+ percentile: number;
7842
+ value: number;
7843
+ }
7844
+ interface StatsPercentileDistribution {
7845
+ unit: string;
7846
+ percentiles: StatsPercentile[];
7847
+ }
7848
+ interface FunctionStats {
7849
+ since: Date;
7850
+ until: Date;
7851
+ inputSuccessCount: number;
7852
+ inputFailureCount: number;
7853
+ inputTimeoutCount: number;
7854
+ inputRunningAtEndCount: number;
7855
+ containerStartedCount: number;
7856
+ containerErrorCount: number;
7857
+ containerCreatingAtEndCount: number;
7858
+ variantCount: number;
7859
+ inputPercentileStats: Record<string, StatsPercentileDistribution>;
7860
+ containerPercentileStats: Record<string, StatsPercentileDistribution>;
7861
+ allVariants: boolean;
7862
+ }
7863
+ interface FunctionStatsParams {
7864
+ /** Inclusive start; defaults to one hour before until. */
7865
+ since?: Date;
7866
+ /** Exclusive end; defaults to the current time. */
7867
+ until?: Date;
7868
+ /** Restrict statistics to this container ID. */
7869
+ container?: string;
7870
+ /** Aggregate the base Function and its variants. Defaults to false. */
7871
+ allVariants?: boolean;
7872
+ }
7831
7873
  /** Optional parameters for {@link Function_#updateAutoscaler Function_.updateAutoscaler()}. */
7832
7874
  interface FunctionUpdateAutoscalerParams {
7833
7875
  minContainers?: number;
@@ -7906,6 +7948,29 @@ declare class Function_ {
7906
7948
  instance(): Promise<Function_>;
7907
7949
  remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
7908
7950
  spawn(args?: any[], kwargs?: Record<string, any>): Promise<FunctionCall>;
7951
+ /**
7952
+ * Return historical statistics. Defaults to the last hour; the maximum range is 7 days.
7953
+ *
7954
+ * @example Read statistics for the last hour.
7955
+ * ```ts
7956
+ * const fn = await modal.functions.fromName("libmodal-test-support", "echo_string");
7957
+ * const stats = await fn.stats();
7958
+ * console.log(stats.inputSuccessCount, stats.inputFailureCount);
7959
+ * ```
7960
+ *
7961
+ * @example Include all variants over the last 24 hours.
7962
+ * ```ts
7963
+ * const until = new Date();
7964
+ * const since = new Date(until.getTime() - 24 * 60 * 60 * 1000);
7965
+ * const variantStats = await fn.stats({ since, until, allVariants: true });
7966
+ * for (const [metric, distribution] of Object.entries(variantStats.inputPercentileStats)) {
7967
+ * console.log(metric, distribution.unit, distribution.percentiles);
7968
+ * }
7969
+ * ```
7970
+ *
7971
+ * Set `container` to a container ID to restrict statistics to that container.
7972
+ */
7973
+ stats(params?: FunctionStatsParams): Promise<FunctionStats>;
7909
7974
  getCurrentStats(): Promise<FunctionCurrentStats>;
7910
7975
  updateAutoscaler(params: FunctionUpdateAutoscalerParams): Promise<FunctionAutoscalerSettings>;
7911
7976
  /**
@@ -10208,4 +10273,4 @@ declare class ClientClosedError extends Error {
10208
10273
 
10209
10274
  declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
10210
10275
 
10211
- export { AlreadyExistsError, App, type AppFromNameParams, AppService, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionCurrentStats, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, FunctionService, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StdioBehavior, type StreamMode, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
10276
+ export { AlreadyExistsError, App, type AppFromNameParams, AppService, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionCurrentStats, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, FunctionService, type FunctionStats, type FunctionStatsParams, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StatsPercentile, type StatsPercentileDistribution, type StdioBehavior, type StreamMode, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
package/dist/index.js CHANGED
@@ -18026,7 +18026,7 @@ var EndpointCreateRequest = {
18026
18026
  }
18027
18027
  };
18028
18028
  function createBaseEndpointCreateResponse() {
18029
- return { endpointId: "", endpointPageUrl: "", name: "" };
18029
+ return { endpointId: "", endpointPageUrl: "", name: "", modelName: "" };
18030
18030
  }
18031
18031
  var EndpointCreateResponse = {
18032
18032
  encode(message, writer = new BinaryWriter()) {
@@ -18039,6 +18039,9 @@ var EndpointCreateResponse = {
18039
18039
  if (message.name !== "") {
18040
18040
  writer.uint32(26).string(message.name);
18041
18041
  }
18042
+ if (message.modelName !== "") {
18043
+ writer.uint32(34).string(message.modelName);
18044
+ }
18042
18045
  return writer;
18043
18046
  },
18044
18047
  decode(input, length) {
@@ -18069,6 +18072,13 @@ var EndpointCreateResponse = {
18069
18072
  message.name = reader.string();
18070
18073
  continue;
18071
18074
  }
18075
+ case 4: {
18076
+ if (tag !== 34) {
18077
+ break;
18078
+ }
18079
+ message.modelName = reader.string();
18080
+ continue;
18081
+ }
18072
18082
  }
18073
18083
  if ((tag & 7) === 4 || tag === 0) {
18074
18084
  break;
@@ -18081,7 +18091,8 @@ var EndpointCreateResponse = {
18081
18091
  return {
18082
18092
  endpointId: isSet5(object.endpointId) ? globalThis.String(object.endpointId) : "",
18083
18093
  endpointPageUrl: isSet5(object.endpointPageUrl) ? globalThis.String(object.endpointPageUrl) : "",
18084
- name: isSet5(object.name) ? globalThis.String(object.name) : ""
18094
+ name: isSet5(object.name) ? globalThis.String(object.name) : "",
18095
+ modelName: isSet5(object.modelName) ? globalThis.String(object.modelName) : ""
18085
18096
  };
18086
18097
  },
18087
18098
  toJSON(message) {
@@ -18095,6 +18106,9 @@ var EndpointCreateResponse = {
18095
18106
  if (message.name !== "") {
18096
18107
  obj.name = message.name;
18097
18108
  }
18109
+ if (message.modelName !== "") {
18110
+ obj.modelName = message.modelName;
18111
+ }
18098
18112
  return obj;
18099
18113
  },
18100
18114
  create(base) {
@@ -18105,6 +18119,7 @@ var EndpointCreateResponse = {
18105
18119
  message.endpointId = object.endpointId ?? "";
18106
18120
  message.endpointPageUrl = object.endpointPageUrl ?? "";
18107
18121
  message.name = object.name ?? "";
18122
+ message.modelName = object.modelName ?? "";
18108
18123
  return message;
18109
18124
  }
18110
18125
  };
@@ -18457,7 +18472,8 @@ function createBaseEndpointGetInfoResponse_EndpointInfoSummary() {
18457
18472
  status: 0,
18458
18473
  lifecycle: void 0,
18459
18474
  volumeId: "",
18460
- modelPath: ""
18475
+ modelPath: "",
18476
+ modelName: ""
18461
18477
  };
18462
18478
  }
18463
18479
  var EndpointGetInfoResponse_EndpointInfoSummary = {
@@ -18492,6 +18508,9 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18492
18508
  if (message.modelPath !== "") {
18493
18509
  writer.uint32(98).string(message.modelPath);
18494
18510
  }
18511
+ if (message.modelName !== "") {
18512
+ writer.uint32(106).string(message.modelName);
18513
+ }
18495
18514
  return writer;
18496
18515
  },
18497
18516
  decode(input, length) {
@@ -18571,6 +18590,13 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18571
18590
  message.modelPath = reader.string();
18572
18591
  continue;
18573
18592
  }
18593
+ case 13: {
18594
+ if (tag !== 106) {
18595
+ break;
18596
+ }
18597
+ message.modelName = reader.string();
18598
+ continue;
18599
+ }
18574
18600
  }
18575
18601
  if ((tag & 7) === 4 || tag === 0) {
18576
18602
  break;
@@ -18590,7 +18616,8 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18590
18616
  status: isSet5(object.status) ? endpointGetInfoResponse_EndpointStatusFromJSON(object.status) : 0,
18591
18617
  lifecycle: isSet5(object.lifecycle) ? EndpointLifecycle.fromJSON(object.lifecycle) : void 0,
18592
18618
  volumeId: isSet5(object.volumeId) ? globalThis.String(object.volumeId) : "",
18593
- modelPath: isSet5(object.modelPath) ? globalThis.String(object.modelPath) : ""
18619
+ modelPath: isSet5(object.modelPath) ? globalThis.String(object.modelPath) : "",
18620
+ modelName: isSet5(object.modelName) ? globalThis.String(object.modelName) : ""
18594
18621
  };
18595
18622
  },
18596
18623
  toJSON(message) {
@@ -18625,6 +18652,9 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18625
18652
  if (message.modelPath !== "") {
18626
18653
  obj.modelPath = message.modelPath;
18627
18654
  }
18655
+ if (message.modelName !== "") {
18656
+ obj.modelName = message.modelName;
18657
+ }
18628
18658
  return obj;
18629
18659
  },
18630
18660
  create(base) {
@@ -18642,6 +18672,7 @@ var EndpointGetInfoResponse_EndpointInfoSummary = {
18642
18672
  message.lifecycle = object.lifecycle !== void 0 && object.lifecycle !== null ? EndpointLifecycle.fromPartial(object.lifecycle) : void 0;
18643
18673
  message.volumeId = object.volumeId ?? "";
18644
18674
  message.modelPath = object.modelPath ?? "";
18675
+ message.modelName = object.modelName ?? "";
18645
18676
  return message;
18646
18677
  }
18647
18678
  };
@@ -44921,7 +44952,7 @@ var SandboxGetExitSnapshotResponse_Error = {
44921
44952
  }
44922
44953
  };
44923
44954
  function createBaseSandboxGetFromNameRequest() {
44924
- return { sandboxName: "", environmentName: "", appName: "" };
44955
+ return { sandboxName: "", environmentName: "", appName: "", includeTerminated: false };
44925
44956
  }
44926
44957
  var SandboxGetFromNameRequest = {
44927
44958
  encode(message, writer = new BinaryWriter()) {
@@ -44934,6 +44965,9 @@ var SandboxGetFromNameRequest = {
44934
44965
  if (message.appName !== "") {
44935
44966
  writer.uint32(26).string(message.appName);
44936
44967
  }
44968
+ if (message.includeTerminated !== false) {
44969
+ writer.uint32(32).bool(message.includeTerminated);
44970
+ }
44937
44971
  return writer;
44938
44972
  },
44939
44973
  decode(input, length) {
@@ -44964,6 +44998,13 @@ var SandboxGetFromNameRequest = {
44964
44998
  message.appName = reader.string();
44965
44999
  continue;
44966
45000
  }
45001
+ case 4: {
45002
+ if (tag !== 32) {
45003
+ break;
45004
+ }
45005
+ message.includeTerminated = reader.bool();
45006
+ continue;
45007
+ }
44967
45008
  }
44968
45009
  if ((tag & 7) === 4 || tag === 0) {
44969
45010
  break;
@@ -44976,7 +45017,8 @@ var SandboxGetFromNameRequest = {
44976
45017
  return {
44977
45018
  sandboxName: isSet5(object.sandboxName) ? globalThis.String(object.sandboxName) : "",
44978
45019
  environmentName: isSet5(object.environmentName) ? globalThis.String(object.environmentName) : "",
44979
- appName: isSet5(object.appName) ? globalThis.String(object.appName) : ""
45020
+ appName: isSet5(object.appName) ? globalThis.String(object.appName) : "",
45021
+ includeTerminated: isSet5(object.includeTerminated) ? globalThis.Boolean(object.includeTerminated) : false
44980
45022
  };
44981
45023
  },
44982
45024
  toJSON(message) {
@@ -44990,6 +45032,9 @@ var SandboxGetFromNameRequest = {
44990
45032
  if (message.appName !== "") {
44991
45033
  obj.appName = message.appName;
44992
45034
  }
45035
+ if (message.includeTerminated !== false) {
45036
+ obj.includeTerminated = message.includeTerminated;
45037
+ }
44993
45038
  return obj;
44994
45039
  },
44995
45040
  create(base) {
@@ -45000,6 +45045,7 @@ var SandboxGetFromNameRequest = {
45000
45045
  message.sandboxName = object.sandboxName ?? "";
45001
45046
  message.environmentName = object.environmentName ?? "";
45002
45047
  message.appName = object.appName ?? "";
45048
+ message.includeTerminated = object.includeTerminated ?? false;
45003
45049
  return message;
45004
45050
  }
45005
45051
  };
@@ -74497,7 +74543,7 @@ var AuthTokenManager = class {
74497
74543
  };
74498
74544
 
74499
74545
  // src/version.ts
74500
- var SDK_VERSION = "0.11.1-dev.6";
74546
+ var SDK_VERSION = "0.11.1-dev.7";
74501
74547
  function getSDKVersion() {
74502
74548
  return SDK_VERSION;
74503
74549
  }
@@ -76380,6 +76426,20 @@ var FunctionService = class {
76380
76426
  }
76381
76427
  }
76382
76428
  };
76429
+ function statsDistributions(stats) {
76430
+ return Object.fromEntries(
76431
+ Object.entries(stats).map(([key, distribution]) => [
76432
+ key,
76433
+ {
76434
+ unit: distribution.unit,
76435
+ percentiles: distribution.percentiles.map((p) => ({
76436
+ percentile: p.percentileBasisPoints / 100,
76437
+ value: p.value
76438
+ }))
76439
+ }
76440
+ ])
76441
+ );
76442
+ }
76383
76443
  function mergeServiceOptions(base, diff) {
76384
76444
  const filteredDiff = Object.fromEntries(
76385
76445
  Object.entries(diff).filter(([, value]) => value !== void 0)
@@ -76747,6 +76807,65 @@ var Function_ = class _Function_ {
76747
76807
  this.functionId
76748
76808
  );
76749
76809
  }
76810
+ /**
76811
+ * Return historical statistics. Defaults to the last hour; the maximum range is 7 days.
76812
+ *
76813
+ * @example Read statistics for the last hour.
76814
+ * ```ts
76815
+ * const fn = await modal.functions.fromName("libmodal-test-support", "echo_string");
76816
+ * const stats = await fn.stats();
76817
+ * console.log(stats.inputSuccessCount, stats.inputFailureCount);
76818
+ * ```
76819
+ *
76820
+ * @example Include all variants over the last 24 hours.
76821
+ * ```ts
76822
+ * const until = new Date();
76823
+ * const since = new Date(until.getTime() - 24 * 60 * 60 * 1000);
76824
+ * const variantStats = await fn.stats({ since, until, allVariants: true });
76825
+ * for (const [metric, distribution] of Object.entries(variantStats.inputPercentileStats)) {
76826
+ * console.log(metric, distribution.unit, distribution.percentiles);
76827
+ * }
76828
+ * ```
76829
+ *
76830
+ * Set `container` to a container ID to restrict statistics to that container.
76831
+ */
76832
+ async stats(params = {}) {
76833
+ const until = params.until ?? /* @__PURE__ */ new Date();
76834
+ const since = params.since ?? new Date(until.getTime() - 60 * 60 * 1e3);
76835
+ if (!Number.isFinite(since.getTime()) || !Number.isFinite(until.getTime())) {
76836
+ throw new InvalidError("`since` and `until` must be valid dates.");
76837
+ }
76838
+ if (since >= until) {
76839
+ throw new InvalidError("`since` must be before `until`.");
76840
+ }
76841
+ const allVariants = params.allVariants ?? false;
76842
+ const resp = await this.#client.cpClient.functionGetTimeRangeStats(
76843
+ FunctionGetTimeRangeStatsRequest.create({
76844
+ functionId: this.functionId,
76845
+ since,
76846
+ until,
76847
+ containerId: params.container || void 0,
76848
+ rollup: allVariants
76849
+ })
76850
+ );
76851
+ return {
76852
+ since: resp.since ?? /* @__PURE__ */ new Date(0),
76853
+ until: resp.until ?? /* @__PURE__ */ new Date(0),
76854
+ inputSuccessCount: resp.inputSuccessCount,
76855
+ inputFailureCount: resp.inputFailureCount,
76856
+ inputTimeoutCount: resp.inputTimeoutCount,
76857
+ inputRunningAtEndCount: resp.inputRunningAtEndCount,
76858
+ containerStartedCount: resp.containerStartedCount,
76859
+ containerErrorCount: resp.containerErrorCount,
76860
+ containerCreatingAtEndCount: resp.containerCreatingAtEndCount,
76861
+ variantCount: resp.variantCount,
76862
+ inputPercentileStats: statsDistributions(resp.inputPercentileStats),
76863
+ containerPercentileStats: statsDistributions(
76864
+ resp.containerPercentileStats
76865
+ ),
76866
+ allVariants
76867
+ };
76868
+ }
76750
76869
  // Returns statistics about the Function.
76751
76870
  async getCurrentStats() {
76752
76871
  const resp = await this.#client.cpClient.functionGetCurrentStats(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modal",
3
- "version": "0.11.1-dev.6",
3
+ "version": "0.11.1-dev.7",
4
4
  "description": "Modal SDK for JavaScript/TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://modal.com/docs/guide/sdk-javascript-go",