diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index adea88ef..9554a42c 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -51,6 +51,7 @@ jobs:
sudo apt install -y g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 90
+ sudo apt install libzip-dev
- name: install-cpprest
run: sudo apt install libcpprest-dev
diff --git a/.gitignore b/.gitignore
index 48b197a5..f966ca0c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,10 @@
Build/
build/
+# Large-files
+zip-examples
+model_data
+
# IDE
.vscode
.idea
@@ -10,6 +14,7 @@ build/
.DS_Store
.AppleDouble
.LSOverride
+*.entitlements
# Javascript
package-lock.json
diff --git a/client/scripts/requests.js b/client/scripts/requests.js
index 35124124..c8049021 100644
--- a/client/scripts/requests.js
+++ b/client/scripts/requests.js
@@ -124,29 +124,60 @@ async function deleteConnection(sending_object) {
return response
}
-function trainRequest() {
- if (!train_data) {
- errorNotification("No training data was set.")
- } else {
- fetch(`http://${py_server_address}/train/${user_id}/${model_id}/0`, {
- method: "PUT",
- mode: "cors",
- headers: {"Content-Type": "text/csv"},
- body: train_data,
- }).then(response => {
- showBuildNotification(response.ok)
- onTrainShowPredict(response.ok)
- if (response.ok) {
- setModelView("success")
- } else {
- setModelView("error")
- }
+function uploadRequest() {
+ if (data_upload.files.length == 0) return
+ const file = data_upload.files[0]
+
+ fetch(`http://${py_server_address}/${user_id}/${model_id}`, {
+ method: "PATCH",
+ mode: "cors",
+ body: file,
+ }).then(response => {
+ if (!response.ok) {
+ Swal.fire({
+ position: "top-end",
+ icon: "error",
+ title: "Failed to upload data",
+ showConfirmButton: false,
+ timer: 1500,
+ })
+ console.error(`Failed to upload data for ${file.name}`)
+ return
+ }
+ Swal.fire({
+ position: "top-end",
+ icon: "success",
+ title: "Successfully uploaded",
+ showConfirmButton: false,
+ timer: 1500,
})
- }
+ })
+ setModelView("irrelevant")
+ // allow user to press a train button from now on
+ button_wrapper = document.getElementById("train-button")
+ button_wrapper.getElementsByTy
+ train_button = button_wrapper.children[0]
+ button_wrapper.removeAttribute("disabled")
+ train_button.removeAttribute("disabled")
+}
+
+function trainRequest() {
+ fetch(`http://${py_server_address}/train/${user_id}/${model_id}/0`, {
+ method: "PUT",
+ mode: "cors",
+ }).then(response => {
+ showBuildNotification(response.ok)
+ onTrainShowPredict(response.ok)
+ if (response.ok) {
+ setModelView("success")
+ } else {
+ setModelView("error")
+ }
+ })
}
async function predictRequest() {
- if (csv_predict.files.length == 0) {
+ if (predict_button.files.length == 0) {
errorNotification("Empty predict file.")
return
}
@@ -159,25 +190,34 @@ async function predictRequest() {
showConfirmButton: true,
})
}
- const file = csv_predict.files[0]
- const text = await file.text()
- const response = await fetch(
+ const file = predict_button.files[0]
+ let response = await fetch(
`http://${py_server_address}/predict/${user_id}/${model_id}`,
{
method: "PUT",
mode: "cors",
- headers: {"Content-Type": "text/csv"},
- body: text,
+ body: file,
},
)
+ if (!response.ok) {
+ Swal.fire("Error!", "Failed to upload the png image", "error")
+ console.error(
+ `Failed to upload the png with ${response.statusText}: ${responseJson.error}`,
+ )
+ return
+ }
+ response = await fetch(
+ `http://${py_server_address}/predict/${user_id}/${model_id}`,
+ {method: "GET", mode: "cors"},
+ )
const responseJson = await response.json()
- hideResult() // hide previous predict result
- if (response.ok) onPredictShowResult(responseJson)
- else {
- Swal.fire("Error!", "Server is not responding now.", "error")
- errorNotification("Failed to predict.\n" + responseJson.error)
- console.log(
- `Predict failed with ${response.statusText}: ${responseJson.error}`,
+ if (!response.ok) {
+ Swal.fire("Error!", "Failed to predict", "error")
+ console.error(
+ `Failed to predict with with ${response.statusText}: ${responseJson.error}`,
)
+ return
}
+ hideResult() // hide previous predict result
+ onPredictShowResult(responseJson)
}
diff --git a/client/templates/main.html b/client/templates/main.html
index a8122627..78bffe8c 100644
--- a/client/templates/main.html
+++ b/client/templates/main.html
@@ -113,7 +113,7 @@