MCPcopy Create free account
hub / github.com/antvis/AVA / execute

Method execute

src/interpreter/python/engine.ts:90–111  ·  view source on GitHub ↗
(code: string, options?: ExecutionOptions)

Source from the content-addressed store, hash-verified

88 }
89
90 async execute<T = Record<string, unknown>>(code: string, options?: ExecutionOptions): Promise<ExecutionResult<T>> {
91 if (!this.source) throw new Error('No data loaded. Please call source() first.');
92
93 const validated = await this.dialect.validateDSL(code);
94 const limits = {
95 maxRows: z.number().int().positive().parse(maxRows(options)),
96 maxResultBytes: maxResultBytes(options),
97 };
98
99 // Bound client waiting; the executor must terminate remote work on timeout.
100 const maxBuffer = limits.maxResultBytes + 1024 * 1024;
101 const response = await runWithTimeout(
102 this.executor(executionCode(validated, this.source, limits), maxBuffer),
103 this.timeoutMs,
104 {
105 onTimeout: () => new Error(`Python execution timed out after ${this.timeoutMs}ms`),
106 }
107 );
108 const result = resultSchema.parse(response);
109 // Row fields are chosen by the caller's query; the envelope is runtime-validated above.
110 return executionResult(result.data as T[], result.schema, limits, result.truncatedBy);
111 }
112
113 private async metadata(code: string): Promise<Record<string, unknown>[]> {
114 const result = await this.execute(code, { maxRows: 10_000 });

Callers 1

metadataMethod · 0.95

Calls 6

maxRowsFunction · 0.90
maxResultBytesFunction · 0.90
runWithTimeoutFunction · 0.90
executionCodeFunction · 0.90
executionResultFunction · 0.90
validateDSLMethod · 0.65

Tested by

no test coverage detected