diff --git a/protocol/innpv.proto b/protocol/innpv.proto index 688d378..ed5b73c 100644 --- a/protocol/innpv.proto +++ b/protocol/innpv.proto @@ -104,9 +104,10 @@ message HabitatResponse { message EnergyResponse { float total_consumption = 1; repeated EnergyConsumptionComponent components = 2; + int32 batch_size = 3; // A list of past energy measurements - repeated EnergyResponse past_measurements = 3; + repeated EnergyResponse past_measurements = 4; } // Reports the energy consumption of one system component (e.g. CPU+DRAM or GPU) diff --git a/skyline/analysis/session.py b/skyline/analysis/session.py index cbe1d5a..e23f700 100644 --- a/skyline/analysis/session.py +++ b/skyline/analysis/session.py @@ -150,45 +150,46 @@ def energy_compute(self) -> pm.EnergyResponse: for _ in range(iterations): iteration(*inputs) energy_measurer.end_measurement() - - resp.total_consumption = energy_measurer.total_energy()/float(iterations) - - components = [] - components_joules = [] - - if energy_measurer.cpu_energy() is not None: - cpu_component = pm.EnergyConsumptionComponent() - cpu_component.component_type = pm.ENERGY_CPU_DRAM - cpu_component.consumption_joules = energy_measurer.cpu_energy()/float(iterations) - components.append(cpu_component) - components_joules.append(cpu_component.consumption_joules) - else: - cpu_component = pm.EnergyConsumptionComponent() - cpu_component.component_type = pm.ENERGY_CPU_DRAM - cpu_component.consumption_joules = 0.0 - components.append(cpu_component) - components_joules.append(cpu_component.consumption_joules) - - gpu_component = pm.EnergyConsumptionComponent() - gpu_component.component_type = pm.ENERGY_NVIDIA - gpu_component.consumption_joules = energy_measurer.gpu_energy()/float(iterations) - components.append(gpu_component) - components_joules.append(gpu_component.consumption_joules) - - resp.components.extend(components) - - # get last 10 runs if they exist - path_to_entry_point = os.path.join(self._project_root, self._entry_point) - past_runs = self._energy_table_interface.get_latest_n_entries_of_entry_point(10, path_to_entry_point) - print(past_runs) - resp.past_measurements.extend(_convert_to_energy_responses(past_runs)) - - # add current run to database - self._energy_table_interface.add_entry([path_to_entry_point] + components_joules) - except PermissionError as err: # Remind user to set their CPU permissions print(err) + + resp.total_consumption = energy_measurer.total_energy()/float(iterations) + resp.batch_size = self._batch_size + + components = [] + components_joules = [] + + if energy_measurer.cpu_energy() is not None: + cpu_component = pm.EnergyConsumptionComponent() + cpu_component.component_type = pm.ENERGY_CPU_DRAM + cpu_component.consumption_joules = energy_measurer.cpu_energy()/float(iterations) + components.append(cpu_component) + components_joules.append(cpu_component.consumption_joules) + else: + cpu_component = pm.EnergyConsumptionComponent() + cpu_component.component_type = pm.ENERGY_CPU_DRAM + cpu_component.consumption_joules = 0.0 + components.append(cpu_component) + components_joules.append(cpu_component.consumption_joules) + + gpu_component = pm.EnergyConsumptionComponent() + gpu_component.component_type = pm.ENERGY_NVIDIA + gpu_component.consumption_joules = energy_measurer.gpu_energy()/float(iterations) + components.append(gpu_component) + components_joules.append(gpu_component.consumption_joules) + + resp.components.extend(components) + + # get last 10 runs if they exist + path_to_entry_point = os.path.join(self._project_root, self._entry_point) + past_runs = self._energy_table_interface.get_latest_n_entries_of_entry_point(10, path_to_entry_point) + resp.past_measurements.extend(_convert_to_energy_responses(past_runs)) + + # add current run to database + current_entry = [path_to_entry_point] + components_joules + current_entry.append(self._batch_size) + self._energy_table_interface.add_entry(current_entry) return resp def habitat_compute_threshold(self, runnable, context): @@ -602,5 +603,8 @@ def _convert_to_energy_responses(entries: list)-> List[pm.EnergyResponse]: energy_response.total_consumption = gpu_component.consumption_joules+cpu_component.consumption_joules energy_response.components.extend([cpu_component, gpu_component]) + + energy_response.batch_size = entry[3] energy_response_list.append(energy_response) + return energy_response_list diff --git a/skyline/db/database.py b/skyline/db/database.py index 9aa32c6..ac90214 100644 --- a/skyline/db/database.py +++ b/skyline/db/database.py @@ -5,7 +5,6 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) DB_PATH = os.path.join(BASE_DIR, "deepview.sqlite3") - class DatabaseInterface: def __init__(self, database_name=DB_PATH) -> None: self.connection = sqlite3.connect(database_name, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) @@ -16,6 +15,7 @@ def create_energy_table(self) -> None: entry_point TEXT, \ cpu_component REAL, \ gpu_component REAL, \ + batch_size INT, \ ts TIMESTAMP \ );") @@ -31,8 +31,8 @@ def is_valid_entry(entry: list) -> bool: and the types match the columns. Note that timestamp is not part of the entry. Returns True if it is valid, else False ''' - return len(entry) == 3 and type(entry[0]) == str and type(entry[1]) == float \ - and type(entry[2]) == float + return len(entry) == 4 and type(entry[0]) == str and type(entry[1]) == float \ + and type(entry[2]) == float and type(entry[3]) == int @staticmethod def is_valid_entry_with_timestamp(entry: list) -> bool: @@ -40,8 +40,9 @@ def is_valid_entry_with_timestamp(entry: list) -> bool: Validates an entry in the Energy table by testing if the length is 4, and the types match the columns. Returns True if it is valid, else False ''' - return len(entry) == 4 and type(entry[0]) == str and type(entry[1]) == float \ - and type(entry[2]) == float and type(entry[3]) == datetime.datetime + return len(entry) == 5 and type(entry[0]) == str and type(entry[1]) == float \ + and type(entry[2]) == float and type(entry[3]) == int \ + and type(entry[4]) == datetime.datetime def add_entry(self, entry: list) -> bool: ''' @@ -53,14 +54,14 @@ def add_entry(self, entry: list) -> bool: try: entry.append(datetime.datetime.now()) cursor = self.database_connection.cursor() - cursor.execute("INSERT INTO ENERGY VALUES(?, ?, ?, ?)", entry) + cursor.execute("INSERT INTO ENERGY VALUES(?, ?, ?, ?, ?)", entry) self.database_connection.commit() return True except sqlite3.IntegrityError as e: print(e) return False else: - return True + return False def get_latest_n_entries_of_entry_point(self, n: int, entry_point: str) -> list: ''' diff --git a/skyline/protocol_gen/innpv_pb2.py b/skyline/protocol_gen/innpv_pb2.py index 6fa9c0d..967c333 100644 --- a/skyline/protocol_gen/innpv_pb2.py +++ b/skyline/protocol_gen/innpv_pb2.py @@ -20,7 +20,7 @@ syntax='proto3', serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x0binnpv.proto\x12\x0einnpv.protocol\"\xcf\x01\n\nFromClient\x12\x17\n\x0fsequence_number\x18\x01 \x01(\r\x12\x37\n\ninitialize\x18\x02 \x01(\x0b\x32!.innpv.protocol.InitializeRequestH\x00\x12\x33\n\x08\x61nalysis\x18\x03 \x01(\x0b\x32\x1f.innpv.protocol.AnalysisRequestH\x00\x12/\n\x07generic\x18\x04 \x01(\x0b\x32\x1c.innpv.protocol.GenericEventH\x00\x42\t\n\x07payload\">\n\x0cGenericEvent\x12\x12\n\nevent_type\x18\x01 \x01(\t\x12\x1a\n\x12optional_arguments\x18\x02 \x01(\t\"X\n\x11InitializeRequest\x12\x18\n\x10protocol_version\x18\x01 \x01(\r\x12\x14\n\x0cproject_root\x18\x02 \x01(\t\x12\x13\n\x0b\x65ntry_point\x18\x03 \x01(\t\"(\n\x0f\x41nalysisRequest\x12\x15\n\rmock_response\x18\x01 \x01(\x08\"\xcf\x03\n\nFromServer\x12\x17\n\x0fsequence_number\x18\x01 \x01(\r\x12.\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x1d.innpv.protocol.ProtocolErrorH\x00\x12\x38\n\ninitialize\x18\x03 \x01(\x0b\x32\".innpv.protocol.InitializeResponseH\x00\x12\x37\n\x0e\x61nalysis_error\x18\x05 \x01(\x0b\x32\x1d.innpv.protocol.AnalysisErrorH\x00\x12\x38\n\nthroughput\x18\x06 \x01(\x0b\x32\".innpv.protocol.ThroughputResponseH\x00\x12\x36\n\tbreakdown\x18\x08 \x01(\x0b\x32!.innpv.protocol.BreakdownResponseH\x00\x12\x32\n\x07habitat\x18\t \x01(\x0b\x32\x1f.innpv.protocol.HabitatResponseH\x00\x12\x30\n\x06\x65nergy\x18\n \x01(\x0b\x32\x1e.innpv.protocol.EnergyResponseH\x00\x42\t\n\x07payloadJ\x04\x08\x04\x10\x05J\x04\x08\x07\x10\x08R\x0cmemory_usageR\x08run_time\"B\n\x17HabitatDevicePrediction\x12\x13\n\x0b\x64\x65vice_name\x18\x01 \x01(\t\x12\x12\n\nruntime_ms\x18\x02 \x01(\x02\"O\n\x0fHabitatResponse\x12<\n\x0bpredictions\x18\x01 \x03(\x0b\x32\'.innpv.protocol.HabitatDevicePrediction\"\xa6\x01\n\x0e\x45nergyResponse\x12\x19\n\x11total_consumption\x18\x01 \x01(\x02\x12>\n\ncomponents\x18\x02 \x03(\x0b\x32*.innpv.protocol.EnergyConsumptionComponent\x12\x39\n\x11past_measurements\x18\x03 \x03(\x0b\x32\x1e.innpv.protocol.EnergyResponse\"\x80\x01\n\x1a\x45nergyConsumptionComponent\x12\x46\n\x0e\x63omponent_type\x18\x01 \x01(\x0e\x32..innpv.protocol.EnergyConsumptionComponentType\x12\x1a\n\x12\x63onsumption_joules\x18\x02 \x01(\x02\"\x8c\x01\n\x12InitializeResponse\x12\x1b\n\x13server_project_root\x18\x01 \x01(\t\x12)\n\x0b\x65ntry_point\x18\x02 \x01(\x0b\x32\x14.innpv.protocol.Path\x12.\n\x08hardware\x18\x03 \x01(\x0b\x32\x1c.innpv.protocol.HardwareInfo\"[\n\rAnalysisError\x12\x15\n\rerror_message\x18\x01 \x01(\t\x12\x33\n\x0c\x66ile_context\x18\x02 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\"\xa1\x02\n\x12ThroughputResponse\x12\x1a\n\x12samples_per_second\x18\x01 \x01(\x02\x12(\n predicted_max_samples_per_second\x18\x02 \x01(\x02\x12\x30\n\x0brun_time_ms\x18\x03 \x01(\x0b\x32\x1b.innpv.protocol.LinearModel\x12\x35\n\x10peak_usage_bytes\x18\x04 \x01(\x0b\x32\x1b.innpv.protocol.LinearModel\x12\x39\n\x12\x62\x61tch_size_context\x18\x05 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\x12!\n\x19\x63\x61n_manipulate_batch_size\x18\x06 \x01(\x08\"\xea\x01\n\x11\x42reakdownResponse\x12\x18\n\x10peak_usage_bytes\x18\x01 \x01(\x04\x12\x1d\n\x15memory_capacity_bytes\x18\x02 \x01(\x04\x12\x1d\n\x15iteration_run_time_ms\x18\x03 \x01(\x02\x12\x12\n\nbatch_size\x18\x06 \x01(\r\x12\x35\n\x0eoperation_tree\x18\x04 \x03(\x0b\x32\x1d.innpv.protocol.BreakdownNode\x12\x32\n\x0bweight_tree\x18\x05 \x03(\x0b\x32\x1d.innpv.protocol.BreakdownNode\"\xca\x01\n\rProtocolError\x12;\n\nerror_code\x18\x01 \x01(\x0e\x32\'.innpv.protocol.ProtocolError.ErrorCode\"|\n\tErrorCode\x12\x0b\n\x07UNKNOWN\x10\x00\x12 \n\x1cUNSUPPORTED_PROTOCOL_VERSION\x10\x01\x12\x1c\n\x18UNINITIALIZED_CONNECTION\x10\x02\x12\"\n\x1e\x41LREADY_INITIALIZED_CONNECTION\x10\x03\"\x1a\n\x04Path\x12\x12\n\ncomponents\x18\x01 \x03(\t\"M\n\rFileReference\x12\'\n\tfile_path\x18\x01 \x01(\x0b\x32\x14.innpv.protocol.Path\x12\x13\n\x0bline_number\x18\x02 \x01(\r\"\xce\x01\n\rBreakdownNode\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0cnum_children\x18\x02 \x01(\r\x12/\n\x08\x63ontexts\x18\x03 \x03(\x0b\x32\x1d.innpv.protocol.FileReference\x12\x32\n\toperation\x18\x04 \x01(\x0b\x32\x1d.innpv.protocol.OperationDataH\x00\x12,\n\x06weight\x18\x05 \x01(\x0b\x32\x1a.innpv.protocol.WeightDataH\x00\x42\x06\n\x04\x64\x61ta\"{\n\x0b\x43ontextInfo\x12.\n\x07\x63ontext\x18\x01 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\x12\x13\n\x0brun_time_ms\x18\x02 \x01(\x02\x12\x12\n\nsize_bytes\x18\x03 \x01(\x04\x12\x13\n\x0binvocations\x18\x04 \x01(\r\"\x83\x01\n\rOperationData\x12\x12\n\nforward_ms\x18\x01 \x01(\x02\x12\x13\n\x0b\x62\x61\x63kward_ms\x18\x02 \x01(\x02\x12\x12\n\nsize_bytes\x18\x03 \x01(\x04\x12\x35\n\x10\x63ontext_info_map\x18\x04 \x03(\x0b\x32\x1b.innpv.protocol.ContextInfo\"9\n\nWeightData\x12\x12\n\nsize_bytes\x18\x01 \x01(\x04\x12\x17\n\x0fgrad_size_bytes\x18\x02 \x01(\x04\"*\n\x0bLinearModel\x12\r\n\x05slope\x18\x01 \x01(\x01\x12\x0c\n\x04\x62ias\x18\x02 \x01(\x01\":\n\x0cHardwareInfo\x12\x10\n\x08hostname\x18\x01 \x01(\t\x12\n\n\x02os\x18\x02 \x01(\t\x12\x0c\n\x04gpus\x18\x03 \x03(\t\"\x1b\n\x13MemoryUsageResponseJ\x04\x08\x01\x10\x65\"\x17\n\x0fRunTimeResponseJ\x04\x08\x01\x10\x65\"\x17\n\x0f\x41\x63tivationEntryJ\x04\x08\x01\x10\x65\"\x13\n\x0bWeightEntryJ\x04\x08\x01\x10\x65\"\x14\n\x0cRunTimeEntryJ\x04\x08\x01\x10\x65*`\n\x1e\x45nergyConsumptionComponentType\x12\x16\n\x12\x45NERGY_UNSPECIFIED\x10\x00\x12\x13\n\x0f\x45NERGY_CPU_DRAM\x10\x01\x12\x11\n\rENERGY_NVIDIA\x10\x02\x62\x06proto3' + serialized_pb=b'\n\x0binnpv.proto\x12\x0einnpv.protocol\"\xcf\x01\n\nFromClient\x12\x17\n\x0fsequence_number\x18\x01 \x01(\r\x12\x37\n\ninitialize\x18\x02 \x01(\x0b\x32!.innpv.protocol.InitializeRequestH\x00\x12\x33\n\x08\x61nalysis\x18\x03 \x01(\x0b\x32\x1f.innpv.protocol.AnalysisRequestH\x00\x12/\n\x07generic\x18\x04 \x01(\x0b\x32\x1c.innpv.protocol.GenericEventH\x00\x42\t\n\x07payload\">\n\x0cGenericEvent\x12\x12\n\nevent_type\x18\x01 \x01(\t\x12\x1a\n\x12optional_arguments\x18\x02 \x01(\t\"X\n\x11InitializeRequest\x12\x18\n\x10protocol_version\x18\x01 \x01(\r\x12\x14\n\x0cproject_root\x18\x02 \x01(\t\x12\x13\n\x0b\x65ntry_point\x18\x03 \x01(\t\"(\n\x0f\x41nalysisRequest\x12\x15\n\rmock_response\x18\x01 \x01(\x08\"\xcf\x03\n\nFromServer\x12\x17\n\x0fsequence_number\x18\x01 \x01(\r\x12.\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x1d.innpv.protocol.ProtocolErrorH\x00\x12\x38\n\ninitialize\x18\x03 \x01(\x0b\x32\".innpv.protocol.InitializeResponseH\x00\x12\x37\n\x0e\x61nalysis_error\x18\x05 \x01(\x0b\x32\x1d.innpv.protocol.AnalysisErrorH\x00\x12\x38\n\nthroughput\x18\x06 \x01(\x0b\x32\".innpv.protocol.ThroughputResponseH\x00\x12\x36\n\tbreakdown\x18\x08 \x01(\x0b\x32!.innpv.protocol.BreakdownResponseH\x00\x12\x32\n\x07habitat\x18\t \x01(\x0b\x32\x1f.innpv.protocol.HabitatResponseH\x00\x12\x30\n\x06\x65nergy\x18\n \x01(\x0b\x32\x1e.innpv.protocol.EnergyResponseH\x00\x42\t\n\x07payloadJ\x04\x08\x04\x10\x05J\x04\x08\x07\x10\x08R\x0cmemory_usageR\x08run_time\"B\n\x17HabitatDevicePrediction\x12\x13\n\x0b\x64\x65vice_name\x18\x01 \x01(\t\x12\x12\n\nruntime_ms\x18\x02 \x01(\x02\"O\n\x0fHabitatResponse\x12<\n\x0bpredictions\x18\x01 \x03(\x0b\x32\'.innpv.protocol.HabitatDevicePrediction\"\xba\x01\n\x0e\x45nergyResponse\x12\x19\n\x11total_consumption\x18\x01 \x01(\x02\x12>\n\ncomponents\x18\x02 \x03(\x0b\x32*.innpv.protocol.EnergyConsumptionComponent\x12\x12\n\nbatch_size\x18\x03 \x01(\x05\x12\x39\n\x11past_measurements\x18\x04 \x03(\x0b\x32\x1e.innpv.protocol.EnergyResponse\"\x80\x01\n\x1a\x45nergyConsumptionComponent\x12\x46\n\x0e\x63omponent_type\x18\x01 \x01(\x0e\x32..innpv.protocol.EnergyConsumptionComponentType\x12\x1a\n\x12\x63onsumption_joules\x18\x02 \x01(\x02\"\x8c\x01\n\x12InitializeResponse\x12\x1b\n\x13server_project_root\x18\x01 \x01(\t\x12)\n\x0b\x65ntry_point\x18\x02 \x01(\x0b\x32\x14.innpv.protocol.Path\x12.\n\x08hardware\x18\x03 \x01(\x0b\x32\x1c.innpv.protocol.HardwareInfo\"[\n\rAnalysisError\x12\x15\n\rerror_message\x18\x01 \x01(\t\x12\x33\n\x0c\x66ile_context\x18\x02 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\"\xa1\x02\n\x12ThroughputResponse\x12\x1a\n\x12samples_per_second\x18\x01 \x01(\x02\x12(\n predicted_max_samples_per_second\x18\x02 \x01(\x02\x12\x30\n\x0brun_time_ms\x18\x03 \x01(\x0b\x32\x1b.innpv.protocol.LinearModel\x12\x35\n\x10peak_usage_bytes\x18\x04 \x01(\x0b\x32\x1b.innpv.protocol.LinearModel\x12\x39\n\x12\x62\x61tch_size_context\x18\x05 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\x12!\n\x19\x63\x61n_manipulate_batch_size\x18\x06 \x01(\x08\"\xea\x01\n\x11\x42reakdownResponse\x12\x18\n\x10peak_usage_bytes\x18\x01 \x01(\x04\x12\x1d\n\x15memory_capacity_bytes\x18\x02 \x01(\x04\x12\x1d\n\x15iteration_run_time_ms\x18\x03 \x01(\x02\x12\x12\n\nbatch_size\x18\x06 \x01(\r\x12\x35\n\x0eoperation_tree\x18\x04 \x03(\x0b\x32\x1d.innpv.protocol.BreakdownNode\x12\x32\n\x0bweight_tree\x18\x05 \x03(\x0b\x32\x1d.innpv.protocol.BreakdownNode\"\xca\x01\n\rProtocolError\x12;\n\nerror_code\x18\x01 \x01(\x0e\x32\'.innpv.protocol.ProtocolError.ErrorCode\"|\n\tErrorCode\x12\x0b\n\x07UNKNOWN\x10\x00\x12 \n\x1cUNSUPPORTED_PROTOCOL_VERSION\x10\x01\x12\x1c\n\x18UNINITIALIZED_CONNECTION\x10\x02\x12\"\n\x1e\x41LREADY_INITIALIZED_CONNECTION\x10\x03\"\x1a\n\x04Path\x12\x12\n\ncomponents\x18\x01 \x03(\t\"M\n\rFileReference\x12\'\n\tfile_path\x18\x01 \x01(\x0b\x32\x14.innpv.protocol.Path\x12\x13\n\x0bline_number\x18\x02 \x01(\r\"\xce\x01\n\rBreakdownNode\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0cnum_children\x18\x02 \x01(\r\x12/\n\x08\x63ontexts\x18\x03 \x03(\x0b\x32\x1d.innpv.protocol.FileReference\x12\x32\n\toperation\x18\x04 \x01(\x0b\x32\x1d.innpv.protocol.OperationDataH\x00\x12,\n\x06weight\x18\x05 \x01(\x0b\x32\x1a.innpv.protocol.WeightDataH\x00\x42\x06\n\x04\x64\x61ta\"{\n\x0b\x43ontextInfo\x12.\n\x07\x63ontext\x18\x01 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\x12\x13\n\x0brun_time_ms\x18\x02 \x01(\x02\x12\x12\n\nsize_bytes\x18\x03 \x01(\x04\x12\x13\n\x0binvocations\x18\x04 \x01(\r\"\x83\x01\n\rOperationData\x12\x12\n\nforward_ms\x18\x01 \x01(\x02\x12\x13\n\x0b\x62\x61\x63kward_ms\x18\x02 \x01(\x02\x12\x12\n\nsize_bytes\x18\x03 \x01(\x04\x12\x35\n\x10\x63ontext_info_map\x18\x04 \x03(\x0b\x32\x1b.innpv.protocol.ContextInfo\"9\n\nWeightData\x12\x12\n\nsize_bytes\x18\x01 \x01(\x04\x12\x17\n\x0fgrad_size_bytes\x18\x02 \x01(\x04\"*\n\x0bLinearModel\x12\r\n\x05slope\x18\x01 \x01(\x01\x12\x0c\n\x04\x62ias\x18\x02 \x01(\x01\":\n\x0cHardwareInfo\x12\x10\n\x08hostname\x18\x01 \x01(\t\x12\n\n\x02os\x18\x02 \x01(\t\x12\x0c\n\x04gpus\x18\x03 \x03(\t\"\x1b\n\x13MemoryUsageResponseJ\x04\x08\x01\x10\x65\"\x17\n\x0fRunTimeResponseJ\x04\x08\x01\x10\x65\"\x17\n\x0f\x41\x63tivationEntryJ\x04\x08\x01\x10\x65\"\x13\n\x0bWeightEntryJ\x04\x08\x01\x10\x65\"\x14\n\x0cRunTimeEntryJ\x04\x08\x01\x10\x65*`\n\x1e\x45nergyConsumptionComponentType\x12\x16\n\x12\x45NERGY_UNSPECIFIED\x10\x00\x12\x13\n\x0f\x45NERGY_CPU_DRAM\x10\x01\x12\x11\n\rENERGY_NVIDIA\x10\x02\x62\x06proto3' ) _ENERGYCONSUMPTIONCOMPONENTTYPE = _descriptor.EnumDescriptor( @@ -48,8 +48,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=3182, - serialized_end=3278, + serialized_start=3202, + serialized_end=3298, ) _sym_db.RegisterEnumDescriptor(_ENERGYCONSUMPTIONCOMPONENTTYPE) @@ -89,8 +89,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=2196, - serialized_end=2320, + serialized_start=2216, + serialized_end=2340, ) _sym_db.RegisterEnumDescriptor(_PROTOCOLERROR_ERRORCODE) @@ -450,8 +450,15 @@ is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), _descriptor.FieldDescriptor( - name='past_measurements', full_name='innpv.protocol.EnergyResponse.past_measurements', index=2, - number=3, type=11, cpp_type=10, label=3, + name='batch_size', full_name='innpv.protocol.EnergyResponse.batch_size', index=2, + number=3, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='past_measurements', full_name='innpv.protocol.EnergyResponse.past_measurements', index=3, + number=4, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, @@ -469,7 +476,7 @@ oneofs=[ ], serialized_start=1053, - serialized_end=1219, + serialized_end=1239, ) @@ -507,8 +514,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1222, - serialized_end=1350, + serialized_start=1242, + serialized_end=1370, ) @@ -553,8 +560,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1353, - serialized_end=1493, + serialized_start=1373, + serialized_end=1513, ) @@ -592,8 +599,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1495, - serialized_end=1586, + serialized_start=1515, + serialized_end=1606, ) @@ -659,8 +666,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1589, - serialized_end=1878, + serialized_start=1609, + serialized_end=1898, ) @@ -726,8 +733,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1881, - serialized_end=2115, + serialized_start=1901, + serialized_end=2135, ) @@ -759,8 +766,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2118, - serialized_end=2320, + serialized_start=2138, + serialized_end=2340, ) @@ -791,8 +798,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2322, - serialized_end=2348, + serialized_start=2342, + serialized_end=2368, ) @@ -830,8 +837,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2350, - serialized_end=2427, + serialized_start=2370, + serialized_end=2447, ) @@ -895,8 +902,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=2430, - serialized_end=2636, + serialized_start=2450, + serialized_end=2656, ) @@ -948,8 +955,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2638, - serialized_end=2761, + serialized_start=2658, + serialized_end=2781, ) @@ -1001,8 +1008,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2764, - serialized_end=2895, + serialized_start=2784, + serialized_end=2915, ) @@ -1040,8 +1047,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2897, - serialized_end=2954, + serialized_start=2917, + serialized_end=2974, ) @@ -1079,8 +1086,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2956, - serialized_end=2998, + serialized_start=2976, + serialized_end=3018, ) @@ -1125,8 +1132,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3000, - serialized_end=3058, + serialized_start=3020, + serialized_end=3078, ) @@ -1150,8 +1157,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3060, - serialized_end=3087, + serialized_start=3080, + serialized_end=3107, ) @@ -1175,8 +1182,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3089, - serialized_end=3112, + serialized_start=3109, + serialized_end=3132, ) @@ -1200,8 +1207,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3114, - serialized_end=3137, + serialized_start=3134, + serialized_end=3157, ) @@ -1225,8 +1232,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3139, - serialized_end=3158, + serialized_start=3159, + serialized_end=3178, ) @@ -1250,8 +1257,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=3160, - serialized_end=3180, + serialized_start=3180, + serialized_end=3200, ) _FROMCLIENT.fields_by_name['initialize'].message_type = _INITIALIZEREQUEST diff --git a/test/test_database.py b/test/test_database.py index 45df087..da01e4a 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -23,13 +23,13 @@ def test_invalid_entry_too_short(self): assert(self.energy_table_interface.is_valid_entry([]) == False) def test_invalid_entry_too_long(self): - assert(self.energy_table_interface.is_valid_entry([1,2,3,4]) == False) + assert(self.energy_table_interface.is_valid_entry([1,2,3,4,5]) == False) def test_invalid_entry_wrong_types(self): assert(self.energy_table_interface.is_valid_entry([None, None, None, None, None]) == False) def test_adding_valid_entry(self): - params = ["entry_point", random.random(), random.random()] + params = ["entry_point", random.random(), random.random(), random.randint()] self.energy_table_interface.add_entry(params) query_result = self.test_database.connection.execute("SELECT * FROM ENERGY;").fetchone() # params is passed in by reference so it have the timestamp in it @@ -38,14 +38,14 @@ def test_adding_valid_entry(self): # add 10 valid entries and get top 3 def test_get_latest_n_entries_of_entry_point(self): for _ in range(10): - params = ["entry_point", random.random(), random.random()] + params = ["entry_point", random.random(), random.random(), random.randint()] self.energy_table_interface.add_entry(params) for _ in range(20): - params = ["other_entry_point", random.random(), random.random()] + params = ["other_entry_point", random.random(), random.random(), random.randint()] self.energy_table_interface.add_entry(params) entries = [] for _ in range(3): - params = ["entry_point", random.random(), random.random()] + params = ["entry_point", random.random(), random.random(), random.randint()] entries.insert(0, params) self.energy_table_interface.add_entry(params) latest_n_entries = self.energy_table_interface.get_latest_n_entries_of_entry_point(3, "entry_point")