-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
/assign @qimingj @Ark-kun @gaoning777 |
sdk/python/kfp/compiler/compiler.py
Outdated
@@ -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'][ |
There was a problem hiding this comment.
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']?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack. thanks
sdk/python/kfp/compiler/compiler.py
Outdated
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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack. thanks
sdk/python/kfp/compiler/compiler.py
Outdated
env_variables = [] | ||
for e in op.env_variables: | ||
env_variables.append(self._convert_k8s_obj_to_dic(e)) | ||
template['container']['env'] = env_variables |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for volume.
There was a problem hiding this comment.
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.
sdk/python/kfp/compiler/compiler.py
Outdated
If obj is dict, return the dict. | ||
If obj is swagger model, return the properties dict. | ||
|
||
:param obj: The data to serialize. |
There was a problem hiding this comment.
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:
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
sdk/python/kfp/dsl/_container_op.py
Outdated
@@ -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""" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'}) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Thanks @IronPan. I added a few comments. |
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
sdk/python/kfp/dsl/_container_op.py
Outdated
|
||
Args: | ||
volume_mounts: a list of Kubernetes volume mounts | ||
For detailed spec, check |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]'):
/lgtm |
/approve |
[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 |
1 similar comment
[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 |
…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.
* v1alpha2 spec for predict,explain,transform * Fix tests * Change endpoints to nouns * Fix default tests * AlibiExplainSpec to AlibiExplainerSpec * Update codegen
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