Skip to content

Commit f1da6c2

Browse files
authored
Merge pull request #86 from qiuosier/job_monitor
Update README and remove unused code in job monitor
2 parents 3bcb13c + f42bad6 commit f1da6c2

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

jobs/flask_job_monitor/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Incubator project to augment the OCI console with useful functionality to support development of Data Science Jobs.
44

5+
This job monitor is a Python Flask app build on top of [Oracle ADS](https://docs.oracle.com/en-us/iaas/tools/ads-sdk/latest/index.html). It allows users to monitor the status and outputs of OCI data science job runs.
6+
7+
![Job Monitor UI](assets/images/job_monitor.png)
8+
9+
User can also see the job definition in YAML:
10+
![Job YAML](assets/images/job_yaml.png)
11+
512
## How to run
613
### Requirements
714
This tool requires `oci>=2.45.1` and `oracle-ads>=2.4.2`.
@@ -41,3 +48,20 @@ The following config can be used in the VS Code `launch.json` to launch the Flas
4148
"jinja": true
4249
},
4350
```
51+
52+
### UI Development
53+
If you would like to develop the UI (HTML and JavaScript) without OCI authentication, you can start the app in "Recording Mode" to cache the data to your local computer.
54+
55+
56+
"mocked" version of the Flask app:
57+
```
58+
OCI_PYTHON_SDK_NO_SERVICE_IMPORTS=1 FLASK_APP=job_monitor_mocked flask run
59+
```
60+
61+
The mocked version will use the cached data from the "mock" directory to render the web page.
62+
63+
The content of the "mocked" version can be generated by running the app in "Recording Mode":
64+
```
65+
OCI_PYTHON_SDK_NO_SERVICE_IMPORTS=1 RECORDING=1 FLASK_APP=job_monitor flask run
66+
```
67+
In this mode, the context of each API response is saved as pickle files in the "mock" directory. The files are named in the format of `{endpoint}/{identifier}.pickle`. This allow us to easily save real data from OCI for mocking purpose. Once the data is saved, we can simply switch to the mocked version work offline.
Loading
Loading

jobs/flask_job_monitor/job_monitor.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
1-
import inspect
21
import os
32
import oci
4-
import sys
53

64
from flask import Flask, render_template, jsonify
75
from ads.common.oci_resource import OCIResource
86
from ads.jobs import Job
97
from ads.jobs.builders.infrastructure.dsc_job import DataScienceJobRun
108

11-
import logging
12-
import json
13-
import time
149

15-
16-
cwd = os.path.dirname(__file__)
17-
if cwd not in sys.path:
18-
sys.path.append(cwd)
19-
from job_monitor_mocked import save_mocked_context
20-
21-
22-
# When RECORDING is set to true, the endpoint context will be saved as pickle for future mocking
23-
RECORDING = os.environ.get("RECORDING")
2410
app = Flask(__name__, template_folder=os.path.dirname(__file__))
2511
config = oci.config.from_file()
2612

@@ -57,8 +43,6 @@ def job_monitor(compartment_id=None, project_id=None):
5743
project_id=project_id,
5844
compartments=compartments,
5945
)
60-
if RECORDING:
61-
save_mocked_context(context, inspect.currentframe().f_code.co_name, compartment_id, project_id)
6246
return render_template(
6347
'job_monitor.html',
6448
**context
@@ -73,8 +57,6 @@ def list_projects(compartment_id):
7357
"compartment_id": compartment_id,
7458
"projects": [{"display_name": project.display_name, "ocid": project.id} for project in projects]
7559
}
76-
if RECORDING:
77-
save_mocked_context(context, inspect.currentframe().f_code.co_name, compartment_id)
7860
return jsonify(context)
7961

8062

@@ -107,8 +89,6 @@ def get_logs(job_run_ocid):
10789
"statusDetails": run.lifecycle_details,
10890
"stopped": True if run.lifecycle_state in DataScienceJobRun.TERMINAL_STATES else False
10991
}
110-
if RECORDING:
111-
save_mocked_context(context, inspect.currentframe().f_code.co_name, job_run_ocid)
11292
return jsonify(context)
11393

11494

0 commit comments

Comments
 (0)