def read_dataset_config(dataset_config_filename): """Returns a DeepVariantDatasetConfig proto read from the dataset config file. Args: dataset_config_filename: String. Path to the dataset config pbtxt file. Returns: A DeepVariantDatasetConfig proto from the dataset_config file. Raises: ValueError: if the dataset config doesn't have the necessary information. """ with tf.gfile.GFile(dataset_config_filename) as f: dataset_config = text_format.Parse( f.read(), deepvariant_pb2.DeepVariantDatasetConfig()) if not dataset_config.name: raise ValueError('dataset_config needs to have a name') if not dataset_config.tfrecord_path: raise ValueError('The dataset in the config {} does not have a ' 'tfrecord_path.'.format(dataset_config_filename)) # redacted # of num_examples. if not dataset_config.num_examples: raise ValueError('The dataset in the config {} does not have a ' 'num_examples.'.format(dataset_config_filename)) return dataset_config
def _test_dataset_config(filename, **kwargs): """Creates a DeepVariantDatasetConfig(**kwargs) and writes it to filename.""" dataset_config_pbtext_filename = test_utils.test_tmpfile(filename) dataset_config = deepvariant_pb2.DeepVariantDatasetConfig(**kwargs) data_providers.write_dataset_config_to_pbtxt( dataset_config, dataset_config_pbtext_filename) return dataset_config_pbtext_filename
def read_dataset_config(dataset_config_pbtxt_filename): with tf.gfile.GFile(dataset_config_pbtxt_filename) as f: return text_format.Parse( f.read(), deepvariant_pb2.DeepVariantDatasetConfig())