Skip to content

Commit 6755af8

Browse files
author
Ceyda Cinarel
committed
make config optional update version
1 parent 466908c commit 6755af8

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,27 @@ Related blog [post](https://cceyda.github.io/blog/torchserve/streamlit/dashboard
88

99
# Usage
1010
Additional Requirement:
11-
[torchserve](https://github.com/pytorch/serve/tree/v0.2.0#install-torchserve) (recommended:v0.2 | works on v0.3(untested))
11+
[torchserve](https://github.com/pytorch/serve/tree/v0.3.1#install-torchserve-and-torch-model-archiver) (recommended:v0.3.1)
1212

1313
Simply run:
1414

1515
```bash
1616
pip3 install torchserve-dashboard --user
17-
# torchserve-dashboard [streamlit_options] -- [config_path] [model_store(optional)] [log_location(optional)] [metrics_location(optional)]
18-
torchserve-dashboard --server.port 8105 -- --config_path ./torchserve.properties --model_store ./model_store
17+
# torchserve-dashboard [streamlit_options(optional)] -- [config_path(optional)] [model_store(optional)] [log_location(optional)] [metrics_location(optional)]
18+
torchserve-dashboard
19+
#OR change port
20+
torchserve-dashboard --server.port 8105 -- --config_path ./torchserve.properties
21+
#OR provide a custom configuration
22+
torchserve-dashboard -- --config_path ./torchserve.properties --model_store ./model_store
1923
```
2024

2125
:exclamation: Keep in mind that If you change any of the `--config_path`,`--model_store`,`--metrics_location`,`--log_location` options while there is a torchserver already running before starting torch-dashboard they won't come into effect until you stop&start torchserve.
2226

2327
OR
2428
```bash
2529
git clone https://github.com/cceyda/torchserve-dashboard.git
30+
streamlit run torchserve_dashboard/dash.py
31+
#OR
2632
streamlit run torchserve_dashboard/dash.py --server.port 8105 -- --config_path ./torchserve.properties
2733
```
2834
Example torchserve [config](https://pytorch.org/serve/configuration.html):
@@ -35,16 +41,19 @@ grpc_inference_port=7070
3541
grpc_management_port=7071
3642
number_of_gpu=0
3743
batch_size=1
38-
model_store=/mnt/pretrained/model_store
44+
model_store=./model_store
3945
```
4046

4147
If the server doesn't start for some reason check if your ports are already in use!
4248

4349
# Updates
50+
4451
[15-oct-2020] add [scale workers](https://pytorch.org/serve/management_api.html#scale-workers) tab
4552

4653
[16-feb-2021] (functionality) make logpath configurable,(functionality)remove model_name requirement,(UI)add cosmetic error messages
4754

55+
[10-may-2021] update config & make it optional. update streamlit. Auto create folders
56+
4857
# FAQs
4958
- **Does torchserver keep running in the background?**
5059

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name="torchserve_dashboard",
10-
version="v0.2.5",
10+
version="v0.3.1",
1111
url="https://github.com/cceyda/torchserve-dashboard",
1212
license="Apache Software License 2.0",
1313
author="Ceyda Cinarel",

torchserve_dashboard/dash.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
parser = argparse.ArgumentParser(description="Torchserve dashboard")
1919

2020
parser.add_argument(
21-
"--model_store", default=None, help="Directory where your models are stored"
21+
"--model_store", default=None, help="Directory where your models are stored (overrides config)"
2222
)
2323
parser.add_argument(
2424
"--config_path",
25-
default="./default.torchserve.properties",
25+
default="./torchserve.properties",
2626
help="Torchserve config path",
2727
)
2828
parser.add_argument(
@@ -42,6 +42,7 @@
4242

4343
st.title("Torchserve Management Dashboard")
4444

45+
4546
M_API = "http://127.0.0.1:8081"
4647
model_store = args.model_store
4748
config_path = args.config_path
@@ -54,8 +55,12 @@
5455
config = None
5556
default_key = "None"
5657

57-
if os.path.exists(args.config_path):
58-
config = open(args.config_path, "r").readlines()
58+
if not os.path.exists(config_path):
59+
st.write(f"Can't find config file at {config_path}. Using default config instead")
60+
config_path = os.path.join(os.path.dirname(__file__),"default.torchserve.properties")
61+
62+
if os.path.exists(config_path):
63+
config = open(config_path, "r").readlines()
5964
for c in config:
6065
if c.startswith("model_store"):
6166
if not model_store:
@@ -64,9 +69,13 @@
6469
M_API = c.split("=")[-1].strip()
6570

6671
if model_store is None:
67-
st.write("model_store is required!")
68-
69-
72+
st.write(f"model_store is required!")
73+
st.stop()
74+
75+
if not os.path.isdir(model_store):
76+
st.write(f"Created model store directory {model_store}")
77+
os.makedirs(model_store, exist_ok=True)
78+
7079
def rerun():
7180
raise RerunException(RerunData(None))
7281

@@ -133,7 +142,7 @@ def get_model_store():
133142
"Choose mar file *", [default_key] + stored_models, index=0
134143
)
135144
# mar_path = os.path.join(model_store,mar_path)
136-
p = st.checkbox("or use another path")
145+
p = st.checkbox("manually enter path")
137146
if p:
138147
mar_path = placeholder.text_input("Input mar file path*")
139148
model_name = st.text_input(label="Model name (overrides predefined)")

torchserve_dashboard/default.torchserve.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ management_address=http://127.0.0.1:8444
33
metrics_address=http://127.0.0.1:8445
44
number_of_gpu=0
55
batch_size=1
6-
model_store=/mnt/pretrained/model_store
6+
model_store=./model_store
77
grpc_inference_port=7070
88
grpc_management_port=7071
99
#install_py_dep_per_model=true

0 commit comments

Comments
 (0)