feat(bridge): wire BRIDGE interface keywords and DEFAULT bridge per scope - #3697
feat(bridge): wire BRIDGE interface keywords and DEFAULT bridge per scope#3697ryanmelt wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## pr3-bridge-runtime #3697 +/- ##
======================================================
- Coverage 79.31% 79.28% -0.03%
======================================================
Files 885 887 +2
Lines 65368 65511 +143
Branches 2585 2537 -48
======================================================
+ Hits 51845 51941 +96
- Misses 12852 12897 +45
- Partials 671 673 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
84b8e09 to
013b3f9
Compare
…cope Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
013b3f9 to
e4bf403
Compare
|
| python_example: | | ||
| INTERFACE DATA_INT openc3/interfaces/tcpip_client_interface.py host.docker.internal 8080 8081 10.0 nil BURST | ||
| MAP_TARGET DATA | ||
| PROTOCOL READ openc3/interfaces/protocols/ignore_packet_protocol.py INST IMAGE # Drop all INST IMAGE packets |
| since: 7.4.0 | ||
| parameters: | ||
| - name: Bridge Name | ||
| required: false |
| name = "#{scope}__BRIDGE__DEFAULT" | ||
| next if MicroserviceModel.get_model(name: name, scope: scope) | ||
|
|
||
| BridgeModel.build_microservice(bridge_name: "DEFAULT", scope: scope, shard: scope_model.shard).create |
There was a problem hiding this comment.
Does this also need to call deploy()? That's what ScopeModel does here
| # removed. Leaving the model untouched lets the relay adapt live instead. | ||
| def deploy_bridge_relay | ||
| relay = MicroserviceModel.get_model(name: bridge_relay_name, scope: @scope) | ||
| raise "Bridge #{@bridge_name} does not exist" unless relay |
There was a problem hiding this comment.
I think this causes orphaned data in redis if not caught up by the caller for explicit cleanup
|
|
||
| it "should have Ruby / Python parity" do | ||
| ruby_not_python = @ruby_interfaces - @python_interfaces - PYTHON_TODO_INTERFACES | ||
| expect(ruby_not_python).to be_empty, "Interfaces found in Ruby but not Python: #{ruby_not_python}" | ||
| python_not_ruby = @python_interfaces - @ruby_interfaces - %w(__init__) | ||
| expect(python_not_ruby).to be_empty, "Interfaces found in Python but not Ruby: #{python_not_ruby}" | ||
| end |
There was a problem hiding this comment.
Idk if we want to remove this entirely... Probably warrants a discussion
There was a problem hiding this comment.
We don't want to remove this ... not yet. Simply add bridge_interface to the list at line 77
| received by the interface while write acts on the data before it is sent out. READ_WRITE applies | ||
| the protocol to both reading and writing.<br/><br/> | ||
| For information on creating your own custom protocol please see [Protocols](../configuration/protocols.md) | ||
| since: 7.4.0 |
There was a problem hiding this comment.
Throughout: Replace with since: _Coming Soon_ which will be updated on release
|
|
||
| when 'BRIDGE' | ||
| parser.verify_num_parameters(1, 1, "#{keyword} <Bridge Name>") | ||
| @bridge_name = parameters[0] |
There was a problem hiding this comment.
Should normalize the name to upper case. Also options: [['BRIDGE_NAME', bridge_name.to_s.upcase]] in build_microservice.
| relay = MicroserviceModel.get_model(name: "DEFAULT__BRIDGE__MYBRIDGE", scope: "DEFAULT") | ||
| expect(relay).to_not be_nil | ||
| expect(relay.cmd[1]).to eql "bridge_microservice.py" | ||
| expect(relay.options).to include(["BRIDGE_NAME", "mybridge"]) |
| @target_names.each { |target_name| ensure_target_exists(target_name) } | ||
| microservice.create | ||
| microservice.deploy(gem_path, variables) | ||
| deploy_bridge_relay |
There was a problem hiding this comment.
This isn't actually deploying anything ... it's checking that the MicroserviceModel exists. Safe to do in the validate case and should be done before creating the microservice (see ryan-pratt comment).
Maybe the ensure_target_exists should also move outside the validate_only check?
| # the connection options and secrets needed to open the device are included. | ||
| def deploy_host_microservice | ||
| host = HostMicroserviceModel.new( | ||
| name: @name, |
There was a problem hiding this comment.
Interface and router could share the same name and overwrite each other. We should probably just disallow this at a higher level because I don't think we account for that anywhere.
| # connection options/secret_options belong to the host interface and | ||
| # are omitted, but protocols and target mapping stay in COSMOS. |
There was a problem hiding this comment.
How are those options omitted? I see lines 197 and 199 iterating over the options and secret_options.
|
|
||
| it "should have Ruby / Python parity" do | ||
| ruby_not_python = @ruby_interfaces - @python_interfaces - PYTHON_TODO_INTERFACES | ||
| expect(ruby_not_python).to be_empty, "Interfaces found in Ruby but not Python: #{ruby_not_python}" | ||
| python_not_ruby = @python_interfaces - @ruby_interfaces - %w(__init__) | ||
| expect(python_not_ruby).to be_empty, "Interfaces found in Python but not Ruby: #{python_not_ruby}" | ||
| end |
There was a problem hiding this comment.
We don't want to remove this ... not yet. Simply add bridge_interface to the list at line 77
| MAP_TARGET DATA | ||
| PROTOCOL READ openc3/interfaces/protocols/ignore_packet_protocol.py INST IMAGE # Drop all INST IMAGE packets | ||
| BRIDGE_OPTION: | ||
| summary: Set a parameter on an bridge interface |
| BRIDGE_OPTION: | ||
| summary: Set a parameter on an bridge interface | ||
| description: | ||
| When an bridge option is set the bridge interface class calls the set_option method. |
| required: false | ||
| description: Name of the secret store for stores with multipart keys | ||
| values: .* | ||
| example: | |
There was a problem hiding this comment.
Include the same context as BRIDGE_OPTION



Stacked PR 4 of 5 — base:
pr3-bridge-runtime(#3696). Part of the #3688 split. Needs PR 2 + 3.Wires the bridge into interface configuration:
BRIDGE,BRIDGE_OPTION,BRIDGE_PROTOCOL,BRIDGE_SECRETdeploy_bridge/undeploy_bridgeon the interface model20260704000000_default_bridge.rb+scope_model)interface_modifiers.yamldocsTests
Has the only tests in the series (
interface_model_spec,scope_model_spec,interface_docs_spec). Also updates two Playwright admin tests, which start failing here because the DEFAULT bridge now adds a secret + microservice to the demo (row-scoped locators instead of positional).🤖 Generated with Claude Code