Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
threshold: 0.1
ksize: 21
#index_server: "http://index"
index_server: "http://index"
metadata_duckdb: "/data/metadata.duckdb"
5 changes: 4 additions & 1 deletion app/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion app/static/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
40 changes: 36 additions & 4 deletions app/templates/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,51 @@ <h3 style="margin-left: 20px; margin-top: 40px">2) Select metadata</h3>
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);
});
});
Expand Down
40 changes: 36 additions & 4 deletions app/templates/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,51 @@ <h6>Refresh the page to try a different genome.</h6>
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);
});
});
Expand Down
40 changes: 36 additions & 4 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,51 @@ <h6>
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);
});
});
Expand Down
Loading