Skip to content

Commit afeb690

Browse files
committed
chore: fix lint errors in discojs
1 parent b50e564 commit afeb690

5 files changed

Lines changed: 10 additions & 14 deletions

File tree

discojs/src/client/decentralized/peer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class Peer {
137137
: FIRST_HEADER_SIZE + b.length,
138138
);
139139
firstChunk.writeUint16BE(messageID);
140-
firstChunk.writeUint8(0 as ChunkID, 2);
140+
firstChunk.writeUint8(0, 2);
141141
firstChunk.writeUint8(totalChunkCount, 3);
142142
b.copy(
143143
firstChunk,
@@ -147,7 +147,7 @@ export class Peer {
147147
);
148148

149149
return Seq.Indexed([firstChunk]).concat(
150-
Range(1 as ChunkID, Number.POSITIVE_INFINITY)
150+
Range(1, Number.POSITIVE_INFINITY)
151151
.zip(tail)
152152
.map(([id, raw]) => {
153153
const chunk = Buffer.alloc(HEADER_SIZE + raw.length);

discojs/src/privacy.spec.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
addOptimalNoise,
88
getClippingRadius,
99
} from "./privacy.js";
10-
import { WeightNormHistory } from "./training/trainer.js";
1110
import * as tf from "@tensorflow/tfjs";
1211
import { List } from "immutable";
1312

@@ -79,17 +78,13 @@ describe("getClippingRadius", () => {
7978
List([10]),
8079
]);
8180

82-
expect(
83-
getClippingRadius(weightNormHistory as WeightNormHistory, 5),
84-
).toEqual([4, 5]);
81+
expect(getClippingRadius(weightNormHistory, 5)).toEqual([4, 5]);
8582
});
8683

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

9087
// Automatically use window size of 2 instead of 10
91-
expect(
92-
getClippingRadius(weightNormHistory as WeightNormHistory, 10),
93-
).toEqual([3]);
88+
expect(getClippingRadius(weightNormHistory, 10)).toEqual([3]);
9489
});
9590
});

discojs/src/processing/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function postprocess<D extends DataType>(
109109
switch (task.dataType) {
110110
case "image": {
111111
// cast as typescript doesn't reduce generic type
112-
const index = encoded as DataFormat.ModelEncoded["image"][1];
112+
const index = encoded;
113113
const labels = List(task.trainingInformation.LABEL_LIST);
114114

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

123123
return v as DataFormat.Inferred[D];
124124
}
125125
case "text": {
126126
// cast as typescript doesn't reduce generic type
127-
const token = encoded as DataFormat.ModelEncoded["text"][1];
127+
const token = encoded;
128128

129129
return task.trainingInformation.tokenizer.decode([
130130
token,

discojs/src/serialization/weights.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function isSerialized(raw: unknown): raw is Serialized {
2929
export async function encode(weights: WeightsContainer): Promise<Encoded> {
3030
const serialized: Serialized[] = await Promise.all(
3131
weights.weights.map(async (t) => ({
32-
shape: t.shape as number[],
32+
shape: t.shape,
3333
data: await t.data<"float32">(),
3434
})),
3535
);

discojs/src/training/disco.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ export class Disco<D extends DataType, N extends Network> extends EventEmitter<{
224224
await this.#preprocessSplitAndBatch(dataset);
225225

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

230231
for await (const [roundNum, round] of enumerate(

0 commit comments

Comments
 (0)