Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
}
],
"compilerOptions": {
"outDir": "dist"
"rootDir": "./src",
"outDir": "dist",
"types": ["node"]
},
"include": ["src"]
}
1 change: 1 addition & 0 deletions discojs-web/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
],
"compilerOptions": {
"lib": ["DOM"],
"rootDir": "./src",
"outDir": "dist"
},
"include": ["src"],
Expand Down
4 changes: 2 additions & 2 deletions discojs/src/client/decentralized/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class Peer {
: FIRST_HEADER_SIZE + b.length,
);
firstChunk.writeUint16BE(messageID);
firstChunk.writeUint8(0 as ChunkID, 2);
firstChunk.writeUint8(0, 2);
firstChunk.writeUint8(totalChunkCount, 3);
b.copy(
firstChunk,
Expand All @@ -147,7 +147,7 @@ export class Peer {
);

return Seq.Indexed([firstChunk]).concat(
Range(1 as ChunkID, Number.POSITIVE_INFINITY)
Range(1, Number.POSITIVE_INFINITY)
.zip(tail)
.map(([id, raw]) => {
const chunk = Buffer.alloc(HEADER_SIZE + raw.length);
Expand Down
9 changes: 2 additions & 7 deletions discojs/src/privacy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
addOptimalNoise,
getClippingRadius,
} from "./privacy.js";
import { WeightNormHistory } from "./training/trainer.js";
import * as tf from "@tensorflow/tfjs";
import { List } from "immutable";

Expand Down Expand Up @@ -79,17 +78,13 @@ describe("getClippingRadius", () => {
List([10]),
]);

expect(
getClippingRadius(weightNormHistory as WeightNormHistory, 5),
).toEqual([4, 5]);
expect(getClippingRadius(weightNormHistory, 5)).toEqual([4, 5]);
});

it("uses smaller window size automatically if needed", () => {
const weightNormHistory = List([List([2, 4])]);

// Automatically use window size of 2 instead of 10
expect(
getClippingRadius(weightNormHistory as WeightNormHistory, 10),
).toEqual([3]);
expect(getClippingRadius(weightNormHistory, 10)).toEqual([3]);
});
});
6 changes: 3 additions & 3 deletions discojs/src/processing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function postprocess<D extends DataType>(
switch (task.dataType) {
case "image": {
// cast as typescript doesn't reduce generic type
const index = encoded as DataFormat.ModelEncoded["image"][1];
const index = encoded;
const labels = List(task.trainingInformation.LABEL_LIST);

const v = labels.get(index);
Expand All @@ -118,13 +118,13 @@ export function postprocess<D extends DataType>(
}
case "tabular": {
// cast as typescript doesn't reduce generic type
const v = encoded as DataFormat.ModelEncoded["tabular"][1];
const v = encoded;

return v as DataFormat.Inferred[D];
}
case "text": {
// cast as typescript doesn't reduce generic type
const token = encoded as DataFormat.ModelEncoded["text"][1];
const token = encoded;

return task.trainingInformation.tokenizer.decode([
token,
Expand Down
2 changes: 1 addition & 1 deletion discojs/src/serialization/weights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function isSerialized(raw: unknown): raw is Serialized {
export async function encode(weights: WeightsContainer): Promise<Encoded> {
const serialized: Serialized[] = await Promise.all(
weights.weights.map(async (t) => ({
shape: t.shape as number[],
shape: t.shape,
data: await t.data<"float32">(),
})),
);
Expand Down
3 changes: 2 additions & 1 deletion discojs/src/training/disco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ export class Disco<D extends DataType, N extends Network> extends EventEmitter<{
await this.#preprocessSplitAndBatch(dataset);

// the client fetches the latest weights upon connection
// TODO unsafe cast
// TODO unsafe cast, and eslint rule is buggy
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
this.trainer.model = (await this.#client.connect()) as Model<D>;

for await (const [roundNum, round] of enumerate(
Expand Down
1 change: 1 addition & 0 deletions docs/examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"skipLibCheck": true,

"outDir": "dist",
"rootDir": ".",
"types": ["node"]
},
"include": ["*.ts"]
Expand Down
17 changes: 14 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,22 @@ export default defineConfigWithVueTs(
ignoreRestSiblings: true,
},
],
// allow biome formatting
"no-mixed-spaces-and-tabs": "off",
// allow for nicer names
"@typescript-eslint/no-namespace": "off",
// rule is buggy, might be necessary to disable it entirely
"@typescript-eslint/no-unnecessary-type-assertion": [
"error",
{
typesToIgnore: ["Model", "DataType"],
},
],
},
},
{
files: ["webapp/**"],
rules: {
// Buggy rule in typescript-eslint 8.59 and at least until 8.62. Check if future versions fix it
"@typescript-eslint/no-unnecessary-type-assertion": "off",
},
},
{
Expand All @@ -61,7 +73,6 @@ export default defineConfigWithVueTs(
files: ["webapp/cypress/**/*.ts"],
},
{ ignores: ["**/dist/*"] },
{ ignores: ["docs/examples/**"] },
{ ignores: ["**/src/protobuf/"] },

// don't use linter for formatting
Expand Down
6 changes: 5 additions & 1 deletion onnx-converter/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": { "outDir": "dist" },
"compilerOptions": {
"rootDir": "./src",
"outDir": "dist",
"types": ["node"]
},
"include": ["src"]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"eslint-plugin-vue": "10.8.0",
"knip": "6.17.1",
"prettier": "3.6.2",
"typescript": "5.9.3",
"typescript-eslint": "8.58.0",
"typescript": "6.0.3",
"typescript-eslint": "8.62.0",
"vitest": "catalog:"
},
"packageManager": "pnpm@11.8.0+sha512.c1f5e7c4cb241c8f174b743851d82f42b802324afc8b0f116b96adb15aa06664948dde36960a3ba1079ba5b4b29dd0140135b94b5b5f5263592249d68e555f26"
Expand Down
Loading