mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-03 20:28:12 +08:00
binary wire format with flatbuffers (#509)
* first flatbuffer schema * do not lint auto-generated files * add flatbuffers package * add flatbuffer module * wire up /data/X/T route * use flatbuffers for matrix data fetc * clarity and comments * add flatbuffer layout route * clean up obsolete code * fix tests * move flake8 config to setup.cfg * add comments * lint * rework layout routes for fbs * add more type support to fbs * lint * add flatbuffer support for annotations * function name improvements * fix botched merge with master * remove unused import * route cleanup for flatbuffers * rename function for clarity * add missing globals to Jest tests * fix client JS tests * fix routes for Python tests * comments for clarity * non-finite floating point hardening * more non-finite number handling * lint * fix tests for summarizeAnnotations * harden diffexp calculation against FP errors * cleanup unused code * lint * add encoding tests for flatbuffers * application type specified as strings * fix spelling error * improve variable names * add note about documentation gap * rename FBS DataFrame to Matrix
This commit is contained in:
@@ -25,17 +25,18 @@ export function catchErrorsWrap(fn, dispatchToUser = false) {
|
||||
}
|
||||
|
||||
/*
|
||||
Wrapper to perform an async fetch and JSON decode response.
|
||||
Wrapper to perform async fetch with some modest error handling
|
||||
and decoding.
|
||||
*/
|
||||
export const doJsonRequest = async url => {
|
||||
const doFetch = async (url, acceptType) => {
|
||||
const res = await fetch(url, {
|
||||
method: "get",
|
||||
headers: new Headers({
|
||||
"Content-Type": "application/json"
|
||||
Accept: acceptType
|
||||
})
|
||||
});
|
||||
if (res.ok && res.headers.get("Content-Type") === "application/json") {
|
||||
return res.json();
|
||||
if (res.ok && res.headers.get("Content-Type") === acceptType) {
|
||||
return res;
|
||||
}
|
||||
// else an error
|
||||
let msg = `Unexpected HTTP response ${res.status}, ${res.statusText}`;
|
||||
@@ -47,6 +48,22 @@ export const doJsonRequest = async url => {
|
||||
throw new Error(msg);
|
||||
};
|
||||
|
||||
/*
|
||||
Wrapper to perform an async fetch and JSON decode response.
|
||||
*/
|
||||
export const doJsonRequest = async url => {
|
||||
const res = await doFetch(url, "application/json");
|
||||
return res.json();
|
||||
};
|
||||
|
||||
/*
|
||||
Wrapper to perform an async fetch for binary data.
|
||||
*/
|
||||
export const doBinaryRequest = async url => {
|
||||
const res = await doFetch(url, "application/octet-stream");
|
||||
return res.arrayBuffer();
|
||||
};
|
||||
|
||||
/*
|
||||
This function "packs" filter index lists into the more efficient
|
||||
"range" form specified in the REST 0.2 spec.
|
||||
|
||||
Reference in New Issue
Block a user