Inconsistency between log and file parser usage
Closed this issue · 0 comments
kzscisoft commented
Describe the bug
- Keyword arguments can be provided to log parser but not file parser.
- You can use a class method as a log parser but not a file parser.
To Reproduce
import multiparser.parsing.file as mp_file_parser
import multiparser
import os
import json
class MyRun:
@mp_file_parser.file_parser
def _my_parser(
self,
input_file: str,
**__):
return {}, json.load(input_file)
def _my_callback(
self,
data,
metadata
):
print(data)
def launch(self):
"""Method which launches the simulation and the monitoring.
By default calls the three methods above, and sets up a FileMonitor for tracking files.
"""
# Start an instance of the file monitor, to keep track of log and results files
with multiparser.FileMonitor(
) as self.file_monitor:
# Monitor each file created by a Vector PostProcessor, and upload results to Simvue if file matches an expected form.
self.file_monitor.track(
path_glob_exprs = "test.json",
parser_func = self._my_parser,
callback = self._my_callback
)
self.file_monitor.run()
myrun = MyRun()
myrun.launch()
Expected behavior
- Behaviour of both parser types consistent.
- Ability to add keyword arguments to file parsers.
Environment (please complete the following information):
- OS: Ubuntu 24.04
- Python version: 3.12