-
Notifications
You must be signed in to change notification settings - Fork 301
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
Grantham/add-attach_shm-template #3020
base: master
Are you sure you want to change the base?
Changes from all commits
a77aab8
6a3dbce
87aa4a7
44e2ea3
067c902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from flytekit.extras.pod_templates.attach_shm import attach_shm | ||
|
||
__all__ = ["attach_shm"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from flytekit.core.pod_template import PodTemplate | ||
|
||
|
||
def attach_shm(name: str, size: str) -> PodTemplate: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we make name -> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re thomas's comment, i was also thinking you were mutating a pod template. if it's just generating a default pod template with an shm, should we rename the function? |
||
from kubernetes.client.models import ( | ||
V1Container, | ||
V1EmptyDirVolumeSource, | ||
V1PodSpec, | ||
V1Volume, | ||
V1VolumeMount, | ||
) | ||
|
||
return PodTemplate( | ||
primary_container_name=name, | ||
pod_spec=V1PodSpec( | ||
containers=[V1Container(name=name, volume_mounts=[V1VolumeMount(mount_path="/dev/shm", name="dshm")])], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential insecure temp file usage
The hardcoded path '/dev/shm' could potentially be insecure. Consider making this path configurable or validating it before use. Code suggestionCheck the AI-generated fix before applying
Code Review Run #dd1f99 Is this a valid issue, or was it incorrectly flagged by the Agent?
|
||
volumes=[V1Volume(name="dshm", empty_dir=V1EmptyDirVolumeSource(medium="", size_limit=size))], | ||
), | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from flytekit.extras.pod_templates import attach_shm | ||
from flytekit.core.task import task | ||
|
||
def test_attach_shm(): | ||
|
||
shm = attach_shm("SHM", "5Gi") | ||
assert shm.name == "SHM" | ||
assert shm.size == "5Gi" | ||
|
||
def my_task(): | ||
pass | ||
|
||
# Verify pod template is attached to task | ||
assert my_task.pod_template == shm | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing task decorator for pod template
Consider adding a decorator to attach the pod template to Code suggestionCheck the AI-generated fix before applying
Code Review Run #8c9989 Is this a valid issue, or was it incorrectly flagged by the Agent?
|
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
attach_shm
function parameters lack type validation. Consider validating thatsize
follows Kubernetes resource quantity format (e.g., '1Gi', '500Mi') to prevent runtime errors.Code suggestion
Code Review Run #dd1f99
Is this a valid issue, or was it incorrectly flagged by the Agent?