Skip to content

Commit

Permalink
no tfjs, back to alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Oct 13, 2022
1 parent fbb4bbd commit f6ce363
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 398 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM node:16-stretch-slim
RUN apt-get update && apt-get upgrade -y && apt-get install -y git build-essential python3
FROM node:14-alpine
RUN mkdir /src
COPY . /src
WORKDIR /src
RUN npm install
ARG viewer
ARG fork
RUN apk add --no-cache git
RUN git clone https://github.com/${fork:-camicroscope}/camicroscope.git --branch=${viewer:-master}
EXPOSE 4010

Expand Down
45 changes: 15 additions & 30 deletions caracal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ const fileHandlers = require('./handlers/fileHandlers.js');
const sanitizeBody = require('./handlers/sanitizeHandler.js');
const DataTransformationHandler = require('./handlers/dataTransformationHandler.js');

// TODO -- make optional
const DISABLE_TF = true; // DUE TO PRODUCTION STABILITY ISSUES WITH TFJS

if (!DISABLE_TF) {
const DataSet = require('./handlers/datasetHandler.js');
const Model = require('./handlers/modelTrainer.js');
}


const {connector} = require("./service/database/connector");

Expand Down Expand Up @@ -129,22 +121,16 @@ var HANDLERS = {
},
};

if (!DISABLE_TF) {
HANDLERS["getDataset"] = DataSet.getDataset;
HANDLERS["trainModel"] = Model.trainModel;
HANDLERS["deleteDataset"] = DataSet.deleteData;
HANDLERS["sendTrainedModel"] = Model.sendTrainedModel;
} else {
function disabledRoute() {
return function(req, res) {
res.status(500).send('{"err":"This TF route is disabled"}');
};
}
HANDLERS["getDataset"] = disabledRoute;
HANDLERS["trainModel"] = disabledRoute;
HANDLERS["deleteDataset"] = disabledRoute;
HANDLERS["sendTrainedModel"] = disabledRoute;
// TODO! -- remove these by fully depreciating tfjs serverside
function disabledRoute() {
return function(req, res) {
res.status(500).send('{"err":"This TF route is disabled"}');
};
}
HANDLERS["getDataset"] = disabledRoute;
HANDLERS["trainModel"] = disabledRoute;
HANDLERS["deleteDataset"] = disabledRoute;
HANDLERS["sendTrainedModel"] = disabledRoute;

// register configurable services
// TODO verify all
Expand Down Expand Up @@ -236,13 +222,12 @@ function masterHandler() {
}).then(()=>{
if (RUN_INDEXER) {
const indexer = require('./idx_mongo.js');
try{
indexer.collections();
indexer.indexes();
indexer.defaults();
console.log("added indexes");
}
catch(e){
try {
indexer.collections();
indexer.indexes();
indexer.defaults();
console.log("added indexes");
} catch (e) {
console.log("error in indexer, ", e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions handlers/authHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function firstSetupUserSignupExists() {

// Use a trusted header instead of a jwt for login. Use carefully if at all.
function loginWithHeader(signKey, userFunction) {
return function(header){
return function(header) {
return function(req, res) {
// get the correct header, set it to use userFunction
let token = {"email": req.headers[header]};
Expand All @@ -292,7 +292,7 @@ function loginWithHeader(signKey, userFunction) {
res.status(401).send(e);
});
};
}
};
}

auth = {};
Expand Down
164 changes: 0 additions & 164 deletions handlers/datasetHandler.js

This file was deleted.

8 changes: 4 additions & 4 deletions handlers/iipHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ preIip = function(req, res, next) {
next();
};

function RemoveParameterFromUrl(url, parameter) {
function removeParameterFromUrl(url, parameter) {
return url
.replace(new RegExp('[?&]' + parameter + '=[^&#]*(#.*)?$'), '$1')
.replace(new RegExp('([?&])' + parameter + '=[^&]*&'), '$1');
.replace(new RegExp('[?&]' + parameter + '=[^&#]*(#.*)?$'), '$1')
.replace(new RegExp('([?&])' + parameter + '=[^&]*&'), '$1');
}

iipHandler = function(req, res, next) {
Expand All @@ -45,7 +45,7 @@ iipHandler = function(req, res, next) {
path = path.replace(req.iipFileRequested, req.newFilepath);
}
// remove token if present
path = RemoveParameterFromUrl(path, "token");
path = removeParameterFromUrl(path, "token");
// NOTE -- this may need to change if the original url has more subdirs or so added
var splitPath = path.split('/');
console.log(path);
Expand Down
Loading

0 comments on commit f6ce363

Please sign in to comment.