run prettier(2.0.5) (#1438)

This commit is contained in:
Severiano Badajoz
2020-05-04 10:26:42 -07:00
committed by GitHub
parent b255e32548
commit 6cccc41c0f
118 changed files with 1979 additions and 1584 deletions
+37 -27
View File
@@ -24,15 +24,17 @@ async function obsAnnotationFetchAndLoad(dispatch, schema) {
const plimit = new PromiseLimit(5);
return Promise.all(
columns.map(col =>
columns.map((col) =>
plimit.add(() =>
fetchBinary(`annotations/obs?annotation-name=${encodeURIComponent(col.name)}`)
.then(buffer => Universe.matrixFBSToDataframe(buffer))
.then(df =>
fetchBinary(
`annotations/obs?annotation-name=${encodeURIComponent(col.name)}`
)
.then((buffer) => Universe.matrixFBSToDataframe(buffer))
.then((df) =>
dispatch({
type: "universe: column load success",
dim: "obsAnnotations",
dataframe: df
dataframe: df,
})
)
)
@@ -48,14 +50,14 @@ async function varAnnotationFetchAndLoad(dispatch, schema) {
const index = varAnnotations.index ?? false;
const names = index ? [index] : [];
return Promise.all(
names.map(name =>
names.map((name) =>
fetchBinary(`annotations/var?annotation-name=${encodeURIComponent(name)}`)
.then(buffer => Universe.matrixFBSToDataframe(buffer))
.then(df =>
.then((buffer) => Universe.matrixFBSToDataframe(buffer))
.then((df) =>
dispatch({
type: "universe: column load success",
dim: "varAnnotations",
dataframe: df
dataframe: df,
})
)
)
@@ -71,17 +73,18 @@ function layoutFetchAndLoad(dispatch, schema) {
const plimit = new PromiseLimit(5);
return Promise.all(
embNames.map(e =>
embNames.map((e) =>
plimit.add(() =>
fetchBinary(`layout/obs?layout-name=${encodeURIComponent(e)}`)
.then(buffer => Universe.matrixFBSToDataframe(buffer))
fetchBinary(
`layout/obs?layout-name=${encodeURIComponent(e)}`
).then((buffer) => Universe.matrixFBSToDataframe(buffer))
)
)
).then(dfs =>
).then((dfs) =>
dispatch({
type: "universe: column load success",
dim: "obsLayout",
dataframe: Dataframe.Dataframe.empty().withColsFromAll(dfs)
dataframe: Dataframe.Dataframe.empty().withColsFromAll(dfs),
})
);
}
@@ -90,13 +93,12 @@ function layoutFetchAndLoad(dispatch, schema) {
return promise fetching user-configured colors
*/
async function userColorsFetchAndLoad(dispatch) {
return fetchJson("colors")
.then(response =>
dispatch({
type: "universe: user color load success",
userColors: loadUserColorConfig(response)
})
);
return fetchJson("colors").then((response) =>
dispatch({
type: "universe: user color load success",
userColors: loadUserColorConfig(response),
})
);
}
/*
@@ -185,11 +187,15 @@ async function _doRequestExpressionData(dispatch, getState, genes) {
/* helper for this function only */
const fetchData = async (geneNames) => {
const query = geneNames
.map(g => `var:${dubEncURIComponent(varIndexName)}=${dubEncURIComponent(g)}`)
.map(
(g) =>
`var:${dubEncURIComponent(varIndexName)}=${dubEncURIComponent(g)}`
)
.join("&");
// TODO: why convert to an Object and not a Dataframe?
return fetchBinary(`data/var?${query}`)
.then(buffer => Universe.convertDataFBStoObject(universe, buffer));
return fetchBinary(`data/var?${query}`).then((buffer) =>
Universe.convertDataFBStoObject(universe, buffer)
);
};
/* preload data already in cache */
@@ -351,7 +357,7 @@ const requestDifferentialExpression = (set1, set2, num_genes = 10) => async (
*/
const plimit = new PromiseLimit(5);
await Promise.all(
topNGenes.map(gene =>
topNGenes.map((gene) =>
plimit.add(() => _doRequestExpressionData(dispatch, getState, [gene]))
)
);
@@ -432,11 +438,15 @@ const saveObsAnnotations = () => async (dispatch, getState) => {
};
function fetchJson(pathAndQuery) {
return doJsonRequest(`${globals.API.prefix}${globals.API.version}${pathAndQuery}`);
return doJsonRequest(
`${globals.API.prefix}${globals.API.version}${pathAndQuery}`
);
}
function fetchBinary(pathAndQuery) {
return doBinaryRequest(`${globals.API.prefix}${globals.API.version}${pathAndQuery}`);
return doBinaryRequest(
`${globals.API.prefix}${globals.API.version}${pathAndQuery}`
);
}
export default {
+10 -10
View File
@@ -3,7 +3,7 @@ import { Universe } from "../util/stateManager";
import {
postNetworkErrorToast,
postAsyncSuccessToast,
postAsyncFailureToast
postAsyncFailureToast,
} from "../components/framework/toasters";
function abortableFetch(request, opts, timeout = 0) {
@@ -18,7 +18,7 @@ function abortableFetch(request, opts, timeout = 0) {
setTimeout(() => controller.abort(), timeout);
}
return fetch(request, { ...opts, signal });
}
},
};
}
@@ -38,19 +38,19 @@ async function doReembedFetch(dispatch, getState) {
method: "PUT",
headers: new Headers({
Accept: "application/octet-stream",
"Content-Type": "application/json"
"Content-Type": "application/json",
}),
body: JSON.stringify({
method: "umap",
filter: { obs: { index: cells } }
filter: { obs: { index: cells } },
}),
credentials: "include"
credentials: "include",
},
60000 // 1 minute timeout
);
dispatch({
type: "reembed: request start",
abortableFetch: af
abortableFetch: af,
});
const res = await af.ready();
@@ -82,17 +82,17 @@ export function requestReembed() {
const buffer = await res.arrayBuffer();
const df = Universe.matrixFBSToDataframe(buffer);
dispatch({
type: "reembed: request completed"
type: "reembed: request completed",
});
dispatch({
type: "reembed: add reembedding",
embedding: df,
schema
schema,
});
postAsyncSuccessToast("Re-embedding has completed.");
} catch (error) {
dispatch({
type: "reembed: request aborted"
type: "reembed: request aborted",
});
if (error.name === "AbortError") {
postAsyncFailureToast("Re-embedding calculation was aborted.");
@@ -108,6 +108,6 @@ export function reembedResetWorldToUniverse(dispatch, getState) {
const { reembedController } = getState();
if (reembedController.pendingFetch) reembedController.pendingFetch.abort();
dispatch({
type: "reembed: clear all reembeddings"
type: "reembed: clear all reembeddings",
});
}