Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ebrains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
tags:
- "*"

permissions:
contents: read

jobs:
to_ebrains:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
release:
types: [published]

permissions:
contents: read

env:
HARBOR_REGISTRY: docker-registry.ebrains.eu
DOCKER_BUILDKIT: 1
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN --mount=type=cache,target=/app/.angular/cache \
# Step 2: Use Nginx to serve the Angular app
FROM nginx:alpine-slim@sha256:858c48843bd53b3f72487a2156071c63954b8e3de4882aeb11efcd92717dd261
RUN apk upgrade --no-cache \
&& apk add --no-cache gettext-envsubst
&& apk add --no-cache gettext-envsubst=1.0-r0
ENV PLATFORM_BACKEND_SERVER=platform-backend-service:8080 \
PLATFORM_BACKEND_CONTEXT=services \
NOTEBOOK_ENABLED=0 \
Expand All @@ -50,6 +50,7 @@ COPY --from=build /app/dist/fl-platform/browser /usr/share/nginx/html
RUN chown -R nginx:nginx /usr/share/nginx/html /etc/nginx/conf.d /var/cache/nginx \
&& install -o nginx -g nginx -m 0644 /dev/null /var/run/nginx.pid

USER nginx
# 101 is the nginx user created by the official alpine image.
USER 101
EXPOSE 80
CMD ["/docker-entrypoint.sh"]
16 changes: 8 additions & 8 deletions package-lock.json

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

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
"@angular/platform-browser": "^22.2.3",
"@angular/router": "^22.2.3",
"@fortawesome/fontawesome-free": "^7.3.1",
"d3": "^7.9.0",
"d3": "7.9.0",
"echarts": "6.1.0",
"html2canvas": "^1.4.1",
"jspdf": "^4.2.1",
"jspdf-autotable": "^5.0.9",
"jszip": "^3.10.2",
"ngx-echarts": "^22.0.0",
"rxjs": "~7.8.2",
"tslib": "^2.8.1"
"html2canvas": "1.4.1",
"jspdf": "4.2.1",
"jspdf-autotable": "5.0.9",
"jszip": "3.10.2",
"ngx-echarts": "22.0.0",
"rxjs": "7.8.2",
"tslib": "2.8.1"
},
"devDependencies": {
"@angular/build": "22.2.4",
Expand Down
7 changes: 7 additions & 0 deletions src/app/core/html.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ describe('escapeHtml', () => {
it('escapes every HTML-significant character', () => {
expect(escapeHtml(`Sex <b>&"'x</b>`)).toBe('Sex &lt;b&gt;&amp;&quot;&#39;x&lt;/b&gt;');
});

it('leaves ordinary chart labels and numbers unchanged', () => {
expect(escapeHtml('PC1 · 12.3%')).toBe('PC1 · 12.3%');
expect(escapeHtml('Mean')).toBe('Mean');
expect(escapeHtml('1.50')).toBe('1.50');
expect(escapeHtml(null)).toBe('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ export function buildBoxPlotChart(result: any): EChartsOption[] {
const showPooled = !!pooled && hasBox(pooled);

const tooltipRow = (name: string, value: number | null) =>
`<div style="display:flex;justify-content:space-between;gap:20px">` +
`<span style="color:${AXIS}">${name}</span><b>${fmt(value)}</b></div>`;
'<div style="display:flex;justify-content:space-between;gap:20px">' +
'<span style="color:' + AXIS + '">' + escapeHtml(name) + '</span><b>' + escapeHtml(fmt(value)) + '</b></div>';
const tooltipFor = (s: BoxStats, title: string, quartileNote = '') =>
`<div style="font-weight:700;margin-bottom:6px">${escapeHtml(title)}</div>` +
'<div style="font-weight:700;margin-bottom:6px">' + escapeHtml(title) + '</div>' +
tooltipRow('Max', s.max) +
tooltipRow(`Q3${quartileNote}`, s.q3) +
tooltipRow(`Median${quartileNote}`, s.median) +
tooltipRow(`Q1${quartileNote}`, s.q1) +
tooltipRow('Q3' + quartileNote, s.q3) +
tooltipRow('Median' + quartileNote, s.median) +
tooltipRow('Q1' + quartileNote, s.q1) +
tooltipRow('Min', s.min) +
`<div style="border-top:1px solid ${SPLIT};margin:6px 0"></div>` +
'<div style="border-top:1px solid ' + SPLIT + ';margin:6px 0"></div>' +
tooltipRow('Mean', s.mean) +
tooltipRow('Std. deviation', s.std);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ export function buildGroupedBarChart(
},
formatter: (params: any) => {
const dataset = params[0]?.axisValue ?? '';
let html = `<b>${escapeHtml(dataset)}</b><br/>`;
let html = '<b>' + escapeHtml(dataset) + '</b><br/>';
for (const p of params) {
const pct = p.data?.value ?? p.value;
const cnt = p.data?.count ?? 0;
html += `${p.marker} ${escapeHtml(p.seriesName)}: ${pct}% (n=${cnt})<br/>`;
html += p.marker + ' ' + escapeHtml(p.seriesName) + ': ' + pct + '% (n=' + cnt + ')<br/>';
}
return html;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ function buildKMeans2DChart(
trigger: 'item',
formatter: (p: any) => {
const size = sizeTexts[p.seriesIndex];
return `${escapeHtml(names[p.seriesIndex])}<br/>${escapeHtml(variables[0])}: <b>${p.value[0].toFixed(2)}</b><br/>${escapeHtml(variables[1])}: <b>${p.value[1].toFixed(2)}</b>` +
(size === null ? '' : `<br/>${escapeHtml(size)} rows`);
return escapeHtml(names[p.seriesIndex]) + '<br/>' + escapeHtml(variables[0]) + ': <b>' + p.value[0].toFixed(2) + '</b><br/>' +
escapeHtml(variables[1]) + ': <b>' + p.value[1].toFixed(2) + '</b>' +
(size === null ? '' : '<br/>' + escapeHtml(size) + ' rows');
},
},
grid: { top: 64, left: 24, right: 32, bottom: 48, containLabel: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function buildMatrixChart(result: any): EChartsOption[] {
const [j, i, r] = params.value;
const row = rows[i];
const col = cols[j];
const lines = [`${escapeHtml(row)} × ${escapeHtml(col)}`, `r = <b>${r.toFixed(3)}</b>`];
const lines = [escapeHtml(row) + ' × ' + escapeHtml(col), 'r = <b>' + r.toFixed(3) + '</b>'];
const lower = cell(ciLower, row, col);
const upper = cell(ciUpper, row, col);
if (lower !== null && upper !== null) lines.push(`95% CI ${lower.toFixed(3)} to ${upper.toFixed(3)}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ function intervalPlot(data: IntervalPoint[], labels: IntervalLabels, height = 38
if (p.seriesType === 'scatter') {
const group = p.name ?? (Array.isArray(p.value) ? p.value[0] : '');
const mean = Array.isArray(p.value) ? p.value[1] : meanMap[group];
return `${escapeHtml(group)}<br/>${labels.value}: <b>${fmt(mean)}</b>`;
return escapeHtml(group) + '<br/>' + escapeHtml(labels.value) + ': <b>' + escapeHtml(fmt(mean)) + '</b>';
}
if (p.seriesType === 'custom' && Array.isArray(p.value)) {
const group = p.value[4];
const low = p.value[1];
const high = p.value[2];
const mean = meanMap[group];
return `${escapeHtml(group)}<br/>${labels.value}: <b>${fmt(mean)}</b><br/>${labels.intervalShort}: <b>${fmt(low)} – ${fmt(high)}</b>`;
return escapeHtml(group) + '<br/>' + escapeHtml(labels.value) + ': <b>' + escapeHtml(fmt(mean)) + '</b><br/>' +
escapeHtml(labels.intervalShort) + ': <b>' + escapeHtml(fmt(low)) + ' – ' + escapeHtml(fmt(high)) + '</b>';
}
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function buildPCAHeatmapChart(result: any): EChartsOption[] {
position: 'top',
formatter: (params: any) => {
const [component, variable, val] = params.value;
return `${componentLabels[component]}<br/>${escapeHtml(variableNames[variable])}: <b>${val.toFixed(3)}</b>`;
return escapeHtml(componentLabels[component]) + '<br/>' + escapeHtml(variableNames[variable]) + ': <b>' + val.toFixed(3) + '</b>';
},
},
grid: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chiSquarePValue, formatPValue, formatRatio, ratioDigits } from '../result-format';
import { chiSquarePValue, formatPValue, formatRatio, ratioDigits, readable } from '../result-format';
import { buildRegressionView } from './regression-view';

describe('result-format', () => {
Expand All @@ -12,6 +12,24 @@ describe('result-format', () => {
expect(chiSquarePValue(0, 3)).toBe(1);
});

it('turns raw snake_case codes into words and leaves other labels unchanged', () => {
expect(readable('stroke_territory_cohort')).toBe('Stroke territory cohort');
expect(readable('cluster_2')).toBe('Cluster 2');
expect(readable('kmeans_labels')).toBe('K-means labels');
expect(readable('a_b_c')).toBe('A b c');
expect(readable('Age')).toBe('Age');
expect(readable('a')).toBe('a');
expect(readable('')).toBe('');
expect(readable('a_')).toBe('a_');
expect(readable('_ab')).toBe('_ab');
expect(readable('a__b')).toBe('a__b');
expect(readable('A_b')).toBe('A_b');
expect(readable('already labelled')).toBe('already labelled');
const long = 'a'.repeat(20000);
expect(readable(long)).toBe(long);
expect(readable('a_' + 'b'.repeat(100) + '_c9')).toBe('A ' + 'b'.repeat(100) + ' c9');
});

it('formats p-values APA style and ratios at 3 significant digits', () => {
expect(formatPValue(1.1102230246251565e-16)).toBe('< 0.001');
expect(formatPValue(0.8119)).toBe('0.812');
Expand Down
23 changes: 22 additions & 1 deletion src/app/pages/experiment-studio/visualisations/result-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,28 @@ export function chiSquarePValue(x: number, df: number): number {
/** A raw snake_case code (a created column such as stroke_territory_cohort, or a level such as
* cluster_2) reads as words; labelled names pass through unchanged. */
export function readable(code: string): string {
if (!/^[a-z0-9]+(_[a-z0-9]+)+$/.test(code)) return code;
if (!isRawSnakeCode(code)) return code;
const words = code.replace(/_/g, ' ').replace(/^kmeans\b/, 'K-means');
return words.charAt(0).toUpperCase() + words.slice(1);
}

/** Same strings as `^[a-z0-9]+(_[a-z0-9]+)+$`, scanned once so a long label cannot backtrack. */
function isRawSnakeCode(code: string): boolean {
let i = 0;
if (!isSnakeWordChar(code, i)) return false;
while (isSnakeWordChar(code, i)) i += 1;
if (i >= code.length) return false;
while (i < code.length) {
if (code.charCodeAt(i) !== 95) return false;
i += 1;
if (!isSnakeWordChar(code, i)) return false;
while (isSnakeWordChar(code, i)) i += 1;
}
return true;
}

function isSnakeWordChar(code: string, index: number): boolean {
if (index >= code.length) return false;
const char = code.charCodeAt(index);
return (char >= 48 && char <= 57) || (char >= 97 && char <= 122);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="key-figures" role="group" aria-label="Key figures">
@for (figure of figures(); track figure.label) {
<div class="key-figure">
<span class="key-figure-label">{{ figure.label }}</span>
<span class="key-figure-value">{{ figure.value }}</span>
@if (figure.note) {
<span class="key-figure-note">{{ figure.note }}</span>
}
</div>
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,7 @@ export interface KeyFigure {
/** The headline numbers of a result: one strip of label / value / note cells. */
@Component({
selector: 'app-key-figures',
template: `
<div class="key-figures" role="group" aria-label="Key figures">
@for (figure of figures(); track figure.label) {
<div class="key-figure">
<span class="key-figure-label">{{ figure.label }}</span>
<span class="key-figure-value">{{ figure.value }}</span>
@if (figure.note) {
<span class="key-figure-note">{{ figure.note }}</span>
}
</div>
}
</div>
`,
templateUrl: './key-figures.component.html',
styleUrl: './key-figures.component.css',
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
10 changes: 5 additions & 5 deletions src/app/pages/terms-page/terms-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class TermsPageComponent implements OnInit {
return;
}
const text = this.formatInline(paragraph.join(' '));
html.push(`<p>${text}</p>`);
html.push('<p>' + text + '</p>');
paragraph = [];
};

Expand Down Expand Up @@ -142,14 +142,14 @@ export class TermsPageComponent implements OnInit {
if (trimmed && next && /^=+$/.test(next)) {
flushParagraph();
closeLists();
html.push(`<h1>${this.formatInline(trimmed)}</h1>`);
html.push('<h1>' + this.formatInline(trimmed) + '</h1>');
i += 1;
continue;
}
if (trimmed && next && /^-+$/.test(next)) {
flushParagraph();
closeLists();
html.push(`<h2>${this.formatInline(trimmed)}</h2>`);
html.push('<h2>' + this.formatInline(trimmed) + '</h2>');
i += 1;
continue;
}
Expand Down Expand Up @@ -177,13 +177,13 @@ export class TermsPageComponent implements OnInit {
}
}
closeOpenItemAtDepth(depth);
html.push(`<li>${this.formatInline(content)}`);
html.push('<li>' + this.formatInline(content));
listStack[depth - 1].openItem = true;
continue;
}

if (listStack.length > 0 && /^\s{4,}/.test(line)) {
html.push(`<p>${this.formatInline(trimmed)}</p>`);
html.push('<p>' + this.formatInline(trimmed) + '</p>');
continue;
}

Expand Down
5 changes: 3 additions & 2 deletions src/app/services/experiment-studio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ export class ExperimentStudioService {
upsertTransformation(step: TransformationStep): boolean {
const current = this.appliedTransformationsSignal();
const index = current.findIndex((existing) => existing.id === step.id);
if (index !== -1 && JSON.stringify(current[index]) === JSON.stringify(step)) return true;
const existing = index === -1 ? undefined : current[index];
if (existing !== undefined && JSON.stringify(existing) === JSON.stringify(step)) return true;
if (index !== -1 && this.outputsInUse(step.id, stepOutputNames(step)).length) return false;
// Replace in place to keep request-order/dependency guarantees; append only when new.
const next = index === -1
Expand Down Expand Up @@ -2037,7 +2038,7 @@ export class ExperimentStudioService {
map((resp) => this.normalizeTransientResponse(resp)),
);
} catch (error) {
console.error(`${algorithmName} report is not available:`, error);
console.error('%s report is not available:', algorithmName, error);
return null;
}
}
Expand Down
Loading