Skip to content

Commit

Permalink
Using proxy node server again for comunication UI with API inside the…
Browse files Browse the repository at this point in the history
… container. Minor fix in API model get
  • Loading branch information
GFibrizo committed Oct 22, 2019
1 parent 10b2c18 commit 9c174b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data_owner/services/model_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_all(cls, args):
def get(cls, model_id):
model = Model.get(model_id)
dataset = DatasetsService().get_dataset_for_training(model.requirements)
if dataset:
if dataset and model.status == TrainingStatus.WAITING.name:
model.status = TrainingStatus.READY.name
model.update()
return model
19 changes: 16 additions & 3 deletions node-server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ var routes = {
DATASETS: "/datasets",
MODELS: "/models",
MODEL: "/models/:id",
ACCEPT: "/trainings/:id/accept"
};

var httpMethods = {
POST: "POST",
GET: "GET"
GET: "GET",
PUT: "PUT"
};


Expand Down Expand Up @@ -84,6 +86,16 @@ app.post(routes.LOGIN, async (req, res) => {
}
});

app.put(routes.ACCEPT, async (req, res) => {
try {
const {id} = req.params;
res.json(executeFetchJson(httpMethods.PUT, "/trainings/"+id+"/accept", JSON.stringify(req.body)));
} catch (e) {
//this will eventually be handled by your error handling middleware
console.log(e)
}
});

app.post(routes.DATASETS, async (req, res) => {
try {
upload(req, res, function (err) {
Expand Down Expand Up @@ -131,13 +143,14 @@ app.get(routes.MODELS, async (req, res) => {

app.get(routes.MODEL, async (req, res) => {
try {
const {id} = req.params;
console.log(req.param("tagId"))
res.json(await executeFetchJson(httpMethods.GET, routes.MODEL));
res.json(await executeFetchJson(httpMethods.GET, "/models/"+id));
} catch (e) {
//this will eventually be handled by your error handling middleware
console.log(e)
}
});


app.listen(port, () => console.log(`Example app listening on port ${port}!`))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))

0 comments on commit 9c174b7

Please sign in to comment.