in services/jenkins-autoscaling/lambda_mxnet_ci/autoscaling/handler.py [0:0]
def _convert_to_jenkins_nodes(server, instances):
"""
Take a list of jenkins node names and convert them to API backed Node objects
:param server: Jenkins server handle
:param instances: Node names
:return: Dict(displayName, node_obj)
"""
nodes = dict()
if not instances:
return nodes
# Unfortunately, the iterator of the jenkinsapi always requests the data of every single node upon calling the
# dict (e.g. all_nodes[nodename]).
# Since this is basically O(MN); M=len(offline_node_names); N=number of total nodes, we have to use a workaround
# and create the objects ourselves instead of using the underlying dict - which is getting created in sequence...
node_obj_list = Parallel(n_jobs=min(JENKINS_PARALLEL_REQUESTS_LIMIT, len(instances)), backend="threading")(
delayed(_create_jenkins_node_obj)(server, x) for x in instances)
for node_obj in node_obj_list:
if node_obj:
nodes[node_obj.name] = node_obj
return nodes