Skip to content

fix: validate Python module syntax during module_manager install#213

Open
HaibinLai wants to merge 1 commit into
BabitMF:masterfrom
HaibinLai:master
Open

fix: validate Python module syntax during module_manager install#213
HaibinLai wants to merge 1 commit into
BabitMF:masterfrom
HaibinLai:master

Conversation

@HaibinLai

Copy link
Copy Markdown

module_manager install previously accepted Python modules with syntax errors (e.g. IndentationError) without any validation. The error was only discovered at runtime when the BMF graph attempted to load the module, causing a crash.

This PR adds a py_compile syntax check in the install_module() function for Python modules. If the syntax check fails, the installation is aborted with a error message showing the syntax error and line number.

relate issue: #193

How to Reproduce

  1. Create a Python module with a syntax error:
c5a1c1a0aeb5c257dda89e3bbf7e4ea5
  1. Install the module
BMF_BIN="/home/xxx/se_pr/bmf/build/output/bmf/bin/module_manager"
BMF_LIB="/home/xxx/se_pr/bmf/build/output/bmf/lib"

sudo LD_LIBRARY_PATH="${BMF_LIB}" \
    ${BMF_BIN} install my_python_module python my_module:my_module \
    $(pwd)/my_python_module v0.0.1

Before this fix, the installation reports success even though the module contains invalid Python syntax.

After this fix, the installation fails early with a clear error message:

b413a35f3bfbcce62ac111f7006e77bf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant