Package dev.dokimos.server.service
Class RunService
java.lang.Object
dev.dokimos.server.service.RunService
-
Constructor Summary
ConstructorsConstructorDescriptionRunService(ExperimentRunRepository runRepository, ItemResultRepository itemResultRepository, IngestedBatchRepository ingestedBatchRepository, DatasetService datasetService, DatasetItemRepository datasetItemRepository, AnnotationRepository annotationRepository, RegressionAlertService regressionAlertService) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddItems(UUID runId, AddItemsRequest request, String idempotencyKey, TenantScope scope) Adds item results to a run; only allowed while the run is RUNNING.createRun(Experiment experiment, CreateRunRequest request, TenantScope scope) Creates a run and persists its provenance fields (name, git SHA, branch, triggered_by) plus an optional link to the dataset version it executed against.createRun(Experiment experiment, Map<String, Object> config) voiddeleteRun(UUID runId, TenantScope scope) Deletes a run visible under the scope; FKs cascade to its item and eval results.voidfailEvaluatedRun(UUID runId) Moves an evaluating run to FAILED when its judge job has terminally failed, so the run does not stay stuck in EVALUATING.voidfinalizeEvaluatedRun(UUID runId) Finalizes a run whose judge job has finished scoring: re-computes the materialized pass-rate fields and moves the run to SUCCESS.getRunDetails(UUID runId, org.springframework.data.domain.Pageable pageable, TenantScope scope) listRuns(Experiment experiment, TenantScope scope) voidupdateRun(UUID runId, UpdateRunRequest request, TenantScope scope) Updates a run's status.
-
Constructor Details
-
RunService
public RunService(ExperimentRunRepository runRepository, ItemResultRepository itemResultRepository, IngestedBatchRepository ingestedBatchRepository, DatasetService datasetService, DatasetItemRepository datasetItemRepository, AnnotationRepository annotationRepository, RegressionAlertService regressionAlertService)
-
-
Method Details
-
createRun
-
createRun
@Transactional public ExperimentRun createRun(Experiment experiment, CreateRunRequest request, TenantScope scope) Creates a run and persists its provenance fields (name, git SHA, branch, triggered_by) plus an optional link to the dataset version it executed against. The dataset linkage is the foundation for the per-case diff and CI gate: runs paired by(datasetVersionId, ordinal)share stable item identities across executions.- Throws:
IllegalArgumentException- if only one ofdatasetName/datasetVersionis supplied, or if the referenced dataset version does not exist
-
addItems
@Transactional public void addItems(UUID runId, AddItemsRequest request, String idempotencyKey, TenantScope scope) Adds item results to a run; only allowed while the run is RUNNING. A pessimistic lock on the run row serializes ingestion againstupdateRun(java.util.UUID, dev.dokimos.server.dto.v1.UpdateRunRequest, dev.dokimos.server.tenant.TenantScope)so materialized counts stay consistent. WhenidempotencyKeyis non-null, a previously committed batch with the same(runId, idempotencyKey)returns a no-op; the composite PK oningested_batchesis the backstop.- Throws:
IllegalStateException- if the run is not RUNNING
-
deleteRun
Deletes a run visible under the scope; FKs cascade to its item and eval results. -
updateRun
Updates a run's status. On a terminal status this method is the sole writer of the materialized pass-rate fields; the pessimistic lock on the run row blocks until any in-flightaddItems(java.util.UUID, dev.dokimos.server.dto.v1.AddItemsRequest, java.lang.String, dev.dokimos.server.tenant.TenantScope)batch commits. -
finalizeEvaluatedRun
Finalizes a run whose judge job has finished scoring: re-computes the materialized pass-rate fields and moves the run to SUCCESS. The run row is locked so the finalization serializes against any concurrent ingestion or status update.- Parameters:
runId- the run to finalize- Throws:
IllegalArgumentException- if the run does not exist
-
failEvaluatedRun
Moves an evaluating run to FAILED when its judge job has terminally failed, so the run does not stay stuck in EVALUATING. No-op if the run is no longer EVALUATING.- Parameters:
runId- the run to fail- Throws:
IllegalArgumentException- if the run does not exist
-
listRuns
@Transactional(readOnly=true) public List<RunSummary> listRuns(Experiment experiment, TenantScope scope) -
getRunDetails
@Transactional(readOnly=true) public RunDetails getRunDetails(UUID runId, org.springframework.data.domain.Pageable pageable, TenantScope scope)
-