make generated plot HTML reproducible
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 18.8k
- Fork
- 2.8k
- Merge trung bình
- 16 giờ 26 phút
- Pull request đã merge (30 ngày)
- 21
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu từ entry point fig.write_html và truy vết nơi các UUID được chèn vào HTML/JavaScript được tạo ra. So sánh các lần ghi lặp lại của figure mẫu và xác định Plotly nên cung cấp cơ chế tạo UUID xác định hoặc thiết lập seed như thế nào. Hoàn thành khi có thể tạo ra các tệp HTML giống hệt nhau đến từng byte mà không monkey-patch uuid.uuid4 của Python.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- data-visualization
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100