Skip to content

add host to PymiloServer constructor - enabling accessiblity on LAN #213

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

Merged
merged 5 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Added
### Changed
- `README.md` updated
- `__init__` function in `PyMiloServer`
- Test system modified
### Removed
- Python 3.6 support
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ communicator.run()
```
Now `PymiloServer` runs on port `8000` and exposes REST API to `upload`, `download` and retrieve **attributes** either **data attributes** like `model._coef` or **method attributes** like `model.predict(x_test)`.

ℹ️ By default, `PymiloServer` listens on the loopback interface (`127.0.0.1`). To make it accessible over a local network (LAN), specify your machine’s LAN IP address in the `host` parameter of the `PymiloServer` constructor.

#### Client
By using `PymiloClient` you can easily connect to the remote `PymiloServer` and execute any functionalities that the given ML model has, let's say you want to run `predict` function on your remote ML model and get the result:
```python
Expand Down
5 changes: 4 additions & 1 deletion pymilo/streaming/pymilo_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init__(
self,
model=None,
port=8000,
host="127.0.0.1",
compressor=Compression.NULL,
communication_protocol=CommunicationProtocol.REST,
):
Expand All @@ -25,6 +26,8 @@ def __init__(
:type model: any
:param port: the port to which PyMiloServer listens
:type port: int
:param host: the url to which PyMilo Server listens
:type host: str
:param compressor: the compression method to be used in client-server communications
:type compressor: pymilo.streaming.compressor.Compression
:param communication_protocol: The communication protocol to be used by PymiloServer
Expand All @@ -34,7 +37,7 @@ def __init__(
self._model = model
self._compressor = compressor.value
self._encryptor = DummyEncryptor()
self.communicator = communication_protocol.value["SERVER"](ps=self, port=port)
self.communicator = communication_protocol.value["SERVER"](ps=self, host=host, port=port)

def export_model(self):
"""
Expand Down