示例#1
0
 def __init__(self):
     self.__view: CommandLineInterface = CommandLineInterface()
     self.__output_service: OutputService = CLIOutputService(self.__view)
     self.__register_output_service()
     try:
         Configurations.load_config_file()
     except InvalidConfigException as e:
         self.__output_service.print_error(e)
示例#2
0
 def __set_values(self, key):
     if key is Key.NAME:
         standard_name = Configurations.get_config_with_key(
             self.module_name, key)
         current_dt = datetime.datetime.now().strftime("%Y_%m_%d_%H:%M:%S")
         self.arguments[key] = standard_name + current_dt
     else:
         self.arguments[key] = Configurations.get_config_with_key(
             self.module_name, key)
def test_collector_with_missing_optional_args_adds_default():
    input_string = "collect -n name"
    size = Configurations.get_config_with_key(Module.COLLECT, Key.SIZE)
    amount = Configurations.get_config_with_key(Module.COLLECT, Key.AMOUNT)
    path = Configurations.get_config_with_key(Module.COLLECT, Key.PATH)
    expected = {
        Key.NAME: "name",
        Key.SIZE: size,
        Key.AMOUNT: amount,
        Key.PATH: path
    }
    command = CommandParser.parse_input(input_string)
    assert isinstance(command, CollectCommand)
    assert dicts_equal(command.arguments, expected) is True
def test_classify_command_with_missing_optional_arg_adds_default():
    input_str = "train -p path -n network"
    train = Configurations.get_config_with_key(Module.TRAIN, Key.TRAIN)
    saving_path = Configurations.get_config_with_key(Module.TRAIN,
                                                     Key.SAVING_PATH)
    expected = {
        Key.PATH: "path",
        Key.NAME: "network",
        Key.TRAIN: train,
        Key.SAVING_PATH: saving_path,
        Key.EXISTING_NETWORK: None,
    }
    command = CommandParser.parse_input(input_str)
    assert isinstance(command, TrainCommand)
    assert dicts_equal(command.arguments, expected) is True
    def __set_parameters():
        # Network Structure:
        TrainingModule.__num_conv_layers = Configurations.get_config(
            Module.TRAIN, "num_conv_layers")
        TrainingModule.__num_dense_layers = Configurations.get_config(
            Module.TRAIN, "num_dense_layers")
        TrainingModule.__layer_activation = Configurations.get_config(
            Module.TRAIN, "layer_activation")
        TrainingModule.__final_activation = Configurations.get_config(
            Module.TRAIN, "final_activation")
        TrainingModule.__dropout = Configurations.get_config(
            Module.TRAIN, "dropout")
        TrainingModule.__num_classes = 4

        # Hyper parameters:
        TrainingModule.__batch_size = Configurations.get_config(
            Module.TRAIN, "batch_size")
        TrainingModule.__learning_rate = Configurations.get_config(
            Module.TRAIN, "learning_rate")
        TrainingModule.__loss = Configurations.get_config(Module.TRAIN, "loss")
        TrainingModule.__epochs = Configurations.get_config(
            Module.TRAIN, "epochs")
def test_load_not_existing_key_returns_null():
    actual = Configurations.get_config_with_key(Module.TRAIN, Key.SIZE)
    assert actual is None
def test_loading_config_has_right_value():
    actual = Configurations.get_config(Module.TRAIN, "learning_rate")
    expected = 0.001
    assert actual == expected
def test_loading_config_values_works():
    actual = Configurations.get_config_with_key(Module.LABEL, Key.SAVING_PATH)
    with open("config.json") as f:
        data = json.load(f)
    expected = data["label"]["saving_path"]
    assert actual == expected
def setup():
    Configurations.load_config_file()
示例#10
0
 def __add_default_args(self) -> None:
     for key, value in self.arguments.items():
         if value is None:
             self.arguments[key] = Configurations.get_config_with_key(
                 self.module_name, key)
def test_loading_config_has_right_value():
    actual = Configurations.get_config_with_key(Module.TRAIN, Key.TRAIN)
    expected = 0.3
    assert actual == expected