Ejemplo n.º 1
0
 def test_data_files_keys(self, tmpdir):
     file = """
             data_files:
                 train:  'tweets-train.csv'
                 test: 'tweets-test.csv'
             transformers:
             estimators:
             vectorizers:
             """
     p = tmpdir.mkdir("test").join("conf_file.yml")
     p.write(file)
     c = Context('exp_name_param', conf_file=str(p))
     with pytest.raises(ValueError) as ex:
         c.validate_configuration_parameters()
         assert ex == "Missing {'target', 'features'} keys under data_files from context file."
Ejemplo n.º 2
0
 def test_data_files_keys_target_empty(self, tmpdir):
     file = """
             data_files:
                 train: '$PROJECT_PATHS$/../data/raw/tweets-train.csv'
                 test: '$PROJECT_PATHS$/../data/raw/tweets-train.csv'
                 target:
                 features:
             transformers:
             estimators:
             vectorizers:
             """
     p = tmpdir.mkdir("test").join("conf_file.yml")
     p.write(file)
     c = Context('exp_name_param', conf_file=str(p))
     with pytest.raises(ValueError) as ex:
         c.validate_configuration_parameters()
         assert 'target cannot be empty.' == str(ex.value)
Ejemplo n.º 3
0
 def test_data_files_keys_train_test(self, tmpdir):
     file = """
             data_files:
                 train:  ''
                 test: 
                 target:
                 features: 
             transformers:
             estimators:
             vectorizers:
             """
     p = tmpdir.mkdir("test").join("conf_file.yml")
     p.write(file)
     c = Context('exp_name_param', conf_file=str(p))
     with pytest.raises(ValueError) as ex:
         c.validate_configuration_parameters()
     assert "train cannot be empty." == str(ex.value)
Ejemplo n.º 4
0
 def test_data_files_key_transformers(self, tmpdir):
     file = """
            data_files:
                train: '$PROJECT_PATHS$/../data/raw/tweets-train.csv'
                test: '$PROJECT_PATHS$/../data/raw/tweets-train.csv'
                target: 'target_name'
                features: 'features_name'
            transformers:
            estimators:
            vectorizers:
             """
     p = tmpdir.mkdir("test").join("conf_file.yml")
     p.write(file)
     c = Context('exp_name_param', conf_file=str(p))
     with pytest.raises(TypeError) as ex:
         c.validate_configuration_parameters()
         assert "from config file expected to be a list got" in str(
             ex.value)
Ejemplo n.º 5
0
 def test_data_files_keys_train_csv_format(self, tmpdir):
     file = """
             data_files:
                 train:  'tweets-train.notcsv'
                 test: 
                 target:
                 features: 
             transformers:
             estimators:
             vectorizers:
             """
     p = tmpdir.mkdir("test").join("conf_file.yml")
     p.write(file)
     c = Context('exp_name_param', conf_file=str(p))
     with pytest.raises(TypeError) as ex:
         c.validate_configuration_parameters()
     assert "Train data must be a csv file with .csv extension." == str(
         ex.value)
Ejemplo n.º 6
0
    def test_data_files_keys_train_csv_format_file_no_exist(self, tmpdir):
        file = """
                data_files:
                    train:  'tweets-train.csv'
                    test: 
                    target:
                    features: 
                transformers:
                estimators:
                vectorizers:
                """
        p = tmpdir.mkdir("test").join("conf_file.yml")
        p.write(file)
        c = Context('exp_name_param', conf_file=str(p))
        with pytest.raises(FileNotFoundError) as ex:
            c.validate_configuration_parameters()

        assert "[Errno 2] File tweets-train.csv does not exist: 'tweets-train.csv'" == str(
            ex.value)
Ejemplo n.º 7
0
    def test_config_params_missing_keys(self, tmpdir):
        file = """
                data_files:
                    train:  'tweets-train.csv'
                    test: 'tweets-test.csv'
                    features: 'fe1'
                    target: 'sent'
                transformers:
                    - transformer1:
                      param1: 'value_trans_1_param_1'
                      param2: 'value_trans_1_param_2'
                    - transformer2:
                      param1: 'value_trans_2_param_1'
                      param2: 'value_trans_2_param_2'
                """
        p = tmpdir.mkdir("test").join("conf_file.yml")
        p.write(file)
        c = Context('exp_name_param', conf_file=str(p))

        with pytest.raises(KeyError) as ex:
            c.validate_configuration_parameters()
            assert ex == "Missing {'estimators', 'vectorizer'} compulsory keys in configuration file."