Exemple #1
0
    def test_not_valid_config(self, mock_logger):
        ret = parser.is_config_valid(self.not_well_formed)
        self.assertFalse(ret)

        mock_logger.error.assert_called_with(
            'Configuration data is not well formed'
        )
Exemple #2
0
    def test_not_minimal_config(self, mock_logger):
        ret = parser.is_config_valid(self.not_minimal)
        self.assertFalse(ret)

        mock_logger.error.assert_called_with(
            'Insufficient configuration file data for an evaluation'
        )
def run_evaluation_from_config(config_file_path, ignore_config_errors=False):
    """ Run an OCW evaluation specified by a config file.

    :param config_file_path: The file path to a OCW compliant YAML file
        specifying how to run the evaluation. For additional information on 
        the valid options that you can set in the config please check the
        project wiki https://cwiki.apache.org/confluence/display/climate/home#'.
    :type config_file_path: :mod:`string`

    :param ignore_config_errors: When this is true configuration parsing errors
        will NOT interrupt the evaluation run. Note, it is very unlikely that
        you will want this value set. However it is possible that you will want
        to graph something that doesn't require a full evaluation run. This is
        provided for that situation.
    :type ignore_config_errors: :func:`bool`
    """
    config = yaml.load(open(config_file_path, 'r'))

    if not ignore_config_errors and not is_config_valid(config):
        logger.warning(
            'Unable to validate configuration file. Exiting evaluation. '
            'Please check documentation for config information.'
        )

        sys.exit(1)

    evaluation = generate_evaluation_from_config(config)

    if evaluation._evaluation_is_valid():
        evaluation.run()

    plot_from_config(evaluation, config)
def run_evaluation_from_config(config_file_path):
    """ Run an OCW evaluation specified by a config file.

    :param config_file_path: The file path to a OCW compliant YAML file
        specifying how to run the evaluation. For additional information on 
        the valid options that you can set in the config please check the
        project wiki https://cwiki.apache.org/confluence/display/climate/home#'.
    :type config_file_path: :mod:`string`
    """
    config = yaml.load(open(config_file_path, 'r'))

    if not is_config_valid(config):
        logger.warning(
            'Unable to validate configuration file. Exiting evaluation. '
            'Please check documentation for config information.'
        )
        sys.exit(1)

    evaluation = generate_evaluation_from_config(config)
    evaluation.run()

    plot_from_config(evaluation, config)
    def test_not_valid_config(self, mock_logger):
        ret = parser.is_config_valid(self.not_well_formed)
        self.assertFalse(ret)

        mock_logger.error.assert_called_with(
            'Configuration data is not well formed')
    def test_not_minimal_config(self, mock_logger):
        ret = parser.is_config_valid(self.not_minimal)
        self.assertFalse(ret)

        mock_logger.error.assert_called_with(
            'Insufficient configuration file data for an evaluation')