Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.2 - Vector representation, fixed prettier pipeline, improved training page #484

Merged
merged 117 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
a3e647f
Setup test for data representation
r59q May 1, 2024
71c9880
Fixed livegraph
r59q May 1, 2024
1ad7226
Merge branch 'issue-444' into 469-generalise-the-data-representation
r59q May 1, 2024
9c8a494
Make Stores container
r59q May 8, 2024
c1de2e5
Fix synthesizer
r59q May 8, 2024
5702eb7
Rename file
r59q May 8, 2024
fc109ff
Renamed file
r59q May 8, 2024
2ac5ca9
Improve state of logging and fix reconnect issue
r59q May 9, 2024
0059b99
Remove unused import
r59q May 9, 2024
47e39b8
Docker compose
r59q May 9, 2024
16c528c
Clarified import
r59q May 10, 2024
c40354b
Add whitespace
r59q May 10, 2024
eafb18d
Whitespace
r59q May 10, 2024
c5c196c
Whitespace
r59q May 10, 2024
fb8b4b7
Fix classifier test
r59q May 10, 2024
d4df57a
whitespace
r59q May 10, 2024
d80f1a0
Added test message
r59q May 10, 2024
ac49475
Removed test message
r59q May 10, 2024
15a8122
Enable development message in prod
r59q May 10, 2024
dee0fff
Reverted logging
r59q May 10, 2024
8bba125
Whitespace
r59q May 10, 2024
418c79a
Add workflow for deployment site
r59q May 10, 2024
3c56b76
Improve consistency for microbits object
r59q May 10, 2024
aa8c9db
Using key on LiveGraph
r59q May 13, 2024
36ea389
Remove Highlighted LiveGraph component
r59q May 13, 2024
de2b61b
Fix flickering confidences
r59q May 13, 2024
0599d6e
Fix issue where switching models would cause memory leaks
r59q May 14, 2024
6f880fe
Maybe fixed issue where axes couldn't be selected
r59q May 14, 2024
3924988
Remove log line
r59q May 14, 2024
1dc8bc1
Stabilize switching between models
r59q May 22, 2024
4f3ee09
Added license identifier
r59q May 22, 2024
e4a9e28
Merge branch 'main' into 469-generalise-the-data-representation
r59q May 22, 2024
e1ec8e6
Fixed pipeline
r59q May 22, 2024
19a5e0a
stop if error
r59q May 22, 2024
a002be5
Simplified workflow
r59q May 22, 2024
28f8c33
Merge pull request #485 from microbit-foundation/469-generalise-the-d…
r59q May 22, 2024
3402521
Merge pull request #487 from microbit-foundation/467-fix-prettier-check
r59q May 22, 2024
18fe90b
Ran prettier
r59q May 23, 2024
a4fdf69
Merge pull request #491 from microbit-foundation/488-fix-formatting-a…
r59q May 23, 2024
feb70b5
Using ci instead of i
r59q May 23, 2024
c6ea397
Ignore bad files
r59q May 23, 2024
d0828f2
Merge branch 'main' into v3.2
r59q May 23, 2024
ef25c9a
Changed the makecode hex to use the new version
r59q May 27, 2024
ea058b7
Merge pull request #493 from microbit-foundation/492-update-makecode-…
r59q May 27, 2024
9afcab9
Fix noname use-same feature
r59q May 27, 2024
54484b9
Create filters list
r59q May 27, 2024
d5af988
Merge pull request #494 from microbit-foundation/471-create-a-filters…
r59q May 27, 2024
5678180
Add license identifier
r59q May 27, 2024
3f0e507
Ran prettier
r59q May 27, 2024
f341c25
Revert branding
r59q May 27, 2024
f5774ee
Add hover preview to filters
r59q May 28, 2024
24bffeb
revert brand
r59q May 28, 2024
03f5f97
Merge pull request #495 from microbit-foundation/470-add-hover-effect…
r59q May 28, 2024
d5f1a4d
Added some more icons
r59q May 28, 2024
2f6eb6f
Navigate by clicking filter preview
r59q May 28, 2024
45e0461
Improved the selected model logic
r59q May 28, 2024
2fe195b
Fix pipe
r59q May 28, 2024
af5358f
update prcomment
r59q May 28, 2024
ae79d27
Tabification
r59q May 29, 2024
512a623
Fix flicker
r59q Jun 3, 2024
be188a3
Refactoring training page
r59q Jun 3, 2024
7539399
Fix issues with knn
r59q Jun 4, 2024
853275b
embed the controls in plot
r59q Jun 4, 2024
23576b2
fix test
r59q Jun 4, 2024
fe92aa0
Ran prettier
r59q Jun 4, 2024
42f7146
used unused variable
r59q Jun 4, 2024
0bbc1e0
Removed irrelevant comment
r59q Jun 4, 2024
0f38751
Remove deprecated objects
r59q Jun 4, 2024
18455a8
Run prettier
r59q Jun 4, 2024
7b3fa67
Merge pull request #496 from microbit-foundation/463-split-knn-and-nn…
r59q Jun 4, 2024
c5474b4
Fix dockerfile
r59q Jun 26, 2024
fa0f18d
Added colors to gestures
r59q Jul 3, 2024
604dfc8
Merge pull request #504 from microbit-foundation/462-proposition-addi…
r59q Jul 3, 2024
6751f25
Enforce correct storage version
r59q Jul 3, 2024
7993656
Fixed npe
r59q Jul 3, 2024
6343850
Merge pull request #505 from microbit-foundation/462-proposition-addi…
r59q Jul 3, 2024
e8c8b62
Remove unused var
r59q Jul 3, 2024
b31b55b
Prettier
r59q Jul 3, 2024
fcd4ed2
Added lossGraph to features.json
r59q Jul 8, 2024
d789009
Merge pull request #506 from microbit-foundation/501-add-loss-graph-f…
r59q Jul 8, 2024
673d08a
Prettier
r59q Jul 8, 2024
382dc11
Disabled training page tabs when knn model is disabled
r59q Jul 9, 2024
cf4d8bf
Prettier
r59q Jul 9, 2024
e080dc8
Merge pull request #507 from microbit-foundation/502-remove-tabs-from…
r59q Jul 9, 2024
694d87e
Make K configurable
r59q Jul 10, 2024
7dbe151
Prettier
r59q Jul 11, 2024
f6939d3
Merge pull request #509 from microbit-foundation/500-add-option-to-ch…
r59q Jul 11, 2024
3fc60ea
Remove unused imports
r59q Jul 16, 2024
67c9853
Cleanup: Remove logs
r59q Jul 16, 2024
25b21e7
PRettier
r59q Jul 30, 2024
f33a49b
Create confidences store
r59q Jul 30, 2024
01d8ef0
Rework confidences
r59q Jul 30, 2024
0aa8618
Merge pull request #510 from microbit-foundation/refactor-confidence
r59q Jul 30, 2024
c8f164b
Add check to test number of samples required by filters
r59q Jul 30, 2024
928f1e5
Merge pull request #511 from microbit-foundation/min-samples-check
r59q Jul 30, 2024
e4bf3c5
Fix bugs where wrongly axes were selected and model wasn't trained co…
r59q Jul 31, 2024
e438392
Ensure no axes are highlighted when training neural network
r59q Jul 31, 2024
15519d7
Prettier and unbranded config
r59q Jul 31, 2024
ab0a13b
Formatting
r59q Jul 31, 2024
3d3b543
Identified as outdated is disabled
r59q Aug 12, 2024
2e2aaef
Merge pull request #517 from microbit-foundation/516-outdated-firmwar…
r59q Aug 12, 2024
1aa89f0
Disabled bad firmware warning
r59q Aug 12, 2024
16206a6
Merge pull request #518 from microbit-foundation/516-outdated-firmwar…
r59q Aug 12, 2024
c9f4163
Allow custom colors and add graph colors to axis selector
r59q Aug 12, 2024
31b9cf7
Merge pull request #519 from microbit-foundation/515-add-colors-to-th…
r59q Aug 12, 2024
6da563f
Fix KNN graph, data outside graph area
r59q Aug 13, 2024
136c1ff
Prettier
r59q Aug 13, 2024
59f1422
Added comments
r59q Aug 13, 2024
bffef8b
Changed the default scale
r59q Aug 14, 2024
55a4ae5
Added comment and prettier
r59q Aug 21, 2024
5f6a1e0
Changed biuild command to using branded version
Aug 28, 2024
833e6a3
Add explanatory text to training page
r59q Sep 17, 2024
b0fe972
Select better gesture colors
r59q Sep 17, 2024
3c9f535
Moved the classes in standard button to a div inside
r59q Sep 17, 2024
976c956
Ran prettier
r59q Sep 17, 2024
1fe3105
Fixed problematic uses of buttons
r59q Sep 17, 2024
49b5d22
Remove the pr comment workflow
r59q Sep 26, 2024
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
24 changes: 3 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v3
- name: Run Tests
run: |
npm install
npm ci
npm test
formatting_and_linting:
name: Prettier / svelte Check
Expand All @@ -44,29 +44,11 @@ jobs:
- name: Run prettier
shell: bash
run: |
npm install
npm run prettier
# if we find the string modified after running git status, it indicates that prettier has changed files!
if git status | grep -c "modified" -eq 0; then
exit 1
else
exit 0
fi
- name: Missing format report
shell: bash
if: ${{ failure() }}
run: |
echo "Missing prettier formatting. Please format files using 'npm run prettier' and resubmit!"
exit 1
npm ci
npm run checkFormat
- name: Svelte check
shell: bash
run: npm run check
- name: Svelte check report
shell: bash
if: ${{ failure() }}
run: |
echo "Running npm run check found warnings, please resolve them before merging!"
exit 1

