Skip to content

Commit

Permalink
trimmed job related callbacks and layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
TibbersHao committed Mar 28, 2024
1 parent 6929433 commit 47f984e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 122 deletions.
8 changes: 0 additions & 8 deletions content-regist/src/app_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,6 @@ def dash_forms(type):
children=[
dbc.CardBody(
[
dbc.Button(
"Launch the Selected",
id="button-launch",
className="mtb-2",
color="success",
size="sm",
n_clicks=0,
),
dbc.Button(
"Delete the Selected",
id="button-delete",
Expand Down
96 changes: 0 additions & 96 deletions content-regist/src/content_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import uuid

import dash_bootstrap_components as dbc
import requests
from app_layout import ContentVariables, app, dash_forms, data_uploader
from dash import ALL, MATCH, Input, Output, State, ctx, dcc, html
from dash_component_editor import JSONParameterEditor
Expand All @@ -20,11 +19,9 @@
)
from registry_util import (
conn_mongodb,
get_content,
get_content_list,
get_dash_table_data,
get_dropdown_options,
job_content_dict,
remove_key_from_dict_list,
send_webhook,
validate_json,
Expand Down Expand Up @@ -645,99 +642,6 @@ def show_gui_layouts_validation(n_clicks, data):
return [""]


# ---------------------------------- launch jobs ------------------------------------------
@app.callback(
Output("dummy", "data"),
Input("button-launch", "n_clicks"),
State("table-contents-memo", "data"),
State("table-model-list", "selected_rows"),
State("table-job-memo", "data"),
State("tab-group", "value"),
prevent_initial_call=True,
)
def apps_jobs(n_clicks, data, rows, job_data, tab_value):
user_id = "001"
changed_id = [p["prop_id"] for p in ctx.triggered][0]
if "button-launch.n_clicks" in changed_id:
job_request = {
"user_uid": user_id,
"host_list": [
"mlsandbox.als.lbl.gov",
"local.als.lbl.gov",
"vaughan.als.lbl.gov",
],
"requirements": {"num_processors": 2, "num_gpus": 0, "num_nodes": 2},
}

job_list = []
dependency = {}
job_names = ""
if tab_value == "workflow":
if rows:
for row in rows:
job_list = []
dependency = {}
print(f"data[row] {data[row]}")
if "workflow_list" in data[row]:
workflow_list = data[row]["workflow_list"]
for i, job_id in enumerate(workflow_list):
job_list.append(
job_content_dict(get_content(job_id), user_id)
)
print(f"job_list {job_list}")
dependency[str(i)] = []
if data[row]["workflow_type"] == "serial":
for j in range(i):
dependency[str(i)].append(j)

job_request["job_list"] = job_list
job_request["dependencies"] = dependency
job_request["description"] = (
data[row]["name"] + " v" + data[row]["version"]
)
if len(job_list) == 1:
job_request["requirements"]["num_nodes"] = 1
response = requests.post(
"http://job-service:8080/api/v0/workflows", json=job_request
)
print(f"workflow response {response}")

elif tab_value == "model" or tab_value == "app":
if rows:
for i, row in enumerate(rows):
job_content = job_content_dict(data[row], user_id)
job_list.append(job_content)
dependency[str(i)] = (
[]
) # all modes and apps are regarded as independent at this time
job_names += job_content["mlex_app"] + ", "

job_request["job_list"] = job_list
job_request["dependencies"] = dependency
job_request["description"] = "parallel workflow: " + job_names
if len(job_list) == 1:
job_request["requirements"]["num_nodes"] = 1
response = requests.post(
"http://job-service:8080/api/v0/workflows", json=job_request
)
print(f"model/app response {response}")
return ""


app.clientside_callback(
"""
function(web_urls) {
for (let i = 0; i < web_urls.length; i++) {
window.open(web_urls[i]);
}
return '';
}
""",
Output("dummy1", "data"),
Input("web-urls", "data"),
)


if __name__ == "__main__":
app.run_server(host="0.0.0.0", port=8051, debug=True)
print("model registry is up running!")
18 changes: 0 additions & 18 deletions content-regist/src/registry_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,6 @@ def workflow_dependency(workflow):
return workflow_list, dependency


def job_content_dict(content, user_id):
job_content = {
"mlex_app": content["name"],
"service_type": content["service_type"],
"working_directory": f"{WORKING_DIR}",
"job_kwargs": {"uri": content["uri"], "cmd": content["cmd"][0]},
}
if "map" in content:
job_content["job_kwargs"]["map"] = content["map"]

if "container_kwargs" in content:
job_content["job_kwargs"]["container_kwargs"] = {
"environment": [f"DATA_DIR={WORKING_DIR}"]
}

return job_content


def send_webhook(msg):
"""
Send a webhook to a specified URL
Expand Down

0 comments on commit 47f984e

Please sign in to comment.