Exemple #1
0
class ProgBar(object):
    
    def __init__(self,max_epoch):
        self.leaf_values = [Value(0) for i in range(1)]
        self.max_epoch = max_epoch
        self.epoch = 0
        self.test_d = {
                'Training Processing:': BarDescriptor(value=self.leaf_values[0],
                                                      type=Bar, 
                                                      kwargs=dict(max_value=self.max_epoch))
                }
        self.t = Terminal()
        self.n = ProgressTree(term=self.t)
        self.n.make_room(self.test_d)


    def incr_value(self):
        if self.epoch < self.max_epoch:
            self.leaf_values[0].value +=1
            self.epoch +=1

    def we_done(self):
        if self.epoch == self.max_epoch:
            return True
        else:
            return False

    def show_progbar(self):
        self.n.cursor.restore()
        self.incr_value()
        self.n.draw(self.test_d)
Exemple #2
0
class TaskGraphics:
    def __init__(self,data,num=__DEFAULT_NUM__):
        self.bind_data=[Value(0) for i in range(num)]
        #self.bind_data=data
        self.terminal=False
        self.bd_defaults=dict(type=Bar,kwargs=dict(max_value=100))
        self.indicator={}
        self.graph_data={}
        for i in range(0,num):
            task_name='task_%d'%i
            self.indicator[i]=task_name
            self.graph_data[task_name]=BarDescriptor(value=self.bind_data[i],**self.bd_defaults)
        self.__init_tree__()
        threading.Thread(target=self.invalidate,args=()).start()
    def __init_tree__(self):
        t=Terminal()
        self.n=ProgressTree(term=t)
        self.n.make_room(self.graph_data)
    def updateTask(self,id,task_name):
        old_task_name=self.indicator[id]
        if task_name == old_task_name:
            return
        self.graph_data[task_name]=self.graph_data[old_task_name]
        self.indicator[id]=task_name
        del self.graph_data[old_task_name]
    def updateValue(self,id,value):
        self.bind_data[id].value=value
    def invalidate(self):
        while not self.terminal:
            time.sleep(0.1)
            self.n.cursor.restore()
            self.n.draw(self.graph_data,BarDescriptor(self.bd_defaults))
    def stop(self):
        self.terminal=True
Exemple #3
0
 def __init__(self,max_epoch):
     self.leaf_values = [Value(0) for i in range(1)]
     self.max_epoch = max_epoch
     self.epoch = 0
     self.test_d = {
             'Training Processing:': BarDescriptor(value=self.leaf_values[0],
                                                   type=Bar, 
                                                   kwargs=dict(max_value=self.max_epoch))
             }
     self.t = Terminal()
     self.n = ProgressTree(term=self.t)
     self.n.make_room(self.test_d)
Exemple #4
0
    def _progress_loop(self, request_method, url, body):
        response = request_method(url, data=json.dumps(body))
        body = response.json()

        max_tasks = body["num_total_tasks"]

        bar = Bar(max_value=max_tasks, title="Completed Tasks",
                  num_rep="percentage", filled_color=2)

        n = ProgressTree(term=self.t)
        n.cursor.clear_lines(self.t.height - 1)

        while True:
            response = request_method(url, data=json.dumps(body))
            body = response.json()

            n.cursor.restore()
            n.cursor.clear_lines(self.t.height - 1)
            n.cursor.save()
            bar.draw(value=body["num_finished_tasks"])

            presp = body
            presp["energy_history"] = sorted(presp["energy_history"])[:10]
            del presp["best_location"]
            print(json.dumps(presp, indent=4))

            if response.status_code == 200:
                return response

            sleep(2.0)