build_and_deploy:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v3
- name: Run Tests
run: |
npm install
npm ci
npm test
build_and_deploy:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
src/translations.ts
src/translations.ts
src/appInsights.ts
src/messages/*
15 changes: 12 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@
"a11y-structure": "ignore",
"a11y-click-events-have-key-events": "ignore",
"a11y-missing-content": "ignore",
"a11y-no-noninteractive-element-interactions":"ignore",
"a11y-no-noninteractive-element-interactions": "ignore",
"a11y-no-static-element-interactions": "ignore"
}
}
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true
},
"hide-files.files": []
}
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
ml:
build: .
ports:
- "5174:8080"
25 changes: 25 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# A Dockerfile must begin with a FROM instruction.
# New base image will be built based on the Node.js version 20
# Image that is based on Debian Linux.
FROM node:20

# Create app directory
WORKDIR /usr/src/app

# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

# Install app dependencies
RUN npm install
RUN npm install express

# Bundle app source
COPY . .

# Creates a "dist" folder with the production build
RUN npm run build

EXPOSE 8080

# Start the server using the production build
CMD [ "node", "dist/main.cjs" ]
6 changes: 4 additions & 2 deletions features.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"title": "Learning tool",
"knnModel": true
}
"knnModel": true,
"lossGraph": true,
"makecode": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"license": "MIT",
"scripts": {
"build": "node prepEnv.js simple && vite build",
"build": "node prepEnv.js branded && vite build",
"dev": "node prepEnv.js unbranded && vite",
"devML": "node prepEnv.js branded && vite",
"devSimple": "node prepEnv.js simple && vite",
Expand Down
13 changes: 7 additions & 6 deletions prepEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
// This script is used to setup different build configurations
// run by ` node prepEnv.js branded ` for ml-machine-branded config
import { copyFile } from 'node:fs/promises';
import { copyFile } from 'fs';

// Validate input
const args = process.argv;
Expand All @@ -31,6 +31,7 @@ const fileMoveTargets = {
['./src/__viteBuildVariants__/ml-machine-simple/features.json', './features.json']
]
}

const availableTargets = Object.getOwnPropertyNames(fileMoveTargets);
const buildVariantTarget = args[2];
if (!availableTargets.includes(buildVariantTarget)) {
Expand All @@ -41,14 +42,14 @@ if (!availableTargets.includes(buildVariantTarget)) {

// The actual work
const copyFiles = fileMoveTargets[buildVariantTarget];

copyFiles.forEach(element => {
const source = element[0];
const destination = element[1];
copyFile(source, destination).then(() => {
copyFile(source, destination, (err) => {
console.log("Copied ", element[0], " -> ", element[1])
}).catch((err) => {
console.error("Failed to move ", source, " to ", destination)
throw new Error(err)
if (err) {
console.error("Failed to move ", source, " to ", destination)
throw new Error(err)
}
})
});
6 changes: 6 additions & 0 deletions public/imgs/dotted_graph_line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/imgs/graph_left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/imgs/graph_line_rounded.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions public/imgs/parallel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions public/main.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const express = require('express');
const path = require('path');
const app = express();

app.use(express.static(path.join(__dirname, '.')));

app.get('/', async (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});

app.listen(8080, () => {
console.log("Server successfully running on port 8080");
});
2 changes: 2 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import { DeviceRequestStates } from './script/stores/connectDialogStore';
import Router from './router/Router.svelte';
import { Feature, getFeature } from './script/FeatureToggles';
import { welcomeLog } from './script/utils/Logger';
welcomeLog();

ConnectionBehaviours.setInputBehaviour(new InputBehaviour());
ConnectionBehaviours.setOutputBehaviour(new OutputBehaviour());
Expand Down
26 changes: 20 additions & 6 deletions src/StaticConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class StaticConfiguration {

// Link to the MakeCode firmware template
public static readonly makecodeFirmwareUrl =
'https://makecode.microbit.org/#pub:54705-16835-80762-83855';
'https://makecode.microbit.org/#pub:52042-28239-00563-08630';

public static readonly isMicrobitOutdated = (origin: HexOrigin, version: number) => {
// Current versions, remember to update these, whenever changes to firmware are made!
Expand All @@ -58,13 +58,22 @@ class StaticConfiguration {
};

// Line colors are picked in the order of this array.
public static readonly liveGraphColors = ['#f9808e', '#80f98e', '#808ef9'];
public static readonly liveGraphColors = [
'#ff606e',
'#30f09e',
'#3030ff',
'#58355E',
'#E0FF4F',
'#FF2ECC',
'#F28F3B',
'#C8553D',
];

// Colors to assign to gestures, useful for identifying gestures on graphs.
public static readonly gestureColors = [
'#FCA311',
'#65334D',
'#CB04A5',
'#00ff81',
'#b1e400',
'#ADFCF9',
'#89A894',
'#4B644A',
Expand Down Expand Up @@ -114,7 +123,9 @@ class StaticConfiguration {
*/
public static readonly minNoOfGestures = 2;

