Goal
Add a knowledge-mapper run subcommand that starts a KnowledgeBase instance defined in a Python file, replacing the boilerplate if __name__ == "__main__" block that users currently need to write.
Motivation
Every Python-defined KB currently requires the same boilerplate:
if __name__ == "__main__":
kb.register()
kb.start_handling_loop()
kb.unregister()
The CLI should handle this lifecycle automatically, including graceful shutdown.
Usage
knowledge-mapper run my_app.py:kb
Where my_app.py is the Python file and kb is the name of the KnowledgeBase variable.
Behaviour
- Load the specified Python module.
- Retrieve the named
KnowledgeBase instance from the module.
- Call
kb.register().
- Call
kb.start_handling_loop() (blocking).
- On SIGINT/SIGTERM: call
kb.unregister() and exit cleanly.
Implementation notes
- Use typer as the CLI framework.
- This is one subcommand of the
knowledge-mapper entry point; knowledge-mapper sparql (separate issue) will be another.
- Add
knowledge-mapper to console_scripts in pyproject.toml.
Goal
Add a
knowledge-mapper runsubcommand that starts aKnowledgeBaseinstance defined in a Python file, replacing the boilerplateif __name__ == "__main__"block that users currently need to write.Motivation
Every Python-defined KB currently requires the same boilerplate:
The CLI should handle this lifecycle automatically, including graceful shutdown.
Usage
Where
my_app.pyis the Python file andkbis the name of theKnowledgeBasevariable.Behaviour
KnowledgeBaseinstance from the module.kb.register().kb.start_handling_loop()(blocking).kb.unregister()and exit cleanly.Implementation notes
knowledge-mapperentry point;knowledge-mapper sparql(separate issue) will be another.knowledge-mappertoconsole_scriptsinpyproject.toml.