Skip to content

Commit 5bdca7d

Browse files
authored
handle job notes as both json and string (#1664)
1 parent d58c2b8 commit 5bdca7d

File tree

3 files changed

+41
-19
lines changed

3 files changed

+41
-19
lines changed

client/modules/_hooks/src/workspace/types.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ export type TAppFileInput = {
5252
targetPath?: string;
5353
};
5454

55+
type TAppNotes = {
56+
label?: string;
57+
shortLabel?: string;
58+
helpUrl?: string;
59+
category?: string;
60+
isInteractive?: boolean;
61+
hideNodeCountAndCoresPerNode?: boolean;
62+
icon?: string;
63+
dynamicExecSystems?: string[];
64+
queueFilter?: string[];
65+
hideQueue?: boolean;
66+
hideAllocation?: boolean;
67+
hideMaxMinutes?: boolean;
68+
jobLaunchDescription?: string;
69+
showReservation?: boolean;
70+
showTargetPath?: boolean;
71+
};
72+
5573
export type TTapisApp = {
5674
sharedAppCtx: string;
5775
isPublic: boolean;
@@ -111,22 +129,7 @@ export type TTapisApp = {
111129
tags: string[];
112130
};
113131
tags: string[];
114-
notes: {
115-
label?: string;
116-
shortLabel?: string;
117-
helpUrl?: string;
118-
category?: string;
119-
isInteractive?: boolean;
120-
hideNodeCountAndCoresPerNode?: boolean;
121-
icon?: string;
122-
dynamicExecSystems?: string[];
123-
queueFilter?: string[];
124-
hideQueue?: boolean;
125-
hideAllocation?: boolean;
126-
hideMaxMinutes?: boolean;
127-
jobLaunchDescription?: string;
128-
showReservation?: boolean;
129-
};
132+
notes: TAppNotes;
130133
uuid: string;
131134
deleted: boolean;
132135
created: string;
@@ -183,7 +186,7 @@ export type TTapisJob = {
183186
mpiCmd?: string;
184187
name: string;
185188
nodeCount: number;
186-
notes: string;
189+
notes: TAppNotes;
187190
owner: string;
188191
parameterSet: string;
189192
remoteChecksFailed: number;

client/modules/workspace/src/JobsDetailModal/JobsDetailModal.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,12 @@ export const JobsDetailModal: React.FC<{ uuid: string }> = ({ uuid }) => {
304304
<dt>Job UUID: </dt>
305305
<dd>{jobData.uuid}</dd>
306306
<dt>Application: </dt>
307-
<dd>{JSON.parse(jobData.notes).label || jobData.appId}</dd>
307+
<dd>
308+
{(typeof jobData.notes === 'string'
309+
? JSON.parse(jobData.notes)
310+
: jobData.notes
311+
).label || jobData.appId}
312+
</dd>
308313
<dt>System: </dt>
309314
<dd>{jobData.execSystemId}</dd>
310315
</dl>

designsafe/apps/workspace/api/utils.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Workspace API Utils"""
22

33
import json
4+
from typing import Union
5+
from tapipy.tapis import TapisResult
46

57

68
def get_tapis_timeout_error_messages(job_id):
@@ -11,14 +13,26 @@ def get_tapis_timeout_error_messages(job_id):
1113
]
1214

1315

16+
def _get_job_notes(job_notes: Union[str, TapisResult]):
17+
"""
18+
Normalize `job.notes` as in older version of Tapis `notes` is a JSON-formatted string
19+
but this is being changed to a TapisResult object. Once all tenants are migrated to
20+
return structured (non-string) 'notes', this can be
21+
removed
22+
"""
23+
if isinstance(job_notes, str):
24+
return json.loads(job_notes)
25+
return job_notes
26+
27+
1428
def check_job_for_timeout(job):
1529
"""
1630
Check an interactive job for timeout status and mark it as finished
1731
since Tapis does not have native support for interactive jobs yet
1832
"""
1933

2034
if hasattr(job, "notes"):
21-
notes = json.loads(job.notes)
35+
notes = _get_job_notes(job.notes)
2236

2337
is_failed = job.status == "FAILED"
2438
is_interactive = notes.get("isInteractive", False)

0 commit comments

Comments
 (0)