From d6406daff5effe3299aa97213d4f97f3770b0b22 Mon Sep 17 00:00:00 2001 From: tharvik Date: Fri, 15 Mar 2024 14:43:32 +0100 Subject: [PATCH] *: upgrade to ES2022 modules --- cli/package.json | 1 + cli/src/args.ts | 1 + cli/src/cli.ts | 6 +-- cli/src/index.ts | 1 - cli/tsconfig.json | 18 +------- discojs/discojs-core/.mocharc.json | 1 + discojs/discojs-core/package.json | 1 + discojs/discojs-core/src/aggregator/base.ts | 4 +- discojs/discojs-core/src/aggregator/get.ts | 3 +- discojs/discojs-core/src/aggregator/index.ts | 14 +++---- .../discojs-core/src/aggregator/mean.spec.ts | 6 +-- discojs/discojs-core/src/aggregator/mean.ts | 6 +-- discojs/discojs-core/src/aggregator/robust.ts | 4 +- .../src/aggregator/secure.spec.ts | 2 +- discojs/discojs-core/src/aggregator/secure.ts | 17 ++++---- discojs/discojs-core/src/async_informant.ts | 2 +- discojs/discojs-core/src/client/base.ts | 10 ++--- .../src/client/decentralized/base.ts | 14 +++---- .../src/client/decentralized/index.ts | 4 +- .../src/client/decentralized/messages.ts | 8 ++-- .../src/client/decentralized/peer.spec.ts | 2 +- .../src/client/decentralized/peer.ts | 8 ++-- .../client/decentralized/peer_pool.spec.ts | 10 ++--- .../src/client/decentralized/peer_pool.ts | 6 +-- .../src/client/event_connection.ts | 12 +++--- .../discojs-core/src/client/federated/base.ts | 12 +++--- .../src/client/federated/index.ts | 4 +- .../src/client/federated/messages.ts | 6 +-- discojs/discojs-core/src/client/index.ts | 16 +++---- discojs/discojs-core/src/client/local.ts | 2 +- discojs/discojs-core/src/client/messages.ts | 6 +-- discojs/discojs-core/src/dataset/data/data.ts | 7 ++-- .../src/dataset/data/data_split.ts | 2 +- .../src/dataset/data/image_data.spec.ts | 6 +-- .../src/dataset/data/image_data.ts | 9 ++-- .../discojs-core/src/dataset/data/index.ts | 12 +++--- .../src/dataset/data/preprocessing/base.ts | 8 ++-- .../data/preprocessing/image_preprocessing.ts | 6 +-- .../src/dataset/data/preprocessing/index.ts | 8 ++-- .../preprocessing/tabular_preprocessing.ts | 4 +- .../data/preprocessing/text_preprocessing.ts | 6 +-- .../src/dataset/data/tabular_data.spec.ts | 6 +-- .../src/dataset/data/tabular_data.ts | 9 ++-- .../src/dataset/data/text_data.ts | 9 ++-- .../src/dataset/data_loader/data_loader.ts | 2 +- .../src/dataset/data_loader/image_loader.ts | 12 +++--- .../src/dataset/data_loader/index.ts | 10 ++--- .../src/dataset/data_loader/tabular_loader.ts | 11 ++--- .../src/dataset/data_loader/text_loader.ts | 8 ++-- .../src/dataset/dataset_builder.ts | 7 ++-- discojs/discojs-core/src/dataset/index.ts | 11 ++--- .../discojs-core/src/default_tasks/cifar10.ts | 6 +-- .../discojs-core/src/default_tasks/geotags.ts | 8 ++-- .../discojs-core/src/default_tasks/index.ts | 16 +++---- .../src/default_tasks/lus_covid.ts | 6 +-- .../discojs-core/src/default_tasks/mnist.ts | 6 +-- .../src/default_tasks/simple_face.ts | 6 +-- .../src/default_tasks/skin_mnist.ts | 6 +-- .../discojs-core/src/default_tasks/titanic.ts | 6 +-- .../src/default_tasks/wikitext.ts | 4 +- discojs/discojs-core/src/index.ts | 36 ++++++++-------- discojs/discojs-core/src/informant/index.ts | 6 +-- .../src/informant/training_informant/base.ts | 5 ++- .../training_informant/decentralized.ts | 2 +- .../informant/training_informant/federated.ts | 2 +- .../src/informant/training_informant/index.ts | 8 ++-- .../src/informant/training_informant/local.ts | 5 ++- .../src/logging/console_logger.ts | 2 +- discojs/discojs-core/src/logging/index.ts | 6 +-- .../src/logging/trainer_logger.ts | 4 +- discojs/discojs-core/src/memory/base.ts | 4 +- discojs/discojs-core/src/memory/empty.ts | 6 +-- discojs/discojs-core/src/memory/index.ts | 6 +-- .../discojs-core/src/models/gpt/evaluate.ts | 2 +- discojs/discojs-core/src/models/gpt/index.ts | 14 +++---- discojs/discojs-core/src/models/gpt/model.ts | 42 +++++++++---------- .../discojs-core/src/models/gpt/optimizers.ts | 4 +- discojs/discojs-core/src/models/gpt/train.ts | 12 +++--- discojs/discojs-core/src/models/index.ts | 6 +-- discojs/discojs-core/src/models/model.ts | 7 ++-- discojs/discojs-core/src/models/tfjs.ts | 12 +++--- discojs/discojs-core/src/privacy.ts | 4 +- .../discojs-core/src/serialization/index.ts | 4 +- .../src/serialization/model.spec.ts | 6 +-- .../discojs-core/src/serialization/model.ts | 4 +- .../src/serialization/weights.spec.ts | 2 +- .../discojs-core/src/serialization/weights.ts | 4 +- .../src/task/display_information.ts | 6 +-- discojs/discojs-core/src/task/index.ts | 14 +++---- discojs/discojs-core/src/task/task.ts | 6 +-- discojs/discojs-core/src/task/task_handler.ts | 8 ++-- .../discojs-core/src/task/task_provider.ts | 2 +- .../src/task/training_information.ts | 4 +- discojs/discojs-core/src/training/disco.ts | 22 ++++------ discojs/discojs-core/src/training/index.ts | 2 +- .../training/trainer/distributed_trainer.ts | 6 +-- .../src/training/trainer/local_trainer.ts | 2 +- .../training/trainer/round_tracker.spec.ts | 2 +- .../src/training/trainer/trainer.ts | 10 ++--- .../src/training/trainer/trainer_builder.ts | 10 ++--- discojs/discojs-core/src/types.ts | 4 +- discojs/discojs-core/src/validation/index.ts | 2 +- .../discojs-core/src/validation/validator.ts | 6 +-- .../src/weights/aggregation.spec.ts | 2 +- .../discojs-core/src/weights/aggregation.ts | 6 +-- discojs/discojs-core/src/weights/index.ts | 4 +- .../src/weights/weights_container.ts | 2 +- discojs/discojs-core/tsconfig.json | 4 +- discojs/discojs-node/.mocharc.json | 1 + discojs/discojs-node/package.json | 1 + .../src/data/image_loader.spec.ts | 4 +- discojs/discojs-node/src/data/index.ts | 6 +-- .../src/data/tabular_loader.spec.ts | 4 +- discojs/discojs-node/src/index.ts | 2 +- discojs/discojs-node/tsconfig.json | 6 +-- discojs/discojs-web/.mocharc.json | 1 + discojs/discojs-web/package.json | 1 + discojs/discojs-web/src/data/image_loader.ts | 2 +- discojs/discojs-web/src/data/index.ts | 6 +-- .../discojs-web/src/data/tabular_loader.ts | 2 +- discojs/discojs-web/src/data/text_loader.ts | 2 +- discojs/discojs-web/src/index.ts | 4 +- discojs/discojs-web/src/memory/index.ts | 2 +- discojs/discojs-web/tsconfig.json | 4 +- discojs/tsconfig.base.json | 20 --------- docs/examples/package.json | 1 + docs/examples/tsconfig.json | 13 ++---- eslint.config.js | 18 ++++++++ isomorphic-wrtc/browser.js | 26 +----------- isomorphic-wrtc/node.js | 5 +-- isomorphic-wrtc/package.json | 1 + server/.mocharc.json | 1 + server/package.json | 1 + server/src/config.ts | 2 +- server/src/get_server.ts | 6 +-- server/src/index.ts | 4 +- server/src/router/decentralized/index.ts | 2 +- server/src/router/decentralized/server.ts | 2 +- server/src/router/federated/index.ts | 2 +- server/src/router/federated/server.ts | 2 +- server/src/router/index.ts | 2 +- server/src/router/router.ts | 10 ++--- server/src/router/server.ts | 2 +- server/src/router/tasks.ts | 4 +- server/src/run_server.ts | 2 +- server/src/utils.ts | 2 +- server/tests/client/decentralized.spec.ts | 2 +- server/tests/client/federated.spec.ts | 2 +- server/tests/e2e/decentralized.spec.ts | 2 +- server/tests/e2e/federated.spec.ts | 2 +- server/tsconfig.json | 16 +------ tsconfig.base.json | 15 +++++++ tsconfig.eslint.json | 15 +------ web-client/vue.config.js | 1 - 154 files changed, 477 insertions(+), 517 deletions(-) delete mode 100644 cli/src/index.ts delete mode 100644 discojs/tsconfig.base.json create mode 100644 eslint.config.js create mode 100644 tsconfig.base.json diff --git a/cli/package.json b/cli/package.json index 2a05a9eee..d8f3f9079 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,7 @@ { "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", diff --git a/cli/src/args.ts b/cli/src/args.ts index d49f4bff7..990143e31 100644 --- a/cli/src/args.ts +++ b/cli/src/args.ts @@ -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' diff --git a/cli/src/cli.ts b/cli/src/cli.ts index 421aeb435..78dca15ed 100644 --- a/cli/src/cli.ts +++ b/cli/src/cli.ts @@ -4,9 +4,9 @@ import type { TrainerLog, data, Task } 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 { const client = new clients.federated.FederatedClient(url, task, new aggregators.MeanAggregator()) diff --git a/cli/src/index.ts b/cli/src/index.ts deleted file mode 100644 index 9c56149ef..000000000 --- a/cli/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './utils' diff --git a/cli/tsconfig.json b/cli/tsconfig.json index cc7ecbe29..02b0fb5c5 100644 --- a/cli/tsconfig.json +++ b/cli/tsconfig.json @@ -1,19 +1,5 @@ { - "compilerOptions": { - "target": "ES5", - "lib": ["ES5"], - - "strict": true, - - "esModuleInterop": true, - "skipLibCheck": true, - "moduleResolution": "node", - "downlevelIteration": true, // needed by diff --git a/discojs/discojs-core/src/aggregator/mean.spec.ts b/discojs/discojs-core/src/aggregator/mean.spec.ts index 31905b233..7906afe36 100644 --- a/discojs/discojs-core/src/aggregator/mean.spec.ts +++ b/discojs/discojs-core/src/aggregator/mean.spec.ts @@ -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' diff --git a/discojs/discojs-core/src/aggregator/mean.ts b/discojs/discojs-core/src/aggregator/mean.ts index 797759259..13b04272c 100644 --- a/discojs/discojs-core/src/aggregator/mean.ts +++ b/discojs/discojs-core/src/aggregator/mean.ts @@ -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. diff --git a/discojs/discojs-core/src/aggregator/robust.ts b/discojs/discojs-core/src/aggregator/robust.ts index a68e6f436..1a5aab72d 100644 --- a/discojs/discojs-core/src/aggregator/robust.ts +++ b/discojs/discojs-core/src/aggregator/robust.ts @@ -1,5 +1,5 @@ -import { Base as Aggregator } from './base' -import type { client, Model, WeightsContainer } from '..' +import { Base as Aggregator } from './base.js' +import type { client, Model, WeightsContainer } from '../index.js' import type { Map } from 'immutable' diff --git a/discojs/discojs-core/src/aggregator/secure.spec.ts b/discojs/discojs-core/src/aggregator/secure.spec.ts index 0437b3794..3d3ae66c1 100644 --- a/discojs/discojs-core/src/aggregator/secure.spec.ts +++ b/discojs/discojs-core/src/aggregator/secure.spec.ts @@ -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 diff --git a/discojs/discojs-core/src/aggregator/secure.ts b/discojs/discojs-core/src/aggregator/secure.ts index 7eb286a52..4632cba43 100644 --- a/discojs/discojs-core/src/aggregator/secure.ts +++ b/discojs/discojs-core/src/aggregator/secure.ts @@ -1,10 +1,9 @@ -import * as crypto from 'crypto' import { Map, List, Range } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -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' /** * Aggregator implementing secure multi-party computation for decentralized learning. @@ -14,8 +13,6 @@ import { aggregation } from '..' * Finally, nodes are able to average the received partial sums to establish the aggregation result. */ export class SecureAggregator extends Aggregator { - public static readonly MAX_SEED: number = 2 ** 47 - constructor ( model?: Model, private readonly maxShareValue = 100 @@ -93,7 +90,11 @@ export class SecureAggregator extends Aggregator { * a uniform distribution between (-maxShareValue, maxShareValue). */ public generateRandomShare (secret: WeightsContainer): WeightsContainer { - const seed = crypto.randomInt(SecureAggregator.MAX_SEED) + const MAX_SEED_BITS = 47 + + const random = crypto.getRandomValues(new BigInt64Array(1))[0] + const seed = Number(BigInt.asUintN(MAX_SEED_BITS, random)) + return secret.map((t) => tf.randomUniform(t.shape, -this.maxShareValue, this.maxShareValue, 'float32', seed)) } diff --git a/discojs/discojs-core/src/async_informant.ts b/discojs/discojs-core/src/async_informant.ts index 530fc7d60..f5feeee4c 100644 --- a/discojs/discojs-core/src/async_informant.ts +++ b/discojs/discojs-core/src/async_informant.ts @@ -1,4 +1,4 @@ -import type { AggregatorBase } from './aggregator' +import type { AggregatorBase } from './aggregator/index.js' export class AsyncInformant { private _round = 0 diff --git a/discojs/discojs-core/src/client/base.ts b/discojs/discojs-core/src/client/base.ts index 89dd6854d..459c2e728 100644 --- a/discojs/discojs-core/src/client/base.ts +++ b/discojs/discojs-core/src/client/base.ts @@ -1,11 +1,11 @@ import axios from 'axios' import type { Set } from 'immutable' -import type { Model, Task, TrainingInformant, WeightsContainer } from '..' -import { serialization } from '..' -import type { NodeID } from './types' -import type { EventConnection } from './event_connection' -import type { Aggregator } from '../aggregator' +import type { Model, Task, TrainingInformant, WeightsContainer } from '../index.js' +import { serialization } from '../index.js' +import type { NodeID } from './types.js' +import type { EventConnection } from './event_connection.js' +import type { Aggregator } from '../aggregator/index.js' /** * Main, abstract, class representing a Disco client in a network, which handles diff --git a/discojs/discojs-core/src/client/decentralized/base.ts b/discojs/discojs-core/src/client/decentralized/base.ts index b5dee6712..2fbed69ef 100644 --- a/discojs/discojs-core/src/client/decentralized/base.ts +++ b/discojs/discojs-core/src/client/decentralized/base.ts @@ -1,12 +1,12 @@ import { Map, Set } from 'immutable' -import { type TrainingInformant, type WeightsContainer, serialization } from '../..' -import { Client, type NodeID } from '..' -import { type, type ClientConnected } from '../messages' -import { timeout } from '../utils' -import { type EventConnection, WebSocketServer, waitMessage, type PeerConnection, waitMessageWithTimeout } from '../event_connection' -import { PeerPool } from './peer_pool' -import * as messages from './messages' +import { type TrainingInformant, type WeightsContainer, serialization } from '../../index.js' +import { Client, type NodeID } from '../index.js' +import { type, type ClientConnected } from '../messages.js' +import { timeout } from '../utils.js' +import { type EventConnection, WebSocketServer, waitMessage, type PeerConnection, waitMessageWithTimeout } from '../event_connection.js' +import { PeerPool } from './peer_pool.js' +import * as messages from './messages.js' /** * Represents a decentralized client in a network of peers. Peers coordinate each other with the diff --git a/discojs/discojs-core/src/client/decentralized/index.ts b/discojs/discojs-core/src/client/decentralized/index.ts index e5172c636..28595d303 100644 --- a/discojs/discojs-core/src/client/decentralized/index.ts +++ b/discojs/discojs-core/src/client/decentralized/index.ts @@ -1,2 +1,2 @@ -export { Base as DecentralizedClient } from './base' -export * as messages from './messages' +export { Base as DecentralizedClient } from './base.js' +export * as messages from './messages.js' diff --git a/discojs/discojs-core/src/client/decentralized/messages.ts b/discojs/discojs-core/src/client/decentralized/messages.ts index d9f844796..93ffafb68 100644 --- a/discojs/discojs-core/src/client/decentralized/messages.ts +++ b/discojs/discojs-core/src/client/decentralized/messages.ts @@ -1,7 +1,7 @@ -import { weights } from '../../serialization' -import { type SignalData } from './peer' -import { isNodeID, type NodeID } from '../types' -import { type, type ClientConnected, type AssignNodeID, hasMessageType } from '../messages' +import { weights } from '../../serialization/index.js' +import { type SignalData } from './peer.js' +import { isNodeID, type NodeID } from '../types.js' +import { type, type ClientConnected, type AssignNodeID, hasMessageType } from '../messages.js' /// Phase 0 communication (between server and peers) diff --git a/discojs/discojs-core/src/client/decentralized/peer.spec.ts b/discojs/discojs-core/src/client/decentralized/peer.spec.ts index 3788b12e7..eeed34458 100644 --- a/discojs/discojs-core/src/client/decentralized/peer.spec.ts +++ b/discojs/discojs-core/src/client/decentralized/peer.spec.ts @@ -1,7 +1,7 @@ import { assert } from 'chai' import { List, Range, Set } from 'immutable' -import { Peer } from './peer' +import { Peer } from './peer.js' describe('peer', function () { let peer1: Peer diff --git a/discojs/discojs-core/src/client/decentralized/peer.ts b/discojs/discojs-core/src/client/decentralized/peer.ts index c58c78024..d91f9dce3 100644 --- a/discojs/discojs-core/src/client/decentralized/peer.ts +++ b/discojs/discojs-core/src/client/decentralized/peer.ts @@ -1,9 +1,9 @@ -import { type NodeID } from '../types' - import { List, Map, Range, Seq } from 'immutable' import wrtc from 'isomorphic-wrtc' import SimplePeer from 'simple-peer' +import type { NodeID } from '../types.js' + type MessageID = number type ChunkID = number @@ -19,7 +19,9 @@ const TICK = 10 // we can't use the definition in DOM as we're platform independent export type SignalData = | { type: 'answer' | 'offer' | 'pranswer' | 'rollback', sdp?: string } - | { type: 'transceiverRequest' | 'renegotiate' | 'candidate' } + | { type: 'transceiverRequest', transceiverRequest: { kind: string } } + | { type: 'renegotiate', renegotiate: true } + | { type: 'candidate', candidate: RTCIceCandidate } interface Events { 'close': () => void diff --git a/discojs/discojs-core/src/client/decentralized/peer_pool.spec.ts b/discojs/discojs-core/src/client/decentralized/peer_pool.spec.ts index 6e383570c..23313672c 100644 --- a/discojs/discojs-core/src/client/decentralized/peer_pool.spec.ts +++ b/discojs/discojs-core/src/client/decentralized/peer_pool.spec.ts @@ -1,11 +1,11 @@ import { assert } from 'chai' import { Map, Range } from 'immutable' -import { type messages } from '.' -import { type } from '../messages' -import { type PeerConnection, type EventConnection } from '../event_connection' +import type { messages } from './index.js' +import { type } from '../messages.js' +import type { PeerConnection, EventConnection } from '../event_connection.js' -import { PeerPool } from './peer_pool' -import { type NodeID } from '../types' +import { PeerPool } from './peer_pool.js' +import type { NodeID } from '../types.js' describe('peer pool', function () { this.timeout(10_000) diff --git a/discojs/discojs-core/src/client/decentralized/peer_pool.ts b/discojs/discojs-core/src/client/decentralized/peer_pool.ts index 1c207a4ee..a9c1f00bf 100644 --- a/discojs/discojs-core/src/client/decentralized/peer_pool.ts +++ b/discojs/discojs-core/src/client/decentralized/peer_pool.ts @@ -1,8 +1,8 @@ import { Map, type Set } from 'immutable' -import { Peer, type SignalData } from './peer' -import { type NodeID } from '../types' -import { PeerConnection, type EventConnection } from '../event_connection' +import { Peer, type SignalData } from './peer.js' +import { type NodeID } from '../types.js' +import { PeerConnection, type EventConnection } from '../event_connection.js' // TODO cleanup old peers diff --git a/discojs/discojs-core/src/client/event_connection.ts b/discojs/discojs-core/src/client/event_connection.ts index fedb50c85..177358f99 100644 --- a/discojs/discojs-core/src/client/event_connection.ts +++ b/discojs/discojs-core/src/client/event_connection.ts @@ -1,12 +1,12 @@ import isomorphic from 'isomorphic-ws' -import type { Peer, SignalData } from './decentralized/peer' -import { type NodeID } from './types' +import type { Peer, SignalData } from './decentralized/peer.js' +import { type NodeID } from './types.js' import msgpack from 'msgpack-lite' -import * as decentralizedMessages from './decentralized/messages' -import { type, type NarrowMessage, type Message } from './messages' -import { timeout } from './utils' +import * as decentralizedMessages from './decentralized/messages.js' +import { type, type NarrowMessage, type Message } from './messages.js' +import { timeout } from './utils.js' -import { EventEmitter } from '../utils/event_emitter' +import { EventEmitter } from '../utils/event_emitter.js' export interface EventConnection { on: (type: K, handler: (event: NarrowMessage) => void) => void diff --git a/discojs/discojs-core/src/client/federated/base.ts b/discojs/discojs-core/src/client/federated/base.ts index f6eb76872..83c9d6f5f 100644 --- a/discojs/discojs-core/src/client/federated/base.ts +++ b/discojs/discojs-core/src/client/federated/base.ts @@ -1,11 +1,11 @@ import { Map } from 'immutable' -import { serialization, type informant, type MetadataKey, type MetadataValue, type WeightsContainer, type TrainingInformant } from '../..' -import { type NodeID } from '../types' -import { Base as Client } from '../base' -import { type, type ClientConnected } from '../messages' -import { type EventConnection, waitMessageWithTimeout, WebSocketServer } from '../event_connection' -import * as messages from './messages' +import { serialization, type informant, type MetadataKey, type MetadataValue, type WeightsContainer, type TrainingInformant } from '../../index.js' +import { type NodeID } from '../types.js' +import { Base as Client } from '../base.js' +import { type, type ClientConnected } from '../messages.js' +import { type EventConnection, waitMessageWithTimeout, WebSocketServer } from '../event_connection.js' +import * as messages from './messages.js' /** * Client class that communicates with a centralized, federated server, when training diff --git a/discojs/discojs-core/src/client/federated/index.ts b/discojs/discojs-core/src/client/federated/index.ts index c45d13a07..6b2d1e5a8 100644 --- a/discojs/discojs-core/src/client/federated/index.ts +++ b/discojs/discojs-core/src/client/federated/index.ts @@ -1,2 +1,2 @@ -export { Base as FederatedClient } from './base' -export * as messages from './messages' +export { Base as FederatedClient } from './base.js' +export * as messages from './messages.js' diff --git a/discojs/discojs-core/src/client/federated/messages.ts b/discojs/discojs-core/src/client/federated/messages.ts index 9cc2b579b..71efc471c 100644 --- a/discojs/discojs-core/src/client/federated/messages.ts +++ b/discojs/discojs-core/src/client/federated/messages.ts @@ -1,7 +1,7 @@ -import { type client, type MetadataKey, type MetadataValue } from '../..' -import { type weights } from '../../serialization' +import { type client, type MetadataKey, type MetadataValue } from '../../index.js' +import { type weights } from '../../serialization/index.js' -import { type, hasMessageType, type AssignNodeID, type ClientConnected } from '../messages' +import { type, hasMessageType, type AssignNodeID, type ClientConnected } from '../messages.js' export type MessageFederated = ClientConnected | diff --git a/discojs/discojs-core/src/client/index.ts b/discojs/discojs-core/src/client/index.ts index c3b4f8940..c657140b7 100644 --- a/discojs/discojs-core/src/client/index.ts +++ b/discojs/discojs-core/src/client/index.ts @@ -1,11 +1,11 @@ -export { Base as Client } from './base' +export { Base as Client } from './base.js' -export * from './types' +export * from './types.js' -export * as aggregator from '../aggregator' -export * as decentralized from './decentralized' -export * as federated from './federated' -export * as messages from './messages' -export * as utils from './utils' +export * as aggregator from '../aggregator/index.js' +export * as decentralized from './decentralized/index.js' +export * as federated from './federated/index.js' +export * as messages from './messages.js' +export * as utils from './utils.js' -export { Local } from './local' +export { Local } from './local.js' diff --git a/discojs/discojs-core/src/client/local.ts b/discojs/discojs-core/src/client/local.ts index f36f9bde6..e3c9ab0f8 100644 --- a/discojs/discojs-core/src/client/local.ts +++ b/discojs/discojs-core/src/client/local.ts @@ -1,3 +1,3 @@ -import { Base } from './base' +import { Base } from './base.js' export class Local extends Base {} diff --git a/discojs/discojs-core/src/client/messages.ts b/discojs/discojs-core/src/client/messages.ts index a12652fbe..b75b0dc60 100644 --- a/discojs/discojs-core/src/client/messages.ts +++ b/discojs/discojs-core/src/client/messages.ts @@ -1,6 +1,6 @@ -import type * as decentralized from './decentralized/messages' -import type * as federated from './federated/messages' -import { type NodeID } from './types' +import type * as decentralized from './decentralized/messages.js' +import type * as federated from './federated/messages.js' +import { type NodeID } from './types.js' export enum type { ClientConnected, diff --git a/discojs/discojs-core/src/dataset/data/data.ts b/discojs/discojs-core/src/dataset/data/data.ts index 049b5a7f8..2aa766582 100644 --- a/discojs/discojs-core/src/dataset/data/data.ts +++ b/discojs/discojs-core/src/dataset/data/data.ts @@ -1,9 +1,10 @@ import type tf from '@tensorflow/tfjs' import type { List } from 'immutable' -import type { Task } from '../..' -import type { Dataset } from '../dataset' -import type { PreprocessingFunction } from './preprocessing/base' +import type { Task } from '../../index.js' +import type { Dataset } from '../index.js' + +import type { PreprocessingFunction } from './preprocessing/base.js' /** * Abstract class representing an immutable Disco dataset, including a TF.js dataset, diff --git a/discojs/discojs-core/src/dataset/data/data_split.ts b/discojs/discojs-core/src/dataset/data/data_split.ts index 215b894c2..5cf56bff8 100644 --- a/discojs/discojs-core/src/dataset/data/data_split.ts +++ b/discojs/discojs-core/src/dataset/data/data_split.ts @@ -1,4 +1,4 @@ -import { type Data } from './data' +import type { Data } from './data.js' /** * Train-validation split of Disco data. diff --git a/discojs/discojs-core/src/dataset/data/image_data.spec.ts b/discojs/discojs-core/src/dataset/data/image_data.spec.ts index 6cd073275..db4fe0392 100644 --- a/discojs/discojs-core/src/dataset/data/image_data.spec.ts +++ b/discojs/discojs-core/src/dataset/data/image_data.spec.ts @@ -1,8 +1,8 @@ import { assert, expect } from 'chai' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import { ImageData } from './image_data' -import type { Task } from '../..' +import { ImageData } from './image_data.js' +import type { Task } from '../../index.js' describe('image data checks', () => { const simplefaceMock: Task = { diff --git a/discojs/discojs-core/src/dataset/data/image_data.ts b/discojs/discojs-core/src/dataset/data/image_data.ts index 83a61117e..5545a085d 100644 --- a/discojs/discojs-core/src/dataset/data/image_data.ts +++ b/discojs/discojs-core/src/dataset/data/image_data.ts @@ -1,9 +1,10 @@ import type tf from '@tensorflow/tfjs' -import type { Task } from '../..' -import type { Dataset } from '../dataset' -import { Data } from './data' -import { ImagePreprocessing, IMAGE_PREPROCESSING } from './preprocessing' +import type { Task } from '../../index.js' +import type { Dataset } from '../dataset.js' + +import { Data } from './data.js' +import { ImagePreprocessing, IMAGE_PREPROCESSING } from './preprocessing/index.js' /** * Disco data made of image samples (.jpg, .png, etc.). diff --git a/discojs/discojs-core/src/dataset/data/index.ts b/discojs/discojs-core/src/dataset/data/index.ts index d09031780..2f5f5fb75 100644 --- a/discojs/discojs-core/src/dataset/data/index.ts +++ b/discojs/discojs-core/src/dataset/data/index.ts @@ -1,9 +1,9 @@ -export type { DataSplit } from './data_split' -export { Data } from './data' -export { ImageData } from './image_data' -export { TabularData } from './tabular_data' -export { TextData } from './text_data' +export type { DataSplit } from './data_split.js' +export { Data } from './data.js' +export { ImageData } from './image_data.js' +export { TabularData } from './tabular_data.js' +export { TextData } from './text_data.js' export { ImagePreprocessing, TabularPreprocessing, TextPreprocessing, IMAGE_PREPROCESSING, TABULAR_PREPROCESSING, TEXT_PREPROCESSING -} from './preprocessing' +} from './preprocessing/index.js' diff --git a/discojs/discojs-core/src/dataset/data/preprocessing/base.ts b/discojs/discojs-core/src/dataset/data/preprocessing/base.ts index 9507dfe6b..dbd18a096 100644 --- a/discojs/discojs-core/src/dataset/data/preprocessing/base.ts +++ b/discojs/discojs-core/src/dataset/data/preprocessing/base.ts @@ -1,9 +1,9 @@ import type tf from '@tensorflow/tfjs' -import type { Task } from '../../..' -import type { ImagePreprocessing } from './image_preprocessing' -import type { TabularPreprocessing } from './tabular_preprocessing' -import type { TextPreprocessing } from './text_preprocessing' +import type { Task } from '../../../index.js' +import type { ImagePreprocessing } from './image_preprocessing.js' +import type { TabularPreprocessing } from './tabular_preprocessing.js' +import type { TextPreprocessing } from './text_preprocessing.js' /** * All available preprocessing type enums. diff --git a/discojs/discojs-core/src/dataset/data/preprocessing/image_preprocessing.ts b/discojs/discojs-core/src/dataset/data/preprocessing/image_preprocessing.ts index 2220a9d69..4b1bd13a0 100644 --- a/discojs/discojs-core/src/dataset/data/preprocessing/image_preprocessing.ts +++ b/discojs/discojs-core/src/dataset/data/preprocessing/image_preprocessing.ts @@ -1,8 +1,8 @@ import { List } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Task } from '../../..' -import type { PreprocessingFunction } from './base' +import type { Task } from '../../../index.js' +import type { PreprocessingFunction } from './base.js' /** * Available image preprocessing types. diff --git a/discojs/discojs-core/src/dataset/data/preprocessing/index.ts b/discojs/discojs-core/src/dataset/data/preprocessing/index.ts index 87d0a2c72..3e805f897 100644 --- a/discojs/discojs-core/src/dataset/data/preprocessing/index.ts +++ b/discojs/discojs-core/src/dataset/data/preprocessing/index.ts @@ -1,4 +1,4 @@ -export type { Preprocessing, PreprocessingFunction } from './base' -export { AVAILABLE_PREPROCESSING as IMAGE_PREPROCESSING, ImagePreprocessing } from './image_preprocessing' -export { AVAILABLE_PREPROCESSING as TABULAR_PREPROCESSING, TabularPreprocessing } from './tabular_preprocessing' -export { AVAILABLE_PREPROCESSING as TEXT_PREPROCESSING, TextPreprocessing } from './text_preprocessing' +export type { Preprocessing, PreprocessingFunction } from './base.js' +export { AVAILABLE_PREPROCESSING as IMAGE_PREPROCESSING, ImagePreprocessing } from './image_preprocessing.js' +export { AVAILABLE_PREPROCESSING as TABULAR_PREPROCESSING, TabularPreprocessing } from './tabular_preprocessing.js' +export { AVAILABLE_PREPROCESSING as TEXT_PREPROCESSING, TextPreprocessing } from './text_preprocessing.js' diff --git a/discojs/discojs-core/src/dataset/data/preprocessing/tabular_preprocessing.ts b/discojs/discojs-core/src/dataset/data/preprocessing/tabular_preprocessing.ts index 4450b41c2..a3de0201b 100644 --- a/discojs/discojs-core/src/dataset/data/preprocessing/tabular_preprocessing.ts +++ b/discojs/discojs-core/src/dataset/data/preprocessing/tabular_preprocessing.ts @@ -1,8 +1,8 @@ import type tf from '@tensorflow/tfjs' import { List } from 'immutable' -import type { Task } from '../../..' -import type { PreprocessingFunction } from './base' +import type { Task } from '../../../index.js' +import type { PreprocessingFunction } from './base.js' /** * Available tabular preprocessing types. diff --git a/discojs/discojs-core/src/dataset/data/preprocessing/text_preprocessing.ts b/discojs/discojs-core/src/dataset/data/preprocessing/text_preprocessing.ts index e372bde4d..239b718bd 100644 --- a/discojs/discojs-core/src/dataset/data/preprocessing/text_preprocessing.ts +++ b/discojs/discojs-core/src/dataset/data/preprocessing/text_preprocessing.ts @@ -1,8 +1,8 @@ import { List } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Task } from '../../..' -import type { PreprocessingFunction } from './base' +import type { Task } from '../../../index.js' +import type { PreprocessingFunction } from './base.js' /** * Available text preprocessing types. diff --git a/discojs/discojs-core/src/dataset/data/tabular_data.spec.ts b/discojs/discojs-core/src/dataset/data/tabular_data.spec.ts index 3a87ea8b3..a0d727570 100644 --- a/discojs/discojs-core/src/dataset/data/tabular_data.spec.ts +++ b/discojs/discojs-core/src/dataset/data/tabular_data.spec.ts @@ -1,9 +1,9 @@ import { assert, expect } from 'chai' import { Map, Set } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import { TabularData } from './tabular_data' -import type { Task } from '../..' +import { TabularData } from './tabular_data.js' +import type { Task } from '../../index.js' describe('tabular data checks', () => { const titanicMock: Task = { diff --git a/discojs/discojs-core/src/dataset/data/tabular_data.ts b/discojs/discojs-core/src/dataset/data/tabular_data.ts index 892c9d8b4..7996223b7 100644 --- a/discojs/discojs-core/src/dataset/data/tabular_data.ts +++ b/discojs/discojs-core/src/dataset/data/tabular_data.ts @@ -1,7 +1,8 @@ -import { type Task } from '../..' -import { type Dataset } from '../dataset' -import { Data } from './data' -import { TABULAR_PREPROCESSING } from './preprocessing' +import type { Task } from '../../index.js' +import type { Dataset } from '../dataset.js' + +import { Data } from './data.js' +import { TABULAR_PREPROCESSING } from './preprocessing/index.js' /** * Disco data made of tabular (.csv, .tsv, etc.) files. diff --git a/discojs/discojs-core/src/dataset/data/text_data.ts b/discojs/discojs-core/src/dataset/data/text_data.ts index 84933e337..64b52aad4 100644 --- a/discojs/discojs-core/src/dataset/data/text_data.ts +++ b/discojs/discojs-core/src/dataset/data/text_data.ts @@ -1,7 +1,8 @@ -import { type Task } from '../..' -import { type Dataset } from '../dataset' -import { Data } from './data' -import { TEXT_PREPROCESSING } from './preprocessing' +import type { Task } from '../../index.js' +import type { Dataset } from '../dataset.js' + +import { Data } from './data.js' +import { TEXT_PREPROCESSING } from './preprocessing/index.js' /** * Disco data made of textual samples. diff --git a/discojs/discojs-core/src/dataset/data_loader/data_loader.ts b/discojs/discojs-core/src/dataset/data_loader/data_loader.ts index a4377d1e8..fd6e578fc 100644 --- a/discojs/discojs-core/src/dataset/data_loader/data_loader.ts +++ b/discojs/discojs-core/src/dataset/data_loader/data_loader.ts @@ -1,4 +1,4 @@ -import type { DataSplit, Dataset } from '..' +import type { DataSplit, Dataset } from '../index.js' export interface DataConfig { features?: string[], labels?: string[], shuffle?: boolean, validationSplit?: number, inference?: boolean } diff --git a/discojs/discojs-core/src/dataset/data_loader/image_loader.ts b/discojs/discojs-core/src/dataset/data_loader/image_loader.ts index a42f5b0d4..713f54227 100644 --- a/discojs/discojs-core/src/dataset/data_loader/image_loader.ts +++ b/discojs/discojs-core/src/dataset/data_loader/image_loader.ts @@ -1,12 +1,12 @@ import { Range } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Task } from '../..' +import type { Task } from '../../index.js' -import type { Data, Dataset, DataSplit } from '..' -import { ImageData } from '../data' -import type { DataConfig } from '../data_loader' -import { DataLoader } from '../data_loader' +import type { Data, Dataset, DataSplit } from '../index.js' +import { ImageData } from '../data/index.js' +import type { DataConfig } from '../data_loader/index.js' +import { DataLoader } from '../data_loader/index.js' /** * Image data loader whose instantiable implementation is delegated by the platform-dependent Disco subprojects, namely, diff --git a/discojs/discojs-core/src/dataset/data_loader/index.ts b/discojs/discojs-core/src/dataset/data_loader/index.ts index 39c0aa34d..50390dc2d 100644 --- a/discojs/discojs-core/src/dataset/data_loader/index.ts +++ b/discojs/discojs-core/src/dataset/data_loader/index.ts @@ -1,6 +1,6 @@ -export type { DataConfig } from './data_loader' -export { DataLoader } from './data_loader' +export type { DataConfig } from './data_loader.js' +export { DataLoader } from './data_loader.js' -export { ImageLoader } from './image_loader' -export { TabularLoader } from './tabular_loader' -export { TextLoader } from './text_loader' +export { ImageLoader } from './image_loader.js' +export { TabularLoader } from './tabular_loader.js' +export { TextLoader } from './text_loader.js' diff --git a/discojs/discojs-core/src/dataset/data_loader/tabular_loader.ts b/discojs/discojs-core/src/dataset/data_loader/tabular_loader.ts index 41e912746..377345d92 100644 --- a/discojs/discojs-core/src/dataset/data_loader/tabular_loader.ts +++ b/discojs/discojs-core/src/dataset/data_loader/tabular_loader.ts @@ -1,11 +1,12 @@ import { List, Map, Set } from 'immutable' -import type { Task } from '../..' +import type { Task } from '../../index.js' -import type { Dataset, DataSplit } from '..' -import { TabularData } from '..' -import type { DataConfig } from '../data_loader' -import { DataLoader } from '../data_loader' +import type { Dataset, DataSplit } from '../index.js' +import { TabularData } from '../index.js' + +import type { DataConfig } from './index.js' +import { DataLoader } from './index.js' // Window size from which the dataset shuffling will sample const BUFFER_SIZE = 1000 diff --git a/discojs/discojs-core/src/dataset/data_loader/text_loader.ts b/discojs/discojs-core/src/dataset/data_loader/text_loader.ts index d1bbd633e..e1b27dbba 100644 --- a/discojs/discojs-core/src/dataset/data_loader/text_loader.ts +++ b/discojs/discojs-core/src/dataset/data_loader/text_loader.ts @@ -1,9 +1,9 @@ -import type { Task } from '../..' +import type { Task } from '../../index.js' -import type { DataSplit, Dataset } from '..' -import { TextData } from '..' +import type { DataSplit, Dataset } from '../index.js' +import { TextData } from '../index.js' -import { DataLoader } from '.' +import { DataLoader } from './index.js' /** * Text data loader whose instantiable implementation is delegated by the platform-dependent Disco subprojects, namely, diff --git a/discojs/discojs-core/src/dataset/dataset_builder.ts b/discojs/discojs-core/src/dataset/dataset_builder.ts index 3506c68f8..847a75c9f 100644 --- a/discojs/discojs-core/src/dataset/dataset_builder.ts +++ b/discojs/discojs-core/src/dataset/dataset_builder.ts @@ -1,6 +1,7 @@ -import { type Task } from '..' -import { type DataSplit } from './data' -import { type DataConfig, type DataLoader } from './data_loader/data_loader' +import type { Task } from '../index.js' + +import type { DataSplit } from './data/index.js' +import type { DataConfig, DataLoader } from './data_loader/data_loader.js' import { Map } from 'immutable' diff --git a/discojs/discojs-core/src/dataset/index.ts b/discojs/discojs-core/src/dataset/index.ts index d25130d14..ec0bde41e 100644 --- a/discojs/discojs-core/src/dataset/index.ts +++ b/discojs/discojs-core/src/dataset/index.ts @@ -1,8 +1,9 @@ -export type { Dataset } from './dataset' -export { DatasetBuilder } from './dataset_builder' -export { ImageLoader, TabularLoader, DataLoader, TextLoader } from './data_loader' +export type { Dataset } from './dataset.js' +export { DatasetBuilder } from './dataset_builder.js' +export { ImageLoader, TabularLoader, DataLoader, TextLoader } from './data_loader/index.js' +export type { DataSplit } from './data/index.js' export { - type DataSplit, Data, TabularData, ImageData, TextData, + Data, TabularData, ImageData, TextData, ImagePreprocessing, TabularPreprocessing, TextPreprocessing, IMAGE_PREPROCESSING, TABULAR_PREPROCESSING, TEXT_PREPROCESSING -} from './data' +} from './data/index.js' diff --git a/discojs/discojs-core/src/default_tasks/cifar10.ts b/discojs/discojs-core/src/default_tasks/cifar10.ts index cb2ce3ab0..413f26baa 100644 --- a/discojs/discojs-core/src/default_tasks/cifar10.ts +++ b/discojs/discojs-core/src/default_tasks/cifar10.ts @@ -1,7 +1,7 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Model, Task, TaskProvider } from '..' -import { data, models } from '..' +import type { Model, Task, TaskProvider } from '../index.js' +import { data, models } from '../index.js' export const cifar10: TaskProvider = { getTask (): Task { diff --git a/discojs/discojs-core/src/default_tasks/geotags.ts b/discojs/discojs-core/src/default_tasks/geotags.ts index e84eb26de..14e24c004 100644 --- a/discojs/discojs-core/src/default_tasks/geotags.ts +++ b/discojs/discojs-core/src/default_tasks/geotags.ts @@ -1,9 +1,9 @@ import { Range } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Model, Task, TaskProvider } from '..' -import { data, models } from '..' -import { LabelTypeEnum } from '../task/label_type' +import type { Model, Task, TaskProvider } from '../index.js' +import { data, models } from '../index.js' +import { LabelTypeEnum } from '../task/label_type.js' export const geotags: TaskProvider = { getTask (): Task { diff --git a/discojs/discojs-core/src/default_tasks/index.ts b/discojs/discojs-core/src/default_tasks/index.ts index 15730a99e..e85e0f216 100644 --- a/discojs/discojs-core/src/default_tasks/index.ts +++ b/discojs/discojs-core/src/default_tasks/index.ts @@ -1,8 +1,8 @@ -export { cifar10 } from './cifar10' -export { geotags } from './geotags' -export { lusCovid } from './lus_covid' -export { mnist } from './mnist' -export { simpleFace } from './simple_face' -export { skinMnist } from './skin_mnist' -export { titanic } from './titanic' -export { wikitext } from './wikitext' +export { cifar10 } from './cifar10.js' +export { geotags } from './geotags.js' +export { lusCovid } from './lus_covid.js' +export { mnist } from './mnist.js' +export { simpleFace } from './simple_face.js' +export { skinMnist } from './skin_mnist.js' +export { titanic } from './titanic.js' +export { wikitext } from './wikitext.js' diff --git a/discojs/discojs-core/src/default_tasks/lus_covid.ts b/discojs/discojs-core/src/default_tasks/lus_covid.ts index 4c36fba58..e789b4419 100644 --- a/discojs/discojs-core/src/default_tasks/lus_covid.ts +++ b/discojs/discojs-core/src/default_tasks/lus_covid.ts @@ -1,7 +1,7 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Model, Task, TaskProvider } from '..' -import { data, models } from '..' +import type { Model, Task, TaskProvider } from '../index.js' +import { data, models } from '../index.js' export const lusCovid: TaskProvider = { getTask (): Task { diff --git a/discojs/discojs-core/src/default_tasks/mnist.ts b/discojs/discojs-core/src/default_tasks/mnist.ts index eceb8b9f7..559d9cd0f 100644 --- a/discojs/discojs-core/src/default_tasks/mnist.ts +++ b/discojs/discojs-core/src/default_tasks/mnist.ts @@ -1,7 +1,7 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Model, Task, TaskProvider } from '..' -import { models } from '..' +import type { Model, Task, TaskProvider } from '../index.js' +import { models } from '../index.js' export const mnist: TaskProvider = { getTask (): Task { diff --git a/discojs/discojs-core/src/default_tasks/simple_face.ts b/discojs/discojs-core/src/default_tasks/simple_face.ts index cc5d55cd2..8d5df19b3 100644 --- a/discojs/discojs-core/src/default_tasks/simple_face.ts +++ b/discojs/discojs-core/src/default_tasks/simple_face.ts @@ -1,7 +1,7 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Model, Task, TaskProvider } from '..' -import { data, models } from '..' +import type { Model, Task, TaskProvider } from '../index.js' +import { data, models } from '../index.js' export const simpleFace: TaskProvider = { getTask (): Task { diff --git a/discojs/discojs-core/src/default_tasks/skin_mnist.ts b/discojs/discojs-core/src/default_tasks/skin_mnist.ts index 357d7edef..b688ab9e6 100644 --- a/discojs/discojs-core/src/default_tasks/skin_mnist.ts +++ b/discojs/discojs-core/src/default_tasks/skin_mnist.ts @@ -1,7 +1,7 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Model, Task, TaskProvider } from '..' -import { data, models } from '..' +import type { Model, Task, TaskProvider } from '../index.js' +import { data, models } from '../index.js' export const skinMnist: TaskProvider = { getTask (): Task { diff --git a/discojs/discojs-core/src/default_tasks/titanic.ts b/discojs/discojs-core/src/default_tasks/titanic.ts index 07cc38aa7..f70170f98 100644 --- a/discojs/discojs-core/src/default_tasks/titanic.ts +++ b/discojs/discojs-core/src/default_tasks/titanic.ts @@ -1,7 +1,7 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Model, Task, TaskProvider } from '..' -import { data, models } from '..' +import type { Model, Task, TaskProvider } from '../index.js' +import { data, models } from '../index.js' export const titanic: TaskProvider = { getTask (): Task { diff --git a/discojs/discojs-core/src/default_tasks/wikitext.ts b/discojs/discojs-core/src/default_tasks/wikitext.ts index 44f834699..60ca82e34 100644 --- a/discojs/discojs-core/src/default_tasks/wikitext.ts +++ b/discojs/discojs-core/src/default_tasks/wikitext.ts @@ -1,5 +1,5 @@ -import type { Model, Task, TaskProvider } from '..' -import { models } from '..' +import type { Model, Task, TaskProvider } from '../index.js' +import { models } from '../index.js' export const wikitext: TaskProvider = { getTask (): Task { diff --git a/discojs/discojs-core/src/index.ts b/discojs/discojs-core/src/index.ts index 593234f84..e6e80d64b 100644 --- a/discojs/discojs-core/src/index.ts +++ b/discojs/discojs-core/src/index.ts @@ -1,23 +1,23 @@ -export * as data from './dataset' -export * as serialization from './serialization' -export * as training from './training' -export * as privacy from './privacy' -export { GraphInformant, TrainingInformant, informant } from './informant' +export * as data from './dataset/index.js' +export * as serialization from './serialization/index.js' +export * as training from './training/index.js' +export * as privacy from './privacy.js' +export { GraphInformant, TrainingInformant, informant } from './informant/index.js' -export * as client from './client' -export * as aggregator from './aggregator' +export * as client from './client/index.js' +export * as aggregator from './aggregator/index.js' -export { WeightsContainer, aggregation } from './weights' -export { AsyncInformant } from './async_informant' -export { Logger, ConsoleLogger, TrainerLog } from './logging' -export { Memory, ModelType, type ModelInfo, type Path, type ModelSource, Empty as EmptyMemory } from './memory' -export { Disco } from './training' -export { Validator } from './validation' +export { WeightsContainer, aggregation } from './weights/index.js' +export { AsyncInformant } from './async_informant.js' +export { Logger, ConsoleLogger, TrainerLog } from './logging/index.js' +export { Memory, ModelType, type ModelInfo, type Path, type ModelSource, Empty as EmptyMemory } from './memory/index.js' +export { Disco } from './training/index.js' +export { Validator } from './validation/index.js' -export { Model } from './models' -export * as models from './models' +export { Model } from './models/index.js' +export * as models from './models/index.js' -export * from './task' -export * as defaultTasks from './default_tasks' +export * from './task/index.js' +export * as defaultTasks from './default_tasks/index.js' -export * from './types' +export * from './types.js' diff --git a/discojs/discojs-core/src/informant/index.ts b/discojs/discojs-core/src/informant/index.ts index ce14ba43e..e3a8c1e65 100644 --- a/discojs/discojs-core/src/informant/index.ts +++ b/discojs/discojs-core/src/informant/index.ts @@ -1,3 +1,3 @@ -export { GraphInformant } from './graph_informant' -export { Base as TrainingInformant } from './training_informant' -export * as informant from './training_informant' +export { GraphInformant } from './graph_informant.js' +export { Base as TrainingInformant } from './training_informant/index.js' +export * as informant from './training_informant/index.js' diff --git a/discojs/discojs-core/src/informant/training_informant/base.ts b/discojs/discojs-core/src/informant/training_informant/base.ts index b4e2a578d..7317e45fb 100644 --- a/discojs/discojs-core/src/informant/training_informant/base.ts +++ b/discojs/discojs-core/src/informant/training_informant/base.ts @@ -1,7 +1,8 @@ import { List, Set } from 'immutable' -import { type Task } from '../../task' -import { GraphInformant } from '../graph_informant' +import type { Task } from '../../index.js' + +import { GraphInformant } from '../graph_informant.js' export abstract class Base { // written feedback diff --git a/discojs/discojs-core/src/informant/training_informant/decentralized.ts b/discojs/discojs-core/src/informant/training_informant/decentralized.ts index 2a9414343..9f307fc91 100644 --- a/discojs/discojs-core/src/informant/training_informant/decentralized.ts +++ b/discojs/discojs-core/src/informant/training_informant/decentralized.ts @@ -1,4 +1,4 @@ -import { Base } from '.' +import { Base } from './index.js' export class DecentralizedInformant extends Base { update (statistics: Record): void { diff --git a/discojs/discojs-core/src/informant/training_informant/federated.ts b/discojs/discojs-core/src/informant/training_informant/federated.ts index 67b0d73fc..dd18c4ab3 100644 --- a/discojs/discojs-core/src/informant/training_informant/federated.ts +++ b/discojs/discojs-core/src/informant/training_informant/federated.ts @@ -1,4 +1,4 @@ -import { Base } from '.' +import { Base } from './index.js' /** * Class that collects information about the status of the training-loop of the model. diff --git a/discojs/discojs-core/src/informant/training_informant/index.ts b/discojs/discojs-core/src/informant/training_informant/index.ts index 88cb0ecc5..8defbf68d 100644 --- a/discojs/discojs-core/src/informant/training_informant/index.ts +++ b/discojs/discojs-core/src/informant/training_informant/index.ts @@ -1,5 +1,5 @@ -export { Base } from './base' +export { Base } from './base.js' -export { FederatedInformant } from './federated' -export { DecentralizedInformant } from './decentralized' -export { LocalInformant } from './local' +export { FederatedInformant } from './federated.js' +export { DecentralizedInformant } from './decentralized.js' +export { LocalInformant } from './local.js' diff --git a/discojs/discojs-core/src/informant/training_informant/local.ts b/discojs/discojs-core/src/informant/training_informant/local.ts index 32ea2c76b..ca6a833db 100644 --- a/discojs/discojs-core/src/informant/training_informant/local.ts +++ b/discojs/discojs-core/src/informant/training_informant/local.ts @@ -1,5 +1,6 @@ -import { type Task } from '../../task' -import { Base } from '.' +import type { Task } from '../../index.js' + +import { Base } from './index.js' export class LocalInformant extends Base { constructor (task: Task, nbrMessagesToShow?: number) { diff --git a/discojs/discojs-core/src/logging/console_logger.ts b/discojs/discojs-core/src/logging/console_logger.ts index 24ad46b6b..1f021e033 100644 --- a/discojs/discojs-core/src/logging/console_logger.ts +++ b/discojs/discojs-core/src/logging/console_logger.ts @@ -1,5 +1,5 @@ import chalk from 'chalk' -import { Logger } from './logger' +import { Logger } from './logger.js' /** * Same properties as Toaster but on the console diff --git a/discojs/discojs-core/src/logging/index.ts b/discojs/discojs-core/src/logging/index.ts index a4cbdaaf0..443f03e2a 100644 --- a/discojs/discojs-core/src/logging/index.ts +++ b/discojs/discojs-core/src/logging/index.ts @@ -1,3 +1,3 @@ -export { Logger } from './logger' -export { ConsoleLogger } from './console_logger' -export { TrainerLog } from './trainer_logger' +export { Logger } from './logger.js' +export { ConsoleLogger } from './console_logger.js' +export { TrainerLog } from './trainer_logger.js' diff --git a/discojs/discojs-core/src/logging/trainer_logger.ts b/discojs/discojs-core/src/logging/trainer_logger.ts index 84bcdec6a..259bc6a51 100644 --- a/discojs/discojs-core/src/logging/trainer_logger.ts +++ b/discojs/discojs-core/src/logging/trainer_logger.ts @@ -1,7 +1,7 @@ import { List } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import { ConsoleLogger } from '.' +import { ConsoleLogger } from './index.js' export class TrainerLog { epochs: List = List() diff --git a/discojs/discojs-core/src/memory/base.ts b/discojs/discojs-core/src/memory/base.ts index 7de82dad6..a28c7ac34 100644 --- a/discojs/discojs-core/src/memory/base.ts +++ b/discojs/discojs-core/src/memory/base.ts @@ -1,8 +1,8 @@ // only used browser-side // TODO: replace IO type -import type { Model, TaskID } from '..' -import type { ModelType } from './model_type' +import type { Model, TaskID } from '../index.js' +import type { ModelType } from './model_type.js' /** * Model path which uniquely identifies a model in memory. diff --git a/discojs/discojs-core/src/memory/empty.ts b/discojs/discojs-core/src/memory/empty.ts index 030222f31..69a73666e 100644 --- a/discojs/discojs-core/src/memory/empty.ts +++ b/discojs/discojs-core/src/memory/empty.ts @@ -1,7 +1,7 @@ -import type { Model } from '..' +import type { Model } from '../index.js' -import type { ModelInfo, Path } from './base' -import { Memory } from './base' +import type { ModelInfo, Path } from './base.js' +import { Memory } from './base.js' /** * Represents an empty model memory. diff --git a/discojs/discojs-core/src/memory/index.ts b/discojs/discojs-core/src/memory/index.ts index f098d8618..7d5d49f82 100644 --- a/discojs/discojs-core/src/memory/index.ts +++ b/discojs/discojs-core/src/memory/index.ts @@ -1,3 +1,3 @@ -export { Empty } from './empty' -export { Memory, type ModelInfo, type Path, type ModelSource } from './base' -export { ModelType } from './model_type' +export { Empty } from './empty.js' +export { Memory, type ModelInfo, type Path, type ModelSource } from './base.js' +export { ModelType } from './model_type.js' diff --git a/discojs/discojs-core/src/models/gpt/evaluate.ts b/discojs/discojs-core/src/models/gpt/evaluate.ts index cd07653b7..db39ce74f 100644 --- a/discojs/discojs-core/src/models/gpt/evaluate.ts +++ b/discojs/discojs-core/src/models/gpt/evaluate.ts @@ -1,4 +1,4 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' export default async function evaluate ( model: tf.LayersModel, diff --git a/discojs/discojs-core/src/models/gpt/index.ts b/discojs/discojs-core/src/models/gpt/index.ts index 39552fc8c..9314c6f20 100644 --- a/discojs/discojs-core/src/models/gpt/index.ts +++ b/discojs/discojs-core/src/models/gpt/index.ts @@ -2,16 +2,16 @@ * this code is taken from gpt-tfjs with modifications from @peacefulotter and @lukemovement **/ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import { WeightsContainer } from '../..' -import type { Dataset } from '../../dataset' -import { Sink } from '../../utils/event_emitter' +import { WeightsContainer } from '../../index.js' +import type { Dataset } from '../../dataset/index.js' +import { Sink } from '../../utils/event_emitter.js' -import type { EpochLogs, Prediction, Sample } from '../model' -import { Model } from '../model' +import type { EpochLogs, Prediction, Sample } from '../model.js' +import { Model } from '../model.js' -import { GPTLMHeadModel } from './model' +import { GPTLMHeadModel } from './model.js' // TODO too big config interface Config { diff --git a/discojs/discojs-core/src/models/gpt/model.ts b/discojs/discojs-core/src/models/gpt/model.ts index f881c50c6..e40acaa33 100644 --- a/discojs/discojs-core/src/models/gpt/model.ts +++ b/discojs/discojs-core/src/models/gpt/model.ts @@ -1,11 +1,11 @@ -import tf, { LayersModel, layers, serialization } from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { GPTConfig } from './config' -import { getModelSizes, DEFAULT_CONFIG } from './config' -import { train } from './train' -import type { TrainingCallbacks } from './types' +import type { GPTConfig } from './config.js' +import { getModelSizes, DEFAULT_CONFIG } from './config.js' +import { train } from './train.js' +import type { TrainingCallbacks } from './types.js' -class Range extends layers.Layer { +class Range extends tf.layers.Layer { static readonly className = 'Range' computeOutputShape (inputShape: tf.Shape | tf.Shape[]): tf.Shape | tf.Shape[] { @@ -25,9 +25,9 @@ class Range extends layers.Layer { }) } } -serialization.registerClass(Range) +tf.serialization.registerClass(Range) -class LogLayer extends layers.Layer { +class LogLayer extends tf.layers.Layer { static readonly className = 'LogLayer' computeOutputShape (inputShape: tf.Shape | tf.Shape[]): tf.Shape | tf.Shape[] { @@ -44,9 +44,9 @@ class LogLayer extends layers.Layer { }) } } -serialization.registerClass(LogLayer) +tf.serialization.registerClass(LogLayer) -class CausalSelfAttentionBase extends layers.Layer { +class CausalSelfAttentionBase extends tf.layers.Layer { static readonly className = 'CausalSelfAttentionBase' private readonly blockSize: number @@ -73,7 +73,7 @@ class CausalSelfAttentionBase extends layers.Layer { return [null, this.blockSize, this.nEmbd] } - getConfig (): serialization.ConfigDict { + getConfig (): tf.serialization.ConfigDict { const config = super.getConfig() return Object.assign({}, config, this.config) } @@ -112,14 +112,14 @@ class CausalSelfAttentionBase extends layers.Layer { }) } } -serialization.registerClass(CausalSelfAttentionBase) +tf.serialization.registerClass(CausalSelfAttentionBase) type CausalSelfAttentionConfig = ConstructorParameters[0] & Record<'blockSize' | 'nHead' | 'nEmbd' | 'dropout', number> & { bias: boolean } -class CausalSelfAttention extends layers.Layer { +class CausalSelfAttention extends tf.layers.Layer { static readonly className = 'CausalSelfAttention' private readonly nHead: number @@ -175,7 +175,7 @@ class CausalSelfAttention extends layers.Layer { return inputShape } - getConfig (): serialization.ConfigDict { + getConfig (): tf.serialization.ConfigDict { const config = super.getConfig() return Object.assign({}, config, this.config) } @@ -241,9 +241,9 @@ class CausalSelfAttention extends layers.Layer { }) } } -serialization.registerClass(CausalSelfAttention) +tf.serialization.registerClass(CausalSelfAttention) -class GELU extends layers.Layer { +class GELU extends tf.layers.Layer { static readonly className = 'GELU' constructor () { @@ -277,9 +277,9 @@ class GELU extends layers.Layer { }) } } -serialization.registerClass(GELU) +tf.serialization.registerClass(GELU) -function MLP (conf: any): LayersModel { +function MLP (conf: any): tf.LayersModel { const config = Object.assign({ name: 'mlp' }, conf) const inputs = tf.input({ shape: [config.blockSize, config.nEmbd] }) let x @@ -309,7 +309,7 @@ function MLP (conf: any): LayersModel { return tf.model({ inputs, outputs: x as any }) } -function Block (conf: CausalSelfAttentionConfig & { debug: boolean }): LayersModel { +function Block (conf: CausalSelfAttentionConfig & { debug: boolean }): tf.LayersModel { const config = Object.assign({ name: 'h' }, conf) const inputs = tf.input({ shape: [config.blockSize, config.nEmbd] }) let x1, x2 @@ -333,7 +333,7 @@ function Block (conf: CausalSelfAttentionConfig & { debug: boolean }): LayersMod return tf.model({ name: config.name, inputs, outputs: x2 as any }) } -function GPT (conf: GPTConfig): LayersModel { +function GPT (conf: GPTConfig): tf.LayersModel { const configDefaults = { name: 'transformer', ...DEFAULT_CONFIG @@ -456,7 +456,7 @@ declare abstract class Dataset { size: number } -class GPTModel extends LayersModel { +class GPTModel extends tf.LayersModel { constructor (protected readonly config: GPTConfig) { const gpt = GPT(config) const { inputs, outputs, name } = gpt diff --git a/discojs/discojs-core/src/models/gpt/optimizers.ts b/discojs/discojs-core/src/models/gpt/optimizers.ts index 7c8ee03ea..ec11e2e57 100644 --- a/discojs/discojs-core/src/models/gpt/optimizers.ts +++ b/discojs/discojs-core/src/models/gpt/optimizers.ts @@ -1,4 +1,4 @@ -import tf, { AdamOptimizer } from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' function l2Loss (tensor: tf.Tensor): tf.Tensor { return tf.div(tf.sum(tf.square(tensor)), 2) @@ -57,7 +57,7 @@ function clipByGlobalNormObj ( return tensorsObjClipped } -class AdamW extends AdamOptimizer { +class AdamW extends tf.AdamOptimizer { weightDecayRate: number includeInWeightDecay: string[] excludeFromWeightDecay: string[] diff --git a/discojs/discojs-core/src/models/gpt/train.ts b/discojs/discojs-core/src/models/gpt/train.ts index 3d1c92649..ade8a0318 100644 --- a/discojs/discojs-core/src/models/gpt/train.ts +++ b/discojs/discojs-core/src/models/gpt/train.ts @@ -1,10 +1,10 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import { AdamW, clipByGlobalNormObj } from './optimizers' -import type { GPTConfig } from './config' -import { DEFAULT_CONFIG } from './config' -import evaluate from './evaluate' -import type { TrainingCallbacks } from './types' +import { AdamW, clipByGlobalNormObj } from './optimizers.js' +import type { GPTConfig } from './config.js' +import { DEFAULT_CONFIG } from './config.js' +import evaluate from './evaluate.js' +import type { TrainingCallbacks } from './types.js' function resolveConfig (config: GPTConfig): Required { return { diff --git a/discojs/discojs-core/src/models/index.ts b/discojs/discojs-core/src/models/index.ts index e6bf727ff..d076c5f55 100644 --- a/discojs/discojs-core/src/models/index.ts +++ b/discojs/discojs-core/src/models/index.ts @@ -1,4 +1,4 @@ -export { Model } from './model' +export { Model } from './model.js' -export { GPT } from './gpt' -export { TFJS } from './tfjs' +export { GPT } from './gpt/index.js' +export { TFJS } from './tfjs.js' diff --git a/discojs/discojs-core/src/models/model.ts b/discojs/discojs-core/src/models/model.ts index dd6e6713a..d92a28857 100644 --- a/discojs/discojs-core/src/models/model.ts +++ b/discojs/discojs-core/src/models/model.ts @@ -1,8 +1,9 @@ import type tf from '@tensorflow/tfjs' -import type { WeightsContainer } from '..' -import type { EventEmitter } from 'utils/event_emitter' -import type { Dataset } from 'dataset' +import type { WeightsContainer } from '../index.js' + +import type { EventEmitter } from '../utils/event_emitter.js' +import type { Dataset } from '../dataset/index.js' // TODO still bound to tfjs export type EpochLogs = tf.Logs | undefined diff --git a/discojs/discojs-core/src/models/tfjs.ts b/discojs/discojs-core/src/models/tfjs.ts index 6808bbbdb..b9596f95e 100644 --- a/discojs/discojs-core/src/models/tfjs.ts +++ b/discojs/discojs-core/src/models/tfjs.ts @@ -1,11 +1,11 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import { Sink } from '../utils/event_emitter' -import { WeightsContainer } from '..' +import { Sink } from '../utils/event_emitter.js' +import { WeightsContainer } from '../index.js' -import { Model } from '.' -import type { EpochLogs, Prediction, Sample } from './model' -import type { Dataset } from '../dataset' +import { Model } from './index.js' +import type { EpochLogs, Prediction, Sample } from './model.js' +import type { Dataset } from '../dataset/index.js' /** TensorFlow JavaScript model with standard training */ export class TFJS extends Model { diff --git a/discojs/discojs-core/src/privacy.ts b/discojs/discojs-core/src/privacy.ts index 754410a6b..adf0e87c0 100644 --- a/discojs/discojs-core/src/privacy.ts +++ b/discojs/discojs-core/src/privacy.ts @@ -1,6 +1,6 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Task, WeightsContainer } from '.' +import type { Task, WeightsContainer } from './index.js' /** * Add task-parametrized Gaussian noise to and clip the weights update between the previous and current rounds. diff --git a/discojs/discojs-core/src/serialization/index.ts b/discojs/discojs-core/src/serialization/index.ts index 62d206c2e..b702ea9e0 100644 --- a/discojs/discojs-core/src/serialization/index.ts +++ b/discojs/discojs-core/src/serialization/index.ts @@ -1,2 +1,2 @@ -export * as model from './model' -export * as weights from './weights' +export * as model from './model.js' +export * as weights from './weights.js' diff --git a/discojs/discojs-core/src/serialization/model.spec.ts b/discojs/discojs-core/src/serialization/model.spec.ts index 8d986dae8..094c0ea5d 100644 --- a/discojs/discojs-core/src/serialization/model.spec.ts +++ b/discojs/discojs-core/src/serialization/model.spec.ts @@ -1,8 +1,8 @@ import { assert } from 'chai' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { Model } from '..' -import { serialization, models } from '..' +import type { Model } from '../index.js' +import { serialization, models } from '../index.js' async function getRawWeights (model: Model): Promise> { return Array.from( diff --git a/discojs/discojs-core/src/serialization/model.ts b/discojs/discojs-core/src/serialization/model.ts index d41585490..4d70584b8 100644 --- a/discojs/discojs-core/src/serialization/model.ts +++ b/discojs/discojs-core/src/serialization/model.ts @@ -1,8 +1,8 @@ import msgpack from 'msgpack-lite' import type tf from '@tensorflow/tfjs' -import type { Model } from '..' -import { models, serialization } from '..' +import type { Model } from '../index.js' +import { models, serialization } from '../index.js' const enum Type { TFJS, GPT } diff --git a/discojs/discojs-core/src/serialization/weights.spec.ts b/discojs/discojs-core/src/serialization/weights.spec.ts index 2a4a10b18..263c8be8a 100644 --- a/discojs/discojs-core/src/serialization/weights.spec.ts +++ b/discojs/discojs-core/src/serialization/weights.spec.ts @@ -1,6 +1,6 @@ import { assert } from 'chai' -import { WeightsContainer, serialization } from '..' +import { WeightsContainer, serialization } from '../index.js' describe('weights', () => { it('can encode what it decodes', async () => { diff --git a/discojs/discojs-core/src/serialization/weights.ts b/discojs/discojs-core/src/serialization/weights.ts index 59d687a55..910264ad0 100644 --- a/discojs/discojs-core/src/serialization/weights.ts +++ b/discojs/discojs-core/src/serialization/weights.ts @@ -1,7 +1,7 @@ import * as msgpack from 'msgpack-lite' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import { WeightsContainer } from '..' +import { WeightsContainer } from '../index.js' interface Serialized { shape: number[] diff --git a/discojs/discojs-core/src/task/display_information.ts b/discojs/discojs-core/src/task/display_information.ts index a008702eb..f8daa730c 100644 --- a/discojs/discojs-core/src/task/display_information.ts +++ b/discojs/discojs-core/src/task/display_information.ts @@ -1,6 +1,6 @@ -import { type Summary, isSummary } from './summary' -import { type DataExample, isDataExample } from './data_example' -import { isLabelType, type LabelType } from './label_type' +import { type Summary, isSummary } from './summary.js' +import { type DataExample, isDataExample } from './data_example.js' +import { type LabelType, isLabelType } from './label_type.js' export interface DisplayInformation { taskTitle?: string diff --git a/discojs/discojs-core/src/task/index.ts b/discojs/discojs-core/src/task/index.ts index d36ef0bf2..64cd69aa6 100644 --- a/discojs/discojs-core/src/task/index.ts +++ b/discojs/discojs-core/src/task/index.ts @@ -1,7 +1,7 @@ -export { isTask, type Task, isTaskID, type TaskID } from './task' -export { type TaskProvider } from './task_provider' -export { isDigest, type Digest } from './digest' -export { isDisplayInformation, type DisplayInformation } from './display_information' -export type { TrainingInformation } from './training_information' -export { pushTask, fetchTasks } from './task_handler' -export { LabelTypeEnum } from './label_type' +export { isTask, type Task, isTaskID, type TaskID } from './task.js' +export { type TaskProvider } from './task_provider.js' +export { isDigest, type Digest } from './digest.js' +export { isDisplayInformation, type DisplayInformation } from './display_information.js' +export type { TrainingInformation } from './training_information.js' +export { pushTask, fetchTasks } from './task_handler.js' +export { LabelTypeEnum } from './label_type.js' diff --git a/discojs/discojs-core/src/task/task.ts b/discojs/discojs-core/src/task/task.ts index 7e9b6ba29..7ebaeaeda 100644 --- a/discojs/discojs-core/src/task/task.ts +++ b/discojs/discojs-core/src/task/task.ts @@ -1,6 +1,6 @@ -import { isDisplayInformation, type DisplayInformation } from './display_information' -import { isTrainingInformation, type TrainingInformation } from './training_information' -import { isDigest, type Digest } from './digest' +import { isDisplayInformation, type DisplayInformation } from './display_information.js' +import { isTrainingInformation, type TrainingInformation } from './training_information.js' +import { isDigest, type Digest } from './digest.js' export type TaskID = string diff --git a/discojs/discojs-core/src/task/task_handler.ts b/discojs/discojs-core/src/task/task_handler.ts index e99021477..1fe8e2981 100644 --- a/discojs/discojs-core/src/task/task_handler.ts +++ b/discojs/discojs-core/src/task/task_handler.ts @@ -1,11 +1,11 @@ import axios from 'axios' import { Map } from 'immutable' -import type { Model } from '..' -import { serialization } from '..' +import type { Model } from '../index.js' +import { serialization } from '../index.js' -import type { Task, TaskID } from './task' -import { isTask } from './task' +import type { Task, TaskID } from './task.js' +import { isTask } from './task.js' const TASK_ENDPOINT = 'tasks' diff --git a/discojs/discojs-core/src/task/task_provider.ts b/discojs/discojs-core/src/task/task_provider.ts index ccb0377a4..64ad74171 100644 --- a/discojs/discojs-core/src/task/task_provider.ts +++ b/discojs/discojs-core/src/task/task_provider.ts @@ -1,4 +1,4 @@ -import type { Model, Task } from '..' +import type { Model, Task } from '../index.js' export interface TaskProvider { getTask: () => Task diff --git a/discojs/discojs-core/src/task/training_information.ts b/discojs/discojs-core/src/task/training_information.ts index 3c2241b4a..8b7012122 100644 --- a/discojs/discojs-core/src/task/training_information.ts +++ b/discojs/discojs-core/src/task/training_information.ts @@ -1,5 +1,5 @@ -import { type AggregatorChoice } from '../aggregator/get' -import { type Preprocessing } from '../dataset/data/preprocessing' +import { type AggregatorChoice } from '../aggregator/get.js' +import { type Preprocessing } from '../dataset/data/preprocessing/index.js' export interface TrainingInformation { // modelID: unique ID for the model diff --git a/discojs/discojs-core/src/training/disco.ts b/discojs/discojs-core/src/training/disco.ts index c31eb3c65..ddcbdd819 100644 --- a/discojs/discojs-core/src/training/disco.ts +++ b/discojs/discojs-core/src/training/disco.ts @@ -1,18 +1,10 @@ -import { - client as clients, - type data, - type Logger, - type Task, - type TrainingInformant, informant as informants, - type Memory, EmptyMemory, - ConsoleLogger, - type TrainingInformation -} from '..' -import { type Trainer } from './trainer/trainer' -import { TrainerBuilder } from './trainer/trainer_builder' -import { type TrainerLog } from '../logging/trainer_logger' -import { type Aggregator } from '../aggregator' -import { MeanAggregator } from '../aggregator/mean' +import type { data, Logger, Memory, Task, TrainingInformant, TrainingInformation } from '../index.js' +import { client as clients, informant as informants, EmptyMemory, ConsoleLogger } from '../index.js' +import type { Trainer } from './trainer/trainer.js' +import { TrainerBuilder } from './trainer/trainer_builder.js' +import type { TrainerLog } from '../logging/trainer_logger.js' +import type { Aggregator } from '../aggregator/index.js' +import { MeanAggregator } from '../aggregator/mean.js' export interface DiscoOptions { client?: clients.Client diff --git a/discojs/discojs-core/src/training/index.ts b/discojs/discojs-core/src/training/index.ts index 3dac39f48..89ccaa1b4 100644 --- a/discojs/discojs-core/src/training/index.ts +++ b/discojs/discojs-core/src/training/index.ts @@ -1 +1 @@ -export { Disco } from './disco' +export { Disco } from './disco.js' diff --git a/discojs/discojs-core/src/training/trainer/distributed_trainer.ts b/discojs/discojs-core/src/training/trainer/distributed_trainer.ts index b66521be4..90caa8ec5 100644 --- a/discojs/discojs-core/src/training/trainer/distributed_trainer.ts +++ b/discojs/discojs-core/src/training/trainer/distributed_trainer.ts @@ -1,9 +1,9 @@ import type tf from '@tensorflow/tfjs' -import type { Model, Memory, Task, TrainingInformant, client as clients } from '../..' -import type { Aggregator } from '../../aggregator' +import type { Model, Memory, Task, TrainingInformant, client as clients } from '../../index.js' +import type { Aggregator } from '../../aggregator/index.js' -import { Trainer } from './trainer' +import { Trainer } from './trainer.js' /** * Class whose role is to train a model in a distributed way with a given dataset. diff --git a/discojs/discojs-core/src/training/trainer/local_trainer.ts b/discojs/discojs-core/src/training/trainer/local_trainer.ts index 5ee597e5d..b774a33a8 100644 --- a/discojs/discojs-core/src/training/trainer/local_trainer.ts +++ b/discojs/discojs-core/src/training/trainer/local_trainer.ts @@ -1,6 +1,6 @@ import type tf from '@tensorflow/tfjs' -import { Trainer } from './trainer' +import { Trainer } from './trainer.js' /** Class whose role is to locally (alone) train a model on a given dataset, * without any collaborators. diff --git a/discojs/discojs-core/src/training/trainer/round_tracker.spec.ts b/discojs/discojs-core/src/training/trainer/round_tracker.spec.ts index d0003caeb..2095bae5d 100644 --- a/discojs/discojs-core/src/training/trainer/round_tracker.spec.ts +++ b/discojs/discojs-core/src/training/trainer/round_tracker.spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai' -import { RoundTracker } from './round_tracker' +import { RoundTracker } from './round_tracker.js' const roundDuration = 2 diff --git a/discojs/discojs-core/src/training/trainer/trainer.ts b/discojs/discojs-core/src/training/trainer/trainer.ts index c9b20d784..e9da7102b 100644 --- a/discojs/discojs-core/src/training/trainer/trainer.ts +++ b/discojs/discojs-core/src/training/trainer/trainer.ts @@ -1,11 +1,11 @@ import type tf from '@tensorflow/tfjs' -import type { Memory, Model, Task, TrainingInformant } from '../..' +import type { Memory, Model, Task, TrainingInformant } from '../../index.js' -import { RoundTracker } from './round_tracker' -import type { TrainerLog } from '../../logging/trainer_logger' -import { TrainerLogger } from '../../logging/trainer_logger' -import { EventEmitter } from '../../utils/event_emitter' +import { RoundTracker } from './round_tracker.js' +import type { TrainerLog } from '../../logging/trainer_logger.js' +import { TrainerLogger } from '../../logging/trainer_logger.js' +import { EventEmitter } from '../../utils/event_emitter.js' /** Abstract class whose role is to train a model with a given dataset. This can be either done * locally (alone) or in a distributed way with collaborators. The Trainer works as follows: diff --git a/discojs/discojs-core/src/training/trainer/trainer_builder.ts b/discojs/discojs-core/src/training/trainer/trainer_builder.ts index 40cdd6399..2154911f9 100644 --- a/discojs/discojs-core/src/training/trainer/trainer_builder.ts +++ b/discojs/discojs-core/src/training/trainer/trainer_builder.ts @@ -1,9 +1,9 @@ -import type { client as clients, Model, Task, TrainingInformant, ModelInfo, Memory } from '../..' -import { ModelType } from '../..' +import type { client as clients, Model, Task, TrainingInformant, ModelInfo, Memory } from '../../index.js' +import { ModelType } from '../../index.js' -import { DistributedTrainer } from './distributed_trainer' -import { LocalTrainer } from './local_trainer' -import type { Trainer } from './trainer' +import { DistributedTrainer } from './distributed_trainer.js' +import { LocalTrainer } from './local_trainer.js' +import type { Trainer } from './trainer.js' /** * A class that helps build the Trainer and auxiliary classes. diff --git a/discojs/discojs-core/src/types.ts b/discojs/discojs-core/src/types.ts index c36a45ad8..7cf8cb020 100644 --- a/discojs/discojs-core/src/types.ts +++ b/discojs/discojs-core/src/types.ts @@ -1,7 +1,7 @@ import type { Map } from 'immutable' -import type { WeightsContainer } from '.' -import type { NodeID } from './client' +import type { WeightsContainer } from './index.js' +import type { NodeID } from './client/index.js' // Filesystem reference export type Path = string diff --git a/discojs/discojs-core/src/validation/index.ts b/discojs/discojs-core/src/validation/index.ts index aaec72d40..c1ad9037c 100644 --- a/discojs/discojs-core/src/validation/index.ts +++ b/discojs/discojs-core/src/validation/index.ts @@ -1 +1 @@ -export { Validator } from './validator' +export { Validator } from './validator.js' diff --git a/discojs/discojs-core/src/validation/validator.ts b/discojs/discojs-core/src/validation/validator.ts index fff18c513..d7969971d 100644 --- a/discojs/discojs-core/src/validation/validator.ts +++ b/discojs/discojs-core/src/validation/validator.ts @@ -1,8 +1,8 @@ import { List } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { data, Model, Task, Logger, client as clients, Memory, ModelSource, Features } from '..' -import { GraphInformant } from '..' +import type { data, Model, Task, Logger, client as clients, Memory, ModelSource, Features } from '../index.js' +import { GraphInformant } from '../index.js' export class Validator { private readonly graphInformant = new GraphInformant() diff --git a/discojs/discojs-core/src/weights/aggregation.spec.ts b/discojs/discojs-core/src/weights/aggregation.spec.ts index fff526cbc..157619f33 100644 --- a/discojs/discojs-core/src/weights/aggregation.spec.ts +++ b/discojs/discojs-core/src/weights/aggregation.spec.ts @@ -1,6 +1,6 @@ import { assert } from 'chai' -import { WeightsContainer, aggregation } from '.' +import { WeightsContainer, aggregation } from './index.js' describe('weights aggregation', () => { it('avg of weights with two operands', async () => { diff --git a/discojs/discojs-core/src/weights/aggregation.ts b/discojs/discojs-core/src/weights/aggregation.ts index b3973b47f..25fb68ed7 100644 --- a/discojs/discojs-core/src/weights/aggregation.ts +++ b/discojs/discojs-core/src/weights/aggregation.ts @@ -1,8 +1,8 @@ import { List } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' -import type { TensorLike } from './weights_container' -import { WeightsContainer } from './weights_container' +import type { TensorLike } from './weights_container.js' +import { WeightsContainer } from './weights_container.js' type WeightsLike = Iterable diff --git a/discojs/discojs-core/src/weights/index.ts b/discojs/discojs-core/src/weights/index.ts index be0b56855..84a0df956 100644 --- a/discojs/discojs-core/src/weights/index.ts +++ b/discojs/discojs-core/src/weights/index.ts @@ -1,2 +1,2 @@ -export { WeightsContainer } from './weights_container' -export * as aggregation from './aggregation' +export { WeightsContainer } from './weights_container.js' +export * as aggregation from './aggregation.js' diff --git a/discojs/discojs-core/src/weights/weights_container.ts b/discojs/discojs-core/src/weights/weights_container.ts index ff5b4e12f..747d23e30 100644 --- a/discojs/discojs-core/src/weights/weights_container.ts +++ b/discojs/discojs-core/src/weights/weights_container.ts @@ -1,5 +1,5 @@ import { List } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' type Weights = tf.Tensor[] diff --git a/discojs/discojs-core/tsconfig.json b/discojs/discojs-core/tsconfig.json index b313ce878..1e0adf398 100644 --- a/discojs/discojs-core/tsconfig.json +++ b/discojs/discojs-core/tsconfig.json @@ -1,8 +1,8 @@ { - "extends": "../tsconfig.base.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist", - "baseUrl": "src" // TODO not needed? + "declaration": true }, "include": ["src"], "exclude": ["**/*.spec.ts"] diff --git a/discojs/discojs-node/.mocharc.json b/discojs/discojs-node/.mocharc.json index 5a26266b1..5a3f09e83 100644 --- a/discojs/discojs-node/.mocharc.json +++ b/discojs/discojs-node/.mocharc.json @@ -2,5 +2,6 @@ "spec": ["src"], "recursive": true, "extension": ["ts"], + "loader": "ts-node/esm", "require": "ts-node/register" } diff --git a/discojs/discojs-node/package.json b/discojs/discojs-node/package.json index 02775fbd7..62a3ccfb7 100644 --- a/discojs/discojs-node/package.json +++ b/discojs/discojs-node/package.json @@ -1,6 +1,7 @@ { "name": "@epfml/discojs-node", "version": "2.1.1", + "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { diff --git a/discojs/discojs-node/src/data/image_loader.spec.ts b/discojs/discojs-node/src/data/image_loader.spec.ts index 4a5369959..5d02d03b1 100644 --- a/discojs/discojs-node/src/data/image_loader.spec.ts +++ b/discojs/discojs-node/src/data/image_loader.spec.ts @@ -1,12 +1,12 @@ import { assert, expect } from 'chai' import { List, Map, Range } from 'immutable' import fs from 'fs' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' import { node as tfNode } from '@tensorflow/tfjs-node' import type { Task } from '@epfml/discojs-core' -import { ImageLoader } from './image_loader' +import { ImageLoader } from './image_loader.js' const readFilesFromDir = (dir: string): string[] => fs.readdirSync(dir).map((file: string) => dir + file) diff --git a/discojs/discojs-node/src/data/index.ts b/discojs/discojs-node/src/data/index.ts index 685b18afb..1db4c045d 100644 --- a/discojs/discojs-node/src/data/index.ts +++ b/discojs/discojs-node/src/data/index.ts @@ -1,3 +1,3 @@ -export { ImageLoader as NodeImageLoader } from './image_loader' -export { TabularLoader as NodeTabularLoader } from './tabular_loader' -export { TextLoader as NodeTextLoader } from './text_loader' +export { ImageLoader as NodeImageLoader } from './image_loader.js' +export { TabularLoader as NodeTabularLoader } from './tabular_loader.js' +export { TextLoader as NodeTextLoader } from './text_loader.js' diff --git a/discojs/discojs-node/src/data/tabular_loader.spec.ts b/discojs/discojs-node/src/data/tabular_loader.spec.ts index c4d45eadb..78365efd3 100644 --- a/discojs/discojs-node/src/data/tabular_loader.spec.ts +++ b/discojs/discojs-node/src/data/tabular_loader.spec.ts @@ -1,10 +1,10 @@ import { assert, expect } from 'chai' import { List } from 'immutable' -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' import type { Task } from '@epfml/discojs-core' -import { TabularLoader } from './tabular_loader' +import { TabularLoader } from './tabular_loader.js' const inputFiles = ['../../datasets/titanic_train.csv'] diff --git a/discojs/discojs-node/src/index.ts b/discojs/discojs-node/src/index.ts index 7f165348f..ed3ca8856 100644 --- a/discojs/discojs-node/src/index.ts +++ b/discojs/discojs-node/src/index.ts @@ -1 +1 @@ -export * from './data' +export * from './data/index.js' diff --git a/discojs/discojs-node/tsconfig.json b/discojs/discojs-node/tsconfig.json index b66143c03..71b6902b9 100644 --- a/discojs/discojs-node/tsconfig.json +++ b/discojs/discojs-node/tsconfig.json @@ -1,9 +1,9 @@ { - "extends": "../tsconfig.base.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { - "types": ["node", "mocha"], + "types": ["mocha", "node"], "outDir": "dist", - "baseUrl": "src" + "declaration": true }, "include": ["src"], "exclude": ["**/*.spec.ts"] diff --git a/discojs/discojs-web/.mocharc.json b/discojs/discojs-web/.mocharc.json index 5a26266b1..5a3f09e83 100644 --- a/discojs/discojs-web/.mocharc.json +++ b/discojs/discojs-web/.mocharc.json @@ -2,5 +2,6 @@ "spec": ["src"], "recursive": true, "extension": ["ts"], + "loader": "ts-node/esm", "require": "ts-node/register" } diff --git a/discojs/discojs-web/package.json b/discojs/discojs-web/package.json index 6fe759f07..b4ce26846 100644 --- a/discojs/discojs-web/package.json +++ b/discojs/discojs-web/package.json @@ -1,6 +1,7 @@ { "name": "@epfml/discojs", "version": "2.1.1", + "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { diff --git a/discojs/discojs-web/src/data/image_loader.ts b/discojs/discojs-web/src/data/image_loader.ts index 537dfe26c..597149557 100644 --- a/discojs/discojs-web/src/data/image_loader.ts +++ b/discojs/discojs-web/src/data/image_loader.ts @@ -1,4 +1,4 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' import { data } from '@epfml/discojs-core' diff --git a/discojs/discojs-web/src/data/index.ts b/discojs/discojs-web/src/data/index.ts index 705a83eb9..41493f2e3 100644 --- a/discojs/discojs-web/src/data/index.ts +++ b/discojs/discojs-web/src/data/index.ts @@ -1,3 +1,3 @@ -export { ImageLoader as WebImageLoader } from './image_loader' -export { TabularLoader as WebTabularLoader } from './tabular_loader' -export { TextLoader as WebTextLoader } from './text_loader' +export { ImageLoader as WebImageLoader } from './image_loader.js' +export { TabularLoader as WebTabularLoader } from './tabular_loader.js' +export { TextLoader as WebTextLoader } from './text_loader.js' diff --git a/discojs/discojs-web/src/data/tabular_loader.ts b/discojs/discojs-web/src/data/tabular_loader.ts index edb9e7d6c..41b34d3f5 100644 --- a/discojs/discojs-web/src/data/tabular_loader.ts +++ b/discojs/discojs-web/src/data/tabular_loader.ts @@ -1,4 +1,4 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' import { data } from '@epfml/discojs-core' diff --git a/discojs/discojs-web/src/data/text_loader.ts b/discojs/discojs-web/src/data/text_loader.ts index 4fdd3c5fc..e83c0866c 100644 --- a/discojs/discojs-web/src/data/text_loader.ts +++ b/discojs/discojs-web/src/data/text_loader.ts @@ -1,4 +1,4 @@ -import tf from '@tensorflow/tfjs' +import * as tf from '@tensorflow/tfjs' import { data } from '@epfml/discojs-core' diff --git a/discojs/discojs-web/src/index.ts b/discojs/discojs-web/src/index.ts index f55da3c7a..85355e753 100644 --- a/discojs/discojs-web/src/index.ts +++ b/discojs/discojs-web/src/index.ts @@ -1,2 +1,2 @@ -export * from './data' -export * from './memory' +export * from './data/index.js' +export * from './memory/index.js' diff --git a/discojs/discojs-web/src/memory/index.ts b/discojs/discojs-web/src/memory/index.ts index e23dad6e6..bad0ecca4 100644 --- a/discojs/discojs-web/src/memory/index.ts +++ b/discojs/discojs-web/src/memory/index.ts @@ -1 +1 @@ -export { IndexedDB } from './memory' +export { IndexedDB } from './memory.js' diff --git a/discojs/discojs-web/tsconfig.json b/discojs/discojs-web/tsconfig.json index fcc5151a4..bbf2759e8 100644 --- a/discojs/discojs-web/tsconfig.json +++ b/discojs/discojs-web/tsconfig.json @@ -1,9 +1,9 @@ { - "extends": "../tsconfig.base.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "lib": ["DOM"], "outDir": "dist", - "baseUrl": "src" + "declaration": true }, "include": ["src"], "exclude": ["**/*.spec.ts"] diff --git a/discojs/tsconfig.base.json b/discojs/tsconfig.base.json deleted file mode 100644 index a6cb0b28a..000000000 --- a/discojs/tsconfig.base.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - // TODO ES6 disallow server's test - "target": "ES5", - "lib": ["ES5"], - - "strict": true, - "noEmitOnError": true, - - "esModuleInterop": true, - "skipLibCheck": true, - "moduleResolution": "node", - "importHelpers": true, - "downlevelIteration": true, // needed by { const server = await runDefaultServer() diff --git a/server/tests/client/decentralized.spec.ts b/server/tests/client/decentralized.spec.ts index 3e25d558e..4c7f8f6cd 100644 --- a/server/tests/client/decentralized.spec.ts +++ b/server/tests/client/decentralized.spec.ts @@ -3,7 +3,7 @@ import type * as http from 'http' import type { Task } from '@epfml/discojs-core' import { aggregator as aggregators, client as clients, defaultTasks } from '@epfml/discojs-core' -import { startServer } from '../../src' +import { startServer } from '../../src/index.js' const TASK = defaultTasks.titanic.getTask() diff --git a/server/tests/client/federated.spec.ts b/server/tests/client/federated.spec.ts index a12839ff2..13d9a79a3 100644 --- a/server/tests/client/federated.spec.ts +++ b/server/tests/client/federated.spec.ts @@ -2,7 +2,7 @@ import type * as http from 'http' import { aggregator as aggregators, client as clients, informant, defaultTasks } from '@epfml/discojs-core' -import { startServer } from '../../src' +import { startServer } from '../../src/index.js' const TASK = defaultTasks.titanic.getTask() diff --git a/server/tests/e2e/decentralized.spec.ts b/server/tests/e2e/decentralized.spec.ts index 29512b1bf..3de1c0832 100644 --- a/server/tests/e2e/decentralized.spec.ts +++ b/server/tests/e2e/decentralized.spec.ts @@ -7,7 +7,7 @@ import { aggregator as aggregators, informant as informants, client as clients, WeightsContainer, defaultTasks, aggregation } from '@epfml/discojs-core' -import { startServer } from '../../src' +import { startServer } from '../../src/index.js' // Mocked aggregators with easy-to-fetch aggregation results class MockMeanAggregator extends aggregators.MeanAggregator { diff --git a/server/tests/e2e/federated.spec.ts b/server/tests/e2e/federated.spec.ts index bb6287e2a..53bedc4c8 100644 --- a/server/tests/e2e/federated.spec.ts +++ b/server/tests/e2e/federated.spec.ts @@ -11,7 +11,7 @@ import { } from '@epfml/discojs-core' import { NodeImageLoader, NodeTabularLoader, NodeTextLoader } from '@epfml/discojs-node' -import { startServer } from '../../src' +import { startServer } from '../../src/index.js' const SCHEME = TrainingSchemes.FEDERATED diff --git a/server/tsconfig.json b/server/tsconfig.json index 1d705d85a..62b037725 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -1,20 +1,8 @@ { + "extends": "../tsconfig.base.json", "compilerOptions": { - "target": "ES5", - "lib": ["ES5"], - - "strict": true, - - "esModuleInterop": true, - "skipLibCheck": true, - "moduleResolution": "node", - "downlevelIteration": true, - - "declaration": true, - "outDir": "dist", - - "baseUrl": "src", + "declaration": true }, "include": ["src"] } diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 000000000..7590b2094 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "node16", + "target": "es2022", + + "strict": true, + + // tfjs and others + "skipLibCheck": true, + + // don't pollute + "noEmitOnError": true + } +} + diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 3db538a75..63b6999b0 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -1,17 +1,4 @@ { - "compilerOptions": { - // TODO ES6 disallow server's test - "target": "ES5", - "lib": ["ES5"], - - "strict": true, - "noEmit": true, - - "esModuleInterop": true, - "skipLibCheck": true, - "moduleResolution": "node", - "importHelpers": true, - "downlevelIteration": true, // needed by