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 volume, volumemount and env to container op #300

Merged
merged 19 commits into from
Nov 17, 2018
Merged

Conversation

IronPan
Copy link
Member

@IronPan IronPan commented Nov 16, 2018

Add these fields to support mounting secret to the container. It replace gcp secret which is to specific to gcp.

I will add a gcp op instead as a syntax sugar.

This change is Reviewable

@IronPan
Copy link
Member Author

IronPan commented Nov 16, 2018

/assign @qimingj @Ark-kun @gaoning777

@@ -140,23 +143,21 @@ def _op_to_template(self, op):
if op.memory_request or op.cpu_request:
template['container']['resources']['requests'] = {}
if op.memory_request:
template['container']['resources']['requests']['memory'] = op.memory_request
template['container']['resources']['requests'][
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor issue: It would be best if these lines are cut in the more natural places, for example after ['memory']?

Copy link
Member Author

Choose a reason for hiding this comment

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

ack. thanks

def _get_uncommon_ancestors(self, op_groups, op1, op2):
"""Helper function to get unique ancestors between two ops.

For example, op1's ancestor groups are [root, G1, G2, G3, op1], op2's ancestor groups are
[root, G1, G4, op2], then it returns a tuple ([G2, G3, op1], [G4, op2]).
"""
both_groups = [op_groups[op1.name], op_groups[op2.name]]
common_groups_len = sum(1 for x in zip(*both_groups) if x==(x[0],)*len(x))
common_groups_len = sum(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please undo the auto-format changes so that the diff is smaller and changes are more clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed.

Copy link
Member Author

Choose a reason for hiding this comment

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

ack. thanks

env_variables = []
for e in op.env_variables:
env_variables.append(self._convert_k8s_obj_to_dic(e))
template['container']['env'] = env_variables
Copy link
Contributor

Choose a reason for hiding this comment

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

can be done in one line (didn't try it so syntax might be off):

template['container']['env'] = map(self._convert_k8s_obj_to_dic, op.env_variables)

Copy link
Contributor

Choose a reason for hiding this comment

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

Same for volume.

Copy link
Member Author

Choose a reason for hiding this comment

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

done. it's much cleaner.

If obj is dict, return the dict.
If obj is swagger model, return the properties dict.

:param obj: The data to serialize.
Copy link
Contributor

Choose a reason for hiding this comment

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

":param" and ":return": are these new Python style docstring? In Python it is usually:

Args:
arg1: ...
arg2: ...
Returns:
...

Copy link
Member Author

Choose a reason for hiding this comment

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

done

sdk/python/kfp/compiler/compiler.py Show resolved Hide resolved
@@ -154,5 +165,20 @@ def set_cpu_limit(self, cpu):
self._validate_cpu_string(cpu)
self.cpu_limit = cpu

def set_volumes(self, volumes):
"""Specifying what K8s volumes the container depends on"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an Args section in docstring? For example:

Args:
volumes: a list of k8s volumes. For example, ...

At least users need to know what type of data to pass.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

'name': 'mlpipeline-minio-artifact',
arguments=['echo %s %s | tee /tmp/message.txt' % (
msg1, msg2)],
file_outputs={'merged': '/tmp/message.txt'})
Copy link
Contributor

Choose a reason for hiding this comment

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

do you also need to cover op.set_volumes?

Copy link
Member Author

Choose a reason for hiding this comment

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

the volume is not specified at container level, so this test won't test it. I have a volume.py test that covers it.

@qimingj
Copy link
Contributor

qimingj commented Nov 17, 2018

Thanks @IronPan. I added a few comments.

@Ark-kun
Copy link
Contributor

Ark-kun commented Nov 17, 2018

/lgtm

Copy link
Contributor

@qimingj qimingj left a comment

Choose a reason for hiding this comment

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

Thanks!


Args:
volume_mounts: a list of Kubernetes volume mounts
For detailed spec, check
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better. It would be clearer if you also specify what type of Python object is expected. For example, does it only accept "k8s_client.V1VolumeMount"? If so, make it explicit. If you were user of this API and knows little about K8s volume mounts, you probably need more help.

Copy link
Member Author

Choose a reason for hiding this comment

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

cool i add the link to the definition file.

Copy link
Contributor

Choose a reason for hiding this comment

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

This would require loading the Kubernetes module for every usage of the API. Do you think that a string annotation might be sufficient?
E.g.

def set_volume_mounts(self, volume_mounts: 'List[kubernetes.client.models.V1VolumeMount]'):

@Ark-kun
Copy link
Contributor

Ark-kun commented Nov 17, 2018

/lgtm

@IronPan
Copy link
Member Author

IronPan commented Nov 17, 2018

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: IronPan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: IronPan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit a47eb10 into master Nov 17, 2018
@Ark-kun Ark-kun deleted the yangpa/container branch November 28, 2018 17:37
Linchin pushed a commit to Linchin/pipelines that referenced this pull request Apr 11, 2023
…low#300)

* Create a cron job to regularly garbage collect test resources.

* Add to cleanup_ci.py an "all" subcommand to delete all resources."
* Add a batch job for one off runs.

Related to:
  kubeflow#87 Cron job to garbage collect test resources
  kubeflow#249 cron job to collect Kubeflow deployments launched by E2E tests

* * Add a cron job to run the cleanup every two hours.
* In cleanup_ci.py; don't load the imports of the manifests
  We encountered an error where the manifest didn't exist. I think
  that may have been a collision because we had a separate script running to do
  the deletes.

* Fix some bugs.

* Deal with config being none.

* Maybe activate service account.
magdalenakuhn17 pushed a commit to magdalenakuhn17/pipelines that referenced this pull request Oct 22, 2023
* v1alpha2 spec for predict,explain,transform

* Fix tests

* Change endpoints to nouns

* Fix default tests

* AlibiExplainSpec to AlibiExplainerSpec

* Update codegen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants