ObjectRef.full_path leaves out the store's location for s3, gcs and azure stores
Los mantenedores suelen responder en 4 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
Línea de trabajo
Empieza en objectref.py, en ObjectRef.full_path, y luego compara sus rutas s3, gcs y azure con StorageBackend._full_path y la rama file. La reproducción muestra que fallan las llamadas ref.fs.exists(ref.full_path) y ref.fs.open(ref.full_path), mientras que ref.read() y ref.fsmap funcionan. El trabajo estará terminado cuando full_path incluya la ubicación del almacenamiento y esas llamadas al sistema de archivos puedan encontrar y abrir el objeto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
On an s3, gcs or azure store with a location, ObjectRef.full_path points to a path where the object is not. ref.fs.exists(ref.full_path) returns False and ref.fs.open(ref.full_path) raises FileNotFoundError, although ref.read() returns the object.
The backend stores an object under <bucket>/<location>/<path> (StorageBackend._full_path). full_path builds s3://<bucket>/<path>, and the same for gs:// and az://, without the location. Its docstring says it includes the "bucket/location", and its file branch does add location.
ref.fsmap builds its root with _full_path, so it is not affected. On a store with an empty location, full_path is correct.
Reproduction
DataJoint 2.3.4 and master, MySQL 8.0, MinIO:
import pathlib
import tempfile
import datajoint as dj
dj.config.stores["outbox"] = {
"protocol": "s3", "endpoint": "localhost:9000", "bucket": "bkt", "location": "proj/outbox",
"access_key": "datajoint", "secret_key": "datajoint", "secure": False,
}
schema = dj.Schema("scratch_full_path")
@schema
class Result(dj.Manual):
definition = """
result_id : int32
---
data : <object@outbox>
"""
src = pathlib.Path(tempfile.mkdtemp()) / "result.txt"
src.write_text("hello")
Result.insert1({"result_id": 1, "data": str(src)})
ref = (Result & {"result_id": 1}).fetch1("data")
ref.read() # b'hello'
ref.full_path # 's3://bkt/_schema/scratch_full_path/result/result_id=1/data_....txt'
ref.fs.exists(ref.full_path) # False
ref.fs.exists(ref.fsmap.root) # True
ref.fs.open(ref.full_path) # FileNotFoundError
Workaround
Use ref.open(), ref.read() or ref.fsmap instead of ref.fs with ref.full_path.
Expected behavior
full_path includes the store's location, so ref.fs.open(ref.full_path) opens the object. For s3, gcs and azure it could return self._backend.get_url(self.path), which already prefixes the protocol to _full_path.
Where
ObjectRef.full_path in objectref.py.
- Lenguaje dominante
- Python
- Estrellas
- 197
- Forks
- 101
- Merge medio
- 3 d 9 h
- PR fusionados (30 d)
- 29
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la 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 datajoint/datajoint-python
-
len() of an expression with an empty primary key generates invalid SQLPosiblemente ocupada @dimitri-yatsenko la tomó hace 11 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
datajoint/datajoint-python#1581 ·
Los mantenedores suelen responder en 4 días
-
dj.Diagram theme: make the font configurablePosiblemente ocupada @dimitri-yatsenko la tomó hace 11 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
datajoint/datajoint-python#1539 · 3 comentarios ·
Los mantenedores suelen responder en 4 días
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
datajoint/datajoint-python#1644 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
bug
Dificultad 4/5 1-2 días Aptitud para principiantes 68/100
datajoint/datajoint-python#1641 ·
Los mantenedores suelen responder en 4 días
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schemaPosiblemente ocupada @dimitri-yatsenko la tomó hace 11 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 82/100
datajoint/datajoint-python#1640 · 1 comentario ·
Los mantenedores suelen responder en 4 días
Todos los issues de datajoint/datajoint-python
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Graphify-Labs/graphify#4860 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
:bug: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
scikit-image/scikit-image#8377 ·
Los mantenedores suelen responder en 1 día
-
Ingredient import validation accepts negative nutrient values and NaNPosiblemente ocupada @LukeSekai la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
wger-project/wger#2564 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/ponymail-foal#351 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
Los mantenedores suelen responder en 4 días