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

fix: workaround for Docker EACCESS issue #71

Merged
merged 3 commits into from
Nov 7, 2022
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: 6 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ python manage.py fake_data -n <num samples>
## Development

1. Run the images in containers:

If you are running containers for the first time:
```sh
docker-compose up -d && docker-compose exec nodeserver sh -c "mkdir -p node_modules/.cache/ && touch node_modules/.cache/.eslintcache && chown -R node:node node_modules/.cache && chmod -R 777 node_modules/.cache/"
```
Otherwise just run:
```sh
docker-compose up
```
Expand Down
25 changes: 23 additions & 2 deletions backend/clin_overview/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ class ClinicalViewSet(viewsets.ModelViewSet):
queryset = ClinicalData.objects.all()

def retrieve(self, request, pk=None):

serializer_class = ClinicalDataSerializer
queryset = ClinicalData.objects.all()
patient = get_object_or_404(queryset, pk=pk)
patient = get_object_or_404(queryset, patient_id=pk)
timelinerecords = TimelineRecord.objects.filter(patient=patient, event="laboratory")
date_relative_max = timelinerecords.aggregate(Max("date_relative"))['date_relative__max']
date_relative_min = timelinerecords.aggregate(Min("date_relative"))['date_relative__min']
Expand Down Expand Up @@ -69,16 +68,35 @@ def retrieve(self, request, pk=None):
],
}

# def add_data(data, range_min, range_max, thresholds, colors):
# date_relative = []
# result = []
# for item in data.iterator():
# date_relative.append(item.date_relative)
# result.append(item.result)
# newdict = {'y': result,
# 'x': date_relative,
# 'colors': colors,
# 'thresholds': thresholds,
# }
# return newdict

def add_data(data, range_min, range_max, thresholds, colors):
date_relative = np.arange(range_min, range_max + 1)
result = np.empty_like(date_relative, dtype=np.float32)
result[:] = np.nan
sparse_date = []
sparse_result = []
for item in data.iterator():
result[item.date_relative-range_min] = item.result
sparse_date.append(item.date_relative)
sparse_result.append(item.result)
newdict = {'y': result.tolist(),
'x': date_relative.tolist(),
'colors': colors,
'thresholds': thresholds,
'sparse_y': sparse_result,
'sparse_x': sparse_date,
}
return newdict

Expand All @@ -87,13 +105,15 @@ def add_data(data, range_min, range_max, thresholds, colors):
leuk_dict = add_data(leuk, date_relative_min, date_relative_max, thresholds["leuk"], colors["leuk"])
platelets_dict = add_data(platelets, date_relative_min, date_relative_max, thresholds["platelets"], colors["platelets"])
neut_dict = add_data(neut, date_relative_min, date_relative_max, thresholds["neut"], colors["neut"])
# navigator = {'x': np.arange(date_relative_min, date_relative_max + 1).tolist()}

time_series = {
'ca125': ca125_dict,
'hb': hb_dict,
'leuk': leuk_dict,
'platelets': platelets_dict,
'neut' : neut_dict,
# 'navigator': navigator,
}

fresh_sample = TimelineRecord.objects.filter(patient=patient, event="fresh_sample").order_by("date_relative").values_list("date_relative", "name").distinct()
Expand Down Expand Up @@ -170,6 +190,7 @@ class TimelineViewSet(viewsets.ModelViewSet): # id paziente
serializer_class = TimelineRecordSerializer

def retrieve(self, request, patient_id=None):
print(patient_id)
queryset = TimelineRecord.objects.filter(patient_id=patient_id, event="laboratory")
ca125 = queryset.filter(name="ca125").order_by("date_relative")
hb = queryset.filter(name="hb").order_by("date_relative")
Expand Down
12 changes: 6 additions & 6 deletions oncodash-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ ENTRYPOINT ["/sbin/tini", "--"]
# Get latest npm
RUN npm i npm@latest -g

# install dependencies first, in a different location for easier app
# bind mounting for local development due to default /opt permissions
# install dependencies first, in a different location for easier app
# bind mounting for local development due to default /opt permissions
# we have to create the dir with root and change perms
RUN mkdir /opt/node_app && chown node:node /opt/node_app
WORKDIR /opt/node_app

# the official node image provides an unprivileged user as a security
# best practice but we have to manually enable it. We put it here so
# best practice but we have to manually enable it. We put it here so
# npm installs dependencies as the same user who runs the app.
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#non-root-user
USER node

# copy package.json, install deps and set $PATH-var for node_modules
COPY --chown=node:node package.json package-lock.json* ./
RUN chmod 777 ./
RUN npm install --no-optional --legacy-peer-deps --unsafe-perm=true --allow-root && npm cache clean --force

RUN npm install --no-optional --legacy-peer-deps && npm cache clean --force
ENV PATH /opt/node_app/node_modules/.bin:$PATH

# copy in our source code last, as it changes the most
Expand All @@ -36,4 +36,4 @@ COPY --chown=node:node . .
EXPOSE 8000

