From 865dee5ea3303b61ada6f2406a77405af459c16d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Fri, 13 Dec 2024 08:17:31 +0100 Subject: [PATCH] Use pattern matching --- src/ert/scheduler/__init__.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ert/scheduler/__init__.py b/src/ert/scheduler/__init__.py index 349e1d3838a..bdcf018f109 100644 --- a/src/ert/scheduler/__init__.py +++ b/src/ert/scheduler/__init__.py @@ -19,23 +19,23 @@ def create_driver(queue_options: QueueOptions) -> Driver: - if queue_options.name == QueueSystem.LOCAL: - return LocalDriver() - elif queue_options.name == QueueSystem.TORQUE: - return OpenPBSDriver(**queue_options.driver_options) - elif queue_options.name == QueueSystem.LSF: - return LsfDriver(**queue_options.driver_options) - elif queue_options.name == QueueSystem.SLURM: - return SlurmDriver( - **dict( - {"user": getpwuid(getuid()).pw_name}, - **queue_options.driver_options, + match str(queue_options.name).upper(): + case QueueSystem.LOCAL: + return LocalDriver() + case QueueSystem.TORQUE: + return OpenPBSDriver(**queue_options.driver_options) + case QueueSystem.LSF: + return LsfDriver(**queue_options.driver_options) + case QueueSystem.SLURM: + return SlurmDriver( + **dict( + {"user": getpwuid(getuid()).pw_name}, + **queue_options.driver_options, + ) ) - ) - else: - raise NotImplementedError( - "Only LOCAL, SLURM, TORQUE and LSF drivers are implemented" - ) + raise NotImplementedError( + "Only LOCAL, SLURM, TORQUE and LSF drivers are implemented" + ) __all__ = [