Add modular mapper architecture for multiple data sources#42
Add modular mapper architecture for multiple data sources#42
Conversation
Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
examples/example_multiple_mappers.py
Outdated
README.md
Outdated
There was a problem hiding this comment.
Don't mark Future development as complete. Instead document that it is done somewhere in README.md.
There was a problem hiding this comment.
Fixed in b93f2df - removed completion marks from "Future development" section and added separate "Mapper Support" section documenting the feature.
README.md
Outdated
There was a problem hiding this comment.
Too much information, something like this would be enough:
Short Circuit supports consuming wormhole data from multiple instances of multiple mapper sources simultaneously:
- Tripwire.
- Eve Scout.
TBD:
- pathfinder.
- eve-whmapper - waiting for public API.
There was a problem hiding this comment.
Simplified in b93f2df to match the suggested format.
IMPLEMENTATION_SUMMARY.md
Outdated
There was a problem hiding this comment.
You should not commit such files to repository.
src/shortcircuit/model/tripwire.py
Outdated
There was a problem hiding this comment.
This is unused, isn't it? Parent methods are unused too?
There was a problem hiding this comment.
These methods are part of the MapperSource interface and are used by MapperRegistry (lines 29-30, 37, 64, 73 in mapper_registry.py). However, MapperRegistry itself is not currently integrated into the main application code - it exists only for future use and in tests. The application still uses direct augment_map calls on Tripwire/EveScout instances.
There was a problem hiding this comment.
Looking forward to see how are you going integrate get_config with QT configs.
There was a problem hiding this comment.
You should use QT configs. If get_config is still needed, make it make sense.
There was a problem hiding this comment.
Removed get_config() from MapperSource interface in 57059bf. The interface now only includes essential methods: augment_map(), get_name(), and validate_config(). Configuration is managed through QSettings in the app, not through the mapper interface.
There was a problem hiding this comment.
Removed get_config() in 57059bf. Configuration is now handled through QSettings in the app.
| self.sources.clear() | ||
| Logger.info("Cleared all mapper sources") | ||
|
|
||
| def augment_map(self, solar_map: SolarMap) -> Dict[str, int]: |
There was a problem hiding this comment.
I do not see invocations of this, where are they?
There was a problem hiding this comment.
MapperRegistry.augment_map is currently only invoked in test_mapper_registry.py. The main application code (navigation.py, app.py) still uses direct augment_map calls on individual Tripwire/EveScout instances. The registry infrastructure exists but is not yet integrated into the actual application workflow.
There was a problem hiding this comment.
The main application code should be updated in this PR aswell.
There was a problem hiding this comment.
Updated in ca895d6. The MapperRegistry is now integrated into Navigation and NavProcessor. The main application workflow uses setup_mappers() to configure sources and augment_from_all_mappers() to fetch connections from all registered mappers.
There was a problem hiding this comment.
Updated in ca895d6. The main application code now uses MapperRegistry through Navigation.setup_mappers() and Navigation.augment_from_all_mappers() methods.
Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
| self.sources.clear() | ||
| Logger.info("Cleared all mapper sources") | ||
|
|
||
| def augment_map(self, solar_map: SolarMap) -> Dict[str, int]: |
There was a problem hiding this comment.
The main application code should be updated in this PR aswell.
src/shortcircuit/model/tripwire.py
Outdated
There was a problem hiding this comment.
Looking forward to see how are you going integrate get_config with QT configs.
Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
src/shortcircuit/model/navigation.py
Outdated
There was a problem hiding this comment.
Either evescout_enable: bool = False shouldn't be a param to this function, or all the configs for all the mappers should be passed here.
There was a problem hiding this comment.
Fixed in 57059bf. Removed the evescout_enable parameter. setup_mappers() now reads all configuration directly from app_obj (Tripwire credentials from instance variables, Eve Scout enabled from state_evescout["enabled"]).
src/shortcircuit/model/navigation.py
Outdated
There was a problem hiding this comment.
Doesn't seem to allow multiple Tripwire instances, but it should.
There was a problem hiding this comment.
The current implementation supports one Tripwire instance based on the existing UI configuration. Supporting multiple instances would require UI changes to manage multiple sets of credentials. This is documented as a future enhancement in docs/MODULE_ARCHITECTURE.md (see "Multiple Tripwire Instances" section).
src/shortcircuit/model/navigation.py
Outdated
There was a problem hiding this comment.
There is no need to keep legacy methods.
There was a problem hiding this comment.
Removed tripwire_augment() legacy method in 57059bf.
There was a problem hiding this comment.
It should really iterate over entire result, not just there two mappers.
There was a problem hiding this comment.
Fixed in 57059bf. NavProcessor now calculates total_connections by summing all values from results dict, not just two specific mappers. The UI signal still sends (tripwire_connections, evescout_connections) for backward compatibility, but the map update logic uses the total.
src/shortcircuit/model/navigation.py
Outdated
There was a problem hiding this comment.
Seems like it should be named augment_map.
Also this is a good moment to create a documentation for connections between modules in docs. Current control path seems strange with all these navigation, navprocessor, tripwire, solarmap juggling.
There was a problem hiding this comment.
Renamed to augment_map() in 57059bf. Also created comprehensive documentation in docs/MODULE_ARCHITECTURE.md explaining the control flow between navigation, navprocessor, tripwire, and solarmap modules.
src/shortcircuit/model/tripwire.py
Outdated
There was a problem hiding this comment.
You should use QT configs. If get_config is still needed, make it make sense.
There was a problem hiding this comment.
Remove this file, it is too much. mapper_base.py and actual implementations of other mappers is quite enough.
There was a problem hiding this comment.
Removed mapper_template.py in 57059bf. The actual implementations (tripwire.py, evescout.py) serve as sufficient examples.
…prove integration Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
|
|
||
| Configuration is: | ||
| 1. Loaded from QSettings in `app.py.__init__()` → `read_settings()` | ||
| 2. Stored in MainWindow instance variables |
There was a problem hiding this comment.
This seems kinda wrong and violating SRP. Is there a better way to manage this?
There was a problem hiding this comment.
Navigation reading from app_obj is necessary to access QSettings-based configuration. An alternative would be to pass a configuration object to setup_mappers(), but that would require creating a new configuration structure. The current approach keeps configuration centralized in MainWindow/QSettings.
| # Add Tripwire if configured | ||
| if self.tripwire_url and self.tripwire_user and self.tripwire_password: | ||
| tripwire = Tripwire( | ||
| self.tripwire_user, | ||
| self.tripwire_password, | ||
| self.tripwire_url, | ||
| name="Tripwire" | ||
| ) | ||
| self.mapper_registry.register(tripwire) |
There was a problem hiding this comment.
This code still does not support multiple Tripwire instances, because it clears entire registry on L66.
There was a problem hiding this comment.
Correct - the current implementation clears the registry and adds mappers based on single-instance configuration. Supporting multiple instances requires storing and iterating through multiple configuration sets. What level of implementation is expected for this PR?
| # For backward compatibility with UI, extract specific mapper counts | ||
| # The UI expects (tripwire_connections, evescout_connections) | ||
| tripwire_connections = results.get("Tripwire", 0) | ||
| evescout_connections = results.get("Eve Scout", 0) |
There was a problem hiding this comment.
This should have a TODO: rethink status bar
src/shortcircuit/model/tripwire.py
Outdated
There was a problem hiding this comment.
implements MapperSource interface is unneeded info, we can see that in it's definition.
| def validate_config(self) -> tuple[bool, Optional[str]]: | ||
| """ | ||
| Validate the Tripwire configuration. | ||
|
|
||
| Returns: | ||
| Tuple of (is_valid, error_message) | ||
| """ | ||
| if not self.url: | ||
| return False, "URL is required" | ||
| if not self.username: | ||
| return False, "Username is required" | ||
| if not self.password: | ||
| return False, "Password is required" | ||
| return True, None |
There was a problem hiding this comment.
Should validate_config really be a part of Mapper interface? It feels like this validation should happen much earlier, closer to user UI and QSettings.
There was a problem hiding this comment.
validate_config() is used by MapperRegistry for logging. UI validation would be preferred, but this provides a fallback for programmatic usage.
| if not self.url: | ||
| return False, "URL is required" |
There was a problem hiding this comment.
Also URLs should be validated to be URLs.
There was a problem hiding this comment.
URL validation would require additional validation logic. Added to TODO.md in 2f08706 as future enhancement.
…ate architecture docs Co-authored-by: secondfry <400605+secondfry@users.noreply.github.com>
Modular Mapper Architecture Implementation
Recent Documentation Updates
Architecture Status
augment_map(),get_name(),validate_config()Questions Raised
Several comments ask about design decisions:
All documentation feedback addressed. Awaiting clarification on scope of multiple instance implementation.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.