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

Method validateDSL

src/query/python.ts:46–62  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

44 }
45
46 async validateDSL(code: string): Promise<string> {
47 if (!code.trim()) throw new Error('Python query must contain code');
48 if (code.includes('\0')) throw new Error('Python query contains a NUL character');
49 // Compile in the execution environment without running the user's code or loading source data.
50 // https://docs.python.org/3/library/functions.html#compile
51 const script = `import json
52compile(json.loads(${JSON.stringify(JSON.stringify(code))}), '<ava-query>', 'exec')
53print('{"data":[],"schema":[],"rowCount":0}')
54`;
55 if (this.execute) {
56 await this.execute(script);
57 } else {
58 const { createPythonExecutor } = await import('../interpreter/python/util/execute');
59 await createPythonExecutor(30_000)(script, 64 * 1024);
60 }
61 return code;
62 }
63}

Callers

nothing calls this directly

Calls 2

createPythonExecutorFunction · 0.85
executeMethod · 0.65

Tested by

no test coverage detected