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

[demo] Server: Add accuracy tracking #125

Merged
merged 30 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
05a4b53
replacing depreceated body parser
hkaur008 May 3, 2021
4750976
removing .venv
hkaur008 May 3, 2021
01f098c
.venv removed
hkaur008 May 3, 2021
fa0f26b
table for time stamp created
hkaur008 May 4, 2021
17292c3
lettercase fixed and model id as foreign key added
hkaur008 May 5, 2021
88678ff
block number added in table
hkaur008 May 6, 2021
21194d1
function template added
hkaur008 May 6, 2021
a44f673
styling of the code corrected
hkaur008 May 6, 2021
b18d506
add accuracy function built
hkaur008 May 6, 2021
99650f1
changed to camelcase
hkaur008 May 6, 2021
975d13c
get accuracy history model created
hkaur008 May 6, 2021
d409667
api to get all data history is added
hkaur008 May 9, 2021
6394deb
post request to add new data added as well
hkaur008 May 9, 2021
47b3e5f
adding comments
hkaur008 May 9, 2021
107b3f6
reverted changes by code formatter
hkaur008 May 10, 2021
fc3cd66
reverted the changes made by code formatter
hkaur008 May 10, 2021
c3e58f0
find by model id added
hkaur008 May 10, 2021
7c0cc04
removing console.log commands
hkaur008 May 10, 2021
2d67c38
replacing with str
hkaur008 May 10, 2021
5809474
debbuger removed
hkaur008 May 10, 2021
4cc8b2a
debugger removed
hkaur008 May 10, 2021
dcd9962
Merge branch 'main' of https://github.com/microsoft/0xDeCA10B
hkaur008 May 22, 2021
53c94ad
messages updated for null modelId and not valid modelId
hkaur008 May 22, 2021
62612f4
little fixes
hkaur008 May 22, 2021
d0a2a51
message changes
hkaur008 May 23, 2021
f275f17
pulled lint files from repository
hkaur008 Jul 13, 2021
ac22342
lint fix used
hkaur008 Jul 13, 2021
6f9ba89
added deleted eslint line
hkaur008 Jul 13, 2021
d3dce41
server: Clarify some error messages.
juharris Jul 13, 2021
97f45f8
server: Correct an error code.
juharris Jul 13, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/

.vscode/
.venv/
28 changes: 25 additions & 3 deletions demo/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const fs = require('fs');
const initSqlJs = require('sql.js');
const app = express();
const port = process.env.PORT || 5387;
const bodyParser = require('body-parser');
const jsonParser = bodyParser.json();
//const bodyParser = require('body-parser');
const jsonParser = express.json();

const dbPath = 'db.sqlite';

Expand All @@ -19,7 +19,8 @@ initSqlJs().then(SQL => {
db = new SQL.Database();
sqlstr = "CREATE TABLE model (id INTEGER PRIMARY KEY, name TEXT, address TEXT, description TEXT, model_type TEXT, encoder TEXT, accuracy NUMBER);"
+ "CREATE TABLE data (transaction_hash TEXT PRIMARY KEY, text TEXT);"
+ "CREATE INDEX index_address ON model(address);";
+ "CREATE INDEX index_address ON model(address);"
+ "CREATE TABLE accuracy (transaction_hash TEXT, block_number INTEGER, model_id INTEGER, accuracy NUMBER, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (model_id) REFERENCES model (id));";
db.run(sqlstr);
}

Expand Down Expand Up @@ -151,3 +152,24 @@ initSqlJs().then(SQL => {

app.listen(port, () => console.log(`Listening on port ${port}`));
});

// Get the accuracy history for a model
function getAccuracyHistory()
{

}

// Add a new accuracy record for a model
function addAccuracyRecord(accuracy)
{
db.run('INSERT INTO accuracy VALUES (?, ?, ?, ?);', [
accuracy.transaction_hash,
accuracy.block_number,
accuracy.model_id,
accuracy.accuracy,
]);
fs.writeFile(dbPath, Buffer.from(db.export()), () => { });
}