Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added gRPC endpoint and python client #21

Merged
merged 16 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Dockerfile.hpo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ WORKDIR /opt/app

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

# Install optuna to the default user
RUN python3 -m pip install --user optuna requests scikit-optimize jsonschema
RUN python3 -m pip install --user optuna requests scikit-optimize jsonschema click grpcio google-api-core

johnaohara marked this conversation as resolved.
Show resolved Hide resolved
LABEL name="Kruize HPO" \
vendor="Red Hat" \
Expand All @@ -54,5 +54,6 @@ COPY --chown=1001:0 index.html /opt/app/


EXPOSE 8085
EXPOSE 50051

ENTRYPOINT python3 -u src/service.py
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
optuna
requests
scikit-optimize
jsonschema
jsonschema
grpcio
click
2 changes: 1 addition & 1 deletion scripts/cluster-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function docker_start() {

check_prereq running ${SERVICE_STATUS_DOCKER}

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

echo
Expand Down
42 changes: 42 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,45 @@ The criteria for setting the experiment status is:
| `success` | The experiment runs successfully without any error. |
| `failure` | The experiment fails due to reason such as OOMKilled. |
| `prune` | The experiment terminates due to reasons such as insufficient cpu and memory. |


## gRPC Client

[`grpc_client.py`](./grpc_client.py) is a command line client that allows users to interact with the gRPC service.

### Usage

```shell
$ python3 ./grpc_client.py
Usage: grpc_client.py [OPTIONS] COMMAND [ARGS]...

A HPO command line tool to allow interaction with HPO service

Options:
--help Show this message and exit.

Commands:
config Obtain a configuration set for a particular experiment trial
count Return a count of experiments currently running
list List names of all experiments currently running
new Create a new experiment
next Generate next configuration set for running experiment
result Update results for a particular experiment trial
show Show details of running experiment

```

Commands provide interactive input for params or allow users to set params on the command line for scripted use;

e.g.

```shell
$ python3 ./grpc_client.py new
Experiment configuration file path:
```

or

```shell
$ python3 ./grpc_client.py new --file=/tmp/hpo/newExperiment.json
```
Empty file added src/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions src/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Error(Exception):
"""Base class for other exceptions"""
pass

class ExperimentNotFoundError(Error):
"""Raised when the input value is too small"""
pass
Empty file added src/gRPC/__init__.py
Empty file.
162 changes: 162 additions & 0 deletions src/gRPC/hpo_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading