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

Support upload to S3 bucket #287

Merged
merged 1 commit into from
Apr 13, 2022
Merged

Conversation

gregorjerse
Copy link
Contributor

@gregorjerse gregorjerse commented Apr 12, 2022

EXP-370

@gregorjerse gregorjerse force-pushed the feature/upload branch 5 times, most recently from a51ab3f to fae3b30 Compare April 12, 2022 10:06
"""The uploader class.

It is used to upload the file to the Genialis platform. Is supports
uploading files directly to the server and also directly to the S3 bucket.
Copy link
Member

Choose a reason for hiding this comment

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

Remove "directly" in front of "to the server".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

try:
self._upload_config = self.resolwe.api.upload_config.get()
except ResolweServerError:
self._upload_config = {"type": "LOCAL"}
Copy link
Member

Choose a reason for hiding this comment

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

Add an error log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

try:
return UploadType[self.upload_config["type"]]
except KeyError:
return UploadType.default()
Copy link
Member

Choose a reason for hiding this comment

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

Error log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@gregorjerse gregorjerse force-pushed the feature/upload branch 2 times, most recently from 2458630 to 8f22270 Compare April 12, 2022 11:08
Copy link
Member

@JureZmrzlikar JureZmrzlikar left a comment

Choose a reason for hiding this comment

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

For me it works on both: QA and QA2

"""

def __init__(self, resolwe: "Resolwe"):
"""Store the ."""
Copy link
Member

Choose a reason for hiding this comment

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

Unfinished docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

UploadType.S3: self._upload_s3,
}
# Use the following upload type if one can not be determined.
self._default_upload_type = UploadType.LOCAL
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rather UploadType.default()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed this line. It is not needed anymore since the default has been moved to the enum.

self._upload_config = self.resolwe.api.upload_config.get()
except ResolweServerError:
self.resolwe.logger.exception("Upload config could not be retrieved.")
self._upload_config = {"type": "LOCAL"}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rather {"type": UploadType.default()} ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost: UploadType.default().name to return the compatible config.

@@ -387,7 +393,8 @@ def test_always_ok(self, resolwe_mock):
status_code=200, **{"json.return_value": requests_response}
)

response = Resolwe._upload_file(resolwe_mock, self.file_path)
response = Uploader(resolwe_mock)._upload_local(self.file_path)
# response = Resolwe._upload_file(resolwe_mock, self.file_path)
Copy link
Member

Choose a reason for hiding this comment

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

Remove if not needed.

@@ -398,14 +405,16 @@ def test_always_bad(self, resolwe_mock, requests_mock):
# Immitate response form server - always status 400
requests_mock.post.return_value = MagicMock(status_code=400)

response = Resolwe._upload_file(resolwe_mock, self.file_path)
response = Uploader(resolwe_mock)._upload_local(self.file_path)
# response = Resolwe._upload_file(resolwe_mock, self.file_path)
Copy link
Member

Choose a reason for hiding this comment

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

Remove if not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@gregorjerse gregorjerse merged commit 80622c0 into genialis:master Apr 13, 2022
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.

None yet

3 participants