JSON data from fetch can't be directly used to store again
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 55/100
Direção de pesquisa
Comece rastreando cwms.get_locations_catalog e cwms.store_location para o endpoint /locations e, em seguida, compare seus mapeamentos de serialização e desserialização com o CDA JSON mostrado na issue. Verifique se o objeto de localização retornado pelo caminho de busca pode ser fornecido ao caminho de armazenamento, incluindo os aliases, e confirme que o round trip não produz mais um erro de serialização.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 16
- Forks
- 11
- Merge médio
- 7h 35min
- PRs com merge (30d)
- 3
Preparar o ambiente
- Inclui um Dockerfile ou arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de HydrologicEngineeringCenter/cwms-python
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
-
enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 28/100
HydrologicEngineeringCenter/cwms-python#299 · 1 comentário ·
-
cwms/projects/projects.py::get_project uses the wrong API version for retrievalTalvez já em andamento @krowvin assumiu há 61 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 25/100
Todas as issues de HydrologicEngineeringCenter/cwms-python
Issues semelhantes
-
[Bug]: graphify query loads every language extractor just for _file_stem (about 34 ms per call)Talvez já em andamento @rohit-jsfreaky assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Graphify-Labs/graphify#5160 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Variable declared without a value suppresses ${VAR:-default} expansionTalvez já em andamento @Omarinho12345 assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
theskumar/python-dotenv#750 ·
Mantenedores costumam responder em até 12 dias
-
Minor bug: Main page buttonAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
Operations on a list[T] | None var throw when the value is NoneTalvez já em andamento @masenf assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
reflex-dev/reflex#7826 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
UKGovernmentBEIS/control-arena#947 ·
Mantenedores costumam responder em até 1 dia