Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #152

Merged
merged 7 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions packages/core/src/BaseServiceClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,58 @@ class BaseServiceClient {
return this._options.concurrency;
}

async getModelStatus(params) {
const request = await this._trainingStatusStateRequest(params);

return new Promise((resolve, reject) => {
this._modelServiceClient.get_model_status(
request,
(err, response) => {
if (err) {
reject(err);
} else {
const modelStatus = response.getStatus();
resolve(modelStatus);
}
}
);
});
}

async _trainingStatusStateRequest(params) {
const message = '__get_model_status';
const { currentBlockNumber, signatureBytes } =
await this._requestSignForModel(params.address, message);

const ModelStateRequest = this._getUpdateModelRequestMethodDescriptor();
const modelStateRequest = new ModelStateRequest();

const ModelDetailsRequest =
this._getModelDetailsRequestMethodDescriptor();
const modelDetailsRequest = new ModelDetailsRequest();

modelDetailsRequest.setModelId(params.modelId);
modelDetailsRequest.setGrpcMethodName(params.method);
modelDetailsRequest.setGrpcServiceName(params.name);

const AuthorizationRequest =
this._getAuthorizationRequestMethodDescriptor();
const authorizationRequest = new AuthorizationRequest();

authorizationRequest.setCurrentBlock(Number(currentBlockNumber));
authorizationRequest.setMessage(message);
authorizationRequest.setSignature(signatureBytes);
authorizationRequest.setSignerAddress(params.address);

modelStateRequest.setAuthorization(authorizationRequest);
modelStateRequest.setUpdateModelDetails(modelDetailsRequest);
return modelStateRequest;
}

async getExistingModel(params) {
const request = await this._trainingStateRequest(params);
request;

return new Promise((resolve, reject) => {
this._modelServiceClient.get_all_models(
request,
Expand Down Expand Up @@ -133,6 +183,7 @@ class BaseServiceClient {
authorizationRequest.setMessage(message);
authorizationRequest.setSignature(signatureBytes);
authorizationRequest.setSignerAddress(params.address);

modelStateRequest.setAuthorization(authorizationRequest);
return modelStateRequest;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snet-sdk-web",
"version": "3.0.0",
"version": "4.0.2",
"description": "SingularityNET SDK for Web",
"main": "./dist/index.js",
"files": [
Expand Down
Loading