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

feat: add warning messages if the response has a "messages" key with a non-empty list value #58

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

kan-fu
Copy link
Collaborator

@kan-fu kan-fu commented Jan 31, 2025

Fix #28. This is the last PR before the 2.5.0 release.

Added the feature to log warning messages. There is also another module called "warning", but logging seems better in this case because I found the "warning" message only warns once for the same code line, which is not what we want.

Also added a flag (default True) in the ONC class so that users can turn off the warning information if they would like.

From what I understand, only /dataProduct/delivery and scalar/raw data web services have this "messages" key in the response.

I tested it by running (code snippet borrowed from #4 )

request = onc.orderDataProduct(
    filters={
        "dataProductCode": "AD",
        "extension": "wav",
        "dateFrom": "2016-06-20T12:00:00.000Z",
        "dateTo": "2016-06-20T12:01:00.000Z",
        "deviceCode": "ICLISTENHF1251",
        "dpo_audioDownsample": -1,
    }
)

It outputs

WARNING: When calling https://data.oceannetworks.ca/api/dataProductDelivery with filters 
{'dataProductCode': 'AD',
 'dateFrom': '2016-06-20T12:00:00.000Z',
 'dateTo': '2016-06-20T12:01:00.000Z',
 'deviceCode': 'ICLISTENHF1251',
 'dpo_audioDownsample': -1,
 'extension': 'wav',
 'method': 'request'},
there are several warning messages:
* No value was given for the required parameter dpo_audioFormatConversion the default value 0 will be used. For additional information about this parameter see https://wiki.oceannetworks.ca/display/DP/Audio+Format+Conversion
* No value was given for the required parameter dpo_hydrophoneDataDiversionMode the default value OD will be used. For additional information about this parameter see https://wiki.oceannetworks.ca/display/DP/Hydrophone+Data+Acquisition+and+Diversion+Mode

Request Id: 22769615
Estimated File Size: 720 MB
.... (normal output)

@eliferguson eliferguson merged commit 7a78cee into main Feb 7, 2025
6 checks passed
@kan-fu kan-fu deleted the issue-28-warning-message branch February 7, 2025 21:54
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.

Raise warnings when "messages" exists in json keys
3 participants