def data_viewer(data_id): data = db_manager.get_data(data_id=data_id) data_dict = data.__dict__ op = Op(id=data_dict["id"]) print(type(op.output).__name__) if type(op.output).__name__ == 'float': data_dict['output'] = op.output data_dict['shape'] = 1 else: data_dict['output'] = op.output.tolist() data_dict['shape'] = op.output.shape return render_template('data_viewer.html', data=data_dict)
def __init__(self, id=None, value=None, dtype=None, **kwargs): self._data_db = None if id is not None: self._data_db = db.get_data(data_id=id) if self._data_db is None: raise Exception("Invalid data id") elif value is not None and dtype is not None: if type(value).__name__ == "list": value = np.array(value) elif type(value).__name__ == "str": x = json.loads(value) if type(x).__name__ == "list": value = np.array(value) self._data_db = self.__create(value=value, dtype=dtype) if self._data_db is None: raise Exception("Unable to create data")
def parse_op_inputs_outputs(op_dict): print(op_dict['inputs']) if op_dict.get("inputs") is not None and op_dict.get("inputs") != "null": inputs = ast.literal_eval(op_dict['inputs']) inputs_list = [] for op_id in inputs: inputs_list.append(db_manager.get_op(op_id=op_id).__dict__) op_dict['inputs'] = inputs_list else: op_dict["inputs"] = [] if op_dict.get("outputs") is not None and op_dict.get("outputs") != "null": outputs = ast.literal_eval(op_dict['outputs']) outputs_list = [] for data_id in outputs: outputs_list.append(db_manager.get_data(data_id=data_id).__dict__) op_dict['outputs'] = outputs_list else: op_dict['outputs'] = [] return op_dict