Exemple #5
0
    txmax = dbt.cols.x[dbt.colindexes['x'][-1]].astype(np.int64)
    tymin = dbt.cols.y[dbt.colindexes['y'][0]].astype(np.int64)
    tymax = dbt.cols.y[dbt.colindexes['y'][-1]].astype(np.int64)
    xbounds = (txmin, txmax)
    ybounds = (tymin, tymax)
    print(xbounds)
    print(ybounds)
    xb, yb = neoextent.pad_grid(xbounds, ybounds)

    f2l_mat = np.array([125E3, 250E3, 500E3, 1E6])
    n_img_feat = np.array([1E3, 5E3, 10E3, 20E3])

    # Create blessings.Terminal instance
    leaf_values, test_d = build_progress(f2l_mat, n_img_feat, img_times)
    tt = Terminal()
    prog_tree = ProgressTree(term=tt)
    prog_tree.make_room(test_d)

    # Full aggregate tile id
    tid, tidcount = np.unique(dbt.cols.pair_id, return_counts=True)
    extent = neoextent.SearchExtent(15, xb, yb, tid, tidcount)
    zoom_depth = 14

    # Ok do whatever
    filters = tb.Filters(complevel=5, complib='blosc')
    atom = tb.Float64Atom()
    neogeo_shape = (img_times.nrows, 64, 64)
    times_shape = (img_times.nrows, )
    leaf_ii = 0
    for f2l in f2l_mat:
Exemple #6
0
def tree():
    """Example showing tree progress view"""

    #############
    # Test data #
    #############

    # For this example, we're obviously going to be feeding fictitious data
    #   to ProgressTree, so here it is
    leaf_values = [Value(0) for i in range(6)]
    bd_defaults = dict(type=Bar, kwargs=dict(max_value=10))

    test_d = {
        "Warp Jump": {
            "1) Prepare fuel": {
                "Load Tanks": {
                    "Tank 1": BarDescriptor(value=leaf_values[0],
                                            **bd_defaults),
                    "Tank 2": BarDescriptor(value=leaf_values[1],
                                            **bd_defaults),
                },
                "Refine tylium ore":
                BarDescriptor(value=leaf_values[2], **bd_defaults),
            },
            "2) Calculate jump co-ordinates": {
                "Resolve common name to co-ordinates": {
                    "Querying resolution from baseship":
                    BarDescriptor(value=leaf_values[3], **bd_defaults),
                },
            },
            "3) Perform jump": {
                "Check FTL drive readiness":
                BarDescriptor(value=leaf_values[4], **bd_defaults),
                "Juuuuuump!":
                BarDescriptor(value=leaf_values[5], **bd_defaults)
            }
        }
    }

    # We'll use this function to bump up the leaf values
    def incr_value(obj):
        for val in leaf_values:
            if val.value < 10:
                val.value += 1
                break

    # And this to check if we're to stop drawing
    def are_we_done(obj):
        return all(val.value == 10 for val in leaf_values)

    ###################
    # The actual code #
    ###################

    # Create blessings.Terminal instance
    t = Terminal()
    # Initialize a ProgressTree instance
    n = ProgressTree(term=t)
    # We'll use the make_room method to make sure the terminal
    #   is filled out with all the room we need
    n.make_room(test_d)

    while not are_we_done(test_d):
        sleep(0.2 * random.random())
        # After the cursor position is first saved (in the first draw call)
        #   this will restore the cursor back to the top so we can draw again
        n.cursor.restore()
        # We use our incr_value method to bump the fake numbers
        incr_value(test_d)
        # Actually draw out the bars
        n.draw(test_d, BarDescriptor(bd_defaults))
bd_directories = dict(type=Bar, kwargs=dict(max_value=dir_count, width='50%'))
bd_files = dict(type=Bar, kwargs=dict(max_value=file_count, width='50%'))
bd_defaults = dict(type=Bar,
                   kwargs=dict(max_value=100,
                               width='50%',
                               num_rep='percentage'))

test_d = {
    'Analyze files in %s' % scan_dir: {
        "Directories": BarDescriptor(value=leaf_values[0], **bd_directories),
        "Files": BarDescriptor(value=leaf_values[1], **bd_files)
    }
}

t = Terminal()
n = ProgressTree(term=t)
n.make_room(test_d)


def are_we_done():
    return files_analyzed == file_count


