Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/__init__.py
# Copyright (C) 2018 The Software Heritage developers | # Copyright (C) 2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from typing import Any, Dict | from typing import Any, Dict, Mapping | ||||
# Percentage of tasks with priority to schedule | # Percentage of tasks with priority to schedule | ||||
PRIORITY_SLOT = 0.6 | PRIORITY_SLOT = 0.6 | ||||
DEFAULT_CONFIG = { | DEFAULT_CONFIG = { | ||||
'scheduler': ('dict', { | 'scheduler': ('dict', { | ||||
'cls': 'local', | 'cls': 'local', | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | def get_scheduler(cls, args={}): | ||||
if cls == 'remote': | if cls == 'remote': | ||||
from .api.client import RemoteScheduler as SchedulerBackend | from .api.client import RemoteScheduler as SchedulerBackend | ||||
elif cls == 'local': | elif cls == 'local': | ||||
from .backend import SchedulerBackend | from .backend import SchedulerBackend | ||||
else: | else: | ||||
raise ValueError('Unknown swh.scheduler class `%s`' % cls) | raise ValueError('Unknown swh.scheduler class `%s`' % cls) | ||||
return SchedulerBackend(**args) | return SchedulerBackend(**args) | ||||
douardda: May I suggest to find a better name here? I mean `load_xxx_module` makes the reader think this… | |||||
def list_plugin_worker_descriptions() -> Mapping[str, Any]: | |||||
"""List plugin worker descriptions (declared in /setup.py) | |||||
""" | |||||
from pkg_resources import iter_entry_points | |||||
return { | |||||
entry_point.name: entry_point | |||||
for entry_point in iter_entry_points('swh.workers') | |||||
} |
May I suggest to find a better name here? I mean load_xxx_module makes the reader think this function will load these plugin python modules (aka import them) which it does not.
It loads known swh.workers plugin declarations.
In fact, I'm not even sure this function is useful. The diffs below like
looks not so useful in terms of code clarity/readability.