// The settings given to the LayersModelTrainer
/**
* The neural network training settings
*/
public static readonly layersModelTrainingSettings: LayersModelTrainingSettings = {
noOfEpochs: 80,
batchSize: 16,
Expand All @@ -123,6 +134,9 @@ class StaticConfiguration {
noOfUnits: 16, // size of hidden layer
};

public static readonly knnNeighbourCount = 3;
/**
* How many samples should the KNN model use for prediction? i.e the k-value.
*/
public static readonly defaultKnnNeighbourCount = 3;
}
export default StaticConfiguration;
32 changes: 16 additions & 16 deletions src/__tests__/classifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@
* SPDX-License-Identifier: MIT
*/

import { classifier, gestures } from '../script/stores/Stores';
import { stores } from '../script/stores/Stores';
import TestMLModelTrainer from './mocks/mlmodel/TestMLModelTrainer';

describe('Classifier tests', () => {
test('Changing matrix does not mark model as untrained', async () => {
const gesture = gestures.createGesture('some gesture');
gestures.createGesture('some gesture2');
await classifier.getModel().train(new TestMLModelTrainer(2));
const gesture = stores.getGestures().createGesture('some gesture');
stores.getGestures().createGesture('some gesture2');
await stores.getClassifier().getModel().train(new TestMLModelTrainer(2));

gesture.setLEDOutput(new Array(25).fill(false) as boolean[]);
expect(classifier.getModel().isTrained()).toBe(true);
expect(stores.getClassifier().getModel().isTrained()).toBe(true);
});

test('Adding gesture marks model as untrained', async () => {
gestures.createGesture('some gesture');
gestures.createGesture('some gesture2');
await classifier.getModel().train(new TestMLModelTrainer(2));
stores.getGestures().createGesture('some gesture');
stores.getGestures().createGesture('some gesture2');
await stores.getClassifier().getModel().train(new TestMLModelTrainer(2));

gestures.createGesture('Added gesture');
stores.getGestures().createGesture('Added gesture');

expect(classifier.getModel().isTrained()).toBe(false);
expect(stores.getClassifier().getModel().isTrained()).toBe(false);
});

test('Removing gesture marks model as untrained', async () => {
gestures.createGesture('some gesture');
gestures.createGesture('some gesture2');
const gesture3 = gestures.createGesture('some gesture2');
await classifier.getModel().train(new TestMLModelTrainer(2));
stores.getGestures().createGesture('some gesture');
stores.getGestures().createGesture('some gesture2');
const gesture3 = stores.getGestures().createGesture('some gesture2');
await stores.getClassifier().getModel().train(new TestMLModelTrainer(2));

gestures.removeGesture(gesture3.getId());
stores.getGestures().removeGesture(gesture3.getId());

expect(classifier.getModel().isTrained()).toBe(false);
expect(stores.getClassifier().getModel().isTrained()).toBe(false);
});
});
Loading
Loading