make generated plot HTML reproducible
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 18.8k
- Forks
- 2.8k
- Merge medio
- 16 h 26 min
- PR fusionados (30 d)
- 21
Descripción
The HTML/js contains UUIDs generated by python's built-in uuid.uuid4. By nature, those are unique and totally random.
But if you generate documents as part of a pipeline (e.g. via https://dvc.org/ ) then it would be great to have them reproducible down to the byte.
import plotly.express as px
fig =px.scatter(x=range(10), y=range(10))
fig.write_html("file1.html")
fig.write_html("file2.html")
The files will be identical except from the UUIDs.
I "solved" this problem by monkey-patching the relevant function:
# monkey patch
import uuid
import random
uuid4_rnd = random.Random(0)
def uuid4_seeded():
"""Generate a random UUID using random.Random"""
return uuid.UUID(bytes=uuid4_rnd.randbytes(16), version=4)
uuid.uuid4 = uuid4_seeded
fig =px.scatter(x=range(10), y=range(10))
fig.write_html("file.html")
re-executing this snippet will produce identical files.
It would be great to exchange one function (or set a seed for an internal version of uuid) in plotly instead of hijacking the python built-in.
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.
Línea de trabajo
Comienza en el punto de entrada fig.write_html y sigue dónde se insertan los UUID en el HTML/JavaScript generado. Compara escrituras repetidas de la figura de ejemplo y determina cómo debería exponer Plotly la generación determinista de UUID o la inicialización de su semilla. Se considera terminado cuando se puedan generar archivos HTML idénticos byte por byte sin hacer monkey-patching de uuid.uuid4 de Python.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- data-visualization
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100