dingo-gw / dingo

Dingo: Deep inference for gravitational-wave observations
MIT License
55 stars 18 forks source link

Saving of `input_dims` / issue with PESummary #148

Closed stephengreen closed 1 year ago

stephengreen commented 1 year ago

The embedding network input_dims configuration is not being saved properly in the settings attribute of HDF5 files. This can be seen using dingo_ls, which includes

          input_dims: !!python/tuple
          - 2
          - 3
          - 8033

settings is saved as a string, and somehow input_dims is not being properly converted to this string.

The problem comes when PESummary tries to create a metafile of samples along with all Dingo settings. It gives the error

2023-03-01  23:53:46 PESummary INFO    : Starting to generate the meta file
Traceback (most recent call last):
  File "/Users/stephen/Documents/Research/dingo-gw/venv/bin/summarypages", line 8, in <module>
    sys.exit(main())
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/cli/summarypages.py", line 247, in main
    meta_file_cls(args, history=_history)
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/gw/file/meta_file.py", line 291, in __init__
    meta_file.save_to_hdf5(
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/gw/file/meta_file.py", line 126, in save_to_hdf5
    _MetaFile.save_to_hdf5(
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/core/file/meta_file.py", line 624, in save_to_hdf5
    recursively_save_dictionary_to_hdf5_file(
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/core/file/meta_file.py", line 56, in recursively_save_dictionary_to_hdf5_file
    recursively_save_dictionary_to_hdf5_file(
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/core/file/meta_file.py", line 56, in recursively_save_dictionary_to_hdf5_file
    recursively_save_dictionary_to_hdf5_file(
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/core/file/meta_file.py", line 56, in recursively_save_dictionary_to_hdf5_file
    recursively_save_dictionary_to_hdf5_file(
  [Previous line repeated 3 more times]
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/core/file/meta_file.py", line 64, in recursively_save_dictionary_to_hdf5_file
    create_hdf5_dataset(
  File "/Users/stephen/Documents/Research/dingo-gw/pesummary/pesummary/core/file/meta_file.py", line 158, in create_hdf5_dataset
    raise TypeError(error_message.format(key, value, type(value)))
TypeError: Cannot process input_dims=(2, 3, 8033) from list with type <class 'tuple'> for hdf5

I had included the Dingo dataset settings among the PESummary metadata to be saved, and it is obviously not able to save this tuple.

I am not sure why it cannot save a tuple, but if it was saved properly (as a list?) to begin with we would not have this problem. So it would be good to track down the source of the weird saving and fix it. Also make sure this does not create any new bugs in Dingo, and include a conversion script to fix existing Dingo datasets.