def test_load_with_crc_fail(self): """Test when crc_fail and will not go to func _event_parse.""" summary_dir = tempfile.mkdtemp() file2 = os.path.join(summary_dir, 'summary.02') write_file(file2, SCALAR_RECORD) ms_loader = MSDataLoader(summary_dir) ms_loader.load() shutil.rmtree(summary_dir) assert 'Check crc failed' in str(MockLogger.log_msg['error'])
def test_load_with_crc_fail(self): """Test when crc_fail and will not go to func _event_parse.""" summary_dir = tempfile.mkdtemp() file2 = os.path.join(summary_dir, 'summary.02') write_file(file2, SCALAR_RECORD) ms_loader = MSDataLoader(summary_dir) ms_loader.load(ComputingResourceManager(1, 1)) shutil.rmtree(summary_dir) assert 'Check crc faild and ignore this file' in str( MockLogger.log_msg['warning'])
def test_load_success_with_crc_pass(self): """Test load success.""" summary_dir = tempfile.mkdtemp() file1 = os.path.join(summary_dir, 'summary.01') write_file(file1, SCALAR_RECORD) ms_loader = MSDataLoader(summary_dir) ms_loader._latest_summary_filename = 'summary.00' ms_loader.load(ComputingResourceManager(1, 1)) shutil.rmtree(summary_dir) tag = ms_loader.get_events_data().list_tags_by_plugin('scalar') tensors = ms_loader.get_events_data().tensors(tag[0]) assert len(tensors) == 3
def test_load_single_pb_file(self): """Test load pb file success.""" filename = 'ms_output.pb' summary_dir = tempfile.mkdtemp() create_graph_pb_file(output_dir=summary_dir, filename=filename) ms_loader = MSDataLoader(summary_dir) ms_loader.load(ComputingResourceManager(1, 1)) events_data = ms_loader.get_events_data() plugins = events_data.list_tags_by_plugin(PluginNameEnum.GRAPH.value) shutil.rmtree(summary_dir) assert len(plugins) == 1 assert plugins[0] == filename
def test_load_success_with_crc_pass(self, crc_pass): """Test load success.""" summary_dir = tempfile.mkdtemp() file1 = os.path.join(summary_dir, 'summary.01') write_file(file1, SCALAR_RECORD) ms_loader = MSDataLoader(summary_dir) ms_loader._latest_summary_filename = 'summary.00' ms_loader.load() assert ms_loader._latest_summary_filename == 'summary.01' assert ms_loader._latest_summary_file_size == RECORD_LEN tag = ms_loader.get_events_data().list_tags_by_plugin('scalar') tensors = ms_loader.get_events_data().tensors(tag[0]) assert len(tensors) == 3