def write_json_for_experiment(experiment_setup, output_dir):
    'Writes json for experiment, recording relevant files for each component.\n\n  Writes a json containing a list of TFRecord file names to read\n  for each experiment component, i.e. spectrum_prediction, library_matching.\n\n  Args:\n    experiment_setup: A dataset_setup_constants.ExperimentSetup tuple\n    output_dir: directory to write json\n  Returns:\n    Writes json recording which files to load for each component\n    of the experiment\n  Raises:\n    ValueError: if the experiment component is not specified to be taken from\n        either the main NIST library or the replicates library.\n\n  '
    experiment_json_dict = {}
    for dataset_kwarg in experiment_setup.experiment_setup_dataset_dict:
        if (dataset_kwarg in experiment_setup.data_to_get_from_mainlib):
            experiment_json_dict[dataset_kwarg] = [((component_basename + FROM_MAINLIB_FILENAME_MODIFIER) + TFRECORD_FILENAME_END) for component_basename in experiment_setup.experiment_setup_dataset_dict[dataset_kwarg]]
        elif (dataset_kwarg in experiment_setup.data_to_get_from_replicates):
            experiment_json_dict[dataset_kwarg] = [((component_basename + FROM_REPLICATES_FILENAME_MODIFIER) + TFRECORD_FILENAME_END) for component_basename in experiment_setup.experiment_setup_dataset_dict[dataset_kwarg]]
        else:
            raise ValueError('Did not specify origin for {}.'.format(dataset_kwarg))
    training_spectra_filename = ((ds_constants.MAINLIB_TRAIN_BASENAME + FROM_MAINLIB_FILENAME_MODIFIER) + NP_LIBRARY_ARRAY_END)
    experiment_json_dict[ds_constants.TRAINING_SPECTRA_ARRAY_KEY] = training_spectra_filename
    with tf.gfile.Open(os.path.join(output_dir, experiment_setup.json_name), 'w') as writer:
        experiment_json = json.dumps(experiment_json_dict)
        writer.write(experiment_json)
Writes json for experiment, recording relevant files for each component.

Writes a json containing a list of TFRecord file names to read
for each experiment component, i.e. spectrum_prediction, library_matching.

Args:
  experiment_setup: A dataset_setup_constants.ExperimentSetup tuple
  output_dir: directory to write json
Returns:
  Writes json recording which files to load for each component
  of the experiment
Raises:
  ValueError: if the experiment component is not specified to be taken from
      either the main NIST library or the replicates library.
def write_json_for_experiment(experiment_setup, output_dir):
    'Writes json for experiment, recording relevant files for each component.\n\n  Writes a json containing a list of TFRecord file names to read\n  for each experiment component, i.e. spectrum_prediction, library_matching.\n\n  Args:\n    experiment_setup: A dataset_setup_constants.ExperimentSetup tuple\n    output_dir: directory to write json\n  Returns:\n    Writes json recording which files to load for each component\n    of the experiment\n  Raises:\n    ValueError: if the experiment component is not specified to be taken from\n        either the main NIST library or the replicates library.\n\n  '
    experiment_json_dict = {}
    for dataset_kwarg in experiment_setup.experiment_setup_dataset_dict:
        if (dataset_kwarg in experiment_setup.data_to_get_from_mainlib):
            experiment_json_dict[dataset_kwarg] = [((component_basename + FROM_MAINLIB_FILENAME_MODIFIER) + TFRECORD_FILENAME_END) for component_basename in experiment_setup.experiment_setup_dataset_dict[dataset_kwarg]]
        elif (dataset_kwarg in experiment_setup.data_to_get_from_replicates):
            experiment_json_dict[dataset_kwarg] = [((component_basename + FROM_REPLICATES_FILENAME_MODIFIER) + TFRECORD_FILENAME_END) for component_basename in experiment_setup.experiment_setup_dataset_dict[dataset_kwarg]]
        else:
            raise ValueError('Did not specify origin for {}.'.format(dataset_kwarg))
    training_spectra_filename = ((ds_constants.MAINLIB_TRAIN_BASENAME + FROM_MAINLIB_FILENAME_MODIFIER) + NP_LIBRARY_ARRAY_END)
    experiment_json_dict[ds_constants.TRAINING_SPECTRA_ARRAY_KEY] = training_spectra_filename
    with tf.gfile.Open(os.path.join(output_dir, experiment_setup.json_name), 'w') as writer:
        experiment_json = json.dumps(experiment_json_dict)
        writer.write(experiment_json)