Skip to content

Commit 0c9689e

Browse files
committed
mock_jobs.json
1 parent 201e531 commit 0c9689e

File tree

2 files changed

+77
-22
lines changed

2 files changed

+77
-22
lines changed

services/static-webserver/client/source/class/osparc/store/Jobs.js

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
1616
************************************************************************ */
1717

18+
/**
19+
* @asset(osparc/mock_jobs.json")
20+
*/
21+
1822
qx.Class.define("osparc.store.Jobs", {
1923
extend: qx.core.Object,
2024
type: "singleton",
@@ -30,42 +34,44 @@ qx.Class.define("osparc.store.Jobs", {
3034

3135
members: {
3236
fetchJobs: function() {
33-
return osparc.data.Resources.get("jobs")
37+
return osparc.utils.Utils.fetchJSON("/resource/osparc/mock_jobs.json")
38+
.then(jobsData => {
39+
const jobs = [];
40+
if ("jobs" in jobsData) {
41+
jobsData.forEach(jobData => {
42+
const job = this.addJob(jobData);
43+
if (job) {
44+
jobs.push(job);
45+
}
46+
});
47+
}
48+
return jobs;
49+
})
50+
.catch(err => console.error(err));
51+
},
52+
53+
fetchJobInfo: function(jobId) {
54+
return osparc.utils.Utils.fetchJSON("/resource/osparc/mock_jobs.json")
3455
.then(jobsData => {
35-
jobsData.forEach(jobData => {
36-
const interval = 1000;
37-
this.addJob(jobData, interval);
38-
});
56+
if ("jobs_info" in jobsData && jobId in jobsData["jobs_info"]) {
57+
return jobsData["jobs_info"][jobId];
58+
}
59+
return null;
3960
})
4061
.catch(err => console.error(err));
4162
},
4263

43-
addJob: function(jobData, interval = 1000) {
64+
addJob: function(jobData) {
4465
const jobs = this.getJobs();
4566
const index = jobs.findIndex(t => t.getJobId() === jobData["job_id"]);
4667
if (index === -1) {
47-
const job = new osparc.data.Job(jobData, interval);
68+
const job = new osparc.data.Job(jobData);
4869
jobs.push(job);
4970
return job;
5071
}
5172
return null;
5273
},
5374

54-
createJob: function(fetchPromise, interval) {
55-
return new Promise((resolve, reject) => {
56-
fetchPromise
57-
.then(jobData => {
58-
if ("status_href" in jobData) {
59-
const job = this.addJob(jobData, interval);
60-
resolve(job);
61-
} else {
62-
throw Error("Status missing");
63-
}
64-
})
65-
.catch(err => reject(err));
66-
});
67-
},
68-
6975
removeJobs: function() {
7076
const jobs = this.getJobs();
7177
jobs.forEach(job => job.dispose());
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"jobs": [{
3+
"job_id": "0cde4607-07de-4bb5-b3e6-487f22387a70",
4+
"solver": "isolve:2.4.12",
5+
"status": "PUBLISHED",
6+
"progress": 0,
7+
"submitted_at": "2024-11-27 14:03:17.357523",
8+
"started_at": null,
9+
"instance": "p5.8xlarge"
10+
}, {
11+
"job_id": "5685a699-4927-479e-9b34-e5ab1616303a",
12+
"solver": "fenics:1.0.4",
13+
"status": "WAITING FOR RESOURCES",
14+
"progress": 2,
15+
"submitted_at": "2024-11-27 14:03:17.413844",
16+
"started_at": "2024-11-27 16:03:17.413844",
17+
"instance": "p5.8xlarge"
18+
}, {
19+
"job_id": "a8ca6a02-8816-48a6-8c6b-b94b3e431c8c",
20+
"solver": "isolve:2.4.12",
21+
"status": "WAITING FOR CLUSTER",
22+
"progress": 0,
23+
"submitted_at": "2024-11-27 14:03:17.357523",
24+
"started_at": null,
25+
"instance": "p5.8xlarge"
26+
}, {
27+
"job_id": "a8ca6a02-8816-48a6-8c6b-b94b3e431c8d",
28+
"solver": "sleeper:2.1.2",
29+
"status": "STARTED",
30+
"progress": 50,
31+
"submitted_at": "2024-11-27 14:03:17.357523",
32+
"started_at": "2024-11-27 14:03:17.357523",
33+
"instance": "p5.8xlarge"
34+
}],
35+
"jobs_info": {
36+
"a8ca6a02-8816-48a6-8c6b-b94b3e431c8d": {
37+
"parent_project_id" : "522f544a-1e05-461e-82ed-e26806e4640d",
38+
"parent_project": "My Project",
39+
"job_id": "a8ca6a02-8816-48a6-8c6b-b94b3e431c8d",
40+
"job_name": "EM",
41+
"log_state": 3,
42+
"solver_key": "simcore/services/comp/sleeper",
43+
"solver_version": "2.1.2",
44+
"version_display" : "The latest",
45+
"input_file_path": "/home/user/balh_blah_a8ca6a02-8816-48a6-8c6b-b94b3e431c8d_Input.h5",
46+
"internal_job_id": "19b883a4-8407-4b81-9c5b-abe5a7f42bc8"
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)