feat: 实现干扰指标最新小时入库
This commit is contained in:
@@ -22,14 +22,16 @@ The summary columns are:
|
||||
hour_start,hour_end,source_type,cgi,cell_name,interference_dbm,source_path
|
||||
```
|
||||
|
||||
The script never modifies source storage and does not write a database yet. Pending decisions are recorded in `docs/assumptions.md`.
|
||||
The script never modifies or deletes source storage files. By default it writes the complete selected hour to MySQL and keeps only that hour in the target table.
|
||||
|
||||
The database table contains one time column, `metric_time DATETIME`, which is the source KPI start time. A same-hour rerun replaces that whole batch. After a successful insert, rows for every other hour are deleted in the same transaction. The script refuses to replace a newer database hour with an older source hour.
|
||||
|
||||
## Local development
|
||||
|
||||
```powershell
|
||||
python -m pip install -r requirements.txt
|
||||
python -m unittest discover -s tests -v
|
||||
python main.py --source-dir C:\path\to\mock-or-exported-tree --output-dir output
|
||||
python main.py --source-dir C:\path\to\mock-or-exported-tree --output-dir output --no-database
|
||||
```
|
||||
|
||||
Use `--window 2026073110001100` to require one exact source window. Without it, the script selects the newest window containing all seven source types and falls back if the newest observed window is incomplete.
|
||||
@@ -39,19 +41,20 @@ Use `--window 2026073110001100` to require one exact source window. Without it,
|
||||
The target server is offline, so build the runtime image on a connected machine and import it through Metrix Container Management:
|
||||
|
||||
```powershell
|
||||
docker build -t interference-etl-runtime:1.0 .
|
||||
docker build -t interference-etl-runtime:1.1 .
|
||||
New-Item -ItemType Directory -Force dist | Out-Null
|
||||
docker save -o dist\interference-etl-runtime-1.0.tar interference-etl-runtime:1.0
|
||||
docker save -o dist\interference-etl-runtime-1.1.tar interference-etl-runtime:1.1
|
||||
```
|
||||
|
||||
The local `dist/` directory is intentionally excluded from Git. Transfer the generated TAR as a deployment artifact rather than source code.
|
||||
The current `1.1` TAR is 46,944,256 bytes with SHA-256 `BF92BF776D52865CA484D0B7D1B10336C998A07E8310D6F01576C74A65A1FF6A`.
|
||||
|
||||
Create the Metrix script project with:
|
||||
|
||||
```text
|
||||
Name: InterferenceETL
|
||||
Language: python
|
||||
Base image: interference-etl-runtime:1.0
|
||||
Base image: interference-etl-runtime:1.1
|
||||
Network: bridge
|
||||
Run command: python main.py
|
||||
Timeout: 1800 seconds
|
||||
@@ -67,11 +70,17 @@ Configure project environment variables in Metrix instead of committing secrets:
|
||||
"INTERFERENCE_SOURCE_ROOT": "/网优日常优化数据文档/(勿删)干扰定时小时指标",
|
||||
"INTERFERENCE_OUTPUT_DIR": "/workspace/output",
|
||||
"INTERFERENCE_LOOKBACK_DAYS": "3",
|
||||
"INTERFERENCE_PLMN": "460-00"
|
||||
"INTERFERENCE_PLMN": "460-00",
|
||||
"INTERFERENCE_DB_HOST": "<reachable MySQL host>",
|
||||
"INTERFERENCE_DB_PORT": "3306",
|
||||
"INTERFERENCE_DB_USER": "<MySQL user>",
|
||||
"INTERFERENCE_DB_PASSWORD": "<MySQL password>",
|
||||
"INTERFERENCE_DB_NAME": "<database name>",
|
||||
"INTERFERENCE_DB_TABLE": "interference_hourly_summary"
|
||||
}
|
||||
```
|
||||
|
||||
`172.17.0.1` is the current Linux Docker default-bridge gateway used to reach the Metrix host port. Verify it before creating the online schedule because Docker bridge configuration can differ by server.
|
||||
`172.17.0.1` is the current Linux Docker default-bridge gateway used to reach the Metrix host port. Verify both API and MySQL addresses before creating the online schedule because Docker network configuration can differ by server. A container name such as `ShareMySQL` resolves only when the script container joins the same Docker network.
|
||||
|
||||
## CLI options
|
||||
|
||||
@@ -85,4 +94,11 @@ Configure project environment variables in Metrix instead of committing secrets:
|
||||
--storage-id ID Metrix storage connection ID
|
||||
--root PATH Source directory in Metrix storage
|
||||
--plmn PLMN LTE/SDR CGI PLMN prefix, default 460-00
|
||||
--no-database Generate CSV files without writing MySQL
|
||||
--db-host HOST MySQL host or INTERFERENCE_DB_HOST
|
||||
--db-port PORT MySQL port, default 3306
|
||||
--db-user USER MySQL user
|
||||
--db-password VALUE MySQL password; prefer the environment variable
|
||||
--db-name NAME MySQL database name
|
||||
--db-table NAME Table name, default interference_hourly_summary
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user