1
|
|
|
# Author: Simon Blanke |
2
|
|
|
# Email: [email protected] |
3
|
|
|
# License: MIT License |
4
|
|
|
|
5
|
|
|
import os |
6
|
|
|
import sys |
7
|
|
|
import time |
8
|
|
|
import streamlit as st |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
from streamlit_backend import StreamlitBackend |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
def main(): |
15
|
|
|
try: |
16
|
|
|
st.set_page_config(page_title="Hyperactive Progress Board", layout="wide") |
17
|
|
|
except: |
18
|
|
|
pass |
19
|
|
|
|
20
|
|
|
search_ids = sys.argv[1:] |
21
|
|
|
backend = StreamlitBackend(search_ids) |
22
|
|
|
lock_files = [] |
23
|
|
|
|
24
|
|
|
for search_id in search_ids: |
25
|
|
|
st.title(search_id) |
26
|
|
|
st.components.v1.html( |
27
|
|
|
"""<hr style="height:1px;border:none;color:#333;background-color:#333;" /> """, |
28
|
|
|
height=10, |
29
|
|
|
) |
30
|
|
|
col1, col2 = st.beta_columns([1, 2]) |
31
|
|
|
|
32
|
|
|
progress_data = backend.get_progress_data(search_id) |
33
|
|
|
|
34
|
|
|
pyplot_fig = backend.pyplot(progress_data) |
35
|
|
|
plotly_fig = backend.plotly(progress_data, search_id) |
36
|
|
|
|
37
|
|
|
if pyplot_fig is not None: |
38
|
|
|
col1.pyplot(pyplot_fig) |
39
|
|
|
if plotly_fig is not None: |
40
|
|
|
col2.plotly_chart(plotly_fig) |
41
|
|
|
|
42
|
|
|
last_best = backend.create_info(search_id) |
43
|
|
|
if last_best is not None: |
44
|
|
|
last_best = last_best.assign(hack="").set_index("hack") |
45
|
|
|
st.table(last_best) |
46
|
|
|
|
47
|
|
|
for _ in range(3): |
48
|
|
|
st.write(" ") |
49
|
|
|
|
50
|
|
|
lock_file = backend._io_.get_lock_file_path(search_id) |
51
|
|
|
lock_files.append(os.path.isfile(lock_file)) |
52
|
|
|
|
53
|
|
|
time.sleep(1) |
54
|
|
|
if all(lock_file is False for lock_file in lock_files): |
55
|
|
|
print("\n --- Deleting progress- and filter-files --- \n") |
56
|
|
|
|
57
|
|
|
for search_id in search_ids: |
58
|
|
|
backend._io_.remove_progress(search_id) |
59
|
|
|
backend._io_.remove_filter(search_id) |
60
|
|
|
|
61
|
|
|
else: |
62
|
|
|
print("\n --- Rerun streamlit --- \n") |
63
|
|
|
st.experimental_rerun() |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
if __name__ == "__main__": |
67
|
|
|
main() |
68
|
|
|
|