JSON data from fetch can't be directly used to store again
还没有人认领这个 Issue。
评估
调研方向
首先跟踪 /locations 端点对应的 cwms.get_locations_catalog 和 cwms.store_location,然后将它们的序列化和反序列化映射与 issue 中显示的 CDA JSON 进行比较。验证 fetch 路径返回的 location 对象可以提供给 store 路径,包括 aliases,并确认往返过程不再产生序列化错误。
由索引模型根据 Issue 内容生成。
描述
At least for the /locations endpoint, the json data from the fetch result can't be passed again into the appropriate store endpoint. CDA reports a serialization error.
Purpose:
I need to load all the locations from our production instance into cwbi-dev, so I wanted to use cwms-python to dump all the locations and insert them into cwbi.
Here's the script I used:
import os
import cwms
CWBI_API_KEY="apikey"
CWBI_API_ROOT="https://water.dev.cwbi.us/cwms-data"
cwms.api.init_session(api_root=os.environ.get("CDA_APT_ROOT", None), api_key=os.environ.get("CDA_APT_KEY", None))
locations = cwms.get_locations_catalog(office_id='SPK', unit_system='EN')
cwms.api.init_session(api_root=CWBI_API_ROOT, api_key=CWBI_API_KEY)
for location in locations.json['entries']:
print(location)
cwms.store_location(data=location, fail_if_exists=False)
The JSON has different key names than CDA returns, or expects in the POST.
For example:
office-id -> office
timezone-name -> time-zone
and many more.
Expectation:
I would expect the JSON data from the get_ method to match what CDA would return, especially since I have to supply JSON data to the relevant store_ methods in cwms-python.
Additional info:
Here's the JSON returned by CDA:
{
"office-id": "SPK",
"name": "Truckee R-Vista",
"latitude": 0,
"longitude": 0,
"active": true,
"public-name": "Truckee River At Vista, NV",
"timezone-name": "US/Pacific",
"location-kind": "SITE",
"nation": "US",
"state-initial": "NV",
"county-name": "Washoe",
"nearest-city": "Sparks",
"horizontal-datum": "NAD27",
"published-longitude": 119.7,
"published-latitude": 39.520555555556,
"vertical-datum": "NAVD88",
"elevation": 0,
"bounding-office-id": "UNK",
"elevation-units": "ft"
}
Here's the JSON returned by cwms-python:
{
"office": "SPK",
"name": "Truckee R-Vista",
"nearest-city": "Sparks",
"public-name": "Truckee River At Vista, NV",
"kind": "SITE",
"time-zone": "US/Pacific",
"latitude": 0.0,
"longitude": 0.0,
"published-latitude": 39.520555555556,
"published-longitude": 119.7,
"horizontal-datum": "NAD27",
"elevation": 0.0,
"unit": "ft",
"vertical-datum": "NAVD88",
"nation": "United States",
"state": "NV",
"county": "Washoe",
"bounding-office": "UNK",
"active": true,
"aliases": [
{"name": "Agency Aliases-USGS Station Name", "value": "Truckee River At Vista, NV"},
{"name": "Agency Aliases-USGS Station Number", "value": "10350000"}
]
}
The "aliases" key is acceptable for storing data, so I'm not sure why it doesn't show up on CDA when fetching via swagger.
- 主要语言
- Python
- 星标
- 16
- 派生
- 11
- 平均合并
- 7 小时 35 分钟
- 30 天内合并 PR
- 3
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
HydrologicEngineeringCenter/cwms-python 的其他 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
-
难度 5/5 一周以上 新手友好度 28/100
HydrologicEngineeringCenter/cwms-python#299 · 1 条评论 ·
-
cwms/projects/projects.py::get_project uses the wrong API version for retrieval可能已有人在做 @krowvin 于 61 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
查看 HydrologicEngineeringCenter/cwms-python 的全部 Issue
相似的 Issue
-
[Bug]: graphify query loads every language extractor just for _file_stem (about 34 ms per call)可能已有人在做 @rohit-jsfreaky 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Graphify-Labs/graphify#5160 · 1 条评论 ·
维护者通常 2 天内回复
-
Variable declared without a value suppresses ${VAR:-default} expansion可能已有人在做 @Omarinho12345 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
theskumar/python-dotenv#750 ·
维护者通常 12 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
-
Operations on a list[T] | None var throw when the value is None可能已有人在做 @masenf 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
reflex-dev/reflex#7826 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
UKGovernmentBEIS/control-arena#947 ·
维护者通常 1 天内回复