Skip to content

Commit

Permalink
*/pkg.json: add watch cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
tharvik committed Feb 9, 2024
1 parent fc3b4f2 commit ae6de40
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 370 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ jobs:
- uses: cypress-io/github-action@v4
with:
browser: chromium
start: npm run dev
start: npm start
wait-on: http://localhost:8080/
working-directory: ${{ env.client_dir }}
config: baseUrl=http://localhost:8080/#/
Expand Down
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 --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 @@ -22,6 +24,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
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 --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 --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,
"noEmit": true,

"esModuleInterop": true,
"skipLibCheck": true,
Expand Down
30 changes: 20 additions & 10 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 @@ -33,22 +32,33 @@ As mentioned in the [developer guide](../DEV.md), there are many ways to use Dis
### Things to know

As a contributor, you will certainly end up having to run TypeScript scripts. A practical way to do so is to use on ts-node:

```
npm i -g ts-node # globally to run scripts from anywhere
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 in every project that run the given script when changes are detected.
As each of theses calls are non-terminating (theses are watching indefinitely), you'll need to run each 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]
> If you are using VSCode, know that you may not be able to open the editor from the repo root level without VSCode raising imports errors. If that is the case, you should start VSCode from inside the module you are working.
> In practice, that is any folder level that contains a `package.json` such as `server`, `web-client`, etc.
> For example, if you are working on the CLI, you should start VSCode with the command `code server` from the root level (or `cd server; code .`)
Next you will find instructions and documentation on how to run DISCO in different settings.
Next you will find instructions and documentation on how to run DISCO in different settings.

### Using DISCO from the `web-client`

Expand All @@ -66,6 +76,6 @@ A standalone example of disco can be found [in this folder](./node_example), wit

1. If you are planning to contribute to the project you should read the [contributing guide](./CONTRIBUTING.md)
2. Depending on what you will be working on you may be interested in different documentation. Have a look at the markdown guides in `docs`. Notably:
* Understanding [Disco.js inner workings](./DISCOJS.md) is key if you are planning to add a new machine learning feature and work in `discojs`
* The [Vue.js architecture guide](./VUEJS.md) explains how the browser client is implemented with Vue.js.
* Are you going to work on cryptography or privacy? This [document](./PRIVACY.md) explains the measures DISCO takes to ensure privacy and confidentiality.
- Understanding [Disco.js inner workings](./DISCOJS.md) is key if you are planning to add a new machine learning feature and work in `discojs`
- The [Vue.js architecture guide](./VUEJS.md) explains how the browser client is implemented with Vue.js.
- Are you going to work on cryptography or privacy? This [document](./PRIVACY.md) explains the measures DISCO takes to ensure privacy and confidentiality.
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 ae6de40

Please sign in to comment.