Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "Feature/45 lecter integration"" #105

Merged
merged 1 commit into from Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions .env.example
Expand Up @@ -2,8 +2,10 @@ CLINICAL_DB_URL=mongodb://localhost:27017/clinical
# has to be lower case
LOG_LEVEL=debug
INITIAL_SCHEMA_VERSION=1.0
SCHEMA_NAME=ARGO Dictionary
SCHEMA_NAME=ARGO Clinical Submission
JWT_TOKEN_PUBLIC_KEY_URL=
# optional, if this is set, it will take precedence over fetching from the url
# if you provide the url instead this env key will be set in the process env from the url
JWT_TOKEN_PUBLIC_KEY=
JWT_TOKEN_PUBLIC_KEY=
# you can use file url for testing : file:///path/to/test/schema/stub-schema.json
LECTERN_URL=
4 changes: 4 additions & 0 deletions Dockerfile
Expand Up @@ -15,5 +15,9 @@ FROM node:12.5.0-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
ARG COMMIT_ID
ENV CLINICAL_COMMIT_ID=${COMMIT_ID}
ARG VERSION
ENV CLINICAL_VERSION=${VERSION}
EXPOSE 3000
CMD ["node", "dist/src/server.js"]
4 changes: 2 additions & 2 deletions Jenkinsfile.groovy
Expand Up @@ -78,7 +78,7 @@ spec:

