JSON data from fetch can't be directly used to store again
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia tracciando cwms.get_locations_catalog e cwms.store_location per l’endpoint /locations, quindi confronta le relative mappature di serializzazione e deserializzazione con il CDA JSON mostrato nell’issue. Verifica che l’oggetto posizione restituito dal percorso di recupero possa essere fornito al percorso di memorizzazione, inclusi gli alias, e conferma che il round trip non produca più un errore di serializzazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 16
- Fork
- 11
- Merge medio
- 7h 35m
- PR unite (30g)
- 3
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di HydrologicEngineeringCenter/cwms-python
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
HydrologicEngineeringCenter/cwms-python#299 · 1 commento ·
-
cwms/projects/projects.py::get_project uses the wrong API version for retrievalForse già presa @krowvin l’ha presa 61 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
Tutte le issue di HydrologicEngineeringCenter/cwms-python
Issue simili
-
[Bug]: graphify query loads every language extractor just for _file_stem (about 34 ms per call)Forse già presa @rohit-jsfreaky l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Graphify-Labs/graphify#5160 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Variable declared without a value suppresses ${VAR:-default} expansionForse già presa @Omarinho12345 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
theskumar/python-dotenv#750 ·
I maintainer di solito rispondono entro 12 giorni
-
Minor bug: Main page buttonApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Operations on a list[T] | None var throw when the value is NoneForse già presa @masenf l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
reflex-dev/reflex#7826 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
UKGovernmentBEIS/control-arena#947 ·
I maintainer di solito rispondono entro 1 giorno