fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs o…#147
fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs o…#147fridayL merged 2 commits intoMemTensor:devfrom
Conversation
fridayL
left a comment
There was a problem hiding this comment.
Summary
This PR refactors the memory scheduler and working memory update logic, improves error handling, and introduces a decorator for exception logging. Key changes include:
Unifying scheduler initialization functions.
Replacing internal attributes for current user and memory cube from private (current) to public (current_).
Improving logging and error handling throughout memory management modules.
Adding a decorator (log_exceptions) for automatic exception logging.
Refactoring code for clarity and robustness, especially around message handling and memory update flows.
Minor bug fixes (typos, error messages, default values).
Updates test code to match new attribute names.
Detailed Review
-
Scheduler Initialization & Config Handling
The two separate scheduler initialization functions are merged into a single run_with_scheduler_init function. This simplifies code maintenance and usage.
The code now loads configuration files more cleanly, directly using MOSConfig.from_yaml_file.
When an AuthConfig is present, OpenAI credentials are injected into the config, improving flexibility and reducing manual steps.
Good: Simplifies the entrypoint and reduces redundancy. -
Attribute Renaming
Internal attributes like _current_user_id, _current_mem_cube_id, and _current_mem_cube are renamed to current_user_id, current_mem_cube_id, and current_mem_cube, and their usages are updated across the codebase.
Good: Improves clarity and consistency, especially with property setters/getters. -
Exception Logging Decorator
Adds a log_exceptions decorator in misc_utils.py, used widely in the scheduler logger module to automatically catch and log exceptions (including stack traces).
Good: Centralizes error handling, reduces boilerplate, and improves debugging capabilities. -
Improved Error Handling & Logging
Several methods in modules/scheduler_logger.py now check for missing keys and log more informative messages.
When parsing user input (userinput_memory_ids), errors are caught and logged.
LLM reranking failures now log the raw response for easier troubleshooting.
Good: Makes the system more robust against malformed input and model errors. -
Message and Label Flow
Changes the label for certain messages from ADD_LABEL to QUERY_LABEL to better reflect the intent.
Refactors message consumer flows for queries, answers, and memory addition to be more robust and easier to follow.
Good: Clarifies the role of each message and improves maintainability. -
General Code Quality
Uses type hints and more descriptive variable names throughout.
Removes unused imports and code.
Updates test cases to use new attribute names.
Good: Overall improvement in readability and reliability.
Suggestions / Potential Issues
Testing: Be sure to test edge cases, especially around error handling and new decorator usage. Verify that all exceptions are properly logged and do not cause silent failures.
Logging Volume: With the new decorator, logging may be more frequent. Make sure log levels and outputs are tuned for production use to avoid log spam.
Backward Compatibility: Attribute renaming may affect external code if attributes were used directly. Ensure all usages are updated.
Performance: Exception logging and additional checks can have minor performance impacts. Monitor if this becomes an issue in high-throughput scenarios.
Overall Impression
This PR is a solid refactor that improves code clarity, error handling, and maintainability. The new decorator is a good addition, and the merged initialization function streamlines the workflow. The changes are logical and well-structured.
Recommendation:
Approve after verifying tests pass and the new error handling works as intended in practice.
MemTensor#147) * fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs of log submittion in MOS * fix bugs: modify mos product, and add more exception catch code
MemTensor#147) * fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs of log submittion in MOS * fix bugs: modify mos product, and add more exception catch code
fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs o log submittion in MOS
Description
Summary: (summary)
fix bugs: fix bugs in the example of memos_w_scheduler and fix bugs o log submittion in MOS
Fix: #(issue)
#5
Docs Issue/PR: (docs-issue-or-pr-link)
Reviewer: @(reviewer)
@fridayL
Checklist: