def __init__(
     self,
     *args,
     scheduler_options: dict = {},
     **kwargs,
 ):
     super().__init__(*args, **kwargs)
     self.name = f"dask-{self.cluster.uuid}-scheduler"
     self.command = " ".join([
         self.set_env,
         "python",
         "-m",
         "distributed.cli.dask_scheduler",
     ] + cli_keywords(scheduler_options, cls=_Scheduler))
Exemple #2
0
    def __init__(
        self,
        scheduler: str,
        *args,
        worker_module: str = None,
        worker_class: str = None,
        worker_options: dict = {},
        **kwargs,
    ):
        super().__init__(*args, **kwargs)
        self.scheduler = scheduler
        self.name = f"dask-{self.cluster.uuid}-worker-{str(uuid.uuid4())[:8]}"
        if worker_module is not None:
            self.worker_module = worker_module

            self.command = " ".join(
                [
                    self.set_env,
                    "python",
                    "-m",
                    self.worker_module,
                    self.scheduler,
                    "--name",
                    str(self.name),
                ]
                + cli_keywords(worker_options, cls=_Worker, cmd=self.worker_module)
            )
        if worker_class is not None:
            self.worker_class = worker_class
            self.command = " ".join(
                [
                    self.set_env,
                    "python",
                    "-m",
                    "distributed.cli.dask_spec",
                    self.scheduler,
                    "--spec",
                    "''%s''"  # in yaml double single quotes escape the single quote
                    % json.dumps(
                        {
                            "cls": self.worker_class,
                            "opts": {
                                **worker_options,
                                "name": self.name,
                            },
                        }
                    ),
                ]
            )