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

Npi 3290 clearer error on empty sinex header extras #27

Merged
merged 2 commits into from
Jun 6, 2024

Conversation

treefern
Copy link
Collaborator

@treefern treefern commented Jun 3, 2024

No description provided.

@treefern treefern requested a review from ronaldmaj June 3, 2024 04:57
Copy link
Collaborator

@ronaldmaj ronaldmaj left a comment

Choose a reason for hiding this comment

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

Tested this, and works for normal SNX file, and with ones missing header info - just wasn't able to get all different error cases.
I'm happy for this to go in though

# read line that starts with %=SNX and parse it into dict
snx_bytes = _gn_io.common.path2bytes(path_or_bytes)
header_begin = snx_bytes.find(b"%=SNX")
if (header_begin == -1):
raise ValueError("Sinex header missing!", file_desc(path_or_bytes))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was able to test this and works well

header_end = snx_bytes.find(b"\n", header_begin)
if header_end == -1:
raise ValueError("Sinex header found but wasn't newline terminated (end unclear)", file_desc(path_or_bytes))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've tried to end up here but wasn't successful in editing an SNX to do so - do you have an example file where you were able to?

raise ValueError(f"Sinex header is empty for UNKNOWN file (passed in as bytes object not path)")
else:
raise ValueError(f"Sinex header is empty for file: '{str(path_or_bytes)}'")
raise ValueError(f"Sinex header found, but empty!", file_desc(path_or_bytes))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, wasn't able to get here.
I've tried just having the %=SNX with nothing afterwards, but the error is around pandas not finding columns I believe:

EmptyDataError: No columns to parse from file

Anyway, none of this is a show stopper so I think it can go in

@ronaldmaj ronaldmaj merged commit 887da53 into main Jun 6, 2024
@treefern treefern deleted the NPI-3290-clearer-error-on-empty-sinex-header-extras branch September 12, 2024 09:13
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.

2 participants