Merge branch 'connect-to-real-data' of https://github.com/seattleflu/incidence-mapper into connect-to-real-data
This commit is contained in:
Коммит
e58ed4cc11
|
@ -38,7 +38,7 @@ ADD docker_scripts/entrypoint.sh docker_scripts/wsgi.ini ./
|
|||
# Add the rest of our library here
|
||||
ADD seattle_flu_incidence_mapper ./seattle_flu_incidence_mapper
|
||||
|
||||
|
||||
EXPOSE 80
|
||||
VOLUME [/model_store]
|
||||
|
||||
CMD /app/entrypoint.sh
|
|
@ -1,42 +1,25 @@
|
|||
version: '3'
|
||||
|
||||
|
||||
services:
|
||||
redis:
|
||||
# We use management so we can have a nice gui
|
||||
# Default login is guest/guest
|
||||
image: redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
# Our queue container
|
||||
rabbit:
|
||||
# We use management so we can have a nice gui
|
||||
# Default login is guest/guest
|
||||
image: rabbitmq:3.7-management
|
||||
ports:
|
||||
- "5672:5672"
|
||||
- "8081:15672"
|
||||
workers:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: idm-docker-production.packages.idmod.org/sfim
|
||||
command: python3 seattle_flu/app.py workers start
|
||||
db:
|
||||
image: postgres
|
||||
restart: always
|
||||
environment:
|
||||
- "DRAMATIQ_USE_PROD=True"
|
||||
POSTGRES_USER: seattle_flu
|
||||
POSTGRES_PASSWORD: seattle_flu
|
||||
|
||||
service:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: idm-docker-production.packages.idmod.org/sfim
|
||||
ports:
|
||||
- 5000:5000
|
||||
- 5000:80
|
||||
volumes:
|
||||
- "/model_store:/model_store"
|
||||
- "./test_model_store:/model_store"
|
||||
environment:
|
||||
- "DEBUG=1"
|
||||
- "FLASK_ENV=development"
|
||||
- "DRAMATIQ_USE_PROD=True"
|
||||
- "CREATE_DB=1"
|
||||
- "SQLALCHEMY_URI=postgres+psycopg2://seattle_flu:@db"
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ http {
|
|||
#include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 5000 default_server;
|
||||
listen [::]:5000 default_server;
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
#root /usr/share/nginx/html;
|
||||
|
||||
|
|
|
@ -1160,7 +1160,7 @@ setDocument = Sizzle.setDocument = function( node ) {
|
|||
// Support: IE<10
|
||||
// Check if getElementById returns elements by name
|
||||
// The broken getElementById methods don't pick up programmatically-set names,
|
||||
// so use a roundabout getElementsByName test
|
||||
// so use a roundabout getElementsByName tests
|
||||
support.getById = assert(function( el ) {
|
||||
docElem.appendChild( el ).id = expando;
|
||||
return !document.getElementsByName || !document.getElementsByName( expando ).length;
|
||||
|
@ -1280,7 +1280,7 @@ setDocument = Sizzle.setDocument = function( node ) {
|
|||
// Regex strategy adopted from Diego Perini
|
||||
assert(function( el ) {
|
||||
// Select is set to empty string on purpose
|
||||
// This is to test IE's treatment of not explicitly
|
||||
// This is to tests IE's treatment of not explicitly
|
||||
// setting a boolean content attribute,
|
||||
// since its presence should be enough
|
||||
// https://bugs.jquery.com/ticket/12359
|
||||
|
@ -1290,7 +1290,7 @@ setDocument = Sizzle.setDocument = function( node ) {
|
|||
|
||||
// Support: IE8, Opera 11-12.16
|
||||
// Nothing should be selected when empty strings follow ^= or $= or *=
|
||||
// The test attribute must be unknown in Opera but "safe" for WinRT
|
||||
// The tests attribute must be unknown in Opera but "safe" for WinRT
|
||||
// https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
|
||||
if ( el.querySelectorAll("[msallowcapture^='']").length ) {
|
||||
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
|
||||
|
@ -6229,7 +6229,7 @@ function addGetHookIf( conditionFn, hookFn ) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Hook needed; redefine it so that the support test is not executed again.
|
||||
// Hook needed; redefine it so that the support tests is not executed again.
|
||||
return ( this.get = hookFn ).apply( this, arguments );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator);
|
||||
};
|
||||
|
||||
// Return the first value which passes a truth test. Aliased as `detect`.
|
||||
// Return the first value which passes a truth tests. Aliased as `detect`.
|
||||
_.find = _.detect = function(obj, iterator, context) {
|
||||
var result;
|
||||
any(obj, function(value, index, list) {
|
||||
|
@ -147,7 +147,7 @@
|
|||
return result;
|
||||
};
|
||||
|
||||
// Return all the elements that pass a truth test.
|
||||
// Return all the elements that pass a truth tests.
|
||||
// Delegates to **ECMAScript 5**'s native `filter` if available.
|
||||
// Aliased as `select`.
|
||||
_.filter = _.select = function(obj, iterator, context) {
|
||||
|
@ -160,7 +160,7 @@
|
|||
return results;
|
||||
};
|
||||
|
||||
// Return all the elements for which a truth test fails.
|
||||
// Return all the elements for which a truth tests fails.
|
||||
_.reject = function(obj, iterator, context) {
|
||||
var results = [];
|
||||
if (obj == null) return results;
|
||||
|
@ -170,7 +170,7 @@
|
|||
return results;
|
||||
};
|
||||
|
||||
// Determine whether all of the elements match a truth test.
|
||||
// Determine whether all of the elements match a truth tests.
|
||||
// Delegates to **ECMAScript 5**'s native `every` if available.
|
||||
// Aliased as `all`.
|
||||
_.every = _.all = function(obj, iterator, context) {
|
||||
|
@ -183,7 +183,7 @@
|
|||
return result;
|
||||
};
|
||||
|
||||
// Determine if at least one element in the object matches a truth test.
|
||||
// Determine if at least one element in the object matches a truth tests.
|
||||
// Delegates to **ECMAScript 5**'s native `some` if available.
|
||||
// Aliased as `any`.
|
||||
var any = _.some = _.any = function(obj, iterator, context) {
|
||||
|
|
|
@ -9,7 +9,6 @@ info:
|
|||
license:
|
||||
name: "Apache 2.0"
|
||||
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
host: "localhost"
|
||||
basePath: "/v1"
|
||||
tags:
|
||||
- name: "pathogen_model"
|
||||
|
@ -39,11 +38,26 @@ paths:
|
|||
schema:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
example:
|
||||
model_type: inla
|
||||
observed:
|
||||
- catchment
|
||||
- encountered_week
|
||||
- flu_shot
|
||||
- n
|
||||
- pathogen
|
||||
- positive
|
||||
- PUMA5CE
|
||||
- sampling_location
|
||||
- time_row
|
||||
responses:
|
||||
200:
|
||||
description: "successful operation"
|
||||
schema:
|
||||
type: "array"
|
||||
items:
|
||||
type: "object"
|
||||
|
||||
/pathogen_models:
|
||||
get:
|
||||
tags:
|
||||
|
|
|
@ -49,7 +49,9 @@ setup(
|
|||
'flask_sqlalchemy',
|
||||
'flask_marshmallow',
|
||||
'marshmallow-sqlalchemy',
|
||||
"docker"
|
||||
"docker",
|
||||
'psycopg2',
|
||||
''
|
||||
],
|
||||
|
||||
extras_require={
|
||||
|
|
|
@ -5,16 +5,30 @@ services:
|
|||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: seattle_flu
|
||||
# placeholder for building worker
|
||||
workers:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.worker
|
||||
image: idm-docker-production.packages.idmod.org/sfim-worker:${version:-latest}
|
||||
command: touch t
|
||||
service:
|
||||
build:
|
||||
context: api_service
|
||||
dockerfile: Dockerfile
|
||||
image: idm-docker-production.packages.idmod.org/sfim-api:${version:-latest}
|
||||
volumes:
|
||||
- "/model_store:/model_store"
|
||||
- db-data:/var/lib/mysql/data
|
||||
volumes:
|
||||
- /model_store:/model_store
|
||||
# pass docker so we can execute other containers
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
- SQLALCHEMY_URI=postgres://seattle_flu:@db
|
||||
- SQLALCHEMY_URI=postgres+psycopg2://seattle_flu:@db
|
||||
- "CREATE_DB=1"
|
||||
#- "MODEL_HOST_PATH=`pwd`/test_model_store"
|
||||
#- "DEBUG_TOKENS=1"
|
||||
depends_on:
|
||||
- db
|
||||
ports:
|
||||
- "80:5000"
|
||||
- "80:80"
|
|
@ -65,8 +65,4 @@ queryLoadedModel <-
|
|||
jsonlite::write_json(model, file.path(outputDir, outputFile))
|
||||
}
|
||||
return(TRUE)
|
||||
}
|
||||
|
||||
#initializeModel <- function (modelId) {
|
||||
# return(loadModelFileById(modelId))
|
||||
#}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
library(logging)
|
||||
|
||||
#' loadModelFileById function for getting modeled data
|
||||
#'
|
||||
#' This function will load a model from the model_store_dir by Id
|
||||
|
@ -52,7 +54,7 @@ returnModel <- function(queryIn = jsonlite::toJSON(
|
|||
cloudDir = Sys.getenv('MODEL_STORE', '/home/rstudio/seattle_flu/test_model_store')){
|
||||
|
||||
basicConfig()
|
||||
|
||||
|
||||
if(class(queryIn)== 'list'){
|
||||
queryList <- queryIn
|
||||
queryIn <- jsonlite::toJSON(queryIn)
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#' getHumanReadableModelIdFromModel: return human readable verion of model from query
|
||||
library(logging)
|
||||
|
||||
|
||||
#'
|
||||
#' @param model INLA model object that will generatie id from
|
||||
#'
|
||||
|
@ -55,14 +58,14 @@ getModelQueryObjectFromModel<- function(model, model_type = 'inla', latent = FAL
|
|||
#' @param query query object container the observed and the model_type attributes
|
||||
#'
|
||||
#' @import logging
|
||||
#'
|
||||
#'
|
||||
#' @return An object containing the observed and the model_type fields
|
||||
#' @export
|
||||
#'
|
||||
getModelQueryObjectFromQuery <- function(query) {
|
||||
basicConfig()
|
||||
setLevel("FINEST")
|
||||
|
||||
|
||||
logdebug("getModelQueryObjectFromQuery Src:", str(query))
|
||||
logdebug("$observed", attr(query, "observed"))
|
||||
result <- newEmptyObject()
|
||||
|
@ -95,7 +98,7 @@ getModelIdFromModel <- function(model) {
|
|||
getModelIdFromQuery <- function(query) {
|
||||
basicConfig()
|
||||
setLevel("FINEST")
|
||||
|
||||
|
||||
#props <- getModelQueryObjectFromQuery(query)
|
||||
modelId <- as.character(jsonlite::toJSON(query, simplifyDataFrame=))
|
||||
logdebug("Model ID JSON:", jsonlite::toJSON(query, simplifyDataFrame=))
|
||||
|
@ -111,6 +114,8 @@ getModelIdFromQuery <- function(query) {
|
|||
#' @export
|
||||
#'
|
||||
saveModel <- function(model, modelStoreDir = Sys.getenv('MODEL_STORE', '/home/rstudio/seattle_flu/test_model_store')) {
|
||||
basicConfig()
|
||||
setLevel("FINEST")
|
||||
ts <- Sys.time()
|
||||
attr(ts, "tzone") <- 'UTC'
|
||||
ts <- paste0(as.character(ts), 'Z')
|
||||
|
@ -139,13 +144,13 @@ saveModel <- function(model, modelStoreDir = Sys.getenv('MODEL_STORE', '/home/r
|
|||
created = ts
|
||||
)
|
||||
|
||||
print("Saving RDS")
|
||||
loginfo("Saving RDS")
|
||||
outfile <- xzfile(paste(modelStoreDir, '/', filename, '.RDS', sep = ''), 'wb', compress=9, encoding = 'utf8')
|
||||
saveRDS(model,file = outfile)
|
||||
close(outfile)
|
||||
|
||||
|
||||
print("Saving smooth model")
|
||||
loginfo("Saving smooth model")
|
||||
# all models output smooth
|
||||
newRow$latent <- FALSE
|
||||
write.csv(
|
||||
|
|
Загрузка…
Ссылка в новой задаче