prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  v2 - support resource requests and limits
  * [x] https://github.com/kubeflow/pipelines/pull/7045
  * [x] #7043
  * [x] #7047
  
  
  </issue>
  <code>
  [start of samples/core/resource_spec/resource_spec_v2.py]
  1 # Copyright 2020-2021 The Kubeflow Authors
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #      http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 import os
  16 from kfp import dsl
  17 
  18 # In tests, we install a KFP package from the PR under test. Users should not
  19 # normally need to specify `kfp_package_path` in their component definitions.
  20 _KFP_PACKAGE_PATH = os.getenv('KFP_PACKAGE_PATH')
  21 
  22 
  23 @dsl.component(kfp_package_path=_KFP_PACKAGE_PATH)
  24 def training_op(n: int) -> int:
  25     # quickly allocate a lot of memory to verify memory is enough
  26     a = [i for i in range(n)]
  27     return len(a)
  28 
  29 
  30 @dsl.pipeline(
  31     name='pipeline-with-resource-spec',
  32     description='A pipeline with resource specification.')
  33 def my_pipeline(n: int = 11234567):
  34     # For units of these resource limits,
  35     # refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes
  36     # 11234567 roughly needs 400Mi+ memory.
  37     #
  38     # Note, with v2 python components, there's a larger memory overhead caused
  39     # by installing KFP SDK in the component, so we had to increase memory limit to 650M.
  40     training_task = training_op(n=n).set_cpu_limit('1').set_memory_limit('650M')
  41 
  42     # TODO(Bobgy): other resource specs like cpu requests, memory requests and
  43     # GPU limits are not available yet: https://github.com/kubeflow/pipelines/issues/6354.
  44     # There are other resource spec you can set.
  45     # For example, to use TPU, add the following:
  46     # .add_node_selector_constraint('cloud.google.com/gke-accelerator', 'tpu-v3')
  47     # .set_gpu_limit(1)
  48
  [end of samples/core/resource_spec/resource_spec_v2.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/samples/core/resource_spec/resource_spec_v2.py b/samples/core/resource_spec/resource_spec_v2.py
  --- a/samples/core/resource_spec/resource_spec_v2.py
  +++ b/samples/core/resource_spec/resource_spec_v2.py
  @@ -38,6 +38,9 @@
       # Note, with v2 python components, there's a larger memory overhead caused
       # by installing KFP SDK in the component, so we had to increase memory limit to 650M.
       training_task = training_op(n=n).set_cpu_limit('1').set_memory_limit('650M')
  +    
  +    # TODO(gkcalat): enable requests once SDK implements the feature
  +    # training_task = training_task.set_cpu_request('1').set_memory_request('650M')
   
       # TODO(Bobgy): other resource specs like cpu requests, memory requests and
       # GPU limits are not available yet: https://github.com/kubeflow/pipelines/issues/6354.
  
verification_info: {"golden_diff": "diff --git a/samples/core/resource_spec/resource_spec_v2.py b/samples/core/resource_spec/resource_spec_v2.py\n--- a/samples/core/resource_spec/resource_spec_v2.py\n+++ b/samples/core/resource_spec/resource_spec_v2.py\n@@ -38,6 +38,9 @@\n     # Note, with v2 python components, there's a larger memory overhead caused\n     # by installing KFP SDK in the component, so we had to increase memory limit to 650M.\n     training_task = training_op(n=n).set_cpu_limit('1').set_memory_limit('650M')\n+    \n+    # TODO(gkcalat): enable requests once SDK implements the feature\n+    # training_task = training_task.set_cpu_request('1').set_memory_request('650M')\n \n     # TODO(Bobgy): other resource specs like cpu requests, memory requests and\n     # GPU limits are not available yet: https://github.com/kubeflow/pipelines/issues/6354.\n", "issue": "v2 - support resource requests and limits\n* [x] https://github.com/kubeflow/pipelines/pull/7045\r\n* [x] #7043\r\n* [x] #7047\r\n\n", "before_files": [{"content": "# Copyright 2020-2021 The Kubeflow Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nfrom kfp import dsl\n\n# In tests, we install a KFP package from the PR under test. Users should not\n# normally need to specify `kfp_package_path` in their component definitions.\n_KFP_PACKAGE_PATH = os.getenv('KFP_PACKAGE_PATH')\n\n\n@dsl.component(kfp_package_path=_KFP_PACKAGE_PATH)\ndef training_op(n: int) -> int:\n    # quickly allocate a lot of memory to verify memory is enough\n    a = [i for i in range(n)]\n    return len(a)\n\n\n@dsl.pipeline(\n    name='pipeline-with-resource-spec',\n    description='A pipeline with resource specification.')\ndef my_pipeline(n: int = 11234567):\n    # For units of these resource limits,\n    # refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes\n    # 11234567 roughly needs 400Mi+ memory.\n    #\n    # Note, with v2 python components, there's a larger memory overhead caused\n    # by installing KFP SDK in the component, so we had to increase memory limit to 650M.\n    training_task = training_op(n=n).set_cpu_limit('1').set_memory_limit('650M')\n\n    # TODO(Bobgy): other resource specs like cpu requests, memory requests and\n    # GPU limits are not available yet: https://github.com/kubeflow/pipelines/issues/6354.\n    # There are other resource spec you can set.\n    # For example, to use TPU, add the following:\n    # .add_node_selector_constraint('cloud.google.com/gke-accelerator', 'tpu-v3')\n    # .set_gpu_limit(1)\n", "path": "samples/core/resource_spec/resource_spec_v2.py"}]}