Skip to content

Commit

Permalink
*/pkg.json: add watch cmd
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Vignoud <[email protected]>
  • Loading branch information
tharvik and JulienVig committed Feb 14, 2024
1 parent d162a26 commit 2635443
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 372 deletions.
2 changes: 2 additions & 0 deletions cli/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# built
/dist/
7 changes: 5 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"private": true,
"main": "dist/benchmark.ts",
"scripts": {
"watch": "nodemon --ext ts --ignore dist --watch ../discojs/discojs-node/dist --watch ../server/dist --watch . --exec npm run",
"start": "npm run build && node dist/benchmark.js",
"build": "tsc",
"test": ": nothing",
"start": "npm run build && node dist/benchmark.js"
"lint": "npx eslint --max-warnings 0 .",
"test": ": nothing"
},
"author": "",
"license": "ISC",
Expand All @@ -23,6 +25,7 @@
"eslint-plugin-import": "2",
"eslint-plugin-node": "11",
"eslint-plugin-promise": "5",
"nodemon": "3",
"ts-command-line-args": "2"
}
}
2 changes: 1 addition & 1 deletion cli/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src"]
"exclude": []
}
3 changes: 2 additions & 1 deletion cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"baseUrl": "src",
"outDir": "dist",
},
"include": ["src"]
"include": ["src"],
"exclude": ["**/*.spec.ts"]
}
4 changes: 3 additions & 1 deletion discojs/discojs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"watch": "nodemon --ext ts --ignore dist --exec npm run",
"build": "tsc",
"lint": "npx eslint --max-warnings 0 .",
"test": "mocha",
"lint": "npx eslint --max-warnings 0 --ignore-pattern '*.spec.ts' .",
"docs": "typedoc ./src/index.ts --theme oxide"
},
"repository": {
Expand Down Expand Up @@ -41,6 +42,7 @@
"eslint": "7",
"eslint-config-standard-with-typescript": "21",
"mocha": "9",
"nodemon": "3",
"ts-node": "10",
"typedoc": "0.22",
"typedoc-theme-oxide": "0.1",
Expand Down
16 changes: 9 additions & 7 deletions discojs/discojs-core/src/validation/validator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { assert } from 'chai'
import fs from 'fs'

import { Task, node, Validator, ConsoleLogger, EmptyMemory,
client as clients, data, aggregator, defaultTasks } from '@epfml/discojs-node'
import {
Task, node, Validator, ConsoleLogger, EmptyMemory,
client as clients, data, aggregator, defaultTasks
} from '@epfml/discojs-node'

const simplefaceMock = {
taskID: 'simple_face',
Expand Down Expand Up @@ -62,10 +64,10 @@ describe('validator', () => {
const titanicTask = defaultTasks.titanic.getTask()
const files = ['../../example_training_data/titanic_train.csv']
const data: data.Data = (await new node.data.NodeTabularLoader(titanicTask, ',').loadAll(files, {
features: titanicTask.trainingInformation.inputColumns,
labels: titanicTask.trainingInformation.outputColumns,
shuffle: false
})).train
features: titanicTask.trainingInformation.inputColumns,
labels: titanicTask.trainingInformation.outputColumns,
shuffle: false
})).train
const meanAggregator = new aggregator.MeanAggregator(titanicTask)
const client = new clients.Local(new URL('http://localhost:8080'), titanicTask, meanAggregator)
meanAggregator.setModel(await client.getLatestModel())
Expand All @@ -78,7 +80,7 @@ describe('validator', () => {
// data.size is undefined because tfjs handles dataset lazily
// instead we count the dataset size manually
let size = 0
await data.dataset.forEachAsync(() => size+=1)
await data.dataset.forEachAsync(() => { size += 1 })
assert(
validator.visitedSamples === size,
`Expected ${size} visited samples but got ${validator.visitedSamples}`
Expand Down
4 changes: 2 additions & 2 deletions discojs/discojs-core/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../tsconfig.base.json",
"include": ["src"],
"extends": "./tsconfig.json",
"exclude": []
}
8 changes: 5 additions & 3 deletions discojs/discojs-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"watch": "nodemon --ext ts --ignore dist --watch ../discojs-core/dist --watch . --exec npm run",
"build": "tsc",
"lint": "npx eslint --max-warnings 0 .",
"test": "mocha",
"lint": "npx eslint --max-warnings 0 --ignore-pattern '*.spec.ts' .",
"docs": "typedoc ./src/imports.ts --theme oxide"
},
"repository": {
Expand All @@ -19,9 +20,10 @@
"homepage": "https://github.com/epfml/disco#readme",
"dependencies": {
"@epfml/discojs-core": "*",
"@tensorflow/tfjs-node": "^4.17.0"
"@tensorflow/tfjs-node": "4"
},
"devDependencies": {
"@types/node": "20"
"@types/node": "20",
"nodemon": "3"
}
}
2 changes: 1 addition & 1 deletion discojs/discojs-node/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src"],
"exclude": []
}
6 changes: 5 additions & 1 deletion discojs/discojs-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"watch": "nodemon --ext ts --ignore dist --watch ../discojs-core/dist --watch . --exec npm run",
"build": "tsc",
"lint": "npx eslint --max-warnings 0 .",
"test": ": nothing",
"lint": "npx eslint --max-warnings 0 --ignore-pattern '*.spec.ts' .",
"docs": "typedoc ./src/index.ts --theme oxide"
},
"repository": {
Expand All @@ -19,5 +20,8 @@
"homepage": "https://github.com/epfml/disco#readme",
"dependencies": {
"@epfml/discojs-core": "*"
},
"devDependencies": {
"nodemon": "3"
}
}
2 changes: 1 addition & 1 deletion discojs/discojs-web/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src"],
"exclude": []
}
1 change: 1 addition & 0 deletions discojs/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"lib": ["ES5", "DOM"],

