make generated plot HTML reproducible
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 18.8k
- Forks
- 2.8k
- Merge médio
- 16h 26min
- PRs com merge (30d)
- 21
Descrição
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.
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.
Direção de pesquisa
Comece pelo ponto de entrada fig.write_html e rastreie onde os UUIDs são inseridos no HTML/JavaScript gerado. Compare gravações repetidas da figura de exemplo e determine como o Plotly deveria expor a geração determinística de UUIDs ou a definição de uma seed. A tarefa estará concluída quando for possível gerar arquivos HTML idênticos byte a byte sem fazer monkey-patching de uuid.uuid4 do Python.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- data-visualization
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100