Skip to content

Commit 46b9225

Browse files
author
Peter Gagarinov
committed
ML servers now uses a dedicated folder for running the notebooks in
1 parent 962c950 commit 46b9225

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

ml_server/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pytorch-CycleGAN-and-pix2pix
1+
_notebook_workspace
22
checkpoints
33
screenlog.0

ml_server/ml_server.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
from ray import serve
55
import signal
66
import sys
7-
import pathlib
7+
from pathlib import Path
88

9-
ML_SERVER_DIR = pathlib.Path(__file__).parent.absolute()
109

10+
ML_SERVER_DIR = Path(__file__).parent.absolute()
11+
NOTEBOOK_WORKING_DIR = ML_SERVER_DIR / "_notebook_workspace"
1112
logger = logging.getLogger(__name__)
1213
logger.setLevel(logging.INFO)
1314

@@ -37,6 +38,7 @@ def transfer_style(flask_request):
3738
notebook_path_or_url,
3839
all_param_dict["RESULTED_NOTEBOOK_PATH_OR_URL"],
3940
nb_param_dict,
41+
cwd=NOTEBOOK_WORKING_DIR,
4042
)
4143
_ = ray.get(obj_ref)
4244

@@ -55,6 +57,8 @@ def signal_handler(sig, frame):
5557
ray.shutdown()
5658
_ = ray.init(num_cpus=8, num_gpus=1)
5759

60+
Path.mkdir(NOTEBOOK_WORKING_DIR, exist_ok=True)
61+
5862
HTTP_OPTIONS = {"host": "0.0.0.0", "port": 8000}
5963

6064
client = serve.start(http_host=HTTP_OPTIONS["host"], http_port=HTTP_OPTIONS["port"])

0 commit comments

Comments
 (0)