-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor s3 submodule to minimize resource usage (#569)
* refactor s3 submodule to minimize resource usage creating sessions and resources costs time and memory * git add benchmark/read_s3.py $ time python benchmark/read_s3.py < benchmark/urls.txt real 1m20.786s user 0m8.619s sys 0m0.894s $ time python benchmark/read_s3.py create_session < benchmark/urls.txt real 1m45.826s user 0m4.554s sys 0m0.149s $ time python benchmark/read_s3.py create_resource < benchmark/urls.txt real 0m22.046s user 0m1.474s sys 0m0.065s $ time python benchmark/read_s3.py create_session_and_resource < benchmark/urls.txt real 0m21.086s user 0m1.496s sys 0m0.073s * fixup * Update smart_open/s3.py Co-authored-by: Radim Řehůřek <radimrehurek@seznam.cz> * Update read_s3.py * update howto * update howto.md Co-authored-by: Radim Řehůřek <radimrehurek@seznam.cz>
- Loading branch information
Showing
4 changed files
with
152 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
|
||
import boto3 | ||
import smart_open | ||
|
||
urls = [line.strip() for line in sys.stdin] | ||
|
||
tp = {} | ||
if 'create_session_and_resource' in sys.argv: | ||
tp['session'] = boto3.Session() | ||
tp['resource'] = tp['session'].resource('s3') | ||
elif 'create_resource' in sys.argv: | ||
tp['resource'] = boto3.resource('s3') | ||
elif 'create_session' in sys.argv: | ||
tp['session'] = boto3.Session() | ||
|
||
for url in urls: | ||
smart_open.open(url, transport_params=tp).read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters