From 32d9d3314c82b3bd3982694885d401b1bcfb1aa7 Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Tue, 5 Jan 2021 10:52:26 +0100 Subject: [PATCH] Fail if scheduler starts with '-' in dask-cuda-worker(#485) Fixes https://github.com/rapidsai/dask-cuda/issues/472 Authors: - Peter Andreas Entschev Approvers: - Mads R. B. Kristensen URL: https://github.com/rapidsai/dask-cuda/pull/485 --- dask_cuda/cli/dask_cuda_worker.py | 7 +++++++ dask_cuda/tests/test_dask_cuda_worker.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/dask_cuda/cli/dask_cuda_worker.py b/dask_cuda/cli/dask_cuda_worker.py index 040e8bb98..4d5ac90b9 100755 --- a/dask_cuda/cli/dask_cuda_worker.py +++ b/dask_cuda/cli/dask_cuda_worker.py @@ -235,6 +235,13 @@ def main( else: security = None + if isinstance(scheduler, str) and scheduler.startswith("-"): + raise ValueError( + "The scheduler address can't start with '-'. Please check " + "your command line arguments, you probably attempted to use " + "unsupported one. Scheduler address: %s" % scheduler + ) + worker = CUDAWorker( scheduler, host, diff --git a/dask_cuda/tests/test_dask_cuda_worker.py b/dask_cuda/tests/test_dask_cuda_worker.py index e361436a3..8718fc797 100644 --- a/dask_cuda/tests/test_dask_cuda_worker.py +++ b/dask_cuda/tests/test_dask_cuda_worker.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, division, print_function import os +import subprocess import pytest @@ -98,3 +99,9 @@ def test_rmm_managed(loop): # noqa: F811 ) for v in memory_resource_type.values(): assert v is rmm.mr.ManagedMemoryResource + + +def test_unknown_argument(): + ret = subprocess.run(["dask-cuda-worker", "--my-argument"], capture_output=True) + assert ret.returncode != 0 + assert b"Scheduler address: --my-argument" in ret.stderr