Compare commits

...

7 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 929d2eb574 Revert sample file changes - fix belongs in preload
Reverted all changes to sample files as the correct fix is to export
NODE_OPTIONS/PYTHONPATH in the preload scripts (sitecustomize.js/py),
not to modify sample files. This was the maintainer's feedback.

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-11-22 14:50:55 +00:00
copilot-swe-agent[bot] ebedd994dd Improve string handling for NODE_OPTIONS and PYTHONPATH
Use filter(Boolean).join() to avoid extra spaces and properly handle
missing environment variables. This ensures clean paths even when
some variables are empty or undefined.

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-11-22 14:47:33 +00:00
copilot-swe-agent[bot] ee7d39f433 Fix NODE_OPTIONS not being available in task_before commands
Export NODE_OPTIONS and PYTHONPATH in bash subprocess so that any
node/python commands in task_before (pre-execution field) can access
the QLAPI preload. This fixes the issue where running
"node /ql/data/scripts/ql_sample.js" in pre-execution fails with
"ReferenceError: QLAPI is not defined".

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-11-22 14:45:56 +00:00
copilot-swe-agent[bot] eab8a93f28 Improve error messages for QLAPI initialization
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-11-22 14:34:17 +00:00
copilot-swe-agent[bot] 16b20e8b54 Add QLAPI auto-initialization for Python and format code
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-11-22 14:31:27 +00:00
copilot-swe-agent[bot] 6dbd980881 Add QLAPI auto-initialization for standalone node execution
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-11-22 14:30:25 +00:00
copilot-swe-agent[bot] 35a17fce95 Initial plan 2025-11-22 14:25:29 +00:00
2 changed files with 15 additions and 0 deletions
+7
View File
@@ -28,6 +28,7 @@ function run() {
numParam,
file_task_before,
file_task_before_js,
file_preload_js,
dir_scripts,
task_before,
PREV_NODE_OPTIONS,
@@ -40,7 +41,13 @@ function run() {
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
const tempFile = `/tmp/env_${process.pid}.json`;
// Export NODE_OPTIONS so task_before can use it for any node commands
const nodeOptionsForBash = file_preload_js
? ['-r', file_preload_js, PREV_NODE_OPTIONS].filter(Boolean).join(' ')
: PREV_NODE_OPTIONS || '';
const commands = [
`export NODE_OPTIONS="${nodeOptionsForBash}"`,
`source ${file_task_before} ${fileName}`,
task_before ? `eval '${task_before.replace(/'/g, "'\\''")}'` : null,
`echo -e '${splitStr}'`,
+8
View File
@@ -44,11 +44,19 @@ def run():
split_str = "__sitecustomize__"
file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "")
# Get environment variables needed for PYTHONPATH
dir_preload = os.getenv("dir_preload", "")
dir_config = os.getenv("dir_config", "")
# 创建临时文件路径
temp_file = f"/tmp/env_{os.getpid()}.json"
# Export PYTHONPATH so task_before can use it for any python commands
pythonpath_for_bash = ':'.join(filter(None, [dir_preload, dir_config, prev_pythonpath]))
# 构建命令数组
commands = [
f'export PYTHONPATH="{pythonpath_for_bash}"',
f'source {os.getenv("file_task_before")} {file_name}'
]