def testMetric(self): track.init(trial_name="test_log") session = track.get_session() for i in range(5): track.log(test=i) result_path = os.path.join(session.logdir, EXPR_RESULT_FILE) self.assertTrue(_check_json_val(result_path, "test", i))
def testLocalMetrics(self): """Checks that metric state is updated correctly.""" track.init(trial_name="test_logs") session = track.get_session() self.assertEqual(set(session.trial_config.keys()), {"trial_id"}) result_path = os.path.join(session.logdir, EXPR_RESULT_FILE) track.log(test=1) self.assertTrue(_check_json_val(result_path, "test", 1)) track.log(iteration=1, test=2) self.assertTrue(_check_json_val(result_path, "test", 2))
def testLogCreation(self): """Checks that track.init() starts logger and creates log files.""" track.init(trial_name="test_init") session = track.get_session() self.assertTrue(session is not None) self.assertTrue(os.path.isdir(session.logdir)) params_path = os.path.join(session.logdir, EXPR_PARAM_FILE) result_path = os.path.join(session.logdir, EXPR_RESULT_FILE) self.assertTrue(os.path.exists(params_path)) self.assertTrue(os.path.exists(result_path)) self.assertTrue(session.logdir == track.trial_dir())