while not are_we_done():
    for root, dirs, files in os.walk(scan_dir, followlinks=False,
                                     topdown=True):
        dirs[:] = [d for d in dirs if d not in exclude]
        for directory_name in dirs:
            directory_name = os.path.join(root, directory_name)
            file_hash = analyze(directory_name).hexdigest()
            upsert_md5_hash(directory_name, file_hash)
def pretty(delete=False):
    import random
    from time import sleep

    from blessings import Terminal

    from progressive.bar import Bar
    from progressive.tree import ProgressTree, Value, BarDescriptor

    leaf_values = [Value(0) for i in range(1)]
    bd_defaults = dict(type=Bar, kwargs=dict(max_value=900))

    test_d = {
        "Verifying [kubeflow]": BarDescriptor(value=leaf_values[0],
                                              **bd_defaults),
        "Verifying [dkube]": BarDescriptor(value=leaf_values[0],
                                           **bd_defaults),
        "Verifying [dkube-ui]": BarDescriptor(value=leaf_values[0],
                                              **bd_defaults),
        "Verifying [argo]": BarDescriptor(value=leaf_values[0], **bd_defaults),
        "Verifying [minio]": BarDescriptor(value=leaf_values[0],
                                           **bd_defaults),
        "Verifying [efk]": BarDescriptor(value=leaf_values[0], **bd_defaults)
    }

    # We'll use this function to bump up the leaf values
    def incr_value(obj):
        for val in leaf_values:
            if val.value < 900:
                val.value += 10
                break

    # And this to check if we're to stop drawing
    def are_we_done(obj):
        return all(val.value == 900 for val in leaf_values)

    ###################
    # The actual code #
    ###################

    # Create blessings.Terminal instance
    t = Terminal()
    # Initialize a ProgressTree instance
    n = ProgressTree(term=t)
    # We'll use the make_room method to make sure the terminal
    #   is filled out with all the room we need
    n.make_room(test_d)

    monitor_freq = 0
    status = False
    while not status and not are_we_done(test_d):
        if monitor_freq >= 60:
            if not delete:
                status = monitorOnCreation()
            else:
                status = monitorOnDeletion()
            monitor_freq = 0
        # After the cursor position is first saved (in the first draw call)
        #   this will restore the cursor back to the top so we can draw again
        n.cursor.restore()
        # We use our incr_value method to bump the fake numbers
        incr_value(test_d)
        # Actually draw out the bars
        n.draw(test_d, BarDescriptor(bd_defaults))
        sleep(10)
        monitor_freq += 10
    return status
Exemple #9
0
def tree():
    """Example showing tree progress view"""

    #############
    # Test data #
    #############

    # For this example, we're obviously going to be feeding fictitious data
    #   to ProgressTree, so here it is
    leaf_values = [Value(0) for i in range(6)]
    bd_defaults = dict(type=Bar, kwargs=dict(max_value=10))

    test_d = {
        "Warp Jump": {
            "1) Prepare fuel": {
                "Load Tanks": {
                    "Tank 1": BarDescriptor(value=leaf_values[0], **bd_defaults),
                    "Tank 2": BarDescriptor(value=leaf_values[1], **bd_defaults),
                },
                "Refine tylium ore": BarDescriptor(
                    value=leaf_values[2], **bd_defaults
                ),
            },
            "2) Calculate jump co-ordinates": {
                "Resolve common name to co-ordinates": {
                    "Querying resolution from baseship": BarDescriptor(
                        value=leaf_values[3], **bd_defaults
                    ),
                },
            },
            "3) Perform jump": {
                "Check FTL drive readiness": BarDescriptor(
                    value=leaf_values[4], **bd_defaults
                ),
                "Juuuuuump!": BarDescriptor(value=leaf_values[5],
                                            **bd_defaults)
            }
        }
    }

    # We'll use this function to bump up the leaf values
    def incr_value(obj):
        for val in leaf_values:
            if val.value < 10:
                val.value += 1
                break

    # And this to check if we're to stop drawing
    def are_we_done(obj):
        return all(val.value == 10 for val in leaf_values)

    ###################
    # The actual code #
    ###################

    # Create blessings.Terminal instance
    t = Terminal()
    # Initialize a ProgressTree instance
    n = ProgressTree(term=t)
    # We'll use the make_room method to make sure the terminal
    #   is filled out with all the room we need
    n.make_room(test_d)

    while not are_we_done(test_d):
        sleep(0.2 * random.random())
        # After the cursor position is first saved (in the first draw call)
        #   this will restore the cursor back to the top so we can draw again
        n.cursor.restore()
        # We use our incr_value method to bump the fake numbers
        incr_value(test_d)
        # Actually draw out the bars
        n.draw(test_d, BarDescriptor(bd_defaults))
