Skip to content

Commit a6fd02e

Browse files
authored
Merge pull request #21 from johnaohara/grpc
Added gRPC endpoint and python client
2 parents 2408431 + a640591 commit a6fd02e

16 files changed

+1160
-168
lines changed

Dockerfile.hpo

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ WORKDIR /opt/app
2525

2626
# Install packages needed for python to function correctly
2727
# Create the non root user, same as the one used in the build phase.
28-
RUN microdnf install -y python3 \
28+
RUN microdnf install -y python3 gcc-c++ python3-devel \
2929
&& microdnf update -y \
3030
&& microdnf -y install shadow-utils \
3131
&& adduser -u 1001 -G root -s /usr/sbin/nologin default \
@@ -38,7 +38,7 @@ RUN microdnf install -y python3 \
3838
USER 1001
3939

4040
# Install optuna to the default user
41-
RUN python3 -m pip install --user optuna requests scikit-optimize jsonschema
41+
RUN python3 -m pip install --user optuna requests scikit-optimize jsonschema click grpcio protobuf
4242

4343
LABEL name="Kruize HPO" \
4444
vendor="Red Hat" \
@@ -54,5 +54,6 @@ COPY --chown=1001:0 index.html /opt/app/
5454

5555

5656
EXPOSE 8085
57+
EXPOSE 50051
5758

5859
ENTRYPOINT python3 -u src/service.py

requirements.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
optuna
22
requests
33
scikit-optimize
4-
jsonschema
4+
jsonschema
5+
grpcio
6+
click
7+
protobuf

scripts/cluster-helpers.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function docker_start() {
6969

7070
check_prereq running ${SERVICE_STATUS_DOCKER}
7171

72-
${CONTAINER_RUNTIME} run -d --name hpo_docker_container -p 8085:8085 ${HPO_CONTAINER_IMAGE} >/dev/null 2>&1
72+
${CONTAINER_RUNTIME} run -d --name hpo_docker_container -p 8085:8085 -p 50051:50051 ${HPO_CONTAINER_IMAGE} >/dev/null 2>&1
7373
check_err "Unexpected error occured. Service Stopped!"
7474

7575
echo

src/README.md

+49
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,52 @@ The criteria for setting the experiment status is:
4646
| `success` | The experiment runs successfully without any error. |
4747
| `failure` | The experiment fails due to reason such as OOMKilled. |
4848
| `prune` | The experiment terminates due to reasons such as insufficient cpu and memory. |
49+
50+
51+
## gRPC Client
52+
53+
[`grpc_client.py`](./grpc_client.py) is a command line client that allows users to interact with the gRPC service.
54+
55+
### Usage
56+
57+
```shell
58+
$ python3 ./grpc_client.py
59+
Usage: grpc_client.py [OPTIONS] COMMAND [ARGS]...
60+
61+
A HPO command line tool to allow interaction with HPO service
62+
63+
Options:
64+
--help Show this message and exit.
65+
66+
Commands:
67+
config Obtain a configuration set for a particular experiment trial
68+
count Return a count of experiments currently running
69+
list List names of all experiments currently running
70+
new Create a new experiment
71+
next Generate next configuration set for running experiment
72+
result Update results for a particular experiment trial
73+
show Show details of running experiment
74+
75+
```
76+
77+
Commands provide interactive input for params or allow users to set params on the command line for scripted use;
78+
79+
e.g.
80+
81+
```shell
82+
$ python3 ./grpc_client.py new
83+
Experiment configuration file path:
84+
```
85+
86+
or
87+
88+
```shell
89+
$ python3 ./grpc_client.py new --file=/tmp/hpo/newExperiment.json
90+
```
91+
92+
> **_NOTE:_** The default host and port for the client is `localhost` and `50051`. If you wish to connect to a remote machine, or via a diferent port, please set the following environment variables, `HPO_HOST` and `HPO_PORT`.
93+
> e.g.
94+
> ```shell
95+
> $ export HPO_HOST=remoteMachine.com
96+
> $ export HPO_PORT=9191
97+
> ```

src/__init__.py

Whitespace-only changes.

src/exceptions.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Copyright (c) 2020, 2022 Red Hat, IBM Corporation and others.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
"""
16+
17+
class Error(Exception):
18+
"""Base class for other exceptions"""
19+
pass
20+
21+
class ExperimentNotFoundError(Error):
22+
"""Raised when the input value is too small"""
23+
pass

src/gRPC/__init__.py

Whitespace-only changes.

src/gRPC/hpo_pb2.py

+162
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)