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 dsl support for preemptible vm/gpus #1306

Merged
merged 2 commits into from
May 14, 2019
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
16 changes: 16 additions & 0 deletions sdk/python/kfp/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from kubernetes.client import V1Toleration

def use_gcp_secret(secret_name='user-gcp-sa', secret_file_path_in_volume='/user-gcp-sa.json', volume_name='gcp-credentials', secret_volume_mount_path='/secret/gcp-credentials'):
"""An operator that configures the container to use GCP service account.

Expand Down Expand Up @@ -85,3 +87,17 @@ def _set_tpu_spec(task):
return task

return _set_tpu_spec

def use_preemptible_vm_gpu(toleration: V1Toleration = V1Toleration(effect='NoSchedule',
gaoning777 marked this conversation as resolved.
Show resolved Hide resolved
key='preemptible',
operator='Equal',
value='true')):
"""An operator that configures the GKE preemptible in a container op.
"""

def _set_preemptible(task):
task.add_toleration(toleration)
gaoning777 marked this conversation as resolved.
Show resolved Hide resolved
task.add_node_selector_constraint("cloud.google.com/gke-preemptible", "true")
return task

return _set_preemptible