Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for preemptible instances on GCP #256

Merged
merged 3 commits into from
Feb 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dask_cloudprovider/gcp/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(
bootstrap=None,
gpu_instance=None,
auto_shutdown=None,
preemptible=None,
**kwargs,
):
super().__init__(**kwargs)
Expand All @@ -84,6 +85,7 @@ def __init__(
self.gpu_instance = gpu_instance
self.bootstrap = bootstrap
self.auto_shutdown = auto_shutdown
self.preemptible = preemptible

self.general_zone = "-".join(self.zone.split("-")[:2]) # us-east1-c -> us-east1

Expand Down Expand Up @@ -146,9 +148,9 @@ def create_gcp_config(self):
},
"labels": {"container-vm": "dask-cloudprovider"},
"scheduling": {
"preemptible": "false",
"preemptible": ("true" if self.preemptible else "false"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making the default preemptible=False rather than None ? I think keeping the massive dictionary cleaner is a good goal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

"onHostMaintenance": "TERMINATE",
"automaticRestart": "true",
"automaticRestart": ("false" if self.preemptible else "true"),
"nodeAffinities": [],
},
"shieldedInstanceConfig": {
Expand Down Expand Up @@ -447,6 +449,8 @@ class GCPCluster(VMCluster):
Configures communication security in this cluster. Can be a security
object, or True. If True, temporary self-signed credentials will
be created automatically. Default is ``True``.
preemptible: bool (optional)
Whether to use preemptible instances in this cluster. Defaults to ``False``.

Examples
--------
Expand Down Expand Up @@ -533,6 +537,7 @@ def __init__(
filesystem_size=None,
auto_shutdown=None,
bootstrap=True,
preemptible=None,
**kwargs,
):

Expand Down Expand Up @@ -566,6 +571,7 @@ def __init__(
"gpu_instance": self.gpu_instance,
"bootstrap": self.bootstrap,
"auto_shutdown": self.auto_shutdown,
"preemptible": preemptible if preemptible is not None else self.config.get("preemptible"),
}
self.scheduler_options = {**self.options}
self.worker_options = {**self.options}
Expand Down