Commit 1a425f43 authored by Daniele Venzano's avatar Daniele Venzano

Fix pylint warnings

parent e1a9d264
......@@ -219,10 +219,10 @@ class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
# Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__)|log|([A-Z][A-Za-z]*Type))$
const-rgx=(([A-Z_][A-Za-z0-9_]*)|(__.*__)|log|([A-Z][A-Za-z]*Type))$
# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__)|log|([A-Z][A-Za-z]*Type))$
const-name-hint=(([A-Z_][A-Za-z0-9_]*)|(__.*__)|log|([A-Z][A-Za-z]*Type))$
# Regular expression matching correct attribute names
attr-rgx=([a-z_][a-z0-9_]{2,30}|id)$
......@@ -254,7 +254,7 @@ notes=FIXME,TODO
[DESIGN]
# Maximum number of arguments for function / method
max-args=5
max-args=7
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
......
......@@ -19,8 +19,6 @@ from concurrent.futures import ThreadPoolExecutor
import logging
from tornado.web import RequestHandler
import tornado.gen
import tornado.iostream
from zoe_api.rest_api.utils import catch_exceptions, get_auth
from zoe_api.api_endpoint import APIEndpoint # pylint: disable=unused-import
......@@ -38,7 +36,7 @@ class ServiceAPI(RequestHandler):
self.api_endpoint = kwargs['api_endpoint'] # type: APIEndpoint
@catch_exceptions
def get(self, service_id) -> dict:
def get(self, service_id):
"""HTTP GET method."""
uid, role = get_auth(self)
......
......@@ -35,9 +35,11 @@ class BaseBackend:
raise NotImplementedError
def spawn_service(self, execution: Execution, service: Service, env_subst_dict: Dict):
"""Create a container for a service."""
raise NotImplementedError
def terminate_service(self, service: Service) -> None:
"""Terminate the container corresponding to a service."""
raise NotImplementedError
def platform_state(self) -> ClusterStats:
......
......@@ -27,10 +27,11 @@ from zoe_master.workspace.filesystem import ZoeFSWorkspace
import zoe_master.backends.common
import zoe_master.backends.base
from zoe_master.backends.old_swarm.threads import SwarmMonitor, SwarmStateSynchronizer
from zoe_master.stats import NodeStats, ClusterStats
from zoe_master.stats import NodeStats, ClusterStats # pylint: disable=unused-import
log = logging.getLogger(__name__)
# These two module-level variables hold the references to the monitor and checker threads
_monitor = None
_checker = None
......
......@@ -20,11 +20,12 @@
import logging
import zoe_lib.config as config
import zoe_master.scheduler
import zoe_master.backends.interface
from zoe_lib.metrics.influxdb import InfluxDBMetricSender
from zoe_lib.metrics.logging import LogMetricSender
from zoe_lib.state import SQLManager
import zoe_master.scheduler
import zoe_master.backends.interface
from zoe_master.preprocessing import restart_resubmit_scheduler
from zoe_master.master_api import APIManager
......
......@@ -21,9 +21,10 @@ import time
import zmq
import zoe_lib.config as config
import zoe_master.preprocessing
from zoe_lib.metrics.base import BaseMetricSender
from zoe_lib.state import SQLManager
import zoe_master.preprocessing
from zoe_master.exceptions import ZoeException
from zoe_master.scheduler import ZoeBaseScheduler
......
......@@ -29,11 +29,11 @@ def _digest_application_description(state: SQLManager, execution: Execution):
total_count = service_descr['total_count']
elastic_count = total_count - essential_count
counter = 0
for i in range(essential_count):
for service_n_ in range(essential_count):
name = "{}{}".format(service_descr['name'], counter)
state.service_new(execution.id, name, service_descr['name'], service_descr, True)
counter += 1
for i in range(elastic_count):
for service_n_ in range(elastic_count):
name = "{}{}".format(service_descr['name'], counter)
state.service_new(execution.id, name, service_descr['name'], service_descr, False)
counter += 1
......
......@@ -19,10 +19,7 @@ class SimulatedNode:
def service_fits(self, service: Service) -> bool:
"""Checks whether a service can fit in this node"""
if service.resource_reservation.memory < self.node_free_memory():
return True
else:
return False
return service.resource_reservation.memory < self.node_free_memory()
def service_add(self, service):
"""Add a service in this node."""
......@@ -56,8 +53,8 @@ class SimulatedNode:
def __repr__(self):
# services = ','.join([str(s.id) for s in self.services])
s = 'SN {} | f {}'.format(self.name, self.node_free_memory())
return s
out = 'SN {} | f {}'.format(self.name, self.node_free_memory())
return out
class SimulatedPlatform:
......@@ -71,7 +68,7 @@ class SimulatedPlatform:
"""Try to find an allocation for essential services"""
for service in execution.essential_services:
candidate_nodes = []
for node_name, node in self.nodes.items():
for node_id_, node in self.nodes.items():
if node.service_fits(service):
candidate_nodes.append(node)
if len(candidate_nodes) == 0: # this service does not fit anywhere
......@@ -84,7 +81,7 @@ class SimulatedPlatform:
def deallocate_essential(self, execution: Execution):
"""Remove all essential services from the simulated cluster"""
for service in execution.essential_services:
for node_name, node in self.nodes.items():
for node_id_, node in self.nodes.items():
if node.service_remove(service):
break
......@@ -95,7 +92,7 @@ class SimulatedPlatform:
if service.status == service.ACTIVE_STATUS:
continue
candidate_nodes = []
for node_name, node in self.nodes.items():
for node_id_, node in self.nodes.items():
if node.service_fits(service):
candidate_nodes.append(node)
if len(candidate_nodes) == 0: # this service does not fit anywhere
......@@ -109,7 +106,7 @@ class SimulatedPlatform:
def deallocate_elastic(self, execution: Execution):
"""Remove all elastic services from the simulated cluster"""
for service in execution.elastic_services:
for node_name, node in self.nodes.items():
for node_id_, node in self.nodes.items():
if node.service_remove(service):
service.set_inactive()
break
......@@ -117,8 +114,8 @@ class SimulatedPlatform:
def aggregated_free_memory(self):
"""Return the amount of free memory across all nodes"""
total = 0
for n_id, n in self.nodes.items():
total += n.node_free_memory()
for node_id_, node in self.nodes.items():
total += node.node_free_memory()
return total
def get_service_allocation(self):
......@@ -130,7 +127,7 @@ class SimulatedPlatform:
return placements
def __repr__(self):
s = ''
for node_name, node in self.nodes.items():
s += str(node) + " # "
return s
out = ''
for node_id_, node in self.nodes.items():
out += str(node) + " # "
return out
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment