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

[python-package] add type hints on Booster.set_network() #4068

Merged
merged 3 commits into from
Mar 15, 2021
Merged
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
13 changes: 10 additions & 3 deletions python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functools import wraps
from logging import Logger
from tempfile import NamedTemporaryFile
from typing import Any, Dict
from typing import Any, Dict, List, Set, Union

import numpy as np
import scipy.sparse
Expand Down Expand Up @@ -2336,8 +2336,13 @@ def _free_buffer(self):
self.__is_predicted_cur_iter = []
return self

def set_network(self, machines, local_listen_port=12400,
listen_time_out=120, num_machines=1):
def set_network(
self,
machines: Union[List[str], Set[str], str],
local_listen_port: int = 12400,
listen_time_out: int = 120,
num_machines: int = 1
) -> "Booster":
"""Set the network configuration.

Parameters
Expand All @@ -2356,6 +2361,8 @@ def set_network(self, machines, local_listen_port=12400,
self : Booster
Booster with set network.
"""
if isinstance(machines, (list, set)):
machines = ','.join(machines)
_safe_call(_LIB.LGBM_NetworkInit(c_str(machines),
ctypes.c_int(local_listen_port),
ctypes.c_int(listen_time_out),
Expand Down