Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiepeng committed Jul 15, 2024
1 parent 07c48e5 commit ac23c06
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 18 deletions.
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,4 @@ See `requirements.txt`

Save data as the `.pkl` or `.csv` files under `./data` directory. See `./data/Example`.

Put the `config.json` in the same directory, and specify the `columns` of the data in `config.json`. Check `./data/Example/config.json`.

### Debug

```bash
redis-server
python app.py
```

- Open `http://127.0.0.1:8050/` in a browser
Put the `info.json` in the same directory, and specify the `columns` of the data in `info.json`. Check `./data/Example/info.json`.
62 changes: 57 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
inputs={"is_modal_open": Input("modal-centered", "is_open")},
)
def on_modal_open(is_modal_open):
"""
Callback function to update the data path when the modal is opened.
Parameters:
- is_modal_open (bool): Whether the modal is open.
Returns:
- dict: A dictionary containing the data path.
"""
if not is_modal_open:
raise PreventUpdate

Expand Down Expand Up @@ -105,6 +114,16 @@ def on_modal_open(is_modal_open):
},
)
def on_path_change(data_path, unused_refresh):
"""
Callback function to update the case options and value when the data path changes.
Parameters:
- data_path (str): The path to the data directory.
- unused_refresh (int): The number of times the refresh button has been clicked.
Returns:
- dict: A dictionary containing the case options and value.
"""
config = load_config("./config.json")

stored_case = config.get("CASE", "")
Expand Down Expand Up @@ -152,6 +171,16 @@ def on_path_change(data_path, unused_refresh):
},
)
def on_case_change(case_val, data_path):
"""
Callback function to update the file options and value when the case changes.
Parameters:
- case_val (str): The name of the case.
- data_path (str): The path to the data directory.
Returns:
- dict: A dictionary containing the file options and value.
"""
config = load_config("./config.json")

stored_file = config.get("FILE", "")
Expand Down Expand Up @@ -229,7 +258,7 @@ def on_case_change(case_val, data_path):
"add_file_options": Output("file-add", "options"),
},
inputs={
"ok_modal": Input("ok-modal", "n_clicks"),
"unused_ok_modal": Input("ok-modal", "n_clicks"),
},
state={
"data_path": State("data-path-modal", "value"),
Expand All @@ -241,9 +270,23 @@ def on_case_change(case_val, data_path):
prevent_initial_call=True,
)
def on_modal_close(
ok_modal, data_path, case_val, file_value, file_options, current_file
unused_ok_modal, data_path, case_val, file_value, file_options, current_file
):

"""
Callback function to update the data path, test case, log file,
and current file when the modal is closed.
Parameters:
- unused_ok_modal (int): The number of times the OK button has been clicked.
- data_path (str): The path to the data directory.
- case_val (str): The name of the case.
- file_value (str): The value of the selected file.
- file_options (list): The list of file options.
- current_file (str): The current file.
Returns:
- dict: A dictionary containing the updated values.
"""
if not file_value:
raise PreventUpdate

Expand Down Expand Up @@ -283,11 +326,20 @@ def on_modal_close(
"modal_is_open": Output("modal-centered", "is_open", allow_duplicate=True),
},
inputs={
"select_modal": Input("select-button", "n_clicks"),
"unused_select_modal": Input("select-button", "n_clicks"),
},
prevent_initial_call=True,
)
def open_modal(select_modal):
def open_modal(unused_select_modal):
"""
Callback function to open the modal.
Parameters:
- unused_select_modal (int): The number of times the select button has been clicked.
Returns:
- dict: A dictionary containing the updated value for the modal's is_open property.
"""
return {"modal_is_open": True}


Expand Down
3 changes: 0 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@
import os
import json

# import pickle
import base64

import pandas as pd

from app_config import EXPIRATION, KEY_TYPES
from app_config import frame_cache

# from app_config import redis_instance


def load_config(json_file):
"""
Expand Down

0 comments on commit ac23c06

Please sign in to comment.