Skip to content

Commit

Permalink
Merge pull request #4 from ABI-Deployment-Thesis/ruiar/add-grpc-stabl…
Browse files Browse the repository at this point in the history
…e-flag

feat(runs): add grpc stable flag
  • Loading branch information
ruigomes99 authored Aug 23, 2024
2 parents 3a08d51 + d0d0de0 commit 14921c6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
HTTP_PORT=3003
GRPC_PORT=50053
GRPC_MODEL_MGMT_HOST=127.0.0.1:50052
HTTP_MODEL_MGMT_HOST: 127.0.0.1:3002
GRPC_STABLE: true
RABBITMQ_HOST=DOMAIN
RABBITMQ_DOCKER_ENGINE_QUEUE=docker_queue
MONGO_DB_URL=MONGO_DB_URL
JWT_SESSION_PASS=password
JWT_SESSION_PASS=password
STORAGE_URL=/uploads
18 changes: 16 additions & 2 deletions http/controllers/runner.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,21 @@ async function runModel(req, res, next) {
const model_id = req.params.model_id
const input_features = req.body.input_features || []

const model = await getModelSync({ model_id: model_id }, req.headers.authorization)
const GRPC_STABLE = process.env.GRPC_STABLE || 'true'
let model
if (GRPC_STABLE == 'true') {
model = await getModelSync({ model_id: model_id }, req.headers.authorization)
} else {
const myHeaders = new Headers();
myHeaders.append("Authorization", req.headers.authorization);
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
const res = await fetch(`http://${process.env.HTTP_MODEL_MGMT_HOST}/models/${model_id}`, requestOptions)
model = await res.json()
}
await validateInput(model, input_features)

const newModelRun = await new ModelRun({
Expand All @@ -76,7 +90,7 @@ async function runModel(req, res, next) {
const destPath = path.join(path.dirname(zipPath), id.toString())
await unzip(zipPath, destPath)
await fs.rmSync(zipPath, { recursive: true, force: true })
await fs.cpSync(model.file_path, destPath, {recursive: true})
await fs.cpSync(model.file_path, destPath, { recursive: true })
message = {
run_id: id,
type: model.type,
Expand Down

0 comments on commit 14921c6

Please sign in to comment.