Verified Commit 71d54817 authored by Raphaël Bleuse's avatar Raphaël Bleuse
Browse files

Introduce the pybatsim.schedulers entry point

This commit introduces the basic mechanism to define schedulers as
plugins.
Schedulers defined as plugins are now registered under the
pybatsim.schedulers entry point.
The plugin module contains the logic to retrieve schedulers based on the
name they have been registered with.
parent abec3b35
......@@ -100,11 +100,11 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "importlib-metadata"
version = "4.8.2"
version = "4.10.0"
description = "Read metadata from Python packages"
category = "main"
optional = false
python-versions = ">=3.6"
python-versions = ">=3.7"
[package.dependencies]
typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""}
......@@ -113,7 +113,7 @@ zipp = ">=0.5"
[package.extras]
docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"]
perf = ["ipython"]
testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"]
testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"]
[[package]]
name = "jinja2"
......@@ -445,7 +445,7 @@ tools = ["pandas"]
[metadata]
lock-version = "1.1"
python-versions = "^3.7.1"
content-hash = "22e5accfd6c6c200a7b01215a4439f9708e2d878b5d3f61ae2993540c031b06d"
content-hash = "a652c3f0a56c7ba6c84aa9e67578d38821c855dc859e9c0ed697a9afb19e1350"
[metadata.files]
alabaster = [
......@@ -585,8 +585,8 @@ imagesize = [
{file = "imagesize-1.3.0.tar.gz", hash = "sha256:cd1750d452385ca327479d45b64d9c7729ecf0b3969a58148298c77092261f9d"},
]
importlib-metadata = [
{file = "importlib_metadata-4.8.2-py3-none-any.whl", hash = "sha256:53ccfd5c134223e497627b9815d5030edf77d2ed573922f7a0b8f8bb81a1c100"},
{file = "importlib_metadata-4.8.2.tar.gz", hash = "sha256:75bdec14c397f528724c1bfd9709d660b33a4d2e77387a3358f20b848bb5e5fb"},
{file = "importlib_metadata-4.10.0-py3-none-any.whl", hash = "sha256:b7cf7d3fef75f1e4c80a96ca660efbd51473d7e8f39b5ab9210febc7809012a4"},
{file = "importlib_metadata-4.10.0.tar.gz", hash = "sha256:92a8b58ce734b2a4494878e0ecf7d79ccd7a128b5fc6014c401e0b61f006f0f6"},
]
jinja2 = [
{file = "Jinja2-3.0.3-py3-none-any.whl", hash = "sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8"},
......
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "pybatsim"
version = "4.0.0-alpha.0"
......@@ -40,7 +44,7 @@ procset = "^1.0"
sortedcontainers = "^2.3.0"
pyzmq = "^22.0.3"
docopt = "^0.6.2"
importlib-metadata = {version = ">=1.0", python = "<3.8"}
importlib-metadata = {version = ">=3.6", python = "<3.10"}
pandas = {version = "^1.3.4", optional = true}
[tool.poetry.dev-dependencies]
......@@ -54,6 +58,10 @@ tools = ["pandas"]
pybatsim = "pybatsim.batsim.cmds.launcher:main"
pybatsim-experiment = "pybatsim.batsim.cmds.experiments:main"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
# definition of officialy maintained schedulers
[tool.poetry.plugins."pybatsim.schedulers"]
backfill-easy = "pybatsim.schedulers.easyBackfill:EasyBackfill"
fcfs-sleeper = "pybatsim.schedulers.fcfsSchedSleep:FcfsSchedSleep"
filler = "pybatsim.schedulers.fillerSched:FillerSched"
filler-events = "pybatsim.schedulers.fillerSchedWithEvents:FillerSchedWithEvents"
random = "pybatsim.schedulers.randomSched:RandomSched"
"""
pybatsim.plugin
~~~~~~~~~~~~~~~
PyBatsim plugin interface.
"""
import sys
# selectable entry points were introduced in Python 3.10
if sys.version_info < (3, 10):
from importlib_metadata import entry_points
else:
from importlib.metadata import entry_points
SCHEDULER_ENTRY_POINT = 'pybatsim.schedulers'
def find_plugin_schedulers():
for scheduler in entry_points(group=SCHEDULER_ENTRY_POINT):
yield scheduler.name, scheduler.load()
Supports Markdown
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