Fix relative paths and imports to make code work as a package#23
Fix relative paths and imports to make code work as a package#23sylwia-budzynska wants to merge 5 commits intoGitHubSecurityLab:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the codebase to function as a proper Python package by converting absolute imports to relative imports and fixing path handling. This enables distribution via PyPi and allows users to run the package with python -m seclab-taskflow-agent.
- Converted absolute imports to relative imports across multiple modules
- Added dynamic log directory creation for package execution from any location
- Added
__main__.pyto enable module execution viapython -m
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| mcp_utils.py | Changed import from env_utils to relative import .env_utils |
| main.py | Updated all internal imports to relative imports and added dynamic log directory creation |
| agent.py | Changed import from capi to relative import .capi |
| main.py | Added entry point for module execution using runpy |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import runpy | ||
|
|
||
| if __name__ == "__main__": | ||
| runpy.run_module("seclab_taskflow_agent.main", run_name="__main__") |
There was a problem hiding this comment.
The module name 'seclab_taskflow_agent.main' is hardcoded and doesn't match the actual package structure. This should use a relative import or derive the module name dynamically to avoid breaking if the package is renamed.
| runpy.run_module("seclab_taskflow_agent.main", run_name="__main__") | |
| module_name = (__package__ + ".main") if __package__ else "main" | |
| runpy.run_module(module_name, run_name="__main__") |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| We need all the code to be in a separate directory to build it into a package, so we create a new dir and copy what is need for the build. | ||
|
|
||
| For pacakges, only underscores are a allowed as legal python idnetifiers and not dashes, so we need to rename the folder. |
There was a problem hiding this comment.
Removed extra 'a' in 'are a allowed' - should be 'are allowed'.
| For pacakges, only underscores are a allowed as legal python idnetifiers and not dashes, so we need to rename the folder. | |
| For pacakges, only underscores are allowed as legal python idnetifiers and not dashes, so we need to rename the folder. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Closing this PR because it has been superseded by #41. |
For the code to work as a PyPi package, we need to fix relative imports and relative paths.
The init.py is added to make the code work as a module.
The main.py file will allow us to run the code with
python -m seclab-taskflow-agent -p assistant "how do modems work"