bilby issueshttps://git.ligo.org/lscsoft/bilby/-/issues2024-03-16T19:47:47Zhttps://git.ligo.org/lscsoft/bilby/-/issues/707Saving Result file ignores outdir if a filename is specified2024-03-16T19:47:47ZJacob GolombSaving Result file ignores outdir if a filename is specifiedIf a user wants to manually save a result file with the `save_to_file` method and specifies both an outdir and filename, the outdir gets ignored and the file is just saved to the local directory with the filename specified as if it is th...If a user wants to manually save a result file with the `save_to_file` method and specifies both an outdir and filename, the outdir gets ignored and the file is just saved to the local directory with the filename specified as if it is the full path (e.g. [this line](https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/core/result.py#L814)). If filename is not specified as an input, then it is written as a local variable as if it were the full path name [here](https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/core/result.py#L781). Maybe if an outdir and filename are both specified, then a `path_to_file = os.path.join(outdir, filename)` and the json/hdf5 should be dumped to `path_to_file`. Then [this loop](https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/core/result.py#L781) should be changed to `path_to_file = result_file_name(outdir, self.label, extension, gzip)`. Unless for some reason it is sometimes expected that filename should contain the outdir in it as well.https://git.ligo.org/lscsoft/bilby/-/issues/693Saving result file after sampling fails if lal dict is passed2023-12-20T19:42:01ZAditya Vijaykumaraditya.vijaykumar@ligo.orgSaving result file after sampling fails if lal dict is passed@ish.gupta recently found out that adding a lal_waveform_dictionary to the waveform_arguments works fine while sampling, but fails to save to file at the end of sampling with the following error traceback.
```
File "/Users/aytida/work...@ish.gupta recently found out that adding a lal_waveform_dictionary to the waveform_arguments works fine while sampling, but fails to save to file at the end of sampling with the following error traceback.
```
File "/Users/aytida/work/rough/bilby/bilby/core/result.py", line 795, in save_to_file
json.dump(dictionary, file, indent=2, cls=BilbyJsonEncoder)
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/__init__.py", line 179, in dump
for chunk in iterable:
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/Users/aytida/work/rough/bilby/bilby/core/utils/io.py", line 87, in default
return json.JSONEncoder.default(self, obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/aytida/miniconda3/envs/bilby2/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Dict is not JSON serializable
<more stuff>
TypeError: cannot pickle 'lal.Dict' object
```
I [created a patch](https://git.ligo.org/aditya.vijaykumar/bilby/-/commit/c6506d2891857666a793429855f7e25c208ca538) that resolves this issue by ignoring the `lal_waveform_dictionary` altogether while saving the file, but I guess that isn't the nicest way to fix this. Happy to start an MR with any suggestions!