Skip to content

watcher started only when needed#4369

Open
dtrawins wants to merge 4 commits into
mainfrom
update-version
Open

watcher started only when needed#4369
dtrawins wants to merge 4 commits into
mainfrom
update-version

Conversation

@dtrawins

@dtrawins dtrawins commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

🛠 Summary

Now the design is:
versionPollingNeeded — member variable re-evaluated by evaluatePollingState() after every config load
Watcher starts if either config file monitoring is needed OR version polling is needed
updateConfigurationWithoutConfigFile() only runs when versionPollingNeeded is true
After each loadConfig(), evaluatePollingState() is called again — so if the new config adds a versioned model, version polling activates dynamically

🧪 Checklist

  • Unit tests added.
  • The documentation updated.
  • Change follows security best practices.
    ``

@dtrawins dtrawins requested a review from Copilot July 16, 2026 23:51
@dtrawins dtrawins marked this pull request as ready for review July 16, 2026 23:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines OVMS model monitoring so the watcher thread starts only when required (config file monitoring and/or filesystem version polling), and gates version polling work behind a dynamically re-evaluated versionPollingNeeded flag.

Changes:

  • Introduces versionPollingNeeded and evaluatePollingState() to decide whether filesystem version polling is required and whether to start the watcher.
  • Updates the watcher loop to run updateConfigurationWithoutConfigFile() only when version polling is needed, and re-evaluates polling state after config reloads.
  • Updates a test JSON config to explicitly set target_device to CPU.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/test/configs/config_string.json Adds target_device: CPU to the string passthrough test config.
src/modelmanager.hpp Adds versionPollingNeeded state and declares evaluatePollingState().
src/modelmanager.cpp Implements polling-state evaluation and gates watcher/version polling behavior accordingly.

Comment thread src/modelmanager.hpp
Comment on lines +132 to +136
/**
* @brief Evaluates whether filesystem version polling is needed
* and starts the watcher thread if at least one model uses version directories
*/
void evaluatePollingState();
Comment thread src/modelmanager.cpp
Comment on lines +242 to +244
} else {
SPDLOG_LOGGER_DEBUG(modelmanager_logger, "Filesystem version polling disabled - no model uses version directories");
}
Comment thread src/modelmanager.cpp
Comment on lines 1086 to 1090
configFileReloadNeeded(isNeeded);
if (isNeeded) {
loadConfig();
evaluatePollingState();
}
Comment thread src/modelmanager.cpp
Comment on lines +215 to +219
void ModelManager::evaluatePollingState() {
static const std::set<std::string> singleFileExtensions = {
".xml", ".onnx", ".pdmodel", ".pdiparams", ".pb", ".tflite"};

versionPollingNeeded = false;
Comment thread src/modelmanager.cpp
Comment on lines +216 to +217
static const std::set<std::string> singleFileExtensions = {
".xml", ".onnx", ".pdmodel", ".pdiparams", ".pb", ".tflite"};
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.

2 participants