"strict": true,
"noEmitOnError": true,

"esModuleInterop": true,
"skipLibCheck": true,
Expand Down
20 changes: 14 additions & 6 deletions docs/ONBOARDING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Onboarding

Disco has grown a lot since its early days, and like any sizeable code base, getting started is both
difficult and intimidating: there are a *lot* of files, it's not clear what's important at first, and even where to start
difficult and intimidating: there are a _lot_ of files, it's not clear what's important at first, and even where to start
is a bit of a puzzle. This document aims at giving you an efficient process to get familiar with DISCO.

The two main technologies behind DISCO are TypeScript and distributed machine learning. In the following sections I will assume that you are familiar
The two main technologies behind DISCO are TypeScript and distributed machine learning. In the following sections I will assume that you are familiar
with both to a certain extent. If not, the following references might be useful:

- [JavaScript](https://eloquentjavascript.net)
- [TypeScript](https://www.typescriptlang.org/docs/handbook/intro.html)
- [Federated and Decentralized Learning](https://arxiv.org/pdf/1912.04977)

> [!IMPORTANT]
> Disco is a big project and some information has probably been omitted or is outdated. It is now *your* responsibility to add missing information or let us know on [slack](https://join.slack.com/t/disco-decentralized/shared_invite/zt-fpsb7c9h-1M9hnbaSonZ7lAgJRTyNsw)!
> Disco is a big project and some information has probably been omitted or is outdated. It is now _your_ responsibility to add missing information or let us know on [slack](https://join.slack.com/t/disco-decentralized/shared_invite/zt-fpsb7c9h-1M9hnbaSonZ7lAgJRTyNsw)!
## First steps

Expand All @@ -22,7 +22,6 @@ a `server` and a `cli` (e.g., for benchmarking). Depending on what your goal is,
1. If you are going to work, contribute and improve the project, I first recommend you get a good understand of what DISCO does: play around with the [website](https://epfml.github.io/disco/#/), train a model from the pre-defined tasks, or even create your own custom task. Feedback is always appreciated, feel free to let us know on slack/in the github issues/in person if you noticed any issues or thought of an improvement.

2. Then, get a high-level understanding of the different parts of the projects in the [developer guide](../DEV.md), even if you're planning on working on a subset of the project. If you want to know more about a specific part of the project, refer to the table of contents at the end of the DEV guide.

3. Follow the installation instructions from the [developer guide](../DEV.md) to launch a DISCO instance working in your browser.

> [!TIP]
Expand All @@ -39,8 +38,17 @@ ts-node your_script.ts
```

* Because TypeScript needs to be transpiled to JavaScript, you need to rebuild the `discojs` folder every time you make any changes to it:
``` js
npm run build -w ./discojs
``` sh
npm -w ./discojs run build
```

If you want to automate the building phase, you can use the `watch` script to rebuild a module whenever changes are detected.
As each of those calls are non-terminating (they're watching indefinitely), you'll need to run each of them in a different terminal.

```sh
npm -w ./discojs/discojs-core run watch build
npm -w ./discojs/discojs-node run watch build # another terminal
npm -w ./discojs/discojs-web run watch build # one more terminal
```

> [!TIP]
Expand Down
1 change: 0 additions & 1 deletion docs/node_example/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["*.ts"],
"exclude": []
}
2 changes: 1 addition & 1 deletion docs/node_example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"typeRoots": ["node_modules/@types", "../../discojs/discojs-core/types"]
},
"include": ["*.ts"],
"exclude": ["node_modules"]
"exclude": ["**/*.spec.ts"]
}

Loading

0 comments on commit 2635443

Please sign in to comment.