Magrep

Python

FastAPI

Oracle

Docker

Overview

MAGREP started with me fixing the legacy C++ application to generate more complete witness reports. I then built a Python proof-of-concept that replicated the old behaviour but added a key feature: letting users edit the underlying data before reports are generated.

I collaborated to migrate the front end and data collection into APEX, and built out the backend microservices for data analysis and document generation, which is designed to plug cleanly into APEX and PL/SQL while keeping complex logic out of the database.

The most interesting part is the new reporting engine. Rather than hardcoded scripts, it's a modular spec-driven system built on FastAPI and Quarto. Pass it a JSON specification and it dynamically generates both PDF and HTML output, this allows for new report formats to be added without touching existing code. Each report is defined as a tree of typed blocks (section, text, table, figure, repeater), with each block declaring its data source, layout, and render options. Data is resolved from Oracle via stored procedures, with {{token}} placeholders substituted from request metadata at runtime.

Superconductor Physics

A core part of the analysis service is fitting the Summers scaling law to critical current measurements for Nb₃Sn superconducting wire:

Ic(B,T)=C(T)⋅bp(1−b)qBpI_c(B, T) = C(T) \cdot \frac{b^p (1-b)^q}{B_p}Ic​(B,T)=C(T)⋅Bp​bp(1−b)q​

Given measured (Bp,Ic,T)(B_p, I_c, T)(Bp​,Ic​,T) triplets, the service uses Levenberg-Marquardt least squares (scipy.optimize.least_squares) to extract the material parameters Bc20B_{c20}Bc20​ and C0C_0C0​. It can also correct IcI_cIc​ to a target temperature using the fitted scaling law, and find intersections between a magnet load line and the fitted critical surface — a key acceptance criterion for accelerator magnets.

Key Features

  • Modular, JSON spec-driven report generation, so new report types need no code changes
  • Dual HTML and PDF output from a single Quarto document source
  • In-process physics fitting with no external tool handoffs
  • Oracle integration via python-oracledb thick mode with a lifespan-managed connection pool
  • Deployed on CERN OKD (OpenShift)

On this page

OverviewSuperconductor PhysicsKey Features

Links

Fit Service Gitlab (Restricted Access to CERN Members)Report Generator Gitlab (Restricted Access to CERN Members)