Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui-ts): update TimeSeriesManagement page to allow the generation of TS #2170

Merged
merged 20 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fbe0445
refactor(ui-hooks): change 'resolved' status name by 'fulfilled' in u…
skamril Oct 3, 2024
65d0efa
refactor(ui-hooks): remove unnecessary code
skamril Oct 3, 2024
ab47668
feat(ui-hooks): create usePromiseHandler
skamril Oct 3, 2024
725eea0
feat(ui-commons): add `allowSubmitOnPristine` prop in Form
skamril Oct 3, 2024
dba1cb1
feat(ui-ts): update TimeSeriesManagement page to allow the generation…
skamril Oct 4, 2024
5943f62
feat(ui-tasks): show ts-generation task inside the tasks view
MartinBelthle Oct 7, 2024
4925d20
refactor(ui-ts): change cell width and pop-up message
MartinBelthle Oct 9, 2024
e08750e
refactor(ui-api,ui-tasks): update tasks API functions
skamril Oct 17, 2024
cf62128
feat(ui-commons): support `disabled` option in Form
skamril Oct 23, 2024
8650aed
refactor(ui-ws): update webSocket types and some renaming
skamril Oct 23, 2024
543d883
feat(ws, ui-ws): add type and study_id inside TaskEventPayload
MartinBelthle Oct 30, 2024
7b7e417
feat(ui-ws): add 'TS_GENERATION_PROGRESS' event type
skamril Oct 24, 2024
dbf61cc
feat(ui-commons): update LinearProgressWithLabel
skamril Oct 29, 2024
58027f8
feat(ui-tasks): remove some notifications
skamril Oct 29, 2024
b19cc34
feat(ui-study): freeze study when blocking tasks running
skamril Oct 29, 2024
f035d03
feat(ui-ts): change form default values
skamril Oct 30, 2024
b757c94
feat(ui-ts): add rule for number value
skamril Oct 30, 2024
79a561e
fix(ui-study): issue with WS event for tasks update
skamril Nov 6, 2024
423008d
refactor(ui-ws): code review
skamril Nov 6, 2024
f5f6f81
feat(ui-i18n): correct french keys
skamril Nov 6, 2024
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: 2 additions & 0 deletions antarest/core/tasks/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class CustomTaskEventMessages(AntaresBaseModel, extra="forbid"):
class TaskEventPayload(AntaresBaseModel, extra="forbid"):
id: str
message: str
type: TaskType
study_id: t.Optional[str] = None


class TaskDTO(AntaresBaseModel, extra="forbid"):
Expand Down
14 changes: 13 additions & 1 deletion antarest/core/tasks/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ def _launch_task(
message=custom_event_messages.start
if custom_event_messages is not None
else f"Task {task.id} added",
type=task.type,
study_id=task.ref_id,
).model_dump(),
permissions=PermissionInfo(owner=request_params.user.impersonator),
)
Expand Down Expand Up @@ -389,6 +391,10 @@ def _run_task(
custom_event_messages: t.Optional[CustomTaskEventMessages] = None,
) -> None:
# attention: this function is executed in a thread, not in the main process
with db():
task = db.session.query(TaskJob).get(task_id)
task_type = task.type
study_id = task.ref_id

