Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iso_date_regex_pattern config in file_batcher module and allow override #1580

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion morpheus/modules/file_batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def file_batcher(builder: mrc.Builder):
sampling = config.get("sampling", None)
sampling_rate_s = config.get("sampling_rate_s", None)

iso_date_regex_pattern = config.get("batch_iso_date_regex_pattern", DEFAULT_ISO_DATE_REGEX_PATTERN)
iso_date_regex_pattern = config.get("iso_date_regex_pattern", DEFAULT_ISO_DATE_REGEX_PATTERN)
iso_date_regex = re.compile(iso_date_regex_pattern)

if (sampling_rate_s is not None and sampling_rate_s > 0):
Expand All @@ -99,6 +99,7 @@ def file_batcher(builder: mrc.Builder):
"sampling": sampling,
"start_time": config.get("start_time"),
"end_time": config.get("end_time"),
"iso_date_regex_pattern": iso_date_regex_pattern
}

default_file_to_df_opts = {
Expand All @@ -123,6 +124,13 @@ def build_period_batches(files: typing.List[str],
params: typing.Dict[any, any]) -> typing.List[typing.Tuple[typing.List[str], int]]:
file_objects: fsspec.core.OpenFiles = fsspec.open_files(files)

nonlocal iso_date_regex_pattern
nonlocal iso_date_regex

if params["iso_date_regex_pattern"] != iso_date_regex_pattern:
iso_date_regex_pattern = params["iso_date_regex_pattern"]
iso_date_regex = re.compile(iso_date_regex_pattern)

try:
start_time = params["start_time"]
end_time = params["end_time"]
Expand Down
Loading