Exemple #10
0
def FMOTF(
    f5,
    f5featmeta,
    dted_path,
    geoid_file,
    frame_yaml,
    cam_yaml,
    dbf,
    out_path,
):
    # f5 = tb.open_file('/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/fc2_f5.hdf', 'r')
    # f5featmeta = pd.read_hdf('/media/sean/D2F2E7B2F2E798CD/Users/student/AIEoutput2/feat/feat_meta.hdf')
    img_times = f5.root.camera.image_raw.compressed.metadata.col('t_valid')
    feat_path = f5featmeta.iloc[:, 3]
    descripath = f5featmeta.iloc[:, 4]

    # Get a truth finder
    # dted_path = '/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/srtm'
    # geoid_file = '/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/egm96-15.tif'
    # frame_yaml = '/home/sean/ImageAidedNav/pypnp/data/fc2_pod_frames.yaml'
    # cam_yaml = '/home/sean/ImageAidedNav/pypnp/data/fc2_cam_model.yaml'

    finder = pnputils.DEMTileFinder(dted_path, geoid_file)
    finder.load_cam_and_vehicle_frames(frame_yaml)
    finder.load_camera_cal(cam_yaml)

    # Get the Feature Database
    # dbf = tb.open_file('/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/pytables_db.hdf', 'r')
    dbt = dbf.get_node('/sift_db/sift_features_sorted')

    # Set up the output file
    # out_path = '/media/sean/D2F2E7B2F2E798CD/Users/student/neo_data/obs_out_mat7.hdf'
    out_tb = tb.open_file(out_path, 'w')

    # You need boundaries
    txmin = dbt.cols.x[dbt.colindexes['x'][0]].astype(np.int64)
    txmax = dbt.cols.x[dbt.colindexes['x'][-1]].astype(np.int64)
    tymin = dbt.cols.y[dbt.colindexes['y'][0]].astype(np.int64)
    tymax = dbt.cols.y[dbt.colindexes['y'][-1]].astype(np.int64)
    xbounds = (txmin, txmax)
    ybounds = (tymin, tymax)
    print(xbounds)
    print(ybounds)
    xb, yb = neoextent.pad_grid(xbounds, ybounds)
    # TODO Redefine xb and yb to be the tiles that encompassed the area defined by the particles and/or confidence ellipse

    f2l_mat = np.array([1E6])
    n_img_feat = np.array([10E3])

    # Create blessings.Terminal instance
    leaf_values, test_d = build_progress(f2l_mat, n_img_feat, img_times)
    tt = Terminal()
    prog_tree = ProgressTree(term=tt)
    prog_tree.make_room(test_d)

    # Full aggregate tile id
    tid, tidcount = np.unique(dbt.cols.pair_id, return_counts=True)
    extent = neoextent.SearchExtent(15, xb, yb, tid, tidcount)
    zoom_depth = 15  # orginal value was 14

    # Ok do whatever
    filters = tb.Filters(complevel=5, complib='blosc')
    atom = tb.Float64Atom()
    neogeo_shape = (img_times.size, 64, 64)
    times_shape = (img_times.size, )
    leaf_ii = 0
    for f2l in f2l_mat:

        f2l_group = out_tb.create_group(out_tb.root, 'loaded_%d' % int(f2l))
        f2l_group.num_feat_loaded = f2l
        db_rows, N = load_all_features(dbt, extent, zoom_depth, f2l)
        flann, t_build_db = build_flann_db(db_rows)
        f2l_group.time_to_build_flann = t_build_db
        obs_shape = (img_times.size, db_rows.shape[0], 4)
        for n_img in n_img_feat:
            n_group = out_tb.create_group(f2l_group, 'feat_%d' % int(n_img))
            n_group.img_feat = n_img
            neogeo_out = out_tb.create_carray(n_group,
                                              'neogeo_out',
                                              atom=atom,
                                              shape=neogeo_shape,
                                              filters=filters)
            obs_out = out_tb.create_carray(n_group,
                                           'obs_out',
                                           atom=atom,
                                           shape=obs_shape,
                                           filters=filters)
            # print(neogeo_out)
            flann_time = out_tb.create_carray(n_group,
                                              'flann_time',
                                              atom=atom,
                                              shape=times_shape,
                                              filters=filters)
            # dbloc = out_tb.create_carray(n_group,'dbloc',atom=atom, shape=dbloc_shape, filters=filters)
            for img_num in np.arange(img_times.size):
                if f5featmeta.num_feat[img_num] > 0:
                    generate_obs(img_num, n_img, db_rows, obs_out, neogeo_out,
                                 flann_time, flann)
                    leaf_values[leaf_ii].value += 1
                    # if np.mod(leaf_values[leaf_ii].value, 5) == 0:
                    #     prog_tree.cursor.restore()
                    #     prog_tree.draw(test_d)

            leaf_ii += 1
            out_tb.flush()

    out_tb.close()
    dbf.close()
    f5.close()
