Skip to content

Issue 538 - fixing wrong grib-filter-expression flag.#539

Open
shubhamkumar-bot wants to merge 3 commits into
google:mainfrom
shubhamkumar-bot:issue-538
Open

Issue 538 - fixing wrong grib-filter-expression flag.#539
shubhamkumar-bot wants to merge 3 commits into
google:mainfrom
shubhamkumar-bot:issue-538

Conversation

@shubhamkumar-bot
Copy link
Copy Markdown

Added a flag that allows the user to choose whether to log invalid files (those missing the key-value pairs specified in the where flag) and continue execution, or to throw an error immediately upon encountering the first invalid file.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 22, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

grib_get_cmd = shutil.which('grib_get')
uniq_cmd = shutil.which('uniq')
for cmd, name in [(grib_get_cmd, 'grib_copy'), (grib_get_cmd, 'grib_get'), (uniq_cmd, 'uniq')]:
for cmd, name in [(grib_copy_cmd, 'grib_copy'), (grib_get_cmd, 'grib_get'), (uniq_cmd, 'uniq')]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this change in a separate PR please!

self.logger.info('Finished uploading %r', self.input_path)
except Exception as e:
log_msg = (
f"GRIB tool failed for {self.input_path!r}. This means the requested "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:

  • GribSplitterV2 failed for ...
  • We can omit This means the requested filter expression {self.grib_filter_expression!r} does not exist in this file. and just log the error instead.

f"Error: {e}"
)
if self.skip_on_invalid_grib_filter_expression:
self.logger.warning(f"{log_msg} | Flag 'skip_on_invalid_grib_filter_expression' is True. Skipping file.")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the log level as error.

nit: Can omit | Flag 'skip_on_invalid_grib_filter_expression' is True. Skipping file.

logger.info('Using splitter: GribSplitterV2')
return GribSplitterV2(file_path, output_info, force_split,
logging_level, grib_filter_expression)
logging_level, grib_filter_expression, skip_on_invalid_grib_filter_expression)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run a linter over the files.

def __init__(self, input_path: str, output_info: OutFileInfo,
force_split: bool = False, logging_level: int = logging.INFO,
grib_filter_expression: t.Optional[str] = None):
grib_filter_expression: t.Optional[str] = None, skip_on_invalid_grib_filter_expression:bool = False):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run a linter over the files.

'specifically supported by the GribSplitterV2'
'implementation.'
'Example: typeOfLevel=isobaricInhPa,level=1000')
parser.add_argument('--skip-on-invalid-grib-filter-expression', action='store_true', default=False,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this flag's name is a bit ambiguous. Rather than validating whether the GRIB filter expression itself is invalid, it seems we are just toggling how the pipeline handles a failure (crashing vs. logging and continuing).

Suggestion: A better name would be suppress_splitter_pipeline_failures.

Copy link
Copy Markdown
Collaborator

@j9sh264 j9sh264 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass

@j9sh264 j9sh264 requested a review from mahrsee1997 May 26, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants