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

Al 131 add streaming read #33

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

cccs-douglass
Copy link
Collaborator

A PR to discuss ongoing work related to streaming read operations in the filestore

@codecov-io
Copy link

codecov-io commented Oct 7, 2020

Codecov Report

Merging #33 into master will increase coverage by 0.28%.
The diff coverage is 64.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   60.89%   61.17%   +0.28%     
==========================================
  Files         115      115              
  Lines        9852     9981     +129     
==========================================
+ Hits         5999     6106     +107     
- Misses       3853     3875      +22     
Impacted Files Coverage Δ
assemblyline/filestore/transport/ftp.py 22.45% <29.16%> (+0.03%) ⬆️
assemblyline/filestore/transport/sftp.py 32.82% <50.00%> (+1.20%) ⬆️
assemblyline/filestore/transport/base.py 53.33% <54.54%> (+0.39%) ⬆️
assemblyline/filestore/__init__.py 69.23% <66.66%> (+6.22%) ⬆️
assemblyline/filestore/transport/s3.py 66.12% <75.00%> (+0.36%) ⬆️
assemblyline/filestore/transport/local.py 70.94% <77.77%> (+0.94%) ⬆️
assemblyline/filestore/transport/http.py 77.41% <85.71%> (+12.41%) ⬆️
assemblyline/filestore/transport/azure.py 69.56% <93.33%> (+2.89%) ⬆️
assemblyline/odm/models/service.py 100.00% <0.00%> (ø)
assemblyline/odm/models/service_delta.py 100.00% <0.00%> (ø)
... and 3 more

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 839f972...3e299bb. Read the comment docs.

if self.readthread is None:
self.readthread = threading.Thread(target=self.retrMethod(chunk_size), daemon=True)
self.readthread.start()
chunk = self.filequeue.get()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Make sure read method doesn't get blocked forever if there is an extra call to read after the last one that returns none

self.response.close()

def read(self, chunk_size=1024):
return next(self.response.iter_content(chunk_size=chunk_size))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but we probably don't want to be created a new iterator on every call to read

@@ -139,3 +150,16 @@ def _join(base, path):
if base is None:
return path
return os.path.join(base, path.lstrip("/")).replace("\\", "/")

class TransportReadStreamLocal(TransportReadStream):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You probably don't need this class, and can return the file object directly from read

@cccs-douglass cccs-douglass added draft Work in progress enhancement New feature or request labels Oct 14, 2020
 - Adds TransportFile and TransportFile children objects
 - Adds TransportReadStreamS3 object
 - Adds FTP implementation
 - Changes TransportFile to TransportReadStream
 - Adds some tests
 - Fixes s3 Transport's read function
 - Adds sftp Transport's read function
 - Adds HTTP read implementation
 - Adds testing for local, http, https read
 - creates infrastructure for FTP test with docker container
 - Adds ftp filestore tests
 - Adds ftpserver docker container
 - Adds SFTP server container to docker compose
 - Adds lines for testing read() operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
draft Work in progress enhancement New feature or request
Projects
None yet
3 participants