Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 0 additions & 14 deletions .eslintrc.js

This file was deleted.

31 changes: 17 additions & 14 deletions .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- run: ./datasets/populate

lint-lib-core:
needs: [build-lib-core, build-lib-node]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -28,7 +27,6 @@ jobs:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- run: npm --workspace=./discojs/discojs-{core,node} run build
- run: npm --workspace=./discojs/discojs-core run lint

lint-lib-node:
Expand Down Expand Up @@ -211,8 +209,7 @@ jobs:
working-directory: docs/examples

test-lib-core:
needs:
[build-lib-core, build-lib-node, build-server-docker, download-datasets]
needs: [build-lib-core, download-datasets]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -228,11 +225,10 @@ jobs:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- run: npm --workspace=./discojs/discojs-{core,node} run build
- run: ./with_server npm --workspace=./discojs/discojs-core test
- run: npm --workspace=./discojs/discojs-core test

test-lib-node:
needs: [build-lib-core, build-server-docker, download-datasets]
needs: [build-lib-core, download-datasets]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -249,10 +245,10 @@ jobs:
cache: npm
- run: npm ci
- run: npm --workspace=./discojs/discojs-core run build
- run: ./with_server npm --workspace=./discojs/discojs-node test
- run: npm --workspace=./discojs/discojs-node test

test-lib-web:
needs: [build-lib-core, build-server-docker, download-datasets]
needs: [build-lib-core]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -269,7 +265,7 @@ jobs:
cache: npm
- run: npm ci
- run: npm --workspace=./discojs/discojs-core run build
- run: ./with_server npm --workspace=./discojs/discojs-web test
- run: npm --workspace=./discojs/discojs-web test

test-server:
needs: [build-lib-core, build-lib-node, download-datasets]
Expand Down Expand Up @@ -309,14 +305,21 @@ jobs:
cache: npm
- run: npm ci
- run: npm --workspace=./discojs/discojs-{core,web} run build
- run: npm --workspace=./web-client run test:unit
- uses: cypress-io/github-action@v6
with:
browser: chromium
start: npm start
working-directory: ./web-client
install: false
wait-on: http://localhost:8081/
component: true
env:
VUE_APP_SERVER_URL: http://server
- uses: cypress-io/github-action@v6
with:
working-directory: ./web-client
config: baseUrl=http://localhost:8081/#/
install: false
start: npm start
env:
VUE_APP_SERVER_URL: http://server

test-cli:
needs: [build-lib-core, build-lib-node, build-server, download-datasets]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COPY server/package.json server/
RUN npm ci

COPY isomorphic-wrtc/ isomorphic-wrtc/
COPY discojs/tsconfig.base.json discojs/
COPY tsconfig.base.json .
COPY discojs/discojs-core/ discojs/discojs-core/
COPY discojs/discojs-node/ discojs/discojs-node/
RUN npm run build --workspace=@epfml/discojs-core --workspace=@epfml/discojs-node
Expand Down
5 changes: 0 additions & 5 deletions cli/.eslintrc.json

This file was deleted.

3 changes: 2 additions & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@epfml/disco-cli",
"private": true,
"type": "module",
"main": "dist/cli.js",
"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/cli.js",
"build": "tsc",
"lint": "npx eslint --ext ts --max-warnings 0 .",
"lint": "npx eslint .",
"test": ": nothing"
},
"author": "",
Expand Down
1 change: 1 addition & 0 deletions cli/src/args.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { parse } from 'ts-command-line-args'
import { Map } from 'immutable'

import type { Task } from '@epfml/discojs-core'
import { defaultTasks } from '@epfml/discojs-core'

Expand Down
11 changes: 5 additions & 6 deletions cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { Range } from 'immutable'

import type { TrainerLog, data, Task } from '@epfml/discojs-core'
import { Disco, TrainingSchemes, aggregator as aggregators, client as clients } from '@epfml/discojs-core'
import { Disco, aggregator as aggregators, client as clients } from '@epfml/discojs-core'
import { startServer } from '@epfml/disco-server'

import { saveLog } from './utils'
import { getTaskData } from './data'
import { args } from './args'
import { saveLog } from './utils.js'
import { getTaskData } from './data.js'
import { args } from './args.js'

