modal 0.3.4 → 0.3.5

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.d.ts CHANGED
@@ -95,6 +95,14 @@ declare class App {
95
95
  imageFromRegistry(tag: string): Promise<Image>;
96
96
  }
97
97
 
98
+ declare enum FunctionCallInvocationType {
99
+ FUNCTION_CALL_INVOCATION_TYPE_UNSPECIFIED = 0,
100
+ FUNCTION_CALL_INVOCATION_TYPE_SYNC_LEGACY = 1,
101
+ FUNCTION_CALL_INVOCATION_TYPE_ASYNC_LEGACY = 2,
102
+ FUNCTION_CALL_INVOCATION_TYPE_ASYNC = 3,
103
+ FUNCTION_CALL_INVOCATION_TYPE_SYNC = 4,
104
+ UNRECOGNIZED = -1
105
+ }
98
106
  declare enum ParameterType {
99
107
  PARAM_TYPE_UNSPECIFIED = 0,
100
108
  PARAM_TYPE_STRING = 1,
@@ -145,6 +153,28 @@ interface MessageFns<T> {
145
153
  fromPartial(object: DeepPartial<T>): T;
146
154
  }
147
155
 
156
+ type FunctionCallGetOptions = {
157
+ timeout?: number;
158
+ };
159
+ type FunctionCallCancelOptions = {
160
+ terminateContainers?: boolean;
161
+ };
162
+ /**
163
+ * Represents a Modal FunctionCall. Function Calls are Function invocations with
164
+ * a given input. They can be consumed asynchronously (see `get()`) or cancelled
165
+ * (see `cancel()`).
166
+ */
167
+ declare class FunctionCall {
168
+ readonly functionCallId: string;
169
+ constructor(functionCallId: string);
170
+ /** Create a new function call from ID. */
171
+ fromId(functionCallId: string): FunctionCall;
172
+ /** Get the result of a function call, optionally waiting with a timeout. */
173
+ get(options?: FunctionCallGetOptions): Promise<any>;
174
+ /** Cancel a running function call. */
175
+ cancel(options?: FunctionCallCancelOptions): Promise<void>;
176
+ }
177
+
148
178
  /** Represents a deployed Modal Function, which can be invoked remotely. */
149
179
  declare class Function_ {
150
180
  readonly functionId: string;
@@ -152,6 +182,8 @@ declare class Function_ {
152
182
  constructor(functionId: string, methodName?: string);
153
183
  static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
154
184
  remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
185
+ spawn(args?: any[], kwargs?: Record<string, any>): Promise<FunctionCall>;
186
+ execFunctionCall(args?: any[], kwargs?: Record<string, any>, invocationType?: FunctionCallInvocationType): Promise<string>;
155
187
  }
156
188
 
157
189
  /** Represents a deployed Modal Cls. */
@@ -170,7 +202,7 @@ declare class ClsInstance {
170
202
  }
171
203
 
172
204
  /** Function execution exceeds the allowed time limit. */
173
- declare class TimeoutError extends Error {
205
+ declare class FunctionTimeoutError extends Error {
174
206
  constructor(message: string);
175
207
  }
176
208
  /** An error on the Modal server, or a Python exception. */
@@ -186,4 +218,4 @@ declare class NotFoundError extends Error {
186
218
  constructor(message: string);
187
219
  }
188
220
 
189
- export { App, Cls, ClsInstance, Function_, Image, InternalFailure, type LookupOptions, NotFoundError, RemoteError, Sandbox, type SandboxCreateOptions, type StdioBehavior, type StreamMode, TimeoutError };
221
+ export { App, Cls, ClsInstance, FunctionCall, type FunctionCallCancelOptions, type FunctionCallGetOptions, FunctionTimeoutError, Function_, Image, InternalFailure, type LookupOptions, NotFoundError, RemoteError, Sandbox, type SandboxCreateOptions, type StdioBehavior, type StreamMode };