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
2 changes: 1 addition & 1 deletion docs/context/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Authorization-sensitive logic appears in `ClaimUtils`, `AnalysisService`, `DataM
- `SpecificationsService` fetches inputdata, preprocessing, and algorithm specifications from Exaflow per request.
- `AnalysisService` executes preview/run synchronously through `AnalysisExecutionService`. Preview stores nothing; successful runs retain owner-only drafts. Save copies a retained result without execution.
- Data model and algorithm metadata are fetched through `HTTPUtil` using configured Exaflow URLs.
- Analysis execution runs exclusively over RabbitMQ. `AnalysisExecutionService` publishes the JSON request body to Exaflow's request queue via `ExaflowAmqpClient` and waits on a backend-owned reply queue. Specifications and metadata stay on `EXAFLOW_URL`. It requires an Exaflow build that includes madgik/exaflow#673 and madgik/exaflow#681 with its RabbitMQ consumer enabled. Replies are at-least-once; a duplicate or late reply is acked and dropped. Transient previews (`POST /analyses/preview`) check `consumer_count == 0` and fail fast with HTTP 503; normal runs (`POST /analyses/runs`) queue in RabbitMQ and rely on `mandatory` return for a missing request queue. A confirmed publish that gets no reply within the reply timeout is HTTP 504. Both use a fixed message. `RABBITMQ_URL` is parsed with the RabbitMQ client's `setUri` so `%2F` and encoded passwords match Exaflow.
- Analysis execution runs exclusively over RabbitMQ. `AnalysisExecutionService` publishes the JSON request body to Exaflow's request queue via `ExaflowAmqpClient` and waits on a backend-owned reply queue. Specifications and metadata stay on `EXAFLOW_URL`. It requires an Exaflow build that includes madgik/exaflow#673, madgik/exaflow#681 and madgik/exaflow#687 with its RabbitMQ consumer enabled. Replies are at-least-once; a duplicate or late reply is acked and dropped. Transient previews (`POST /analyses/preview`) check `consumer_count == 0` and fail fast with HTTP 503; normal runs (`POST /analyses/runs`) queue in RabbitMQ and rely on `mandatory` return for a missing request queue. A confirmed publish that gets no reply within the reply timeout is HTTP 504. Both use a fixed message. `RABBITMQ_URL` is parsed with the RabbitMQ client's `setUri` so `%2F` and encoded passwords match Exaflow.

## Config and Environment Model
- All runtime config is in `src/main/resources/application.yml` with `${ENV:default}` placeholders.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private AnalysisResultDTO execute(UUID requestId, AnalysisRequestDTO analysisReq
static Object convertResponseToAnalysisResult(Logger logger, int code, String responseBody) {
return switch (code) {
case 200 -> new RawJson(responseBody);
case 400, 413, 422, 460, 461, 512, 513 -> convertExaflowResponseToAnalysisResult(responseBody);
case 400, 413, 422, 460, 461, 462, 512, 513 -> convertExaflowResponseToAnalysisResult(responseBody);
case 500 -> convertExaflowResponseToAnalysisResult(GENERIC_ERROR_MESSAGE);
// Exaflow is at its concurrent-analysis limit; its own message names internal components,
// so it goes to the log and the user gets a retry message.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/hbp/mip/algorithm/ExaflowAmqpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ private static int httpCode(String errorCode) {
case "invalid_request" -> 422;
case "BadUserInput", "DataModelUnavailable", "DatasetUnavailable" -> 460;
case "insufficient_data" -> 461;
case "AnalysisExecutionError" -> 462;
case "WorkerUnresponsiveError" -> 512;
case "WorkerTaskTimeoutError" -> 513;
case "GlobalWorkerUnavailableError" -> 503;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ void errorReplyGoesThroughExistingConverter() {
assertThat(response.code()).isEqualTo(461);
}

@Test
void analysisExecutionErrorReplyKeepsItsMessage() {
ExaflowAmqpClient amqp = mock(ExaflowAmqpClient.class);
when(amqp.submit(anyString(), anyString(), eq(false), any()))
.thenReturn(new ExaflowAmqpClient.ExaflowReply(
462, "Logistic regression could not converge to a stable solution."));

var response = new AnalysisExecutionService(amqp)
.runAnalysis(UUID.randomUUID(), analysisRequest(), new Logger("user", "test"));

assertThat(response.body()).isEqualTo(Map.of(
"data", "Logistic regression could not converge to a stable solution.",
"type", "text/plain+error"));
assertThat(response.code()).isEqualTo(462);
}

private static AnalysisRequestDTO analysisRequest() {
return new AnalysisRequestDTO("original-request-id",
new AnalysisRequestDTO.AnalysisInputDataDTO("dm:1", List.of("ds1"), List.of("validation"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static Stream<Arguments> mappingRows() {
Arguments.of(failed("DataModelUnavailable", "model"), 460, "model"),
Arguments.of(failed("DatasetUnavailable", "dataset"), 460, "dataset"),
Arguments.of(failed("insufficient_data", "not enough"), 461, "not enough"),
Arguments.of(failed("AnalysisExecutionError", "could not converge"), 462, "could not converge"),
Arguments.of(failed("SMPCUsageError", "smpc"), 500, "smpc"),
Arguments.of(failed("WorkerUnresponsiveError", "unresponsive"), 512, "unresponsive"),
Arguments.of(failed("WorkerTaskTimeoutError", "task timeout"), 513, "task timeout"),
Expand Down
Loading