Skip to content

Commit

Permalink
Merge branch 'main' into Update-Grounding-and-DKG-types
Browse files Browse the repository at this point in the history
  • Loading branch information
YohannParis committed Jan 24, 2025
2 parents c7d0e25 + 55ce56b commit effe7e3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,25 @@ export function generateRankingCharts(
({ id }) => id === metadata.simulationAttributes?.interventionPolicyId
);

if (!policy?.name || !modelConfiguration?.name) {
const policyName = policy?.name ?? 'no policy';

if (!modelConfiguration?.name) {
return;
}

if (!interventionNameColorMap[policy.name]) {
interventionNameColorMap[policy.name] = CATEGORICAL_SCHEME[colorIndex];
interventionNameScoresMap[policy.name] = [];
colorIndex++;
if (!interventionNameColorMap[policyName]) {
interventionNameScoresMap[policyName] = [];
if (!policy?.name) {
interventionNameColorMap[policyName] = 'black';
} else {
interventionNameColorMap[policyName] = CATEGORICAL_SCHEME[colorIndex];
colorIndex++;
}
}

rankingCriteriaValues.push({
score: pointOfComparison[`${variableKey}:${index}`] ?? 0,
policyName: policy.name,
policyName,
configName: modelConfiguration.name
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<template #content>
<div class="top-toolbar">
<div class="btn-group">
<Button v-if="showSpinner" label="Stop" icon="pi pi-stop" @click="stop" />
<Button :loading="showSpinner" label="Run" icon="pi pi-play" @click="run" />
</div>
</div>
Expand Down Expand Up @@ -407,6 +408,7 @@ import {
type ProcessedFunmanResult,
type FunmanConstraintsResponse,
processFunman,
cancelQueries,
makeQueries
} from '@/services/models/funman-service';
import { createFunmanStateChart, createFunmanParameterCharts } from '@/services/charts';
Expand Down Expand Up @@ -649,6 +651,15 @@ async function run() {
emit('update-state', state);
}
async function stop() {
const state = cloneDeep(props.node.state);
await cancelQueries(state.inProgressId);
showSpinner.value = false;
// Clean up the in-progress id
state.inProgressId = '';
emit('update-state', state);
}
function updateCodeState(hasCodeRun: boolean) {
const state = saveCodeToState(props.node, rawRequest.value, hasCodeRun);
emit('update-state', state);
Expand Down
10 changes: 10 additions & 0 deletions packages/client/hmi-client/src/services/models/funman-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ export async function makeQueries(body: FunmanPostQueriesRequest, modelId: strin
}
}

export async function cancelQueries(taskId: string) {
try {
const { data } = await API.delete(`/funman/queries/${taskId}`);
return data;
} catch (err) {
logger.error(err);
return null;
}
}

export function generateConstraintExpression(config: ConstraintGroup) {
const { constraintType, interval, variables, timepoints } = config;
let expression = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -141,4 +143,32 @@ public ResponseEntity<Simulation> createValidationRequest(

return ResponseEntity.ok(newSimulation);
}

@DeleteMapping("/{task-id}")
@Secured(Roles.USER)
@Operation(summary = "Cancel a model configuration validation task")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "Dispatched cancellation successfully",
content = @Content(
mediaType = "application/json",
schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = Void.class)
)
),
@ApiResponse(
responseCode = "500",
description = "There was an issue dispatching the cancellation",
content = @Content
)
}
)
public ResponseEntity<Void> cancelTask(
@PathVariable("task-id") final UUID taskId,
@RequestParam(name = "project-id", required = false) final UUID projectId
) {
taskService.cancelTask(TaskType.FUNMAN, taskId);
return ResponseEntity.ok().build();
}
}

0 comments on commit effe7e3

Please sign in to comment.