-
Notifications
You must be signed in to change notification settings - Fork 19
check to raise error when non-standard utf-8 #873
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
Conversation
@@ -323,6 +324,19 @@ def publish_from_csv(path: Path, new_topic: str = None) -> None: | |||
LOGGER.debug(f'Publishing station list from {path}') | |||
station_list = [] | |||
with path.open() as fh: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with path.open() as fh:
try:
_ = fh.readlines()
except UnicodeDecodeError as err:
msg = f'Invalid utf-8 in station metadata file: {err}'
LOGGER.error(msg)
raise RuntimeError(msg)
fh.seek(0)
reader = csv.DictReader(fh)
@alhelguera to add test data/CI integration. |
- name: add Brazil wrongly encoded station data and check for error message | ||
env: | ||
STATION_METADATA: /data/wis2box/metadata/station/brazil.csv | ||
run: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be encoding test logic in CI. This test should be in put forth in tests/integration/test_workflow.py
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomkralidis, I disagree with your comment you asked Alberto to write the test in CI in your previous request and this test is based on command-line logic to demonstrate that the user receives a clear error when ingesting stations from the command-line, we should not put this in tests/integration/test_workflow.py
catching the UTF-8 decoding error to give a better error message