Skip to content

Commit

Permalink
Update GUI code to reflect recent config/data changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaskom committed Feb 20, 2024
1 parent 88d78a4 commit c33e8e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Deploy the training backend with three business functions (`launch`, `train`, `c

```bash
modal deploy src
modal run src.gui
modal run src.gui --config=... --data=...
```

The `*.modal.host` link from the latter will take you to the Gradio GUI. There will be three tabs: launch training runs, test out trained models and explore the files on the volume.
Expand Down
24 changes: 11 additions & 13 deletions src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def jobs_table():

return md

def launch_training_job(config_yml, my_data_jsonl):
run_folder, handle = launch.remote(config_yml, my_data_jsonl)
def launch_training_job(config_yml, data_jsonl):
run_folder, handle = launch.remote(config_yml, data_jsonl)
result = (
f"Started training run in folder {run_folder}.\n\n"
f"Follow training logs at https://modal.com/logs/call/{handle.object_id}\n"
Expand Down Expand Up @@ -79,7 +79,7 @@ def model_changed(model):
run_folder = f"/runs/{model.split('@')[0]}"
with (
open(f"{run_folder}/config.yml", "r") as config,
open(f"{run_folder}/my_data.jsonl", "r") as data,
open(f"{run_folder}/data.jsonl", "r") as data,
):
return config.read(), data.read()
except (AttributeError, FileNotFoundError):
Expand Down Expand Up @@ -109,9 +109,7 @@ def get_model_choices():
label="config.yml", lines=20, value=config_raw
)
with gr.Tab("Data (JSONL)"):
data_input = gr.Code(
label="my_data.jsonl", lines=20, value=data_raw
)
data_input = gr.Code(label="data.jsonl", lines=20, value=data_raw)
with gr.Column():
with gr.Group():
train_button = gr.Button(
Expand All @@ -138,7 +136,7 @@ def get_model_choices():
with gr.Tab("Config (YAML)"):
model_config = gr.Code(label="config.yml", lines=20)
with gr.Tab("Data (JSONL)"):
model_data = gr.Code(label="my_data.jsonl", lines=20)
model_data = gr.Code(label="data.jsonl", lines=20)

with gr.Column():
input_text = gr.Textbox(
Expand Down Expand Up @@ -174,12 +172,12 @@ def get_model_choices():


@stub.local_entrypoint()
def main():
parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
with open(f"{parent}/config/mixtral.yml", "r") as cfg, open(
f"{parent}/data/sqlqa.jsonl", "r"
) as data:
handle = gui.spawn(cfg.read(), data.read())
def main(
config: str,
data: str,
):
with open(config, "r") as cfg, open(data, "r") as dat:
handle = gui.spawn(cfg.read(), dat.read())
url = stub.q.get()
print(f"GUI available at -> {url}\n")
webbrowser.open(url)
Expand Down

0 comments on commit c33e8e5

Please sign in to comment.