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

Extend upload endpoint to accept both types - clks and clknblocks #503

Closed
wants to merge 6 commits into from

Conversation

joyceyuu
Copy link
Contributor

By introducting blocking in anonlink-client, we also want to update entity-service to support blocking.

In this pull request, we extended the upload endpoint i.e. upload_json_clk_data to accept both uploading types:

  • json with clks element
  • json with clknblocks element
    with a focus on error handling.

Note that we also changed the way that writes to MINIO from put_object to fput_object to avoid large in memory bytes conversion.

Currently it will fail CI since it is only the start of this update to support blocking and more modifications are required to make the whole entity service work with blocking.

Close #501

backend/entityservice/views/project.py Outdated Show resolved Hide resolved
backend/entityservice/views/project.py Outdated Show resolved Hide resolved
backend/entityservice/views/project.py Outdated Show resolved Hide resolved
backend/entityservice/database/selections.py Outdated Show resolved Hide resolved
backend/entityservice/views/project.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@hardbyte hardbyte left a comment

Choose a reason for hiding this comment

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

A few suggested changes to consider then good to merge.

backend/entityservice/views/auth_checks.py Show resolved Hide resolved
Comment on lines 63 to 66
# check if the following combinations are true
# - uses_blocking is False AND 'clks' element in upload JSON
# - uses_blocking if True AND 'clknblocks' element in upload JSON
# otherwise, return safe_fail_request
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: This might as well be a docstring. (code comments like this don't come up IDE tooltips)

backend/entityservice/views/project.py Show resolved Hide resolved
@@ -216,8 +220,7 @@ def project_clks_post(project_id):
# However, as connexion is very, very strict about input validation when it comes to json, it will always
# consume the stream first to validate it against the spec. Thus the backflip to fully reading the CLks as
# json into memory. -> issue #184

receipt_token, raw_file = upload_json_clk_data(dp_id, get_json(), span)
receipt_token, raw_file = upload_json_clk_data(dp_id, get_json(), span, uses_blocking)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another nitpick. Utility arguments such as span should come after the useful ones.

Comment on lines 355 to 356
Convert user provided encodings from json array of base64 data into
a newline separated file of base64 data.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this docstring is now out of date?

backend/entityservice/views/project.py Show resolved Hide resolved
Comment on lines 380 to 374
logger.info('Writing uploaded {} JSON to {}'.format(element.upper(), tmp.name))
json.dump(clk_json, tmp)

logger.info(f"Received {count} encodings. Uploading {fmt_bytes(num_bytes)} to object store")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This now looks like a debug log statement - the tmp.name won't actually be around after the tmp file goes out of scope.

Could be worth logging the object store filename at info level in here though.

@hardbyte hardbyte mentioned this pull request Feb 19, 2020
@hardbyte
Copy link
Collaborator

Closing after rebasing into feature-blocking

@hardbyte hardbyte closed this Feb 20, 2020
@hardbyte hardbyte mentioned this pull request Feb 20, 2020
@wilko77 wilko77 deleted the project-clk-post branch June 18, 2020 05:03
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.

Extend upload endpoint to accept all formats specified in openAPI
3 participants