more distinct miniseed read errors, print zero size instead of unknown format - #3721
more distinct miniseed read errors, print zero size instead of unknown format#3721filefolder wants to merge 5 commits into
Conversation
| # create empty file | ||
| open(tmpfile, 'wb').close() | ||
| # create small non-empty file | ||
| open(tmpfile, 'wb').write(b'\x82\x00\x00') |
There was a problem hiding this comment.
@filefolder you're changing the behaviour here ? I see the change in base.py is raising a ValueError when the file is empty, but the pytest below only checks TypeError, no?
There was a problem hiding this comment.
Yeah, has to be reverted, this is an intentional test for empty files clearly.
| else: | ||
| raise ValueError("Invalid MiniSEED file.") | ||
| raise ValueError("Invalid MiniSEED file: " | ||
| "unexpected content in noise record.") |
There was a problem hiding this comment.
ha I don't actually know. the comment for that block is # Might be a noise record or completely empty. and I continued on with that just to better isolate where the failure was happening. IIRC the whole point to this PR is just to narrow down what's actually causing the error.
There was a problem hiding this comment.
But, you clearly did this for an unclear error you encountered right? So what was the actual problem in your case? Was it a noise record?
| else: | ||
| if isinstance(filename, str) and \ | ||
| Path(filename).stat().st_size == 0: | ||
| raise ValueError("File is empty: {}".format(filename)) |
There was a problem hiding this comment.
In principle something like this is nice, but if we do it, I think we should have a proper function that goes through all the options a read input can have (str, BytesIO, ...) and checks for empty file.
|
I feel like let's wait for feedback. It seems a bit unclear what the actual use case for this was and if it helped make the error clearer. |
|
TBH this PR can probably be flushed; it was mainly just to provide a clue for issues like #3549 |
What does this PR do?
the "Invalid MiniSEED file" error messages are often a bit too vague to determine what is happening (e.g. #3549). Now expanded somewhat.
Also catches the read in base.py-- after all attempts to determine format it will finally check if the file is zero before printing the "unknown format".
on master
AI used?
for sanity washing