Python wrapper API has changed; python examples are not working
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia con python/examples/read_way.py e python/examples/augmented_diff.py, poi esamina i percorsi del wrapper Python alla base di nodes.get() e ways.get(), insieme alla versione della dipendenza pycapnp. Riproduci i comandi mostrati nell’issue e determina l’approccio di compatibilità appropriato. Il lavoro è completato quando entrambi gli esempi vengono eseguiti senza gli errori di attributo del context manager segnalati e il comportamento del wrapper è coerente con la versione di pycapnp supportata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The python examples in the repository aren't working. As an example, here's me running read_way.py.
$ python python/examples/read_way.py washington.osmx 761811137
Traceback (most recent call last):
File "/Users/jake/Code/FOSS/protomaps/OSMExpress/python/examples/read_way.py", line 18, in <module>
for node_id in way.nodes:
^^^^^^^^^
AttributeError: '_GeneratorContextManager' object has no attribute 'nodes'
The augmented_diff.py script fails similarly:
python python/examples/augmented_diff.py washington.osmx 155421965.osc 155421965.adiff
No old loc found for tagless node 5694096597
Traceback (most recent call last):
File "/Users/jake/Code/FOSS/protomaps/OSMExpress/python/examples/augmented_diff.py", line 138, in <module>
set_old_metadata(prev_version)
File "/Users/jake/Code/FOSS/protomaps/OSMExpress/python/examples/augmented_diff.py", line 74, in set_old_metadata
elem.set('version',str(o.metadata.version))
^^^^^^^^^^
AttributeError: '_GeneratorContextManager' object has no attribute 'metadata'
The root cause is that pycapnp from_bytes() now returns a context manager, requiring callers to change from this:
way = messages_capnp.Way.from_bytes(msg)
# do stuff with way
...to this:
with messages_capnp.Way.from_bytes(msg) as way:
# do stuff with way
This change was introduced in pycapnp 1.1.1. It looks like the Python examples were developed against an older version of OSMX that used pycapnp 0.6.4, but #46 bumped the pycapnp version to 2.0.0. This effectively changed the API of nodes.get(), ways.get(), etc by making them return context managers rather than return nodes/ways/etc directly, but I assume this wasn't noticed at the time and the examples weren't updated to match.
I think there are two possible fixes: either downgrade the Python osmx wrapper to use pycapnp <= 1.1.0, or change the Python examples to use with. I'm not sure which is more appropriate. It's worth noting that if pycapnp ~= 2.0.0 is kept, the next release of osmx will be a breaking API change for any users of the Python wrapper.
EDIT: Actually it looks like a version with the new context-manager API has already been published, though as a 0.0.x release I think most users would know not to expect a stable API 😉
I might be able to work on a PR for this at some point soon, but wanted to open this issue for now in case I don't end up having time to.
- Lingua principale
- C++
- Stelle
- 274
- Fork
- 23
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna 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 bdon/OSMExpress
-
Release binaries?Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
bdon/OSMExpress#79 · 3 commenti ·
-
Optimize build timeAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
bdon/OSMExpress#63 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
bdon/OSMExpress#51 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
bdon/OSMExpress#39 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
bdon/OSMExpress#37 · 2 commenti ·
Tutte le issue di bdon/OSMExpress
Issue simili
-
bug intrinsic medium priority rt_lib
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
sumatrapdfreader/sumatrapdf#6417 · 3 commenti ·
-
[BUG] Cython cache evicts most recent instead of oldest entry on cleanupForse già presa @scoder l’ha presa oggi. ApertaBuild System defect
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NVIDIA-Omniverse/PhysX#590 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno