Python wrapper API has changed; python examples are not working
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Comienza con python/examples/read_way.py y python/examples/augmented_diff.py; después inspecciona las rutas del wrapper de Python detrás de nodes.get() y ways.get(), junto con la versión de la dependencia pycapnp. Reproduce los comandos mostrados en el issue y determina el enfoque de compatibilidad adecuado. Se considera terminado cuando ambos ejemplos se ejecutan sin los errores de atributos del context manager indicados y el comportamiento del wrapper es coherente con la versión de pycapnp compatible.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C++
- Estrellas
- 274
- Forks
- 23
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bdon/OSMExpress
-
Release binaries?Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
bdon/OSMExpress#79 · 3 comentarios ·
-
Optimize build timeAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
bdon/OSMExpress#63 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
bdon/OSMExpress#51 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
bdon/OSMExpress#39 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
bdon/OSMExpress#37 · 2 comentarios ·
Todos los issues de bdon/OSMExpress
Issues similares
-
OMPI 5.0.x CI builds failingAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
sandialabs/Fenix#172 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
scp-fs2open/fs2open.github.com#7953 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
SteveMacenski/slam_toolbox#907 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día