Skip to content

Commit

Permalink
Merge pull request #152 from singnet/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
TerNik authored Nov 15, 2024
2 parents 673d1cf + 85c5afd commit e7d8485
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
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

0 comments on commit e7d8485

Please sign in to comment.