diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..505c864 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 51d7d3b..1ec0c7d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e7a13ff..b0839c0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,34 +1,23 @@ - + + + + - + + + + - - - - - - @@ -87,112 +58,109 @@ - + - + - - + + + + + - + - - - - - - - - - - - + + - - + + - - + + + + + + + + + - + - - + + - + - - - - - - + + - + - - + + - - + + - - - - - + + - + - + - + - - + + - - - - - - - + + + + + + + + + + @@ -203,74 +171,23 @@ - - - iterations - println - primitive - Pair.of - import org.apache.commons.lang3.tuple.Pair; - org.apache.commons.math3.util.Pair - labels - - - new Pair<> - import org.apache.commons.math3.util.Pair; - de.dmi3y.behaiv.tools.Pair - - - - - - @@ -366,31 +223,21 @@ - - - + - - - + + - - - - - - - - - - + + - + + @@ -405,98 +252,72 @@ - - - - - - - - - - 1568462778055 + + 1572681659480 - - 1568716925425 + + 1572682257911 - - 1568718098260 - - - 1568734566680 - - - 1568789356822 - - - 1568790191247 - - - 1568790207911 - - - 1568790254142 - - - 1568793347210 - - - 1568793449765 - - - 1568877283518 - - - 1568877693410 - - - 1568878104407 - - - 1568880358231 - - - 1568968986374 - - - 1568969072659 - - - 1569054133314 - - - 1569054615889 - - - 1569054677808 - - - 1569057802524 - - - 1569058597939 - - - 1569058952686 - - - 1569228602458 - - - 1569228628431 - - - 1569228635292 - - - 1569830422499 - - - 1569831633349 - - - 1569831639948 - - - 1569831731167 - - - - - - - - - - - - - - - - - - - + + - - + + - + - + - - + + + + + + + + - - - - - - - - - + - + - + + + + + - - - - + + + + + + + + - - + + - - - - - - - - - + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - de.dmi3y.behaiv.tools.* - - - de.dmi3y.behaiv.kernel.* - - - de.dmi3y.behaiv.kernel.* - - - de.dmi3y.behaiv.kernel.* - - - - - - reader.readLine() - JAVA - CODE_FRAGMENT - - - final ArrayList<Pair<ArrayList<Double>, String>> pairs = gson.fromJson(reader.readLine(), data.getClass()); - JAVA - CODE_FRAGMENT - - - - - ((ArrayList<Pair<ArrayList<Double>, String>>) gson.fromJson(reader.readLine(), data.getClass())); - JAVA - EXPRESSION - - - sigmoid(x.mult(theta)) - JAVA - EXPRESSION - - - x.negative() .elementExp() .plus(1) - JAVA - EXPRESSION - - - x.negative() .elementExp() .plus(1).pseudoInverse() - JAVA - EXPRESSION - - - (x.mult(theta)) - JAVA - EXPRESSION - - - sigmoid(x.mult(theta) - JAVA - EXPRESSION - - - x.transpose() - .mult(sigmoid(x.mult(theta)).minus(y)) - JAVA - EXPRESSION - - - x.mult(theta) - JAVA - EXPRESSION - - - y - JAVA - EXPRESSION - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + - + - - + + - - + - - - - - - - - - - - - - - - + - - + + - + - - + + - + - - + + - + - - + + - + - - - - - - + + - + - - + + - + - + + - + - + + + - + - - + + + + + - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -1355,7 +533,7 @@ @@ -1363,11 +541,10 @@ - No facets are configured @@ -1375,11 +552,10 @@ - babel @@ -1387,11 +563,10 @@ - 1.8 @@ -1399,7 +574,7 @@ - main|behaiv + kernel-api|behaiv - Gradle: com.fasterxml.jackson.core:jackson-annotations:2.9.0 diff --git a/build.gradle b/build.gradle index b49db82..f99380b 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ plugins { id 'jacoco' id 'com.github.kt3k.coveralls' version '2.8.4' id 'maven-publish' + id 'org.hidetake.swagger.generator' version '2.18.1' } sourceCompatibility = 1.7 @@ -37,12 +38,17 @@ repositories { } dependencies { + // Swagger codegen dependencies + swaggerCodegen 'io.swagger:swagger-codegen-cli:2.4.2' // Swagger Codegen V2 // This dependency is exported to consumers, that is to say found on their compile classpath. + // This dependency is used internally, and not exposed to consumers on their own compile classpath. implementation 'org.apache.commons:commons-lang3:3.9' implementation 'com.google.guava:guava:28.0-jre' implementation 'io.reactivex.rxjava3:rxjava:3.0.0-RC2' + implementation 'javax.annotation:jsr250-api:1.0' + implementation files('./jars/kernel-api-1.0.0.jar') compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9' compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.9' @@ -55,6 +61,16 @@ dependencies { } +swaggerSources { + behaivRemote { + inputFile = file("./docs/swagger.json") + code { + language = 'java' + outputDir = file('./kernel-api') + } + } +} + jacocoTestReport { dependsOn test reports { diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..8947dcf --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,315 @@ +{ + "swagger": "2.0", + "info": { + "version": "0.1.0", + "title": "Behaiv remote kernel" + }, + "paths": { + "/kernel/predictionReady": { + "get": { + "summary": "Checks if netowrk is ready for prediction", + "description": "", + "responses": { + "200": { + "description": "If network is ready to predict", + "schema": { + "type": "object", + "properties": { + "predictionReady": { + "type": "boolean", + "description": "Network ready to predict" + } + } + } + } + }, + "tags": [ + "kernel" + ] + } + }, + "/kernel/predict": { + "get": { + "summary": "Feed network with more data", + "description": "", + "responses": { + "200": { + "description": "If network is ready to predict", + "schema": { + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "predicted label" + } + } + } + }, + "500": { + "description": "some problems occurred from backend side" + } + }, + "parameters": [ + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/KernelData" + } + } + ], + "tags": [ + "kernel" + ] + } + }, + "/kernel/feed": { + "post": { + "summary": "Feed network with more data", + "description": "", + "responses": { + "200": { + "description": "data saved successfuly" + }, + "500": { + "description": "some problems occurred from backend side" + } + }, + "parameters": [ + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/KernelData" + } + } + ], + "tags": [ + "kernel" + ] + } + }, + "/config/": { + "post": { + "summary": "Add new config object to global config", + "description": "", + "responses": { + "200": { + "description": "object saved successfully" + }, + "404": { + "description": "no object was found" + }, + "500": { + "description": "some problems occurred from backend sid" + } + }, + "parameters": [ + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/Config" + } + } + ], + "tags": [ + "config" + ] + }, + "get": { + "summary": "Get all existing objects", + "description": "", + "responses": { + "200": { + "description": "returns all the config objects", + "schema": { + "$ref": "#/definitions/Config" + } + }, + "404": { + "description": "no object was found" + }, + "500": { + "description": "some problems occurred from backend sid" + } + }, + "tags": [ + "config" + ] + } + }, + "/kernel/": { + "get": { + "summary": "Method that ensures you're on the right track", + "description": "", + "responses": { + "200": { + "description": "Dependency injection and API routing is working" + } + } + } + }, + "/user/": { + "post": { + "summary": "Register user/client in Behaiv", + "description": "", + "responses": { + "200": { + "description": "If network is ready to predict", + "schema": { + "$ref": "#/definitions/User" + } + }, + "500": { + "description": "some problems occurred from backend side" + } + }, + "parameters": [ + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/User" + } + } + ], + "tags": [ + "user" + ] + } + }, + "//": { + "get": { + "summary": "Redirects to static folder with react ui", + "description": "", + "responses": { + "302": { + "description": "redirection to /web/index.html" + } + }, + "tags": [ + "ui" + ] + } + }, + "/config/{id}": { + "put": { + "summary": "Update existing config", + "description": "", + "responses": { + "200": { + "description": "object updated successfully" + }, + "404": { + "description": "no object was found" + }, + "500": { + "description": "some problems occurred from backend sid" + } + }, + "parameters": [ + { + "in": "path", + "name": "id", + "type": "string", + "required": true, + "description": "id of existing config" + }, + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/Config" + } + } + ], + "tags": [ + "config" + ] + }, + "delete": { + "summary": "Delete existing config", + "description": "", + "responses": { + "200": { + "description": "object deleted successfully" + }, + "404": { + "description": "no object was found" + }, + "500": { + "description": "some problems occurred from backend sid" + } + }, + "parameters": [ + { + "in": "path", + "name": "id", + "type": "string", + "required": true, + "description": "id of existing config" + } + ], + "tags": [ + "config" + ] + } + } + }, + "definitions": { + "KernelData": { + "required": [ + "features", + "label" + ], + "properties": { + "features": { + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "label": { + "type": "string", + "description": "label for features" + } + } + }, + "Config": { + "required": [ + "key", + "value" + ], + "properties": { + "key": { + "type": "string", + "description": "key of config" + }, + "value": { + "type": "string", + "description": "value for key of config" + }, + "description": { + "type": "string", + "description": "description of what this config is doing" + } + } + }, + "User": { + "required": [ + "login" + ], + "properties": { + "login": { + "type": "string", + "description": "login of user" + }, + "token": { + "type": "string", + "description": "token that will be used for submitting data" + } + } + } + } +} \ No newline at end of file diff --git a/jars/kernel-api-1.0.0.jar b/jars/kernel-api-1.0.0.jar new file mode 100644 index 0000000..7b5a76b Binary files /dev/null and b/jars/kernel-api-1.0.0.jar differ