Skip to content

Commit

Permalink
queue jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
joglekara committed Nov 13, 2024
1 parent e9ff8ca commit 4453cea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
8 changes: 5 additions & 3 deletions mambaenv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ dependencies:
- python=3.12
- git
- pip
- pyhdf
- mlflow
- numpy
- streamlit
- boto3
# install pip requirements
- pip:
- git+https://github.com/ergodicio/tsadar.git
# - pip:
# - git+https://github.com/ergodicio/tsadar.git
45 changes: 20 additions & 25 deletions tsadar_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
config.update("jax_enable_x64", True)

import streamlit as st
import yaml, os, mlflow, tempfile
from flatten_dict import flatten, unflatten
import yaml, os, mlflow, tempfile, boto3

from tsadar_gui import config
from tsadar import run_for_app


def process_file(file_path):
Expand All @@ -26,28 +24,8 @@ def process_file(file_path):
config_dir = os.path.join(os.getcwd(), "temp")

os.makedirs(config_dir, exist_ok=True)
if mode == "file":
defaults = st.file_uploader("Upload the defaults file", type=["yaml", "yml"])
if defaults:
with open(os.path.join(config_dir, defaults.name), "wb") as f:
f.write(defaults.getvalue())

inputs = st.file_uploader("Upload the inputs file", type=["yaml", "yml"])
if inputs:
with open(os.path.join(config_dir, inputs.name), "wb") as f:
f.write(inputs.getvalue())

with open(os.path.join(config_dir, "defaults.yaml"), "r") as f:
defs = yaml.safe_load(f)

with open(os.path.join(config_dir, "inputs.yaml"), "r") as f:
inps = yaml.safe_load(f)

defaults = flatten(defs)
defaults.update(flatten(inps))
cfg = unflatten(defaults)

elif mode == "Home":
if mode == "Home":
st.header("Welcome to TSADARapp")
st.write(
"This web app is a Streamlit implementation of the [Thomson Scattering Analysis](https://www.github.com/ergodicio/inverse-thomson-scattering/) software [1]."
Expand Down Expand Up @@ -86,11 +64,28 @@ def process_file(file_path):
mlflow.log_artifacts(tempdir)
run_id = mlflow_run.info.run_id

# requests.post(
# "http://sciapi.continuum/queue-run",
# data={"jq_nm": "gpu", "jd_nm": "gpu", "job_name": "thomson", "run_type": "dm", "run_id": run_id},
# )
client = boto3.client("batch", region_name="us-east-1")

job_template = {
"jobQueue": "gpu",
"jobDefinition": "tsadar-gpu",
"jobName": "tsadar",
"parameters": {"run_id": run_id},
"retryStrategy": {
"attempts": 10,
"evaluateOnExit": [{"action": "RETRY", "onStatusReason": "Host EC2*"}],
},
}
submissionResult = client.submit_job(**job_template)
st.write(
f"The job is queued. The status and results can be found at the mlflow experiment {cfg["mlflow"]["experiment"]} and run id {run_id}. Email [email protected] if you have any trouble."
)

run_for_app(run_id)
# run_for_app(run_id)

st.sidebar.title("About")
## Add attribution
Expand Down

0 comments on commit 4453cea

Please sign in to comment.