def test_run_workload(): # Setup aixprt.add_workload("test_workload1", "test comment", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', "10", "0.02", "10", "20", "10", "100", "-1", "100", "True", "0", "0", "0", "") aixprt.add_workload("test_workload2", "", '', "", "", "", "", "", "", "", "", "", "", "", "", "help dir") # Try running a workload with invalid iterations assert aixprt.run_workload('five', "Small_Workload") == 1 assert aixprt.run_workload(-2, "Small_Workload") == 1 # Try running a workload that is not in the system assert aixprt.run_workload(3, "Not_in_System") == 1 # Sucessfully run a workload assert aixprt.run_workload(1, "test_workload1") == 0 # Sucessfully run a command based workload assert aixprt.run_workload(1, "test_workload2") == 0 pass
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_run_suite(): # Setup assert aixprt.add_workload("test_workload1", "test comment", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', "10", "0.02", "10", "20", "10", "100", "-2", "100", "True", "0", "0", "0", "") == 0 assert aixprt.add_workload("test_workload2", "", '', "", "", "", "", "", "", "", "", "", "", "", "", "help dir") == 0 new_suite = { "new_suite": [ { "name": "test_workload1", "iterations": "2" }, { "name": "test_workload2", "iterations": "1" } ] } assert aixprt.add_suite(new_suite) == 0 # Run a suite sucessfully assert aixprt.run_suite("new_suite") == 0 # Try to run a suite that does not exist assert aixprt.run_suite("Not_in_system") == 1 pass
def add_workload(self): """ Actual method call to add a workload. Passes in values from the TextInput boxes. """ valid = aixprt.add_workload( self.ids.name.text, self.ids.comment.text, self.ids.tfhub_model.text, self.ids.training_steps.text, self.ids.learning_rate.text, self.ids.testing_percentage.text, self.ids.validation_percentage.text, self.ids.eval_step_interval.text, self.ids.train_batch_size.text, self.ids.test_batch_size.text, self.ids.validation_batch_size.text, self.ids.flip_left_right.text, self.ids.random_crop.text, self.ids.random_scale.text, self.ids.random_brightness.text, self.ids.command.text) # Check if the workload was added successfully if valid != 0: if valid == 1: App.get_running_app().message_text = 'Workload Already Exists' else: App.get_running_app( ).message_text = 'Failed To Add Workload\nSee console for details.' else: App.get_running_app().message_text = 'Workload Added'
def test_add_workload(): WL_data = aixprt.get_workloads() workload1 = Workload("test_workload1", "test comment", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', 4100, 0.02, 10, 20, 10, 100, -2, 100, True, 0, 0, 0, "") # Test to ensure that the workload to be added does not exist in the file assert not "test_workload1" in WL_data # Then add and assert that it does exist in it aixprt.add_workload("test_workload1", "test comment", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', "4100", "0.02", "10", "20", "10", "100", "-2", "100", "True", "0", "0", "0", "") WL_data = aixprt.get_workloads() assert "test_workload1" in WL_data assert compare_workloads(WL_data["test_workload1"], workload1) # Try to add the same workload again and ensure it does not assert len(WL_data) == 3 assert aixprt.add_workload("test_workload1", "test comment", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', "4100", "0.02", "10", "20", "10", "100", "-2", "100", "True", "0", "0", "0", "") == 1 WL_data = aixprt.get_workloads() assert len(WL_data) == 3 # Try to add invalid workloads and ensure it does not # Workload with 1 thing wrong invalid_1 = aixprt.add_workload("wrong_workload", "test comment", 'https://tfhub.dev/google/imagenet/inception_v3/feature_vector/1', "4100", "0.02", "1.0", "20", "10", "100", "-2", "100", "True", "0", "0", "0", "") expected_invalid_1 = ["testing_percentage"] WL_data = aixprt.get_workloads() assert len(WL_data) == 3 assert len(invalid_1) == 1 assert invalid_1 == expected_invalid_1 # Workload with everything wrong (except for the comment and command parameters, which can both be empty strings) invalid_2 = aixprt.add_workload("", "", '', "cat", "0..02", "1.0", "False", "1.0", "asdga100", "--2", "1%00", "FTrue", "z", "e", "ro", "") expected_invalid_2 = ["name", "tfhub_model", "training_steps", "learning_rate", "testing_percentage", "validation_percentage", "eval_step_interval", "train_batch_size", "test_batch_size", "validation_batch_size", "flip_left_right", "random_crop", "random_scale", "random_brightness"] WL_data = aixprt.get_workloads() assert len(WL_data) == 3 assert len(invalid_2) == 14 #TODO fix after regex is corrected assert invalid_2 == expected_invalid_2 # Add a workload with a command WL_data = aixprt.get_workloads() assert len(WL_data) == 3 assert aixprt.add_workload("test_workload2", "", '', "", "", "", "", "", "", "", "", "", "", "", "", "help dir") == 0 WL_data = aixprt.get_workloads() assert len(WL_data) == 4