ISISNeutronMuon / ISISNeutronMuon/MDANSE
[CI/CD] Add tests for encoding inputs
- Dominant language
- Python
- Stars
- 29
- Forks
- 8
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 9
Description
Currently no automated testing for JSONising structural formats.
> At the moment, manual testing shows problems with saving the input parameters in the output files:
> ```
> File "MDANSE/Framework/Jobs/IJob.py", line 419, in run
> raise JobError(self, tb)
> MDANSE.Framework.Jobs.IJob.JobError: Traceback (most recent call last):
> File "MDANSE/Framework/Jobs/IJob.py", line 412, in run
> self.finalize()
> File "MDANSE/Framework/Jobs/AngularCorrelation.py", line 213, in finalize
> self._outputData.write(
> File "MDANSE/Framework/OutputVariables/IOutputVariable.py", line 42, in write
> temp_format.write(basename, self, header, inputs)
> File "MDANSE/Framework/Formats/MDAFormat.py", line 64, in write
> HDFFormat.write(filename, data, header, run_instance, extension)
> File "MDANSE/Framework/Formats/HDFFormat.py", line 97, in write
> inputs = run_instance.output_configuration()
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "MDANSE/Framework/Configurable.py", line 209, in output_configuration
> result[name] = conf.to_json()
> ^^^^^^^^^^^^^^
> File "MDANSE/Framework/Configurators/IConfigurator.py", line 263, in to_json
> return self._encoder.encode(self._original_input)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 200, in encode
> chunks = self.iterencode(o, _one_shot=True)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 258, in iterencode
> return _iterencode(o, 0)
> ^^^^^^^^^^^^^^^^^
> File "python@3.11/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 180, in default
> raise TypeError(f'Object of type {o.__class__.__name__} '
> TypeError: Object of type PosixPath is not JSON serializable
> ```
_Originally posted by @MBartkowiakSTFC in https://github.com/ISISNeutronMuon/MDANSE/issues/646#issuecomment-2634269887_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with Configurable.py's output_configuration and IConfigurator.py's to_json, then follow the HDFFormat.py and MDAFormat.py write paths shown in the traceback. Add automated coverage for JSON encoding of structural-format inputs, including the PosixPath failure, and verify that the tests catch the reported serialization problem.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100