Exemple #11
0
        self.p_id[_p_id] = _p_id
        self.arrive_time[_p_id] = _arrive_time
        self.service_time[_p_id] = _service_time
        self.finish_time[_p_id] = 0
        self.remain_time[_p_id] = _service_time

    def process_exit(self, _p_id):
        self.p_id.pop(_p_id)
        self.arrive_time.pop(_p_id)
        self.service_time.pop(_p_id)
        self.finish_time.pop(_p_id)
        self.remain_time.pop(_p_id)


t = Terminal()
n = ProgressTree(term=t)


class Processor(object):
    def __init__(self, _p_id, _arrive_time, _service_time):
        self.current_time = 0
        self.result = []
        self.process = Process(p_id, _arrive_time, _service_time)
        # self.process.add_process('B', 2, 6)
        # self.process.add_process('C', 4, 4)
        # self.process.add_process('D', 6, 5)
        # self.process.add_process('E', 8, 2)

    def all_process_done(self):
        for p in self.process.p_id:
            if self.process.remain_time[p] != 0:
Exemple #12
0
 def __init_tree__(self):
     t=Terminal()
     self.n=ProgressTree(term=t)
     self.n.make_room(self.graph_data)
Exemple #13
0
hx4.tare()

leaf_values = [Value(0) for i in range(4)]
bd_defaults = dict(type=Bar, kwargs=dict(max_value=MAX_BAR_VALUE, width=BAR_WID$

test_d = {
"Carb 1": BarDescriptor(value=leaf_values[0], **bd_defaults),
"Carb 2": BarDescriptor(value=leaf_values[1], **bd_defaults),
"Carb 3": BarDescriptor(value=leaf_values[2], **bd_defaults),
"Carb 4": BarDescriptor(value=leaf_values[3], **bd_defaults),
}

# Create blessings.Terminal instance
t = Terminal()
# Initialize a ProgressTree instance
n = ProgressTree(term=t)
# We'll use the make_room method to make sure the terminal
# is filled out with all the room we need
os.system('clear')
n.make_room(test_d)
#n.cursor.save()
while True:
    try:
        # These three lines are usefull to debug wether to use MSB or LSB in th$
        # for the first parameter of "hx.set_reading_format("LSB", "MSB")".
        # Comment the two lines "val = hx.get_weight(5)" and "print val" and un$
        #np_arr8_string = hx.get_np_arr8_string()
        #binary_string = hx.get_binary_string()
        #print binary_string + " " + np_arr8_string
        
        # Prints the weight. Comment if you're debbuging the MSB and LSB issue.