Passed
Push — master ( 7e35c2...37974c )
by Simon
03:12
created

hyperactive.dashboards.progress_board.progress_board   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ProgressBoard.__init__() 0 7 1
A ProgressBoard.open_dashboard() 0 9 1
A ProgressBoard.init_paths() 0 9 2
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
6
import os
7
import uuid
8
9
from ...data_tools import DataCollector
10
from .progress_io import ProgressIO
11
12
13
class ProgressBoard:
14
    def __init__(self, filter_file=None):
15
        self.filter_file = filter_file
16
17
        self.uuid = uuid.uuid4().hex
18
        self.search_ids = []
19
20
        self._io_ = ProgressIO("./")
21
22
    def init_paths(self, search_id, search_space):
23
        self._io_.remove_progress(search_id)
24
        data_c = DataCollector(self._io_.get_progress_data_path(search_id))
25
26
        self.search_ids.append(search_id)
27
        if self.filter_file:
28
            self._io_.create_filter(search_id, search_space)
29
30
        return data_c
31
32
    def open_dashboard(self):
33
        abspath = os.path.abspath(__file__)
34
        dir_ = os.path.dirname(abspath)
35
36
        paths = " ".join(self.search_ids)
37
        open_streamlit = "streamlit run " + dir_ + "/run_streamlit.py " + paths
38
39
        # from: https://stackoverflow.com/questions/7574841/open-a-terminal-from-python
40
        os.system("gnome-terminal -e 'bash -c \" " + open_streamlit + " \"'")
41