self.event_bus.push(
Event(
Expand All @@ -398,6 +404,8 @@ def _run_task(
message=custom_event_messages.running
if custom_event_messages is not None
else f"Task {task_id} is running",
type=task_type,
study_id=study_id,
).model_dump(),
permissions=PermissionInfo(public_mode=PublicMode.READ),
channel=EventChannelDirectory.TASK + task_id,
Expand Down Expand Up @@ -444,6 +452,8 @@ def _run_task(
if custom_event_messages is not None
else f"Task {task_id} {event_msg}"
),
type=task_type,
study_id=study_id,
).model_dump(),
permissions=PermissionInfo(public_mode=PublicMode.READ),
channel=EventChannelDirectory.TASK + task_id,
Expand All @@ -469,7 +479,9 @@ def _run_task(
self.event_bus.push(
Event(
type=EventType.TASK_FAILED,
payload=TaskEventPayload(id=task_id, message=message).model_dump(),
payload=TaskEventPayload(
id=task_id, message=message, type=task_type, study_id=study_id
).model_dump(),
permissions=PermissionInfo(public_mode=PublicMode.READ),
channel=EventChannelDirectory.TASK + task_id,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def action_fail(notifier: ITaskNotifier) -> TaskResult:
failed_id = service.add_task(
action_fail,
"failed action",
None,
TaskType.COPY,
None,
None,
None,
Expand Down Expand Up @@ -172,7 +172,7 @@ def action_ok(notifier: ITaskNotifier) -> TaskResult:
ok_id = service.add_task(
action_ok,
None,
None,
TaskType.COPY,
None,
None,
None,
Expand Down
26 changes: 16 additions & 10 deletions webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"global.enabled": "Enabled",
"global.close": "Close",
"global.replace": "Replace",
"global.status": "Status",
"global.time.hourly": "Hourly",
"global.time.daily": "Daily",
"global.time.weekly": "Weekly",
Expand Down Expand Up @@ -164,15 +165,15 @@
"tasks.scan": "Scan",
"tasks.typeFilter": "Filter by type",
"tasks.runningTasks": "Running tasks",
"tasks.all": "All",
"tasks.DOWNLOAD": "Download",
"tasks.LAUNCH": "Launch",
"tasks.COPY": "Copy",
"tasks.ARCHIVE": "Archive",
"tasks.UPGRADE_STUDY": "Upgrade",
"tasks.UNARCHIVE": "Unarchive",
"tasks.SCAN": "Scan",
"tasks.UNKNOWN": "Unknown",
"tasks.type.DOWNLOAD": "Download",
"tasks.type.LAUNCH": "Launch",
"tasks.type.COPY": "Copy",
"tasks.type.ARCHIVE": "Archive",
"tasks.type.UPGRADE_STUDY": "Upgrade",
"tasks.type.UNARCHIVE": "Unarchive",
"tasks.type.SCAN": "Scan",
"tasks.type.UNKNOWN": "Unknown",
"tasks.type.THERMAL_CLUSTER_SERIES_GENERATION": "TS Generation",
"settings.createUser": "Create user",
"settings.createToken": "Create token",
"settings.createGroup": "Create group",
Expand Down Expand Up @@ -363,6 +364,12 @@
"study.configuration.general.thematicTrimming.group.generationThermals": "Generation / Thermals",
"study.configuration.general.thematicTrimming.group.links": "Links",
"study.configuration.general.filtering": "Filtering",
"study.configuration.tsManagement.numberStochasticTs": "Number Stochastic TS",
"study.configuration.tsManagement.status.toBeGenerated": "To Be Generated",
"study.configuration.tsManagement.status.readyMade": "Ready Made",
"study.configuration.tsManagement.generateTs": "Generate TS",
"study.configuration.tsManagement.generateTs.error": "Failed to run generate TS task",
"study.configuration.tsManagement.generateTs.pending": "Launch of the TS generation task...",
"study.configuration.optimization.legend.general": "General",
"study.configuration.optimization.legend.links": "Links",
"study.configuration.optimization.legend.thermalClusters": "Thermal Clusters",
Expand Down Expand Up @@ -572,7 +579,6 @@
"study.success.deleteConstraint": "Binding constraint deleted successfully",
"study.success.addCluster": "Cluster added successfully",
"study.success.deleteCluster": "Cluster deleted successfully",
"study.message.upgradeInProgress": "Running study upgrade",
"study.message.outputExportInProgress": "Downloading study outputs...",
"study.question.deleteLink": "Are you sure you want to delete this link?",
"study.question.deleteArea": "Are you sure you want to delete this area?",
Expand Down
26 changes: 16 additions & 10 deletions webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"global.enabled": "Activé",
"global.close": "Fermer",
"global.replace": "Remplacer",
"global.status": "Statut",
"global.time.hourly": "Horaire",
"global.time.daily": "Journalier",
"global.time.weekly": "Hebdomadaire",
Expand Down Expand Up @@ -164,15 +165,15 @@
"tasks.scan": "Scan",
"tasks.typeFilter": "Filtrer par type",
"tasks.runningTasks": "Tâches en cours",
"tasks.all": "Tous",
"tasks.DOWNLOAD": "Téléchargement",
"tasks.LAUNCH": "Lancement",
"tasks.COPY": "Copie",
"tasks.ARCHIVE": "Archivage",
"tasks.UPGRADE_STUDY": "Mise à jour",
"tasks.UNARCHIVE": "Désarchivage",
"tasks.SCAN": "Scan",
"tasks.UNKNOWN": "Inconnu",
"tasks.type.DOWNLOAD": "Téléchargement",
"tasks.type.LAUNCH": "Lancement",
"tasks.type.COPY": "Copie",
"tasks.type.ARCHIVE": "Archivage",
"tasks.type.UPGRADE_STUDY": "Mise à jour",
"tasks.type.UNARCHIVE": "Désarchivage",
"tasks.type.SCAN": "Scan",
"tasks.type.UNKNOWN": "Inconnu",
"tasks.type.THERMAL_CLUSTER_SERIES_GENERATION": "Génération des TS",
skamril marked this conversation as resolved.
Show resolved Hide resolved
"settings.createUser": "Créer un utilisateur",
"settings.createToken": "Créer un token",
"settings.createGroup": "Créer un groupe",
Expand Down Expand Up @@ -363,6 +364,12 @@
"study.configuration.general.thematicTrimming.group.generationThermals": "Génération / Thermiques",
"study.configuration.general.thematicTrimming.group.links": "Liens",
"study.configuration.general.filtering": "Filtering",
"study.configuration.tsManagement.numberStochasticTs": "Nombre stochastique TS",
"study.configuration.tsManagement.status.toBeGenerated": "À générer",
"study.configuration.tsManagement.status.readyMade": "Prête à l'emploi",
"study.configuration.tsManagement.generateTs": "Générer les TS",
"study.configuration.tsManagement.generateTs.error": "Échec de l'exécution de la tâche de génération des TS",
"study.configuration.tsManagement.generateTs.pending": "Lancement de la tâche de génération des TS...",
"study.configuration.optimization.legend.general": "Générale",
"study.configuration.optimization.legend.links": "Liens",
"study.configuration.optimization.legend.thermalClusters": "Cluster thermiques",
Expand Down Expand Up @@ -572,7 +579,6 @@
"study.success.deleteConstraint": "Contrainte couplante supprimée avec succès",
"study.success.addCluster": "Cluster créé avec succès",
"study.success.deleteCluster": "Cluster supprimé avec succès",
"study.message.upgradeInProgress": "Mise à jour de l'étude en cours",
"study.message.outputExportInProgress": "Téléchargement des sorties en cours...",
"study.question.deleteLink": "Êtes-vous sûr de vouloir supprimer ce lien ?",
"study.question.deleteArea": "Êtes-vous sûr de vouloir supprimer cette zone ?",
Expand Down
104 changes: 6 additions & 98 deletions webapp/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* This file is part of the Antares project.
*/

import { ReactNode } from "react";
import type { TTaskType } from "../services/api/tasks/types";

export type IdType = number | string;

Expand All @@ -30,12 +30,6 @@ export interface GenericInfo {
name: string;
}

export interface StudySummary {
id: string;
name: string;
workspace: string;
}

export interface SynthesisSummary {
study_id: string;
}
Expand Down Expand Up @@ -314,42 +308,7 @@ export interface CommandDTO {
args: object;
}

export enum WSEvent {
STUDY_CREATED = "STUDY_CREATED",
STUDY_DELETED = "STUDY_DELETED",
STUDY_EDITED = "STUDY_EDITED",
STUDY_DATA_EDITED = "STUDY_DATA_EDITED",
STUDY_JOB_STARTED = "STUDY_JOB_STARTED",
STUDY_JOB_LOG_UPDATE = "STUDY_JOB_LOG_UPDATE",
STUDY_JOB_COMPLETED = "STUDY_JOB_COMPLETED",
STUDY_JOB_STATUS_UPDATE = "STUDY_JOB_STATUS_UPDATE",
STUDY_VARIANT_GENERATION_COMMAND_RESULT = "STUDY_VARIANT_GENERATION_COMMAND_RESULT",
TASK_ADDED = "TASK_ADDED",
TASK_RUNNING = "TASK_RUNNING",
TASK_COMPLETED = "TASK_COMPLETED",
TASK_FAILED = "TASK_FAILED",
DOWNLOAD_CREATED = "DOWNLOAD_CREATED",
DOWNLOAD_READY = "DOWNLOAD_READY",
DOWNLOAD_EXPIRED = "DOWNLOAD_EXPIRED",
DOWNLOAD_FAILED = "DOWNLOAD_FAILED",
MESSAGE_INFO = "MESSAGE_INFO",
MAINTENANCE_MODE = "MAINTENANCE_MODE",
LAUNCH_PROGRESS = "LAUNCH_PROGRESS",
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface WSMessage<T = any> {
type: string;
payload: T;
}

export interface WSLogMessage {
log: string;
job_id: string;
study_id: string;
}

export type Components = Record<string, () => ReactNode>;
export type Components = Record<string, () => React.ReactNode>;

export interface CommandResultDTO {
study_id: string;
Expand All @@ -358,57 +317,6 @@ export interface CommandResultDTO {
message: string;
}

export interface TaskResult {
success: boolean;
message: string;
return_value?: string;
}

export interface TaskLogDTO {
id: string;
message: string;
}

export enum TaskStatus {
PENDING = 1,
RUNNING = 2,
COMPLETED = 3,
FAILED = 4,
TIMEOUT = 5,
CANCELLED = 6,
}

export enum TaskType {
LAUNCH = "LAUNCH",
EXPORT = "EXPORT",
VARIANT_GENERATION = "VARIANT_GENERATION",
COPY = "COPY",
ARCHIVE = "ARCHIVE",
UNARCHIVE = "UNARCHIVE",
DOWNLOAD = "DOWNLOAD",
SCAN = "SCAN",
UPGRADE_STUDY = "UPGRADE_STUDY",
UNKNOWN = "UNKNOWN",
}

export interface TaskDTO extends IdentityDTO<string> {
id: string;
name: string;
owner?: number;
status: TaskStatus;
creation_date_utc: string;
completion_date_utc?: string;
result?: TaskResult;
logs?: TaskLogDTO[];
type?: TaskType;
ref_id?: string;
}

export interface TaskEventPayload {
id: string;
message: string;
}

export interface Cluster {
id: string;
name: string;
Expand Down Expand Up @@ -652,11 +560,11 @@ export interface AreaInfoDTO extends AreaCreationDTO {

export interface TaskView {
id: string;
name: ReactNode;
dateView: ReactNode;
action: ReactNode;
name: React.ReactNode;
dateView: React.ReactNode;
action: React.ReactNode;
date: string;
type: TaskType;
type: TTaskType | "DOWNLOAD" | "LAUNCH" | "UNKNOWN";
status: string;
}
skamril marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Loading
Loading