// the network=host needed to download dependencies using the host network (since we are inside 'docker'
// container)
sh "docker build --network=host -f Dockerfile . -t icgcargo/clinical:edge -t icgcargo/clinical:${version}-${commit}"
sh "docker build --build-arg COMMIT_ID=${commit} --build-arg VERSION=${version} --network=host -f Dockerfile . -t icgcargo/clinical:edge -t icgcargo/clinical:${version}-${commit}"
sh "docker push icgcargo/clinical:${version}-${commit}"
sh "docker push icgcargo/clinical:edge"
}
Expand Down Expand Up @@ -110,7 +110,7 @@ spec:
withCredentials([usernamePassword(credentialsId:'argoDockerHub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login -u $USERNAME -p $PASSWORD'
}
sh "docker build --network=host -f Dockerfile . -t icgcargo/clinical:latest -t icgcargo/clinical:${version}"
sh "docker build --build-arg COMMIT_ID=${commit} --build-arg VERSION=${version} --network=host -f Dockerfile . -t icgcargo/clinical:latest -t icgcargo/clinical:${version}"
sh "docker push icgcargo/clinical:${version}"
sh "docker push icgcargo/clinical:latest"
}
Expand Down
2 changes: 2 additions & 0 deletions README.md
@@ -1,5 +1,7 @@
# Argo clinical

[![Build Status](https://jenkins.qa.cancercollaboratory.org/buildStatus/icon?job=ARGO%2Fargo-clinical%2Fmaster)](https://jenkins.qa.cancercollaboratory.org/job/ARGO/job/argo-clinical/job/master/)

## Requirements:

- node 12+
Expand Down
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -97,6 +97,7 @@
"multer": "^1.4.1",
"node-fetch": "^2.6.0",
"nodemailer": "^6.2.1",
"promise-tools": "^2.1.0",
"swagger-ui-express": "^4.0.7",
"winston": "^3.2.1",
"yamljs": "^0.3.0"
Expand Down
142 changes: 142 additions & 0 deletions sampleFiles/sample-schema.json
@@ -0,0 +1,142 @@
{
"schemas": [
{
"name": "registration",
"description": "TSV for Registration of Donor-Specimen-Sample",
"key": "submitter_donor_id",
"fields": [
{
"name": "program_id",
"valueType": "string",
"description": "Unique identifier for program",
"meta": {
"key": true
},
"restrictions": {
"required": true,
"regex": "^[A-Z1-9][-_A-Z1-9]{2,7}(-[A-Z][A-Z])$"
}
},
{
"name": "submitter_donor_id",
"valueType": "string",
"description": "Unique identifier for donor, assigned by the data provider.",
"meta": {
"key": true
},
"restrictions": {
"required": true,
"regex": "^(?!(DO|do)).+"
}
},
{
"name": "gender",
"valueType": "string",
"description": "The gender of the patient",
"restrictions": {
"required": true,
"codeList": ["Male", "Female", "Other"]
}
},
{
"name": "submitter_specimen_id",
"valueType": "string",
"description": "Submitter assigned specimen id",
"meta": {
"key": true
},
"restrictions": {
"required": true,
"regex": "^(?!(SP|sp)).+"
}
},
{
"name": "specimen_type",
"valueType": "string",
"description": "Indicate the tissue source of the biospecimen",
"meta": {
"default": "Other"
},
"restrictions": {
"required": true,
"codeList": [
"Blood derived",
"Blood derived - bone marrow",
"Blood derived - peripheral blood",
"Bone marrow",
"Buccal cell",
"Lymph node",
"Solid tissue",
"Plasma",
"Serum",
"Urine",
"Cerebrospinal fluid",
"Sputum",
"NOS (Not otherwise specified)",
"Other",
"FFPE",
"Pleural effusion",
"Mononuclear cells from bone marrow",
"Saliva",
"Skin"
]
}
},
{
"name": "tumour_normal_designation",
"valueType": "string",
"description": "Indicate whether specimen is tumour or normal type",
"restrictions": {
"required": true,
"codeList": [
"Normal",
"Normal - tissue adjacent to primary tumour",
"Primary tumour",
"Primary tumour - adjacent to normal",
"Primary tumour - additional new primary",
"Recurrent tumour",
"Metastatic tumour",
"Metastatic tumour - metastasis local to lymph node",
"Metastatic tumour - metastasis to distant location",
"Metastatic tumour - additional metastatic",
"Xenograft - derived from primary tumour",
"Xenograft - derived from tumour cell line",
"Cell line - derived from xenograft tissue",
"Cell line - derived from tumour",
"Cell line - derived from normal"
]
}
},
{
"name": "submitter_sample_id",
"valueType": "string",
"description": "Submitter assigned sample id",
"restrictions": {
"required": true,
"regex": "^(?!(SA|sa)).+"
}
},
{
"name": "sample_type",
"valueType": "string",
"description": "Specimen Type",
"restrictions": {
"required": true,
"codeList": [
"Total DNA",
"Amplified DNA",
"ctDNA",
"other DNA enrichments",
"Total RNA",
"Ribo-Zero RNA",
"polyA+ RNA",
"other RNA fractions"
]
}
}
]
}
],
"name": "ARGO Clinical Submission",
"version": "1.0"
}
45 changes: 45 additions & 0 deletions src/app-health.ts
@@ -0,0 +1,45 @@
export type AppHealth = {
all: ComponentStatus;
db: ComponentStatus;
schema: ComponentStatus;
egoPublicKey: ComponentStatus;
};

export type ComponentStatus = {
status: "GREEN" | "RED" | "UNKNOWN";
info?: any;
};

const health: AppHealth = {
all: {
status: "UNKNOWN"
},
db: {
status: "UNKNOWN"
},
schema: {
status: "UNKNOWN"
},
egoPublicKey: {
status: "UNKNOWN"
}
};

export function setStatus(component: keyof AppHealth, status: ComponentStatus) {
health[component] = status;
for (const k in health) {
const key = k as keyof AppHealth;
if (key == "all") {
continue;
}
if (health[key].status !== "GREEN") {
health["all"].status = "RED";
return;
}
}
health["all"].status = "GREEN";
}

export function getHealth(): AppHealth {
return health;
}
16 changes: 14 additions & 2 deletions src/app.ts
Expand Up @@ -3,13 +3,14 @@ import errorHandler from "errorhandler";
import bodyParser from "body-parser";
import path from "path";
import submissionAPI from "./submission/submission-api";
import * as schemaApi from "./lectern-client/schema-api";
import * as schemaApi from "./submission/schema-api";
import * as middleware from "./middleware";
import * as swaggerUi from "swagger-ui-express";
import yaml from "yamljs";
import multer from "multer";
import { loggerFor } from "./logger";
import { findDonors, deleteDonors } from "./clinical/clinical-api";
import { getHealth } from "./app-health";

const L = loggerFor(__filename);

Expand All @@ -28,6 +29,17 @@ app.use(
app.set("port", process.env.PORT || 3000);

app.get("/", (req, res) => res.sendFile(path.join(__dirname, "./resources/working.gif")));
app.get("/health", (req, res) => {
const health = getHealth();
const resBody = {
version: `${process.env.CLINICAL_VERSION} - ${process.env.CLINICAL_COMMIT_ID}`,
health: health
};
if (health.all.status == "GREEN") {
return res.status(200).send(resBody);
}
return res.status(500).send(resBody);
});
app.get(
"/submission/program/:programId/registration",
middleware.wrapAsync(submissionAPI.getRegistrationByProgramId)
Expand Down Expand Up @@ -61,7 +73,7 @@ app.delete("/clinical/donors", middleware.wrapAsync(deleteDonors));
// this has to be defined after all routes for it to work for these paths.
app.use(middleware.errorHandler);
app.use(
"/swagger",
"/api-docs",
swaggerUi.serve,
swaggerUi.setup(yaml.load(path.join(__dirname, "./resources/swagger.yaml")))
);
Expand Down