Skip to content

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

@joyceyuu joyceyuu requested a review from wilko77 February 17, 2020 05:31
@joyceyuu joyceyuu requested a review from hardbyte February 19, 2020 04:39
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.

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)

# 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?

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

4 participants