|
13 | 13 |
|
14 | 14 | from quant_platform_kit.common.strategy_plugin_artifacts import ( |
15 | 15 | cache_path_for_remote_artifact, |
16 | | - download_gcs_object, |
17 | | - materialize_local_or_gcs_artifact, |
18 | | - parse_gcs_uri, |
| 16 | + download_remote_object, |
| 17 | + materialize_local_or_remote_artifact, |
| 18 | + parse_cloud_uri, |
19 | 19 | ) |
20 | 20 |
|
21 | 21 | PLUGIN_CRISIS_RESPONSE_SHADOW = "crisis_response_shadow" |
22 | 22 | PLUGIN_MARKET_REGIME_CONTROL = "market_regime_control" |
23 | 23 | PLUGIN_MACRO_RISK_GOVERNOR = "macro_risk_governor" |
24 | 24 | PLUGIN_TACO_REBOUND_SHADOW = "taco_rebound_shadow" |
| 25 | +PLUGIN_PANIC_REVERSAL_SHADOW = "panic_reversal_shadow" |
25 | 26 | GENERAL_MARKET_REGIME_NOTIFICATION_TARGET = "market_regime_notification" |
26 | 27 | PLUGIN_MODE_SHADOW = "shadow" |
27 | 28 | STRATEGY_PLUGIN_ALERT_CHANNEL_EMAIL = "email" |
@@ -1310,7 +1311,10 @@ def _translate_first_formatted( |
1310 | 1311 | if translator is None: |
1311 | 1312 | return None |
1312 | 1313 | for key in keys: |
1313 | | - translated = translator(key, **kwargs) |
| 1314 | + try: |
| 1315 | + translated = translator(key, **kwargs) |
| 1316 | + except TypeError: |
| 1317 | + translated = translator(key) |
1314 | 1318 | if translated != key: |
1315 | 1319 | text = str(translated).strip() |
1316 | 1320 | if text: |
@@ -1695,19 +1699,24 @@ def _sanitize_key_part(value: Any) -> str: |
1695 | 1699 |
|
1696 | 1700 |
|
1697 | 1701 | def _materialize_artifact_path(reference: str, *, client_factory: Any = None) -> tuple[Path, dict[str, str | None]]: |
1698 | | - return materialize_local_or_gcs_artifact( |
| 1702 | + return materialize_local_or_remote_artifact( |
1699 | 1703 | reference, |
1700 | 1704 | cache_dir=DEFAULT_PLUGIN_ARTIFACT_CACHE_DIR, |
1701 | 1705 | client_factory=client_factory, |
1702 | 1706 | ) |
1703 | 1707 |
|
1704 | 1708 |
|
1705 | | -def _download_gcs_object(uri: str, destination: Path, *, client_factory: Any = None) -> None: |
1706 | | - download_gcs_object(uri, destination, client_factory=client_factory) |
| 1709 | +def _download_remote_object(uri: str, destination: Path, *, client_factory: Any = None) -> None: |
| 1710 | + download_remote_object(uri, destination, client_factory=client_factory) |
| 1711 | + |
| 1712 | + |
| 1713 | +def _parse_cloud_uri(uri: str) -> tuple[str, str]: |
| 1714 | + return parse_cloud_uri(uri) |
1707 | 1715 |
|
1708 | 1716 |
|
1709 | | -def _parse_gcs_uri(uri: str) -> tuple[str, str]: |
1710 | | - return parse_gcs_uri(uri) |
| 1717 | +# Backward-compatible aliases (used internally by notification modules) |
| 1718 | +_download_gcs_object = _download_remote_object |
| 1719 | +_parse_gcs_uri = _parse_cloud_uri |
1711 | 1720 |
|
1712 | 1721 |
|
1713 | 1722 | def _cache_path_for_remote_artifact(reference: str) -> Path: |
@@ -1742,7 +1751,10 @@ def _translate( |
1742 | 1751 | ) -> str: |
1743 | 1752 | if translator is None: |
1744 | 1753 | return fallback.format(**kwargs) |
1745 | | - translated = translator(key, **kwargs) |
| 1754 | + try: |
| 1755 | + translated = translator(key, **kwargs) |
| 1756 | + except TypeError: |
| 1757 | + translated = translator(key) |
1746 | 1758 | return translated if translated != key else fallback.format(**kwargs) |
1747 | 1759 |
|
1748 | 1760 |
|
|
0 commit comments