modal 0.3.3 → 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 +113 -9
- package/dist/index.js +1590 -179
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
2
|
+
|
|
1
3
|
declare class Image {
|
|
2
4
|
readonly imageId: string;
|
|
3
5
|
constructor(imageId: string);
|
|
@@ -93,8 +95,114 @@ declare class App {
|
|
|
93
95
|
imageFromRegistry(tag: string): Promise<Image>;
|
|
94
96
|
}
|
|
95
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
|
+
}
|
|
106
|
+
declare enum ParameterType {
|
|
107
|
+
PARAM_TYPE_UNSPECIFIED = 0,
|
|
108
|
+
PARAM_TYPE_STRING = 1,
|
|
109
|
+
PARAM_TYPE_INT = 2,
|
|
110
|
+
/** PARAM_TYPE_PICKLE - currently unused */
|
|
111
|
+
PARAM_TYPE_PICKLE = 3,
|
|
112
|
+
PARAM_TYPE_BYTES = 4,
|
|
113
|
+
/** PARAM_TYPE_UNKNOWN - used in schemas to signify unrecognized or un-annotated types */
|
|
114
|
+
PARAM_TYPE_UNKNOWN = 5,
|
|
115
|
+
PARAM_TYPE_LIST = 6,
|
|
116
|
+
PARAM_TYPE_DICT = 7,
|
|
117
|
+
PARAM_TYPE_NONE = 8,
|
|
118
|
+
PARAM_TYPE_BOOL = 9,
|
|
119
|
+
UNRECOGNIZED = -1
|
|
120
|
+
}
|
|
121
|
+
/** TODO: rename into NamedPayloadType or similar */
|
|
122
|
+
interface ClassParameterSpec {
|
|
123
|
+
name: string;
|
|
124
|
+
/** TODO: deprecate - use full_type instead */
|
|
125
|
+
type: ParameterType;
|
|
126
|
+
hasDefault: boolean;
|
|
127
|
+
/** Default *values* are only registered for class parameters */
|
|
128
|
+
stringDefault?: string | undefined;
|
|
129
|
+
intDefault?: number | undefined;
|
|
130
|
+
pickleDefault?: Uint8Array | undefined;
|
|
131
|
+
bytesDefault?: Uint8Array | undefined;
|
|
132
|
+
boolDefault?: boolean | undefined;
|
|
133
|
+
/** supersedes `type` */
|
|
134
|
+
fullType: GenericPayloadType | undefined;
|
|
135
|
+
}
|
|
136
|
+
declare const ClassParameterSpec: MessageFns<ClassParameterSpec>;
|
|
137
|
+
interface GenericPayloadType {
|
|
138
|
+
baseType: ParameterType;
|
|
139
|
+
/** sub-type for generic types like lists */
|
|
140
|
+
subTypes: GenericPayloadType[];
|
|
141
|
+
}
|
|
142
|
+
declare const GenericPayloadType: MessageFns<GenericPayloadType>;
|
|
143
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
144
|
+
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
145
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
146
|
+
} : Partial<T>;
|
|
147
|
+
interface MessageFns<T> {
|
|
148
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
149
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
150
|
+
fromJSON(object: any): T;
|
|
151
|
+
toJSON(message: T): unknown;
|
|
152
|
+
create(base?: DeepPartial<T>): T;
|
|
153
|
+
fromPartial(object: DeepPartial<T>): T;
|
|
154
|
+
}
|
|
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
|
+
|
|
178
|
+
/** Represents a deployed Modal Function, which can be invoked remotely. */
|
|
179
|
+
declare class Function_ {
|
|
180
|
+
readonly functionId: string;
|
|
181
|
+
readonly methodName: string | undefined;
|
|
182
|
+
constructor(functionId: string, methodName?: string);
|
|
183
|
+
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
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>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Represents a deployed Modal Cls. */
|
|
190
|
+
declare class Cls {
|
|
191
|
+
#private;
|
|
192
|
+
constructor(serviceFunctionId: string, schema: ClassParameterSpec[], methodNames: string[]);
|
|
193
|
+
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Cls>;
|
|
194
|
+
/** Create a new instance of the Cls with parameters. */
|
|
195
|
+
instance(params?: Record<string, any>): Promise<ClsInstance>;
|
|
196
|
+
}
|
|
197
|
+
/** Represents an instance of a deployed Modal Cls, optionally with parameters. */
|
|
198
|
+
declare class ClsInstance {
|
|
199
|
+
#private;
|
|
200
|
+
constructor(methods: Map<string, Function_>);
|
|
201
|
+
method(name: string): Function_;
|
|
202
|
+
}
|
|
203
|
+
|
|
96
204
|
/** Function execution exceeds the allowed time limit. */
|
|
97
|
-
declare class
|
|
205
|
+
declare class FunctionTimeoutError extends Error {
|
|
98
206
|
constructor(message: string);
|
|
99
207
|
}
|
|
100
208
|
/** An error on the Modal server, or a Python exception. */
|
|
@@ -105,13 +213,9 @@ declare class RemoteError extends Error {
|
|
|
105
213
|
declare class InternalFailure extends Error {
|
|
106
214
|
constructor(message: string);
|
|
107
215
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
readonly functionId: string;
|
|
112
|
-
constructor(functionId: string);
|
|
113
|
-
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
114
|
-
remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
|
|
216
|
+
/** Some resource was not found. */
|
|
217
|
+
declare class NotFoundError extends Error {
|
|
218
|
+
constructor(message: string);
|
|
115
219
|
}
|
|
116
220
|
|
|
117
|
-
export { App, Function_, Image, InternalFailure, type LookupOptions, RemoteError, Sandbox, type SandboxCreateOptions, type StdioBehavior, type StreamMode
|
|
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 };
|