Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/targets/ibkr/default.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"plugin": "example_notification_plugin",
"signal_path": "gs://example-bucket/strategy-artifacts/example_strategy_profile/plugins/example_notification_plugin/latest_signal.json",
"enabled": true,
"expected_mode": "shadow"
"expected_mode": "shadow",
"expected_schema_version": "example_notification_plugin.v1"
}
],
"extra_variables": {}
Expand Down
3 changes: 2 additions & 1 deletion examples/targets/longbridge/sg.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"plugin": "example_notification_plugin",
"signal_path": "gs://example-bucket/strategy-artifacts/example_strategy_profile/plugins/example_notification_plugin/latest_signal.json",
"enabled": true,
"expected_mode": "shadow"
"expected_mode": "shadow",
"expected_schema_version": "example_notification_plugin.v1"
}
],
"extra_variables": {
Expand Down
3 changes: 2 additions & 1 deletion examples/targets/schwab/live.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"plugin": "example_notification_plugin",
"signal_path": "gs://example-bucket/strategy-artifacts/example_strategy_profile/plugins/example_notification_plugin/latest_signal.json",
"enabled": true,
"expected_mode": "shadow"
"expected_mode": "shadow",
"expected_schema_version": "example_notification_plugin.v1"
}
],
"extra_variables": {}
Expand Down
3 changes: 3 additions & 0 deletions schemas/runtime-target.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@
},
"expected_mode": {
"type": "string"
},
"expected_schema_version": {
"type": "string"
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions scripts/runtime_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ def validate_plugin_mounts(target: dict[str, Any], errors: list[str]) -> None:
if not isinstance(mount.get("enabled"), bool):
errors.append(f"plugin_mounts[{index}].enabled must be boolean")

expected_schema_version = mount.get("expected_schema_version")
if expected_schema_version is not None and (
not isinstance(expected_schema_version, str) or not expected_schema_version.strip()
):
errors.append(f"plugin_mounts[{index}].expected_schema_version must be a non-empty string")

signal_path = mount.get("signal_path")
if not isinstance(signal_path, str) or not signal_path.startswith("gs://"):
errors.append(f"plugin_mounts[{index}].signal_path must be a gs:// URI")
Expand Down
15 changes: 15 additions & 0 deletions tests/test_runtime_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ def test_example_targets_have_matching_plugin_mount(self):
)
)

def test_plugin_mount_schema_version_is_rendered_for_platform_parser(self):
_, target = self.load_target("examples/targets/schwab/live.example.json")
assignments = {item.name: item.value for item in runtime_settings.build_assignments(target)}

self.assertIn('"expected_schema_version":"example_notification_plugin.v1"', assignments["SCHWAB_STRATEGY_PLUGIN_MOUNTS_JSON"])

def test_plugin_mount_schema_version_must_be_non_empty_string(self):
_, target = self.load_target("examples/targets/schwab/live.example.json")
target["plugin_mounts"][0]["expected_schema_version"] = ""

self.assertIn(
"plugin_mounts[0].expected_schema_version must be a non-empty string",
runtime_settings.validate_target(target),
)

def test_generated_variables_cannot_be_overridden(self):
_, target = self.load_target("examples/targets/schwab/live.example.json")
target["extra_variables"] = {"STRATEGY_PROFILE": "old_strategy"}
Expand Down