Skip to content

Commit

Permalink
outsource startup to Controller init
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdai committed Sep 24, 2024
1 parent 9530f4f commit 0156d5a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions arc_finetuning_st/streamlit/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
from llama_index.core.tools.function_tool import async_to_sync

from arc_finetuning_st.streamlit.controller import Controller
from arc_finetuning_st.streamlit.startup import download_data

# startup
st.set_page_config(layout="wide")


@st.cache_resource
def startup() -> Tuple[Controller,]:
download_data()
# download_data()
controller = Controller()
return (controller,)

Expand Down
6 changes: 6 additions & 0 deletions arc_finetuning_st/streamlit/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from llama_index.llms.openai import OpenAI

from arc_finetuning_st.finetuning.finetuning_example import FineTuningExample
from arc_finetuning_st.streamlit.startup import download_data
from arc_finetuning_st.workflows.arc_task_solver import (
ARCTaskSolverWorkflow,
WorkflowOutput,
Expand All @@ -33,6 +34,11 @@ def __init__(self) -> None:
Path(__file__).parents[2].absolute(), "finetuning_examples"
)
self._finetuning_examples_path.mkdir(exist_ok=True, parents=True)
try:
listdir(self._data_path)
except FileNotFoundError:
# download data
download_data()

def reset(self) -> None:
# clear prediction
Expand Down
3 changes: 1 addition & 2 deletions arc_finetuning_st/streamlit/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@


def download_data() -> None:
ret = subprocess.run("; ".join(commands), capture_output=True, shell=True)
print(ret.stdout.decode())
subprocess.run("; ".join(commands), capture_output=True, shell=True)


if __name__ == "__main__":
Expand Down

0 comments on commit 0156d5a

Please sign in to comment.