WaterButler is a Python web application for interacting with various file storage services via a single RESTful API, developed at Center for Open Science.
Apache License 2.0
62
stars
76
forks
source link
[OathPit] Throw the Box Provider into OathPit #374
Throw the box provider into the oath pit. That is, in human-readable English, refactoring the box provider for aiohttp 0.18 -> 3.4 upgrade.
Changes
Updated MultiStream and CutoffStream with __aiter__() and __anext__()
Similar to the fix for OSFStorage/GoogleCloud, both streams must implement the __anext__() to properly read the chunk. CutoffStream is used for chunked upload (Box, Dropbox, FigShare and Amazon S3). MultiStream is inherited by FormDataStream (Box contiguous upload), by JsonStream (GitHub) and by ZipLocalFile (ZipStreamReader, DataVerse).
Removed usage of self.request() and context manager
Before: the provider used self.request() and self.make_request() interchangeably when making requests; the former was just a simple context wrap-up around the latter so that CM could be used; but it still had to use the latter for streaming requests probably due to similar CM limitations we encountered during aiohttp upgrade
After: the provider now uses make_request() consistently. All CM async with ... as ... usages have been replaced with its non-CM counterpart. Please note that self.request() was already removed from the core provider during OSFStorage/GoogleCloud upgrade.
Other Changes
Updated configurations to enable the provider and test
Removed redundant json.dumps() on request data
--retry -> retry -= 1 for chunked upload try loop
Style updates: more compact (less blank lines), added comma for the last param of each make_request() call if not present
[x] Fixd tests
In aiohttp3, ClientResponse's json() method now requires a content type header. Thus, 'headers': {'Content-Type': 'application/json'} (default value, unless another type is explicitly provided) must be provided when registering a URI if json() is called by the response.
WB core provider's newmake_request() uses upper case for HTTP method. All lower case method must be changed during URI registration in tests.
Before and after: aiohttpretty is case sensitive on HTTP method.
Before core and OSFStorage upgrade: URI registering in tests must choose the case carefully according to how the code is written in each provider :( After: simply use upper case everywhere in tests :)
Coverage increased (+4.9%) to 43.746% when pulling acb537a15b76f748f1ec6769dad17d59d882f818 on cslzchen:feature/oathpit-box into 04bec9a42e71cff664845567c7d3ce0177c7aed3 on CenterForOpenScience:feature/oathpit.
Ticket
https://openscience.atlassian.net/browse/ENG-313
Purpose
Throw the box provider into the oath pit. That is, in human-readable English, refactoring the box provider for
aiohttp
0.18 -> 3.4 upgrade.Changes
Updated MultiStream and CutoffStream with
__aiter__()
and__anext__()
Similar to the fix for OSFStorage/GoogleCloud, both streams must implement the__anext__()
to properly read the chunk.CutoffStream
is used for chunked upload (Box, Dropbox, FigShare and Amazon S3).MultiStream
is inherited byFormDataStream
(Box contiguous upload), byJsonStream
(GitHub) and byZipLocalFile
(ZipStreamReader
, DataVerse).Removed usage of
self.request()
and context managerself.request()
andself.make_request()
interchangeably when making requests; the former was just a simple context wrap-up around the latter so that CM could be used; but it still had to use the latter for streaming requests probably due to similar CM limitations we encountered duringaiohttp
upgrademake_request()
consistently. All CMasync with ... as ...
usages have been replaced with its non-CM counterpart. Please note thatself.request()
was already removed from the core provider during OSFStorage/GoogleCloud upgrade.Other Changes
json.dumps()
on request data--retry
->retry -= 1
for chunked upload try loopmake_request()
call if not present[x] Fixd tests
aiohttp3
,ClientResponse
'sjson()
method now requires a content type header. Thus,'headers': {'Content-Type': 'application/json'}
(default value, unless another type is explicitly provided) must be provided when registering a URI ifjson()
is called by the response.make_request()
uses upper case for HTTP method. All lower case method must be changed during URI registration in tests.aiohttpretty
is case sensitive on HTTP method.Side effects
No
QA Notes
No, please refer to the ticket
Deployment Notes
No, please refer to the ticket