def test_log_warning_if_not_running_in_job_does_not_show_warning_if_in_running_job( self): from foundations.utils import log_warning_if_not_running_in_job self.foundations_job.is_in_running_job.return_value = True log_warning_if_not_running_in_job(_some_function, {'result': False}) self.mock_logger.warning.assert_not_called()
def test_log_warning_if_not_running_in_job_does_not_run_function_if_not_in_job( self): from foundations.utils import log_warning_if_not_running_in_job self.foundations_job.is_in_running_job.return_value = False some_dict = {'result': False} log_warning_if_not_running_in_job(_some_function, some_dict) self.assertFalse(some_dict['result'])
def test_log_warning_if_not_running_in_job_shows_warning_only_once_if_not_in_running_job( self): from foundations.utils import log_warning_if_not_running_in_job log_warning_if_not_running_in_job(_some_function, {'result': False}) log_warning_if_not_running_in_job(_some_function, {'result': False}) self.mock_logger.warning.assert_called_once_with( 'Script not run with Foundations.')
def set_tag(key, value=''): """ Adds additional static, predetermined information as a tag to the job. This is a way to categorize attributes of a job that is not dynamically generated during runtime. Arguments: key {str} -- the name of the tag. value {number, str, bool, array of [number|str|bool], array of array of [number|str|bool]} -- the value associated with the given tag. Returns: - This function doesn't return a value. Raises: - This method doesn't raise any exceptions. Notes: If a tag is updated multiple times, Foundations will update the tag to the newest value, but return a warning indicating that the key has been updated. """ from foundations.utils import log_warning_if_not_running_in_job log_warning_if_not_running_in_job(_set_tag_in_running_jobs, key, value)
def _log_metric(key, value): from foundations.utils import log_warning_if_not_running_in_job log_warning_if_not_running_in_job(_log_metric_in_running_job, key, value)
def test_log_warning_if_not_running_in_job_logs_correct_warning(self): from foundations.utils import log_warning_if_not_running_in_job log_warning_if_not_running_in_job(_some_function, {'result': False}) self.mock_logger.warning.assert_called_with( 'Script not run with Foundations.')
def log_param(key, value): from foundations.utils import log_warning_if_not_running_in_job log_warning_if_not_running_in_job(_log_param_in_running_job, key, value)