nasa / cumulus-message-adapter-python Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
When installing this package using Poetry I received the following error message
Invalid constraint (cumulus-message-adapter>=2.0.0<2.1.0) found in cumulus-message-adapter-python-2.0.1 dependencies, skipping
After reviewing the source code I noticed that the entry in the requirements.txt file is malformed. Per PEP 440 version clauses should be separated by a comma.
Recommended fix is to update requirements.txt file to
cumulus-message-adapter>=2.0.0, <2.1.0
It's great that cumulus-message-adapter-python
is available on pypi. I'm wondering if you would consider making it available on conda-forge
too? I'm happy to do the initial legwork, but it would be good to keep the maintainers of this repository as the maintainers on the conda recipe. Thoughts?
Sometimes we want our lambda to log messages that include a JSON string, but provide a little context, such as 'Post to CMR response: <JSON here>'
. Unfortunately, that causes an error if passed as a string to logger.debug
(and the other functions) or is included in the error message, due to this line:
https://github.com/nasa/cumulus-message-adapter-python/blob/v1.2.1/cumulus_logger.py#L213
That is, this code leads to a KeyError: '"easter_bunny"'
:
from cumulus_logger import CumulusLogger
logger = CumulusLogger()
response_txt = '{"easter_bunny": "fake sample response"}'
logger.debug(f'POST to CMR response: {response_txt}')
And this code leads to an IndexError: Replacement index 0 out of range for positional args tuple
:
logger.debug('POST to CMR response: {}')
When we first encountered this and I tracked down the .format()
call on the LOC I linked above, I realized I could work around this issue with this code change:
# # broken version from above
# response_txt = '{"easter_bunny": "fake sample response"}'
# logger.debug(f'POST to CMR response: {response_txt}')
# workaround, send the JSON string to str.format's **kwargs
logger.debug('POST to CMR response: {response}', response=response_text)
However, this did not fully eliminate the KeyErrors
; in the case where the CMR request failed, we raise an Exception so that the lambda fails appropriately:
if not response.ok:
raise RuntimeError('Post to CMR Failed:', response.text)
And when cumulus-message-adapter-python tries to log the exception object at...
https://github.com/nasa/cumulus-message-adapter-python/blob/v1.2.1/run_cumulus_task.py#L68
...the exception gets converted to a string, .format()
is called, and once again any curly braces in the message lead to a KeyError
or IndexError
.
I want to be able to have curly brace characters in my strings passed to the logger without an error being raised. #39 accomplishes this while maintaining the .format()
functionality by skipping the .format()
call if no args or kwargs are given.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.