Ejemplo n.º 1
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 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_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
Ejemplo n.º 6
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