Skip to content

Commit 8decd7a

Browse files
Pigbibicodex
andauthored
docs: make public GCS examples portable (#334)
* docs: make public GCS examples portable Co-Authored-By: Codex <noreply@openai.com> * docs: clarify snapshot bucket access prerequisites Co-Authored-By: Codex <noreply@openai.com> --------- Co-authored-by: Codex <noreply@openai.com>
1 parent e336963 commit 8decd7a

3 files changed

Lines changed: 44 additions & 5 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ ORDER_POLL_MAX_ATTEMPTS=36
3838

3939
# ── Execution Report ──
4040
EXECUTION_REPORT_OUTPUT_DIR=/tmp/quant_runtime_reports
41-
EXECUTION_REPORT_GCS_URI=gs://qsl-runtime-logs-shared/execution-reports
41+
EXECUTION_REPORT_GCS_URI=gs://your-bucket/execution-reports
4242
QSL_EXECUTION_REPORT_GCS_URI=

docs/hk_equity_runtime.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ gh workflow run build-hk-low-vol-snapshot-artifacts.yml \
108108
-f execute_publish=false
109109
```
110110

111-
如果生成结果通过校验,并确认目标 bucket 可由 HK Cloud Run runtime service account 读取,可以发布到 GCS:
111+
如果生成结果通过校验,并确认 workflow 使用的 publisher/deploy service account 对自定义目标 bucket 具备所需对象写权限,同时 HK Cloud Run runtime service account 具备读取权限,可以发布到 GCS:
112112

113113
```bash
114114
gh workflow run build-hk-low-vol-snapshot-artifacts.yml \
@@ -117,7 +117,7 @@ gh workflow run build-hk-low-vol-snapshot-artifacts.yml \
117117
-f profile=hk_low_vol_dividend_quality_snapshot \
118118
-f data_source_mode=public_yfinance_staging \
119119
-f allow_research_defaults=false \
120-
-f gcs_prefix=gs://qsl-runtime-logs-shared/strategy-artifacts/hk_equity/hk_low_vol_dividend_quality_snapshot \
120+
-f gcs_prefix=gs://your-bucket/strategy-artifacts/hk_equity/hk_low_vol_dividend_quality_snapshot \
121121
-f execute_publish=true
122122
```
123123

@@ -126,8 +126,8 @@ gh workflow run build-hk-low-vol-snapshot-artifacts.yml \
126126
```bash
127127
STRATEGY_PROFILE=hk_low_vol_dividend_quality_snapshot
128128
LONGBRIDGE_DRY_RUN_ONLY=true
129-
LONGBRIDGE_FEATURE_SNAPSHOT_PATH=gs://qsl-runtime-logs-shared/strategy-artifacts/hk_equity/hk_low_vol_dividend_quality_snapshot/hk_low_vol_dividend_quality_snapshot_factor_snapshot_latest.csv
130-
LONGBRIDGE_FEATURE_SNAPSHOT_MANIFEST_PATH=gs://qsl-runtime-logs-shared/strategy-artifacts/hk_equity/hk_low_vol_dividend_quality_snapshot/hk_low_vol_dividend_quality_snapshot_factor_snapshot_latest.csv.manifest.json
129+
LONGBRIDGE_FEATURE_SNAPSHOT_PATH=gs://your-bucket/strategy-artifacts/hk_equity/hk_low_vol_dividend_quality_snapshot/hk_low_vol_dividend_quality_snapshot_factor_snapshot_latest.csv
130+
LONGBRIDGE_FEATURE_SNAPSHOT_MANIFEST_PATH=gs://your-bucket/strategy-artifacts/hk_equity/hk_low_vol_dividend_quality_snapshot/hk_low_vol_dividend_quality_snapshot_factor_snapshot_latest.csv.manifest.json
131131
```
132132

133133
注意:`allow_research_defaults=true` 只允许做研究 smoke,不允许发布到 GCS,也不能作为 live-enable 证据。public yfinance 数据源用于让 snapshot artifact 生成和券商执行解耦;它仍需要按策略证据包记录数据源、生成时间和 broker dry-run 结果。
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from pathlib import Path
2+
import re
3+
from urllib.parse import urlparse
4+
5+
6+
REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
7+
PUBLIC_CONFIG_FILES = (
8+
REPOSITORY_ROOT / ".env.example",
9+
REPOSITORY_ROOT / "docs" / "hk_equity_runtime.md",
10+
)
11+
12+
13+
def test_public_gcs_examples_use_portable_bucket_placeholders():
14+
observed = 0
15+
16+
for path in PUBLIC_CONFIG_FILES:
17+
for line_number, line in enumerate(
18+
path.read_text(encoding="utf-8").splitlines(), start=1
19+
):
20+
for uri in re.findall(r"gs://[^\s`\"']+", line):
21+
parsed = urlparse(uri.rstrip("\\"))
22+
observed += 1
23+
24+
assert parsed.scheme == "gs"
25+
assert parsed.path not in {"", "/"}
26+
assert parsed.netloc == "your-bucket" or (
27+
parsed.netloc.startswith("<") and parsed.netloc.endswith(">")
28+
), f"{path.name}:{line_number} uses a deployment-specific GCS bucket"
29+
30+
assert observed == 6
31+
32+
33+
def test_snapshot_publish_prerequisites_cover_writer_and_runtime_reader():
34+
runtime_doc = (
35+
REPOSITORY_ROOT / "docs" / "hk_equity_runtime.md"
36+
).read_text(encoding="utf-8")
37+
38+
assert "publisher/deploy service account 对自定义目标 bucket 具备所需对象写权限" in runtime_doc
39+
assert "runtime service account 具备读取权限" in runtime_doc

0 commit comments

Comments
 (0)