Giving engineers a governed way to run their own Python analysis on THEIA data.
I led the backend design and implementation, connecting versioned packages, human review, reproducible builds and isolated execution into a usable engineering workflow.
Python
FastAPI
Redis
PostgreSQL
Azure Container Apps
Azure Blob Storage
Docker
Azure DevOps
The challenge
A client-specific calculation could take months to become a built-in product feature. Experienced engineers needed a more direct way to apply their own analysis to data already held in THEIA.
Pockets provides a governed route: an engineer submits a Python analysis package, a reviewer approves it, and users run the approved version against selected platform data.
My contribution
I led the backend architecture and implementation, from package upload and approval through execution, session management and resource cleanup. I coordinated with Product, technical leadership and DevOps, and supplied API contracts and mocks for parallel frontend development.
The Frontend team built the UI. Engineering created and maintains the Pocket template, defining what a Pocket can do and the functions it exposes. I designed and implemented the surrounding backend workflow, from upload and review through runtime execution, session management, results and cleanup.
Key engineering decisions
Separate user code from the shared API. Dedicated Azure execution environments accommodate different Python dependencies and reduce the impact of an individual analysis on the main application.
Make runs reproducible and traceable. Approved, versioned packages and prepared dependencies link results to the code that produced them. Redis manages temporary session state, while PostgreSQL preserves durable metadata and run history.
Balance responsiveness with cost. A configurable warm executor pool addresses slow or stalled provisioning. Ready capacity improves startup experience, but consumes resources while idle, so availability and cost must be considered together.
Approved packages, isolated execution and separate session and history stores support the Pocket lifecycle. Open the architecture diagram at full size.
How engineers use it
Engineers prepare and submit a Pocket, then select an approved version and supply THEIA data. The backend validates the session, coordinates execution and returns results for review and download. Resources are cleaned up when the session ends.
Validation and human approval provide a controlled release path. Container isolation is part of that design, alongside access checks and lifecycle management.
The workflow in the web app
Getting started
Setup guidance and template access help engineers prepare a Pocket.
Selecting inputs
Engineers connect THEIA data to the selected analysis.
Reviewing results
The run view brings inputs, outputs and downloads together.
Review and approval
Reviewers manage submitted versions before execution is enabled.
Outcome
Penspen engineers adopted Pockets internally before rollout to external clients. Feedback highlighted flexibility and usability, and the feature generated interest in the wider THEIA platform.
Pocket results were later connected to Kosmos charts, bringing custom analysis into an existing visualisation workflow. The result was a new way to make bespoke analysis available without turning every calculation into a separate product feature.