EnergyAtlasWeb Job (Single-Click, No GUI)¶
A GUI-less job is a pre-configured background task that the user triggers with a single click. It has no input form — parameters are hard-coded in the factory or read from server-side configuration. The only user-facing surface is a Start button, a real-time log stream, and (optionally) a completion status.
Architecture overview¶
1 2 3 4 5 | |
- Frontend shows a list of registered jobs (from
GET /api/jobList). - User clicks Start —
POST /api/jobList/{jobName}/start. - The controller resolves the factory, creates the job, runs it on a background thread.
- Progress is streamed to the client via SignalR (
JobHub).
Key interfaces¶
IJobFactory¶
EnergyAtlasWeb/Jobs/Abstractions/IJobFactory.cs
1 2 3 4 5 6 | |
The factory is a singleton registered in DI. It provides a name/description for the job list and
creates a fresh IControllerJob instance for each run.
IControllerJob¶
EnergyAtlasWeb/Jobs/Abstractions/IControllerJob.cs
1 2 3 4 | |
No inputs, no outputs. The job does its work and reports progress via the IJobReporter it
received at construction time.
Factory registration¶
Factories are registered as singletons in Program.cs:
1 2 3 4 | |
JobRegistry receives IEnumerable<IJobFactory> via constructor injection and builds a
lookup dictionary keyed by JobName.
Adding a new one-click job¶
- Create a class that implements
IJobFactory. - In
Create(...), return a new instance of your job (implementingIControllerJob). - Register it in
Program.cs:builder.Services.AddSingleton<IJobFactory, MyJobFactory>();. - It automatically appears in the job list.
Minimal code template¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
See SignalR Logging for the full reference on
BinaryProgress,TQDM,JobSignal, and how each log type renders in the frontend.
Execution flow (controller side)¶
JobRouterController.StartJob (POST /api/jobList/{jobName}/start):
- Resolve factory from
JobRegistry. - Generate a
jobId(GUID). - Create
JobRuntimeStateviaJobStore.Create(jobId, jobName). - Spawn
Task.Run: - Create
SignalRJobReporter(_hub, jobId). - Call
factory.Create(logger, reporter)→IControllerJob. - Call
job.Run(). - On success:
JobStore.Complete(jobId). - On failure:
JobStore.Fail(jobId, ex.Message). - Return
{ success: true, jobId }immediately.
The frontend connects to SignalR (JoinJob(jobId)) and renders signals in real time.
When to use this vs a GUI job¶
| Criterion | GUI-less job | GUI job |
|---|---|---|
| User-provided parameters | None (or server config) | Yes — typed input form |
| Output artefacts | None (results are side effects) | Yes — text, charts, files |
| Use case | Batch processing, cron-like tasks, infrastructure | Analysis, reports, interactive tools |
If the job needs any user input or produces downloadable output, use a GUI Job instead.
See also¶
- GUI Job — auto-generated job pages with inputs and outputs
- SignalR Logging — reporter, signal types, progress bars
- Working with Local Files — file picking, artifact sink, execution mode differences
- Execution Modes — browser vs local mode