-
Notifications
You must be signed in to change notification settings - Fork 0
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
Uploading spreadsheet for updates #15
Conversation
478968a
to
0f510d8
Compare
75cf343
to
7dc73f9
Compare
767d4e4
to
4e3148b
Compare
def tearDown(self) -> None: | ||
if self.test_file: | ||
if os.path.exists(self.test_file): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could use the tempfile library for tempfiles that automatically delete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, very nice lib! thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
raise SpreadsheetUploadError(401, "An authentication token must be supplied when uploading a spreadsheet") | ||
self.ingest_api.set_token(token) | ||
|
||
def upload(self, submission_url, path, project_uuid=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is upload
for a full project rather than just updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The upload function is for uploading spreadsheets with new entities. Sometime's the project is created before submission so we supply it if it already exists.
submission_resource = self.ingest_api.create_submission() | ||
return submission_resource | ||
|
||
def _assert_token_exists(self, token): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this input validation code? assert
makes it sound like testing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to _validate_token_exists
broker_app.py
Outdated
ingest_api = IngestApi() | ||
spreadsheet_generator = SpreadsheetGenerator(ingest_api) | ||
spreadsheet_job_manager = SpreadsheetJobManager(spreadsheet_generator, SPREADSHEET_STORAGE_DIR) | ||
global ingest_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is using global
a safe approach?
Should we use flask's app context instead? or the "g" object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, i didn't know about that. Applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm it doesn't function as a global variable.
This is a good place to store resources during a request. During testing, you can use the Faking Resources and Context pattern to pre-configure such resources.
I'll revert to using the global :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be my lack of knowledge, but why are we defining these 3 variables here and once again at the setup
method?
@@ -12,7 +13,13 @@ | |||
import tempfile | |||
import yaml | |||
|
|||
|
|||
# TODO these are integration tests, could either move to a separate directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the comments, I already moved them now to a separate directory to make it easier to run tests locally 😅
This reverts commit e7b8bda.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a tiny comment. Could we clarify it, please?
Tx
broker_app.py
Outdated
ingest_api = IngestApi() | ||
spreadsheet_generator = SpreadsheetGenerator(ingest_api) | ||
spreadsheet_job_manager = SpreadsheetJobManager(spreadsheet_generator, SPREADSHEET_STORAGE_DIR) | ||
global ingest_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be my lack of knowledge, but why are we defining these 3 variables here and once again at the setup
method?
@ke4 i think you're right, they're not needed. I removed them and moved the setup function on top to make it clearer there are global vars to be initialised. I don't know how else to avoid using global vars at the moment. But, I can see the performance benefit of it that it only initialises the schema template obj which is being used in template spreadsheet generation only once instead of initialising it every request so I'd like to retain the use of global vars for now. |
|
||
try: | ||
logger.info('Uploading spreadsheet!') | ||
submission_resource = spreadsheet_upload_svc.async_upload(token, request_file, is_update, project_uuid) | ||
submission_resource = spreadsheet_upload_svc.async_upload(token, request_file, is_update, project_uuid, submission_uuid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The is_update param is just passed through here, and there is subsequent branching logic further down the execution sequence.
This smells of unclean design. Maybe there would be room here for the "strategy" pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't have time to implement that for this sprint.
@@ -8,7 +8,7 @@ itsdangerous==0.24 | |||
jdcal==1.4 | |||
MarkupSafe==1.1 | |||
werkzeug>=0.15.3 | |||
-e git+https://github.com/ebi-ait/ingest-client.git@7f04ab9a#egg=hca_ingest | |||
-e git+https://github.com/ebi-ait/ingest-client.git@7038dcb#egg=hca_ingest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not using a normal version number? (x.y.z)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done this way in the early development of the ingest-client python lib. It wasn't changed yet. We should also set up and release build for the ingest-client repo so that it'll release the module to PyPI every merges to master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed a ticket for the ingest-client CI/CD setup: ebi-ait/dcp-ingest-central#385
Hi @amnonkhen , I would like to merge this today so that I can deploy and hand over to a wrangler for testing, we could apply those comments later. |
Closing in favour of PR #16 . This branch was already merged with that branch. |
ebi-ait/dcp-ingest-central#349