From 68a53bd4891a566aac7c3f2c7e1d528af913293a Mon Sep 17 00:00:00 2001 From: Studio Date: Sat, 5 Dec 2026 14:45:24 -0500 Subject: [PATCH] =?UTF-8?q?T-213:=20M2.4b=20=E2=80=94=20Add=20Python=20sto?= =?UTF-8?q?ckbot=20register=5Fsignal,=20batch=20feature=20runner,=20and=20?= =?UTF-8?q?M2=20MarketDataStore=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/tests/test_m2_sdk_parity.py | 2 ++ scripts/test/python-stockbot-sdk.test.ts | 44 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 scripts/test/python-stockbot-sdk.test.ts diff --git a/python/tests/test_m2_sdk_parity.py b/python/tests/test_m2_sdk_parity.py index 724de732..852d7676 100644 --- a/python/tests/test_m2_sdk_parity.py +++ b/python/tests/test_m2_sdk_parity.py @@ -1097,6 +1097,7 @@ def test_polars_batch_per_year_availability_ceiling_blocks_later_year_macro_leak left_on="ts", right_on="macro_known_at", strategy="backward", + coalesce=False, ) return joined.select( pl.col("listing_id"), @@ -1311,6 +1312,7 @@ const opened = await openDuckDbMarketDataStore({{ }}, }}); try {{ + await opened.executor.run("SET TimeZone = 'UTC';"); await runFeatureBatch( RET_1D_V1, {{ curatedRoot, fromYear: 2024, toYear: 2024, vaultCutoffDate: {json.dumps(vault_cutoff_date)} }}, diff --git a/scripts/test/python-stockbot-sdk.test.ts b/scripts/test/python-stockbot-sdk.test.ts new file mode 100644 index 00000000..af950df3 --- /dev/null +++ b/scripts/test/python-stockbot-sdk.test.ts @@ -0,0 +1,44 @@ +import { existsSync } from 'node:fs'; +import { delimiter, dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { expect, test } from 'bun:test'; + +const repoRoot = fileURLToPath(new URL('../../', import.meta.url)); +const pythonDir = join(repoRoot, 'python'); +const venvPython = join(pythonDir, '.venv/bin/python'); + +function buildEnv(baseEnv: NodeJS.ProcessEnv = process.env): Record { + const env: Record = {}; + for (const [key, value] of Object.entries(baseEnv)) { + if (value !== undefined) { + env[key] = value; + } + } + const bunDir = dirname(process.execPath); + env.PATH = env.PATH ? `${bunDir}${delimiter}${env.PATH}` : bunDir; + env.PYTHONPATH = pythonDir; + env.PYTHONDONTWRITEBYTECODE = '1'; + return env; +} + +test( + 'python stockbot SDK offline pytest suite passes', + () => { + const cmd = existsSync(venvPython) + ? [venvPython, '-m', 'pytest', '-q', '-rf', join(pythonDir, 'tests')] + : ['uv', 'run', '--directory', pythonDir, '--offline', '--extra', 'dev', 'pytest', '-q', '-rf']; + + const spawned = Bun.spawnSync(cmd, { + cwd: pythonDir, + env: buildEnv(), + stdout: 'pipe', + stderr: 'pipe', + }); + + const stdout = new TextDecoder().decode(spawned.stdout); + const stderr = new TextDecoder().decode(spawned.stderr); + + expect(spawned.exitCode, `${stdout}\n${stderr}`).toBe(0); + }, + 60_000 +);