Skip to content

Commit

Permalink
[python-package] add type hints on Booster.set_network() (#4068)
Browse files Browse the repository at this point in the history
* [python-package] add type hints on Booster.set_network()

* change behavior
  • Loading branch information
jameslamb committed Mar 15, 2021
1 parent b044070 commit dc1bc23
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit dc1bc23

Please sign in to comment.