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

Async IO for HttpsDataVault, Fox Error Handling #7137

Merged
merged 15 commits into from
Jun 19, 2023
Merged

Async IO for HttpsDataVault, Fox Error Handling #7137

merged 15 commits into from
Jun 19, 2023

Conversation

fm3
Copy link
Member

@fm3 fm3 commented Jun 13, 2023

  • VaultPath.readBytes now returns Fox[Array[Byte]]
  • Adapted usages and implementations accordingly
  • Used the actually async http client play ws in the HttpsDataVault
  • 404 is now propagated as Fox.empty and fill-value is inserted there. Other errors are propagated as errors (leading to neutral gray rendered by the front-end rather than the fill value’s black). Note that this only works for the HttpsDataVault at this point

TODO

  • adapt vault path and data vault array interfaces
  • adapt usages
    • adapt opening arrays and reading headers
    • adapt reading chunks
  • adapt tests
  • use non-blocking http request in HttpsDataVault
    • pass ws in there
    • use ws to get info and data
    • basic auth
    • what about connect timeout?
    • ensure this works with gzip and brotli encodings
  • 404 should be propagated as Fox.empty and use fill value where appropriate
  • merge master into this after Shared Chunk Cache for all DatasetArrays, CacheWeight for AlfuCache #7067 is in there

URL of deployed dev instance (used for testing):

Steps to test:

  • Explore and view some remote datasets with different stores/data types, should still show data as before
  • Self-streaming should now work (create zarr link in annotation, explore that link in the same webknossos instance)

Issues:


  • Removed dev-only changes like prints and application.conf edits
  • Needs datastore update after deployment

@fm3
Copy link
Member Author

fm3 commented Jun 13, 2023

@frcroth do you happen to know a test dataset that uses brotli compression and can be accessed via https directly?

@fm3
Copy link
Member Author

fm3 commented Jun 14, 2023

I was able to validate that both gzip and brotli work ok with the adapted HttpsDataVault. Looks like play ws does decode gzip itself, but it then also “eats” the encoding header, so our own decode code does not attempt to decode it again. On the other hand, when ws encounters an encoding it does not know how to decode, it keeps the header and does not decode. So that also works with our VaultPath code.

To test this I used this simple flask server:

from flask import Flask, make_response
import gzip
import brotli

app = Flask(__name__)
app.config["COMPRESS_REGISTER"] = False

@app.route("/")
def hello_world():
    return "Hello, World!"

@app.route("/gzip")
def test_gzip():
    s = "Hello, World!"
    b = s.encode('utf8')
    content = gzip.compress(b, 5)
    response = make_response(content)
    response.headers['Content-length'] = len(content)
    response.headers['Content-Encoding'] = 'gzip'
    return response

@app.route("/brotli")
def test_brotli():
    s = "Hello, World!"
    b = s.encode('utf8')
    content = brotli.compress(b)
    response = make_response(content)
    response.headers['Content-length'] = len(content)
    response.headers['Content-Encoding'] = 'br'
    return response

and the test route in commit bdef9ce

@fm3 fm3 changed the title WIP: return Fox in DataVault reads Async IO for HttpsDataVault Jun 14, 2023
@fm3 fm3 changed the title Async IO for HttpsDataVault Async IO for HttpsDataVault, Fox Error Handling Jun 14, 2023
@fm3 fm3 marked this pull request as ready for review June 14, 2023 10:14
@fm3 fm3 requested a review from frcroth June 19, 2023 09:20
def ?~>(s: String): Fox[A] =
new Fox(futureBox.map(_ ?~! s))

// Add error message only in case of Failure, pass through Empty
def ?~~>(s: String): Fox[A] =
Copy link
Member

Choose a reason for hiding this comment

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

Not totally happy with the name, can we find something more distinguishable?

@fm3 fm3 merged commit b921d82 into master Jun 19, 2023
2 checks passed
@fm3 fm3 deleted the vault-read-fox branch June 19, 2023 10:48
fm3 added a commit that referenced this pull request Jun 19, 2023
fm3 added a commit that referenced this pull request Jun 19, 2023
fm3 added a commit that referenced this pull request Jun 19, 2023
fm3 added a commit that referenced this pull request Jun 19, 2023
* Revert "Revert "Async IO for HttpsDataVault, Fox Error Handling (#7137)" (#7154)"

This reverts commit 723e207.

* separate RemoteSourceDescriptorService and DataVaultService

* remove unused imports
hotzenklotz added a commit that referenced this pull request Jun 20, 2023
…esign-right-sidebar

* 'master' of github.com:scalableminds/webknossos:
  added Youtube videos to docs
  Log dataset uploads (with no conversion) to slack (#7157)
  Added "Automation Tutorial" to docs (#7160)
  fix logo image in README.md
  Second try for “Async IO for HttpsDataVault, Fox Error Handling” (#7155)
  Revert "Async IO for HttpsDataVault, Fox Error Handling (#7137)" (#7154)
  Async IO for HttpsDataVault, Fox Error Handling (#7137)
  Fix vault path for precomputed datasets (#7151)
  Add extended keyboard shortcut mode via ctrl + k for tool shortcuts (#7112)
  Shared Chunk Cache for all DatasetArrays, CacheWeight for AlfuCache (#7067)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants