Skip to content

Commit

Permalink
Merge pull request #8 from ABI-Deployment-Thesis/ruiar/change-db-fields
Browse files Browse the repository at this point in the history
feat(db): change db fields
  • Loading branch information
ruigomes99 authored Aug 31, 2024
2 parents 9b1fab3 + c80001b commit 94bd566
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions grpc/controllers/runner.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ async function UpdateRunninState(call, callback) {
try {
logger.debug(`Received gRPC call: ${JSON.stringify(call.request)}`)

const { run_id, state, container_id, container_exit_code, logs } = call.request
const { run_id, state, result, logs } = call.request

if (!mongoose.Types.ObjectId.isValid(run_id)) {
logger.error(`model_id ${run_id} not valid`)
return callback(null, { resolved: true, err: '' })
}

const filter = { _id: run_id }
const update = { state: state, container_id: container_id, container_exit_code: container_exit_code, result: logs }
const update = { state: state, result: result, logs: logs }

await ModelRun.findOneAndUpdate(filter, update)
callback(null, { resolved: true, err: '' })
Expand Down
5 changes: 2 additions & 3 deletions grpc/protos/ModelRunnerService.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ service ModelRunnerService {
message StateRequest {
string run_id = 1;
string state = 2;
string container_id = 3;
int32 container_exit_code = 4;
string logs = 5;
string result = 3;
string logs = 4;
}

message StateResponse {
Expand Down
22 changes: 13 additions & 9 deletions models/modelRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@ const ModelRun = new Schema({
required: true,
default: 'queue'
},
container_id: {
result: {
type: String,
required: false
},
container_exit_code: {
type: Number,
required: false
required: false,
default: ''
},
result: {
logs: {
type: String,
required: false
required: false,
default: ''
}
}, { timestamps: true, versionKey: false })
}, {
timestamps: {
createdAt: 'created_at',
updatedAt: 'updated_at'
},
versionKey: false
})

module.exports = model('model_run', ModelRun)

0 comments on commit 94bd566

Please sign in to comment.