Skip to content

utils: allow ujson for requests calls if it can be imported#102

Merged
RussTorres merged 2 commits intodevelopfrom
ujson_serialization
May 9, 2018
Merged

utils: allow ujson for requests calls if it can be imported#102
RussTorres merged 2 commits intodevelopfrom
ujson_serialization

Conversation

@RussTorres
Copy link
Copy Markdown
Collaborator

@RussTorres RussTorres commented May 8, 2018

overwrites default json handler for requests model with ujson if it is importable.

in testing cjson, simplejson, standard json, and ujson, ujson was the clear winner in all trials where there was a difference -- this seems to confirm what the internet has to say about the issue as well. This change should resolve #78 to a reasonable degree while not altering the code in the library.

@RussTorres
Copy link
Copy Markdown
Collaborator Author

For testing, I think we should treat this like we're treating scipy in the transform module -- have it as a test dependency and toggle its importability -- but I'm not sure which tests make sense to run with/without ujson since we don't have explicit integration tests for the utility module.

@RussTorres RussTorres requested a review from fcollman May 8, 2018 20:32
@codecov
Copy link
Copy Markdown

codecov bot commented May 8, 2018

Codecov Report

Merging #102 into develop will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #102      +/-   ##
===========================================
+ Coverage    93.86%   93.88%   +0.02%     
===========================================
  Files           16       16              
  Lines         1662     1668       +6     
===========================================
+ Hits          1560     1566       +6     
  Misses         102      102
Impacted Files Coverage Δ
renderapi/utils.py 95.45% <100%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 221e73e...ab0d730. Read the comment docs.

@fcollman
Copy link
Copy Markdown
Member

fcollman commented May 9, 2018

in travis we could make a matrix of environment variables, and have the import be conditional on an environment variable, and it would test it with the variable both ways. Or something akin to that..


# use ujson if installed for faster json
try:
import ujson as requests_json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you put this in here but didn't actually make use of it yet.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

right -- our test environment doesn't have ujson yet, but if it did we would use it as the default json implementation for all the requests json handling. I suppose we could just assume that the standard library json interface works if ujson works as well as checking to make sure that the defaulting works.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we just put it in test_requirements?

@RussTorres RussTorres merged commit ef5d187 into develop May 9, 2018
@fcollman fcollman deleted the ujson_serialization branch August 17, 2018 14:56
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