diff --git a/app/config.yml b/app/config.yml
index 392c1f8..2248646 100644
--- a/app/config.yml
+++ b/app/config.yml
@@ -1,4 +1,4 @@
threshold: 0.1
ksize: 21
-#index_server: "http://index"
+index_server: "http://index"
metadata_duckdb: "/data/metadata.duckdb"
diff --git a/app/functions.py b/app/functions.py
index 72a4d10..02e22c5 100644
--- a/app/functions.py
+++ b/app/functions.py
@@ -42,7 +42,10 @@ def getacc(signatures, config, http, threshold=0.1):
r = http.request('POST',
f"{base_url}/search",
body=buf.getvalue(),
- headers={'Content-Type': 'application/json'})
+ headers={'Content-Type': 'application/json'},
+ timeout=300,
+ retries=3,
+ )
if r.status != 200:
raise SearchError(r.data.decode('utf-8'), r.status)
diff --git a/app/static/dashboard.js b/app/static/dashboard.js
index 3cafa13..48edb98 100644
--- a/app/static/dashboard.js
+++ b/app/static/dashboard.js
@@ -201,7 +201,12 @@ function createdashboard(jsonData, paragraphElement, navElement) {
// Data prep for plots ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Create the column definitions for the Tabulator table
- const columns = Object.keys(jsonData[0]).map((key) => {
+ const commonKeys = Object.keys(jsonData[0]);
+ const values = Array.from({ length: commonKeys.length }, () => []);
+
+ const columns = commonKeys.map((key, j) => {
+ values[j] = jsonData.map((obj) => obj[key]);
+
// check if columns are numeric or not
const isNumericColumn = jsonData.every(
(row) => !isNaN(parseFloat(row[key]))
diff --git a/app/templates/advanced.html b/app/templates/advanced.html
index 6cbf257..e62b7fe 100644
--- a/app/templates/advanced.html
+++ b/app/templates/advanced.html
@@ -217,19 +217,51 @@
2) Select metadata
const startTime = performance.now();
var data = {};
+ const MAX_NB_RETRY = 5;
+ const RETRY_DELAY_MS = 200;
+
+ async function fetchRetry(input, init) {
+ let retryLeft = MAX_NB_RETRY;
+ while (retryLeft > 0){
+ try {
+ return await fetch(input, init);
+ }
+ catch (err) {
+ // TODO: callback to update UI with retry count?
+ await sleep(RETRY_DELAY_MS)
+ }
+ finally {
+ retryLeft -= 1;
+ }
+ }
+ throw new Error(`Too many retries`);
+ }
+
+ function sleep(delay){
+ return new Promise((resolve) => setTimeout(resolve, delay));
+ }
+
//Do fetch request to proper route and create dashboard
- fetch("/advanced", {
+ fetchRetry("/advanced", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formdata),
})
- .then((response) => response.json())
- .then((jsonData) =>
+ .then((response) => {
+ // TODO: update UI to say we have the results
+ console.log("got the data!")
+ return response.json()
+ })
+ .then((jsonData) => {
+ // TODO: update UI to say we are generating graphs
+ console.log("preparing the graphs!")
createdashboard(jsonData, paragraphElement, navElement)
- )
+ })
.catch((error) => {
+ // TODO: update UI to say request failed =(
+ console.log("oops, request failed =(")
console.error("Error sending data to Flask server:", error);
});
});
diff --git a/app/templates/examples.html b/app/templates/examples.html
index 2759fd0..e38ef8d 100644
--- a/app/templates/examples.html
+++ b/app/templates/examples.html
@@ -177,19 +177,51 @@ Refresh the page to try a different genome.
formdata = Pelagi_sig;
}
+ const MAX_NB_RETRY = 5;
+ const RETRY_DELAY_MS = 200;
+
+ async function fetchRetry(input, init) {
+ let retryLeft = MAX_NB_RETRY;
+ while (retryLeft > 0){
+ try {
+ return await fetch(input, init);
+ }
+ catch (err) {
+ // TODO: callback to update UI with retry count?
+ await sleep(RETRY_DELAY_MS)
+ }
+ finally {
+ retryLeft -= 1;
+ }
+ }
+ throw new Error(`Too many retries`);
+ }
+
+ function sleep(delay){
+ return new Promise((resolve) => setTimeout(resolve, delay));
+ }
+
//Do fetch request to proper route and create dashboard
- fetch("/", {
+ fetchRetry("/", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formdata),
})
- .then((response) => response.json())
- .then((jsonData) =>
+ .then((response) => {
+ // TODO: update UI to say we have the results
+ console.log("got the data!")
+ return response.json()
+ })
+ .then((jsonData) => {
+ // TODO: update UI to say we are generating graphs
+ console.log("preparing the graphs!")
createdashboard(jsonData, paragraphElement, navElement)
- )
+ })
.catch((error) => {
+ // TODO: update UI to say request failed =(
+ console.log("oops, request failed =(")
console.error("Error sending data to Flask server:", error);
});
});
diff --git a/app/templates/index.html b/app/templates/index.html
index da631d1..12cef7f 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -123,19 +123,51 @@
const startTime = performance.now();
var data = {};
+ const MAX_NB_RETRY = 5;
+ const RETRY_DELAY_MS = 200;
+
+ async function fetchRetry(input, init) {
+ let retryLeft = MAX_NB_RETRY;
+ while (retryLeft > 0){
+ try {
+ return await fetch(input, init);
+ }
+ catch (err) {
+ // TODO: callback to update UI with retry count?
+ await sleep(RETRY_DELAY_MS)
+ }
+ finally {
+ retryLeft -= 1;
+ }
+ }
+ throw new Error(`Too many retries`);
+ }
+
+ function sleep(delay){
+ return new Promise((resolve) => setTimeout(resolve, delay));
+ }
+
//Do fetch request to proper route and create dashboard
- fetch("/", {
+ fetchRetry("/", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formdata),
})
- .then((response) => response.json())
- .then((jsonData) =>
+ .then((response) => {
+ // TODO: update UI to say we have the results
+ console.log("got the data!")
+ return response.json()
+ })
+ .then((jsonData) => {
+ // TODO: update UI to say we are generating graphs
+ console.log("preparing the graphs!")
createdashboard(jsonData, paragraphElement, navElement)
- )
+ })
.catch((error) => {
+ // TODO: update UI to say request failed =(
+ console.log("oops, request failed =(")
console.error("Error sending data to Flask server:", error);
});
});