-
Notifications
You must be signed in to change notification settings - Fork 32
Migrate to pnpm #1167
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
base: develop
Are you sure you want to change the base?
Migrate to pnpm #1167
Changes from all commits
e30c9cc
f5cf0b0
274df12
249a35c
462d20a
2666eec
efd52aa
3a5d357
331965e
3115891
651a0ae
eff23f9
8cdafa2
df22553
be3a84a
996c943
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| # dependencies | ||
| /node_modules/ | ||
| /docs/examples/node_modules/ | ||
| /*/node_modules/ | ||
|
|
||
| # stored trained models | ||
| models/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| "ignore": ["docs/**"] | ||
| }, | ||
| "webapp": { | ||
| "ignore": ["env.d.ts", "src/shims-vue.d.ts"] | ||
| "ignore": ["env.d.ts"] | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ git clone git@github.com:epfml/disco.git | |
| cd disco | ||
| ``` | ||
|
|
||
| **2.** Install Node.js | ||
| **2.** Install Node.js and pnpm | ||
|
|
||
| We recommend using [nvm](https://github.com/nvm-sh/nvm) (Node Version Manager) to handle multiple Node.js versions. Start by installing `nvm` by following [their installation instructions](https://github.com/nvm-sh/nvm#installing-and-updating). | ||
| After installation, you should be able to run | ||
|
|
@@ -71,24 +71,33 @@ Use it to install the version we use in DISCO. | |
| nvm install # it reads `.nvmrc` to select the correct version | ||
| ``` | ||
|
|
||
| `nvm` manages your different Node.js versions while `npm` handles your different Node.js project packages within one version. | ||
| To use pnpm, you can use corepack, which usually comes bundled with Node.js | ||
|
|
||
| ``` | ||
| corepack enable | ||
| corepack use pnpm | ||
| ``` | ||
|
Comment on lines
+74
to
+79
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corepack is dying |
||
|
|
||
| `nvm` manages your different Node.js versions while `pnpm` handles your different Node.js project packages within one version. | ||
|
|
||
| There are many possible way to install those programs, feel free to pick the one that suits you. | ||
|
|
||
| **3.** Install the dependencies | ||
|
|
||
| ``` | ||
| npm ci | ||
| pnpm ci | ||
| ``` | ||
|
|
||
| **4.** Build the projects | ||
|
|
||
| Then we need to build the packages, which means to compile TypeScript into JavaScript. | ||
|
|
||
| Disco is split in multiple packages, called workspaces in NPM, which are described in the [Structure Section](#structure). | ||
| You can add `--workspaces` (or shorter as `-ws`) to many `npm` commands to act on all packages. | ||
| Or you can select a specific workspace via `--workspace=$name-or-path-to-package` (`-w $name-or-path-to-package`). | ||
| You can add `-r` to many `pnpm` commands to act on all packages. | ||
| Or you can select a specific workspace via `--filter=$name-or-path-to-package` (`-F $name-or-path-to-package`). | ||
|
|
||
| ``` | ||
| npm -ws run build | ||
| pnpm -r run build | ||
| ``` | ||
|
|
||
| **5.** Download and extract the sample training datasets. These datasets are used in the automated tests. | ||
|
|
@@ -104,15 +113,15 @@ As you may have seen, there are many ways to use DISCO. Here we will run a serve | |
| - First launch a `server` instance, which is used for federated and decentralized learning tasks, e.g. to list peers participating in a decentralized task. | ||
|
|
||
| ``` | ||
| npm -w server start | ||
| pnpm -F server start | ||
| ``` | ||
|
|
||
| The server should be listening on `http://localhost:8080/`. | ||
|
|
||
| - Secondly, start a web client, which will allow you to use DISCO from your browser. You will have to do so **from another terminal** since the previous one is now used by the server. | ||
|
|
||
| ``` | ||
| npm -w webapp start # from another terminal | ||
| pnpm -F webapp start # from another terminal | ||
| ``` | ||
|
|
||
| The web client should be running on `http://localhost:1351`, if not first restart the server and then the web client. | ||
|
|
@@ -136,15 +145,15 @@ The last step of the installation instructions describe how to start a web inter | |
| From the root level, launch a `server` instance: | ||
|
|
||
| ``` | ||
| npm -w server start | ||
| pnpm -F server start | ||
| ``` | ||
|
|
||
| The server should be listening on `http://localhost:8080/`. | ||
|
|
||
| Start the webapp: | ||
|
|
||
| ``` | ||
| npm -w webapp start # from another terminal | ||
| pnpm -F webapp start # from another terminal | ||
| ``` | ||
|
|
||
| The web client should be running on `http://localhost:8081`. Running the last command should also output a Network address at which devices on the same network can access the UI. You can find more information in the [Contributing to the `webapp`](./docs/CONTRIBUTING.md#contributing-to-webapp) Section as well as the [server README](./server/README.md). | ||
|
|
@@ -159,8 +168,8 @@ Training a model with the `cli` on pre-defined tasks is straightforward: | |
|
|
||
| ``` | ||
| # From the root folder | ||
| npm -w cli start -- --task cifar10 --numberOfUsers 4 --epochs 15 --roundDuration 5 | ||
| npm -w cli start -- --help # for all options | ||
| pnpm -F cli start --task cifar10 --numberOfUsers 4 --epochs 15 --roundDuration 5 | ||
| pnpm -F cli start --help # for all options | ||
| ``` | ||
|
|
||
| Adding CLI support for another task is described in the [CLI README](./cli/README.md). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,44 @@ | ||
| # TODO freeze to 22 until tfjs#8425 is merged | ||
| FROM node:22 AS builder | ||
|
|
||
| RUN corepack enable | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| WORKDIR /disco | ||
|
|
||
| COPY package*.json . | ||
| COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
| COPY isomorphic-wrtc/package.json isomorphic-wrtc/ | ||
| COPY discojs/package.json discojs/ | ||
| COPY discojs-node/package.json discojs-node/ | ||
| COPY server/package.json server/ | ||
| RUN npm ci | ||
| RUN pnpm ci | ||
|
|
||
| COPY isomorphic-wrtc/ isomorphic-wrtc/ | ||
| # Necessary for syncing workspace injected dependencies | ||
| RUN pnpm ci | ||
| COPY discojs/ discojs/ | ||
| COPY discojs-node/ discojs-node/ | ||
| COPY tsconfig.base.json . | ||
| RUN npm --workspace=discojs --workspace=discojs-node run build | ||
| RUN pnpm -F discojs -F discojs-node run build | ||
|
|
||
| COPY server/ server/ | ||
| RUN cd server/ && npm run build | ||
| RUN pnpm -F server run build | ||
|
|
||
| FROM node:22-slim AS runner | ||
|
|
||
| WORKDIR /disco | ||
|
|
||
| COPY --link --from=builder /disco/package*.json /disco/ | ||
| RUN corepack enable | ||
|
|
||
| COPY --link --from=builder /disco/package.json /disco/pnpm*.yaml /disco/ | ||
| COPY --link --from=builder /disco/isomorphic-wrtc/package.json isomorphic-wrtc/ | ||
| COPY --link --from=builder /disco/discojs/package.json discojs/ | ||
| COPY --link --from=builder /disco/discojs-node/package.json discojs-node/ | ||
| COPY --link --from=builder /disco/server/package.json server/ | ||
| RUN npm --omit=dev ci | ||
|
|
||
| # We need to copy the file dependency before installing | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| COPY --link --from=builder /disco/isomorphic-wrtc/ isomorphic-wrtc/ | ||
| RUN pnpm --prod ci | ||
|
|
||
| COPY --link --from=builder /disco/discojs/dist/ discojs/dist/ | ||
| COPY --link --from=builder /disco/discojs-node/dist/ discojs-node/dist/ | ||
| COPY --link --from=builder /disco/server/dist/ server/dist/ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more need to avoid this one as it shouldn't ever appear