# start the dev server
CMD ["npm", "start", "--prefix", "/opt/node_app/app"]
CMD ["npm", "start", "--prefix", "/opt/node_app/app"]
109 changes: 75 additions & 34 deletions oncodash-app/src/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,44 @@ import {Patient} from './Clinical/Patient.js';
},
})
).then(patients => {
return patients.map((s)=> new Patient( s.id,
s.age,
s.cud_survival,
s.cud_histology,
s.cud_stage,
s.cud_treatment_strategy,
s.cud_primary_therapy_outcome,
s.cud_current_treatment_phase,
s.maintenance_therapy,
s.extra_patient_info,
s.other_diagnosis,
s.cancer_in_family,
s.chronic_illness,
s.other_medication,
s.time_series,
// console.log(patients);
return patients.map((s)=> new Patient(
s.patient_id,
s.cohort_code,
s.chronic_illnesses_at_dg,
s.chronic_illnesses_type,
s.time_series,
s.event_series,
s.histology,
s.stage,
s.primary_therapy_outcome,
s.survival,
s.treatment_strategy,
s.followup_time,
s.platinum_free_interval_at_update,
s.platinum_free_interval,
s.days_to_progression,
s.days_from_beva_maintenance_end_to_progression,
s.days_to_death,
s.age_at_diagnosis,
s.height_at_diagnosis,
s.weight_at_diagnosis,
s.bmi_at_diagnosis,
s.previous_cancer,
s.previous_cancer_diagnosis,
s.progression,
s.operation1_cancelled,
s.residual_tumor_pds,
s.wgs_available,
s.operation2_cancelled,
s.residual_tumor_ids,
s.debulking_surgery_ids,
s.brca_mutation_status,
s.hr_signature_pretreatment_wgs,
s.hr_signature_per_patient,
s.hrd_myriad_status,
s.sequencing_available,
s.paired_fresh_samples_available,
));
});

Expand All @@ -70,26 +93,44 @@ import {Patient} from './Clinical/Patient.js';
},
})
).then(patient => {
// console.log(patient.time_series);
return new Patient(
patient.id,
patient.age,
patient.cud_survival,
patient.cud_histology,
patient.cud_stage,
patient.cud_treatment_strategy,
patient.cud_primary_therapy_outcome,
patient.cud_current_treatment_phase,
patient.maintenance_therapy,
patient.extra_patient_info,
patient.other_diagnosis,
patient.cancer_in_family,
patient.chronic_illness,
patient.other_medication,
JSON.parse(patient.time_series),
JSON.parse(patient.event_series),
patient.height,
patient.weight,
patient.has_brca_mutation,
patient.patient_id,
patient.cohort_code,
patient.chronic_illnesses_at_dg,
patient.chronic_illnesses_type,
JSON.parse(patient.time_series),
JSON.parse(patient.event_series),
patient.histology,
patient.stage,
patient.primary_therapy_outcome,
patient.survival,
patient.treatment_strategy,
patient.followup_time,
patient.platinum_free_interval_at_update,
patient.platinum_free_interval,
patient.days_to_progression,
patient.days_from_beva_maintenance_end_to_progression,
patient.days_to_death,
patient.age_at_diagnosis,
patient.height_at_diagnosis,
patient.weight_at_diagnosis,
patient.bmi_at_diagnosis,
patient.previous_cancer,
patient.previous_cancer_diagnosis,
patient.progression,
patient.operation1_cancelled,
patient.residual_tumor_pds,
patient.wgs_available,
patient.operation2_cancelled,
patient.residual_tumor_ids,
patient.debulking_surgery_ids,
patient.brca_mutation_status,
patient.hr_signature_pretreatment_wgs,
patient.hr_signature_per_patient,
patient.hrd_myriad_status,
patient.sequencing_available,
patient.paired_fresh_samples_available,
);
});

Expand Down
4 changes: 2 additions & 2 deletions oncodash-app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function App() {
try{
// setToken(cookie["token"]);
// setLogged(true);
console.log(cookie);
// console.log(cookie);
setWaiting(true);
const patients = await API.getPatients(token);
setPatients([...patients]);
Expand All @@ -80,7 +80,7 @@ function App() {
const getFilteredPatients = () =>{
let filteredPatients = [...patients];
if(filter!=="")
filteredPatients = filteredPatients.filter(p=>String(p.id).includes(String(filter)) || String(p.stage).toLowerCase().includes(String(filter).toLowerCase()));
filteredPatients = filteredPatients.filter(p=>String(p.patient_id).includes(String(filter)) || String(p.stage).toLowerCase().includes(String(filter).toLowerCase()));
if(statusFilter!=="")
filteredPatients = filteredPatients.filter(p=>String(p.survival).toLowerCase()===String(statusFilter).toLowerCase());
return filteredPatients;
Expand Down
8 changes: 4 additions & 4 deletions oncodash-app/src/Clinical/Clinical.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import alive from '../assets/alive.svg';
import dead from '../assets/not-alive.svg';

function Clinical(props) {
const displayOrder1 = ["id", "age", "survival", "histology", "stage", "bmi"];
const displayOrder2 = ["cancer_in_family", "BRCA"];
const displayOrder3 = ["strategy", "primary_outcome", "current_phase", "maintenance"];
const displayOrder1 = ["patient_id", "age_at_diagnosis", "survival", "histology", "stage", "bmi_at_diagnosis"];
const displayOrder2 = ["brca_mutation_status"]; // cancer_in_family deprecated
const displayOrder3 = ["treatment_strategy", "primary_therapy_outcome", ]; // "current_phase", "maintenance" deprecated

// const location = useLocation();

Expand Down Expand Up @@ -69,7 +69,7 @@ function Clinical(props) {
{displayOrder2.map(d=>
<Row key={d} className="text-center text-primary font-weight-bold">
<Col className="text-end text-dark">{d.replace('', '')}: </Col>
<Col className="text-start">{props.patient[d]}{props.patient[d]===true?"True": ""}{props.patient[d]===false?"False": ""}{props.patient[d]===NaN?"NaN": ""}</Col>
<Col className="text-start">{props.patient[d]}{props.patient[d]===true?"True": ""}{props.patient[d]===false?"False": ""}{props.patient[d]===NaN?"NaN": ""}{props.patient[d]===null?"Not Available": ""}</Col>
</Row>)}
</div>
</Col>
Expand Down