Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll committed Oct 7, 2024
1 parent dbf8d6d commit 6e7cafa
Show file tree
Hide file tree
Showing 36 changed files with 16,643 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local
coverage

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
29 changes: 29 additions & 0 deletions src/ts/demo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { startClientInternal, Context, Client, GetParametersIns, GetParametersRes, FitIns, FitRes, EvaluateIns, EvaluateRes } from "../src/lib";
import { Code } from "../src/lib/typing";

class CustomClient extends Client {
getParameters(ins: GetParametersIns): GetParametersRes {
return {} as GetParametersRes;
}
fit(ins: FitIns): FitRes {
const bytes = new Uint8Array(4);
bytes[0] = 256;
return { parameters: { tensors: [bytes, bytes], tensorType: "numpy.ndarray" }, numExamples: 1, metrics: {}, status: { code: Code.OK, message: "OK" } } as FitRes;
}
evaluate(ins: EvaluateIns): EvaluateRes {
return {} as EvaluateRes;
}
}

async function main() {
const clientfn = (context: Context) => new CustomClient(context);
const address = "127.0.0.1:9092";

try {
await startClientInternal(address, {}, undefined, null, clientfn, true, null, null, null, null, null);
} catch (error) {
console.error(`Failed to start client: ${error}`);
}
}

main().then();
Loading

0 comments on commit 6e7cafa

Please sign in to comment.