async function runUser (task: Task, url: URL, data: data.DataSplit): Promise<TrainerLog> {
const client = new clients.federated.FederatedClient(url, task, new aggregators.MeanAggregator())

// force the federated scheme
const scheme = TrainingSchemes.FEDERATED
const disco = new Disco(task, { scheme, client })
const disco = new Disco(task, { scheme: 'federated', client })

await disco.fit(data)
await disco.close()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function simplefaceData (task: Task): Promise<data.DataSplit> {

const filesPerFolder = [youngFiles, oldFiles]

const labels = filesPerFolder.flatMap((files, index) => Array(files.length).fill(index))
const labels = filesPerFolder.flatMap((files, index) => Array<string>(files.length).fill(`${index}`))
const files = filesPerFolder.flat()

return await new NodeImageLoader(task).loadAll(files, { labels })
Expand Down
1 change: 0 additions & 1 deletion cli/src/index.ts

This file was deleted.

18 changes: 2 additions & 16 deletions cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
{
"compilerOptions": {
"target": "ES5",
"lib": ["ES5"],

"strict": true,

"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "node",
"downlevelIteration": true, // needed by <ES6

"declaration": true,

"baseUrl": "src",
"outDir": "dist",
},
"extends": "../tsconfig.base.json",
"compilerOptions": { "outDir": "dist" },
"include": ["src"],
}
1 change: 1 addition & 0 deletions discojs/discojs-core/.mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"spec": ["src"],
"recursive": true,
"extension": ["ts"],
"loader": "ts-node/esm",
"require": "ts-node/register"
}
3 changes: 2 additions & 1 deletion discojs/discojs-core/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@epfml/discojs-core",
"version": "2.1.1",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"watch": "nodemon --ext ts --ignore dist --exec npm run",
"build": "tsc",
"lint": "npx eslint --ext ts --max-warnings 0 .",
"lint": "npx eslint .",
"test": "mocha",
"docs": "typedoc ./src/index.ts --theme oxide"
},
Expand Down
13 changes: 9 additions & 4 deletions discojs/discojs-core/src/aggregator/base.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Map, Set } from 'immutable'

import type { client, Model, AsyncInformant } from '..'
import type { client, Model, AsyncInformant } from '../index.js'

import { EventEmitter } from '../utils/event_emitter'
import { EventEmitter } from '../utils/event_emitter.js'

export enum AggregationStep {
ADD,
Expand Down Expand Up @@ -119,16 +119,21 @@ export abstract class Base<T> {
switch (step) {
case AggregationStep.ADD:
console.log(`> Adding contribution from node ${from ?? '"unknown"'} for round (${this.communicationRound}, ${this.round})`)
return
break
case AggregationStep.UPDATE:
if (from === undefined) {
return
}
console.log(`> Updating contribution from node ${from} for round (${this.communicationRound}, ${this.round})`)
return
break
case AggregationStep.AGGREGATE:
console.log('*'.repeat(80))
console.log(`Buffer is full. Aggregating weights for round (${this.communicationRound}, ${this.round})\n`)
break
default: {
const _: never = step
throw new Error('should never happen')
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions discojs/discojs-core/src/aggregator/get.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { aggregator, type Task } from '..'
import type { Task } from '../index.js'
import { aggregator } from '../index.js'

/**
* Enumeration of the available types of aggregator.
*/
export enum AggregatorChoice {
MEAN,
ROBUST,
SECURE,
BANDIT
}
Expand All @@ -20,8 +20,6 @@ export function getAggregator (task: Task): aggregator.Aggregator {
switch (task.trainingInformation.aggregator) {
case AggregatorChoice.MEAN:
return new aggregator.MeanAggregator()
case AggregatorChoice.ROBUST:
throw error
case AggregatorChoice.BANDIT:
throw error
case AggregatorChoice.SECURE:
Expand Down
13 changes: 6 additions & 7 deletions discojs/discojs-core/src/aggregator/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { WeightsContainer } from '../weights'
import type { Base } from './base'
import type { WeightsContainer } from '../weights/index.js'
import type { Base } from './base.js'

export { Base as AggregatorBase, AggregationStep } from './base'
export { MeanAggregator } from './mean'
export { RobustAggregator } from './robust'
export { SecureAggregator } from './secure'
export { Base as AggregatorBase, AggregationStep } from './base.js'
export { MeanAggregator } from './mean.js'
export { SecureAggregator } from './secure.js'

export { getAggregator, AggregatorChoice } from './get'
export { getAggregator, AggregatorChoice } from './get.js'

export type Aggregator = Base<WeightsContainer>
6 changes: 3 additions & 3 deletions discojs/discojs-core/src/aggregator/mean.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assert, expect } from 'chai'
import type { Map } from 'immutable'

import type { client, Model } from '..'
import { aggregator, defaultTasks } from '..'
import { AggregationStep } from './base'
import type { client, Model } from '../index.js'
import { aggregator, defaultTasks } from '../index.js'
import { AggregationStep } from './base.js'

const model = defaultTasks.titanic.getModel()
const id = 'a'
Expand Down
6 changes: 3 additions & 3 deletions discojs/discojs-core/src/aggregator/mean.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Map } from 'immutable'

import { AggregationStep, Base as Aggregator } from './base'
import type { Model, WeightsContainer, client } from '..'
import { aggregation } from '..'
import { AggregationStep, Base as Aggregator } from './base.js'
import type { Model, WeightsContainer, client } from '../index.js'
import { aggregation } from '../index.js'

/**
* Mean aggregator whose aggregation step consists in computing the mean of the received weights.
Expand Down
53 changes: 0 additions & 53 deletions discojs/discojs-core/src/aggregator/robust.ts

This file was deleted.

2 changes: 1 addition & 1 deletion discojs/discojs-core/src/aggregator/secure.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { List, Set, Range } from 'immutable'
import { assert } from 'chai'

import { aggregator as aggregators, aggregation, WeightsContainer } from '@epfml/discojs-core'
import { aggregator as aggregators, aggregation, WeightsContainer } from '../index.js'

describe('secret shares test', function () {
const epsilon = 1e-4
Expand Down
Loading