def test_get_suite(): # Expected contents for "Smaller_Suite" to compare against expected_suite = [ { "name": "Smaller_Workload", "iterations": "1" }, { "name": "Smaller_Workload", "iterations": "1" } ] assert expected_suite == aixprt.get_suite("Smaller_Suite") # Try to get a suite that doesn't exist in the system assert aixprt.get_suite("Not_in_system") == 1
def update_fields(self): """ Auto-fills the labels on the screen with the Workloads in the Suite. """ # Update active workload with our selected. if self.ids.spin_suite_edit.text != 'Choose...': self.active_suite = aixprt.get_suite(self.ids.spin_suite_edit.text) self.active_suite_name = self.ids.spin_suite_edit.text self.ids.edit_suite_name.text = self.active_suite_name App.get_running_app().wl_counter = len(self.active_suite) self.clear_labels() # Show workloads in labels and enable checkboxes for existing workloads for i in range(len(self.active_suite)): self.ids["edit_wl_" + str( i )].text = self.active_suite[i]['name'] + ", Iterations: " + str( self.active_suite[i]['iterations'] ) + " | [u][size=20][color=#0000ff][ref=edit]Edit[/ref][/u][/size][/color]" # Status should be initially blank self.ids.edit_suite_status.text = '' if App.get_running_app().wl_counter >= 10: self.ids.suite_max_edit.text = "Max workloads added!" else: self.ids.suite_max_edit.text = ""
def delete_suite(self): """ Deletes the selected Suite from the system. :return: """ if self.ids.spin_suite.text != 'Choose...': suite_to_delete = { self.ids.spin_suite.text: aixprt.get_suite(self.ids.spin_suite.text), } aixprt.remove_suite(suite_to_delete)
def test_remove_workload(): expected_workload1 = Workload("test_workload(I_v3)", "", "https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1", 4000, 0.01, 10, 10, 10, 100, -1, 100, False, 0, 0, 0, "") expected_workload2 = Workload("Small_Workload", "", "https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1", 200, 0.01, 10, 10, 10, 100, -1, 100, False, 0, 0, 0, "") expected_workload3 = Workload("Smaller_Workload", "", "https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1", 100, 0.01, 10, 10, 10, 100, -1, 100, False, 0, 0, 0, "") # Ensure file is setup properly WL_data = aixprt.get_workloads() assert len(WL_data) == 2 assert "test_workload(I_v3)" in WL_data assert "Small_Workload" in WL_data # Try to remove a non-existent workload assert aixprt.remove_workload("Not_in_file") == 0 assert len(WL_data) == 2 assert "test_workload(I_v3)" in WL_data assert "Small_Workload" in WL_data # Remove an existing workload actual_workload1 = aixprt.remove_workload("test_workload(I_v3)") WL_data = aixprt.get_workloads() assert len(WL_data) == 1 assert not "test_workload(I_v3)" in WL_data assert compare_workloads(expected_workload1, actual_workload1) # Remove an existing workload that is used in a suite suite1 = aixprt.get_suite("Small_Suite") assert len(suite1) == 2 actual_workload2 = aixprt.remove_workload("Small_Workload") WL_data = aixprt.get_workloads() assert len(WL_data) == 0 assert not "Small_Workload" in WL_data assert compare_workloads(expected_workload2, actual_workload2) suite1 = aixprt.get_suite("Small_Suite") assert len(suite1) == 1 assert not "Small_Workload" in suite1 # Remove a workload that occurs multiple times in multiple suites # Setup for this particular test: aixprt.add_workload("test_workload(I_v3)", "", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', "4100", "0.01", "10", "10", "10", "100", "-1", "100", "False", "0", "0", "0", "") aixprt.add_workload("Small_Workload", "", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', "200", "0.01", "10", "10", "10", "100", "-1", "100", "False", "0", "0", "0", "") aixprt.add_workload("Smaller_Workload", "", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', "100", "0.01", "10", "10", "10", "100", "-1", "100", "False", "0", "0", "0", "") WL_data = aixprt.get_workloads() assert len(WL_data) == 3 suite2_A = aixprt.get_suite("Small_Suite") assert len(suite2_A) == 1 suite2_B = aixprt.get_suite("Smaller_Suite") assert len(suite2_B) == 2 # Now remove actual_workload3 = aixprt.remove_workload("Smaller_Workload") WL_data = aixprt.get_workloads() assert len(WL_data) == 2 assert not "Smaller_Workload" in WL_data assert compare_workloads(expected_workload3, actual_workload3) suite2_A = aixprt.get_suite("Small_Suite") assert len(suite2_A) == 0 assert not "Smaller_Workload" in suite2_A suite2_B = aixprt.get_suite("Smaller_Suite") assert len(suite2_B) == 0 assert not "Smaller_Workload" in suite2_B
def test_add_suite(): # Load Suites and ensure there are only two suites in the file SU_data = aixprt.load_suites() assert len(SU_data) == 2 # Add a new suite sucessfully new_suite = { "new_suite": [ { "name": "test_workload(I_v3)", "iterations": "3" }, { "name": "Small_Workload", "iterations": "2" } ] } new_suite_list = [ { "name": "test_workload(I_v3)", "iterations": "3" }, { "name": "Small_Workload", "iterations": "2" } ] assert aixprt.add_suite(new_suite) == 0 SU_data = aixprt.load_suites() assert len(SU_data) == 3 assert new_suite_list == aixprt.get_suite("new_suite") # Now try to add that same suite again and ensure it is not added assert aixprt.add_suite(new_suite) == 1 SU_data = aixprt.load_suites() assert len(SU_data) == 3 # Try to add a suite with a name that exceeds the character limit (20) long_suite = { "this_name_is_wayyyyyyyyyyyyyyyyyyyyyyyyyyy_longer_than_twenty_characters": [ { "name": "test_workload(I_v3)", "iterations": "2" }, { "name": "Smaller_Workload", "iterations": "2" } ] } assert aixprt.add_suite(long_suite) == 1 SU_data = aixprt.load_suites() assert len(SU_data) == 3
def update_fields(self): """ Auto-fills the labels on the screen with the Workloads in the Suite. """ # Update active workload with our selected. if self.ids.spin_suite.text != 'Choose...': self.active_suite = aixprt.get_suite(self.ids.spin_suite.text) self.active_suite_name = self.ids.spin_suite.text App.get_running_app().wl_counter = len(self.active_suite) # Before showing the new workloads, clear the old ones: self.clear_labels() # Show workloads in labels and enable checkboxes for existing workloads for i in range(len(self.active_suite)): self.ids["wl_" + str(i)].text = self.active_suite[i][ 'name'] + ", Iterations: " + str( self.active_suite[i]['iterations'])
def test_edit_suite(): # Load Suites and ensure there are only two suites in the file SU_data = aixprt.load_suites() assert len(SU_data) == 2 # Edit a suite sucessfully edited_suite1 = { "Smaller_Suite": [ { "name": "Smaller_Workload", "iterations": "2" }, { "name": "Smaller_Workload", "iterations": "1" } ] } edited_suite_list1 = [ { "name": "Smaller_Workload", "iterations": "2" }, { "name": "Smaller_Workload", "iterations": "1" } ] assert aixprt.edit_suite("Smaller_Suite", edited_suite1) == 0 SU_data = aixprt.load_suites() assert len(SU_data) == 2 assert edited_suite_list1 == aixprt.get_suite("Smaller_Suite") # Edit a suite with a new name sucessfully edited_suite2 = { "New_Suite": [ { "name": "Small_Workload", "iterations": "3" }, { "name": "Small_Workload", "iterations": "1" } ] } edited_suite_list2 = [ { "name": "Small_Workload", "iterations": "3" }, { "name": "Small_Workload", "iterations": "1" } ] assert aixprt.edit_suite("Small_Suite", edited_suite2) == 0 SU_data = aixprt.load_suites() assert len(SU_data) == 2 assert edited_suite_list2 == aixprt.get_suite("New_Suite") # Try to edit a suite that doesn't exist edited_suite3 = { "Not_exist": [ { "name": "Small_Workload", "iterations": "3" }, { "name": "Small_Workload", "iterations": "1" } ] } assert aixprt.edit_suite("Not_in_system", edited_suite3) == 1 assert len(SU_data) == 2 # Try to edit a suite with a new name that is too long assert aixprt.edit_suite("this_name_is_wayyyyyyyyyyyyyyyyyyyy_longer_than_twenty_characters", edited_suite3) == 1 assert len(SU_data) == 2