Skip to content

Commit 7d19f9c

Browse files
committed
Fixed labeling bug
1 parent fe5eb51 commit 7d19f9c

File tree

7 files changed

+37
-17
lines changed

7 files changed

+37
-17
lines changed

dist/index.browser.esm.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,6 +2453,7 @@ async function datasetCollector(
24532453
var uploadComplete = false;
24542454
var dataStore = { data: [] };
24552455
var lastChecked = Date.now();
2456+
var timeSeries = timeSeries;
24562457

24572458
/**
24582459
* Uploads a vlaue for a specific timestamp to a datasets timeSeries with name sensorName
@@ -2462,6 +2463,10 @@ async function datasetCollector(
24622463
* @returns A Promise indicating success or failure of upload
24632464
*/
24642465
function addDataPoint(time, name, value) {
2466+
2467+
if (!timeSeries.includes(name)) {
2468+
throw Error("invalid time-series name")
2469+
}
24652470
if (typeof value !== "number") {
24662471
throw new Error("Datapoint is not a number");
24672472
}
@@ -2501,9 +2506,9 @@ async function datasetCollector(
25012506
}
25022507
}
25032508

2504-
async function upload(datasetLabel) {
2509+
async function upload(uploadLabel) {
25052510
const tmp_datastore = JSON.parse(JSON.stringify(dataStore));
2506-
await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": labeling});
2511+
await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": uploadLabel});
25072512
}
25082513

25092514
/**
@@ -2513,7 +2518,7 @@ async function datasetCollector(
25132518
if (uploadComplete) {
25142519
throw new Error("Dataset is already uploaded");
25152520
}
2516-
await upload();
2521+
await upload(labeling);
25172522
uploadComplete = true;
25182523
}
25192524

dist/index.browser.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,7 @@ var edgeML = (function () {
24562456
var uploadComplete = false;
24572457
var dataStore = { data: [] };
24582458
var lastChecked = Date.now();
2459+
var timeSeries = timeSeries;
24592460

24602461
/**
24612462
* Uploads a vlaue for a specific timestamp to a datasets timeSeries with name sensorName
@@ -2465,6 +2466,10 @@ var edgeML = (function () {
24652466
* @returns A Promise indicating success or failure of upload
24662467
*/
24672468
function addDataPoint(time, name, value) {
2469+
2470+
if (!timeSeries.includes(name)) {
2471+
throw Error("invalid time-series name")
2472+
}
24682473
if (typeof value !== "number") {
24692474
throw new Error("Datapoint is not a number");
24702475
}
@@ -2504,9 +2509,9 @@ var edgeML = (function () {
25042509
}
25052510
}
25062511

2507-
async function upload(datasetLabel) {
2512+
async function upload(uploadLabel) {
25082513
const tmp_datastore = JSON.parse(JSON.stringify(dataStore));
2509-
await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": labeling});
2514+
await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": uploadLabel});
25102515
}
25112516

25122517
/**
@@ -2516,7 +2521,7 @@ var edgeML = (function () {
25162521
if (uploadComplete) {
25172522
throw new Error("Dataset is already uploaded");
25182523
}
2519-
await upload();
2524+
await upload(labeling);
25202525
uploadComplete = true;
25212526
}
25222527

dist/index.esm.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16965,6 +16965,7 @@ async function datasetCollector(
1696516965
var uploadComplete = false;
1696616966
var dataStore = { data: [] };
1696716967
var lastChecked = Date.now();
16968+
var timeSeries = timeSeries;
1696816969

1696916970
/**
1697016971
* Uploads a vlaue for a specific timestamp to a datasets timeSeries with name sensorName
@@ -16974,6 +16975,10 @@ async function datasetCollector(
1697416975
* @returns A Promise indicating success or failure of upload
1697516976
*/
1697616977
function addDataPoint(time, name, value) {
16978+
16979+
if (!timeSeries.includes(name)) {
16980+
throw Error("invalid time-series name")
16981+
}
1697716982
if (typeof value !== "number") {
1697816983
throw new Error("Datapoint is not a number");
1697916984
}
@@ -17013,9 +17018,9 @@ async function datasetCollector(
1701317018
}
1701417019
}
1701517020

17016-
async function upload(datasetLabel) {
17021+
async function upload(uploadLabel) {
1701717022
const tmp_datastore = JSON.parse(JSON.stringify(dataStore));
17018-
await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": labeling});
17023+
await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": uploadLabel});
1701917024
}
1702017025

1702117026
/**
@@ -17025,7 +17030,7 @@ async function datasetCollector(
1702517030
if (uploadComplete) {
1702617031
throw new Error("Dataset is already uploaded");
1702717032
}
17028-
await upload();
17033+
await upload(labeling);
1702917034
uploadComplete = true;
1703017035
}
1703117036

dist/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16981,6 +16981,7 @@ async function datasetCollector(
1698116981
var uploadComplete = false;
1698216982
var dataStore = { data: [] };
1698316983
var lastChecked = Date.now();
16984+
var timeSeries = timeSeries;
1698416985

1698516986
/**
1698616987
* Uploads a vlaue for a specific timestamp to a datasets timeSeries with name sensorName
@@ -16990,6 +16991,10 @@ async function datasetCollector(
1699016991
* @returns A Promise indicating success or failure of upload
1699116992
*/
1699216993
function addDataPoint(time, name, value) {
16994+
16995+
if (!timeSeries.includes(name)) {
16996+
throw Error("invalid time-series name")
16997+
}
1699316998
if (typeof value !== "number") {
1699416999
throw new Error("Datapoint is not a number");
1699517000
}
@@ -17029,9 +17034,9 @@ async function datasetCollector(
1702917034
}
1703017035
}
1703117036

17032-
async function upload(datasetLabel) {
17037+
async function upload(uploadLabel) {
1703317038
const tmp_datastore = JSON.parse(JSON.stringify(dataStore));
17034-
await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": labeling});
17039+
await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": uploadLabel});
1703517040
}
1703617041

1703717042
/**
@@ -17041,7 +17046,7 @@ async function datasetCollector(
1704117046
if (uploadComplete) {
1704217047
throw new Error("Dataset is already uploaded");
1704317048
}
17044-
await upload();
17049+
await upload(labeling);
1704517050
uploadComplete = true;
1704617051
}
1704717052

examples/example-webcam-brightness-web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h1>Webcam Brightness</h1>
8787
await collector.onComplete();
8888
}
8989
else {
90-
collector = await edgeML.datasetCollector("http://localhost:3004", apiKeyInput.value, "testName", true, ["brightness"], { "min": 0, "max": 255 })
90+
collector = await edgeML.datasetCollector("http://localhost:3004", apiKeyInput.value, "testName", true, ["brightness"], { "min": 0, "max": 255 }, "brightness_desk")
9191
startTime = Date.now();
9292
isRecording = true;
9393
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "edge-ml",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Data collection tool for edge-ml (https://github.com/edge-ml)",
55
"main": "dist/index.js",
66
"module": "dist/index.esm.js",

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ async function datasetCollector(
134134
}
135135
}
136136

137-
async function upload(datasetLabel) {
137+
async function upload(uploadLabel) {
138138
const tmp_datastore = JSON.parse(JSON.stringify(dataStore));
139-
const response = await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": labeling});
139+
const response = await axios.post(url + URLS.addDatasetIncrement + key + "/" + datasetKey, {"data": tmp_datastore.data, "labeling": uploadLabel});
140140
}
141141

142142
/**
@@ -146,7 +146,7 @@ async function datasetCollector(
146146
if (uploadComplete) {
147147
throw new Error("Dataset is already uploaded");
148148
}
149-
await upload(datasetLabel);
149+
await upload(labeling);
150150
if (error) {
151151
throw new Error(error);
152152
}

0 commit comments

Comments
 (0)