nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: cdk8s-team/cdk8s-plus
Pull request #5681 (2025-05-03 06:32:08)

fix(pvc): fractional gibibytes storage sizes are not allowed
Fixes https://github.com/cdk8s-team/cdk8s/issues/2511


Patch:
diff --git a/src/pvc.ts b/src/pvc.ts
index 25c133ae..5c23eec2 100644
--- a/src/pvc.ts
+++ b/src/pvc.ts
@@ -1,4 +1,4 @@
-import { Size, ApiObject, Lazy } from 'cdk8s';
+import { Size, SizeRoundingBehavior, ApiObject, Lazy } from 'cdk8s';
 import { Construct } from 'constructs';
 import * as base from './base';
 import * as k8s from './imports/k8s';
@@ -197,7 +197,9 @@ export class PersistentVolumeClaim extends base.Resource implements IPersistentV
    * @internal
    */
   public _toKube(): k8s.PersistentVolumeClaimSpec {
-    const storage = this.storage ? k8s.Quantity.fromString(this.storage.toGibibytes() + 'Gi') : undefined;
+    const storage = this.storage ? k8s.Quantity.fromString(this.storage.toGibibytes({
+      rounding: SizeRoundingBehavior.NONE,
+    }) + 'Gi') : undefined;
     return {
       volumeName: this.volume ? this.volume.name : undefined,
       accessModes: this.accessModes?.map(a => a.toString()),


Test patch:
diff --git a/test/__snapshots__/pvc.test.ts.snap b/test/__snapshots__/pvc.test.ts.snap
index 90a908d2..fe7599ca 100644
--- a/test/__snapshots__/pvc.test.ts.snap
+++ b/test/__snapshots__/pvc.test.ts.snap
@@ -100,3 +100,23 @@ Array [
   },
 ]
 `;
+
+exports[`small size 1`] = `
+Array [
+  Object {
+    "apiVersion": "v1",
+    "kind": "PersistentVolumeClaim",
+    "metadata": Object {
+      "name": "test-persistentvolumeclaim-c8af0974",
+    },
+    "spec": Object {
+      "resources": Object {
+        "requests": Object {
+          "storage": "0.5Gi",
+        },
+      },
+      "volumeMode": "Filesystem",
+    },
+  },
+]
+`;
diff --git a/test/pvc.test.ts b/test/pvc.test.ts
index 3b1c1bec..e0619c7f 100644
--- a/test/pvc.test.ts
+++ b/test/pvc.test.ts
@@ -49,6 +49,19 @@ test('custom', () => {
 
 });
 
+test('small size', () => {
+
+  const chart = cdk8s.Testing.chart();
+  const pvc = new kplus.PersistentVolumeClaim(chart, 'PersistentVolumeClaim', {
+    storage: cdk8s.Size.mebibytes(512),
+  });
+
+  expect(pvc.storage).toEqual(cdk8s.Size.mebibytes(512));
+
+  const resources = cdk8s.Testing.synth(chart);
+  expect(resources).toMatchSnapshot();
+});
+
 test('can be imported', () => {
 
   const chart = Testing.chart();
Repository: cdk8s-team/cdk8s-plus
Pull request #5707 (2025-05-07 15:40:53)

fix(pvc): fractional gibibytes storage sizes are not allowed (backport #5681)
# Backport

This will backport the following commits from `k8s-32/main` to `k8s-30/main`:
 - [fix(pvc): fractional gibibytes storage sizes are not allowed (#5681)](https://github.com/cdk8s-team/cdk8s-plus/pull/5681)

<!--- Backport version: 9.5.1 -->

### Questions ?
Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)


Patch:
diff --git a/src/pvc.ts b/src/pvc.ts
index 25c133ae..5c23eec2 100644
--- a/src/pvc.ts
+++ b/src/pvc.ts
@@ -1,4 +1,4 @@
-import { Size, ApiObject, Lazy } from 'cdk8s';
+import { Size, SizeRoundingBehavior, ApiObject, Lazy } from 'cdk8s';
 import { Construct } from 'constructs';
 import * as base from './base';
 import * as k8s from './imports/k8s';
@@ -197,7 +197,9 @@ export class PersistentVolumeClaim extends base.Resource implements IPersistentV
    * @internal
    */
   public _toKube(): k8s.PersistentVolumeClaimSpec {
-    const storage = this.storage ? k8s.Quantity.fromString(this.storage.toGibibytes() + 'Gi') : undefined;
+    const storage = this.storage ? k8s.Quantity.fromString(this.storage.toGibibytes({
+      rounding: SizeRoundingBehavior.NONE,
+    }) + 'Gi') : undefined;
     return {
       volumeName: this.volume ? this.volume.name : undefined,
       accessModes: this.accessModes?.map(a => a.toString()),


Test patch:
diff --git a/test/__snapshots__/pvc.test.ts.snap b/test/__snapshots__/pvc.test.ts.snap
index 90a908d2..fe7599ca 100644
--- a/test/__snapshots__/pvc.test.ts.snap
+++ b/test/__snapshots__/pvc.test.ts.snap
@@ -100,3 +100,23 @@ Array [
   },
 ]
 `;
+
+exports[`small size 1`] = `
+Array [
+  Object {
+    "apiVersion": "v1",
+    "kind": "PersistentVolumeClaim",
+    "metadata": Object {
+      "name": "test-persistentvolumeclaim-c8af0974",
+    },
+    "spec": Object {
+      "resources": Object {
+        "requests": Object {
+          "storage": "0.5Gi",
+        },
+      },
+      "volumeMode": "Filesystem",
+    },
+  },
+]
+`;
diff --git a/test/pvc.test.ts b/test/pvc.test.ts
index 3b1c1bec..e0619c7f 100644
--- a/test/pvc.test.ts
+++ b/test/pvc.test.ts
@@ -49,6 +49,19 @@ test('custom', () => {
 
 });
 
+test('small size', () => {
+
+  const chart = cdk8s.Testing.chart();
+  const pvc = new kplus.PersistentVolumeClaim(chart, 'PersistentVolumeClaim', {
+    storage: cdk8s.Size.mebibytes(512),
+  });
+
+  expect(pvc.storage).toEqual(cdk8s.Size.mebibytes(512));
+
+  const resources = cdk8s.Testing.synth(chart);
+  expect(resources).toMatchSnapshot();
+});
+
 test('can be imported', () => {
 
   const chart = Testing.chart();
Repository: cdk8s-team/cdk8s-plus
Pull request #5708 (2025-05-07 15:40:57)

fix(pvc): fractional gibibytes storage sizes are not allowed (backport #5681)
# Backport

This will backport the following commits from `k8s-32/main` to `k8s-31/main`:
 - [fix(pvc): fractional gibibytes storage sizes are not allowed (#5681)](https://github.com/cdk8s-team/cdk8s-plus/pull/5681)

<!--- Backport version: 9.5.1 -->

### Questions ?
Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)


Patch:
diff --git a/src/pvc.ts b/src/pvc.ts
index 25c133ae..5c23eec2 100644
--- a/src/pvc.ts
+++ b/src/pvc.ts
@@ -1,4 +1,4 @@
-import { Size, ApiObject, Lazy } from 'cdk8s';
+import { Size, SizeRoundingBehavior, ApiObject, Lazy } from 'cdk8s';
 import { Construct } from 'constructs';
 import * as base from './base';
 import * as k8s from './imports/k8s';
@@ -197,7 +197,9 @@ export class PersistentVolumeClaim extends base.Resource implements IPersistentV
    * @internal
    */
   public _toKube(): k8s.PersistentVolumeClaimSpec {
-    const storage = this.storage ? k8s.Quantity.fromString(this.storage.toGibibytes() + 'Gi') : undefined;
+    const storage = this.storage ? k8s.Quantity.fromString(this.storage.toGibibytes({
+      rounding: SizeRoundingBehavior.NONE,
+    }) + 'Gi') : undefined;
     return {
       volumeName: this.volume ? this.volume.name : undefined,
       accessModes: this.accessModes?.map(a => a.toString()),


Test patch:
diff --git a/test/__snapshots__/pvc.test.ts.snap b/test/__snapshots__/pvc.test.ts.snap
index 90a908d2..fe7599ca 100644
--- a/test/__snapshots__/pvc.test.ts.snap
+++ b/test/__snapshots__/pvc.test.ts.snap
@@ -100,3 +100,23 @@ Array [
   },
 ]
 `;
+
+exports[`small size 1`] = `
+Array [
+  Object {
+    "apiVersion": "v1",
+    "kind": "PersistentVolumeClaim",
+    "metadata": Object {
+      "name": "test-persistentvolumeclaim-c8af0974",
+    },
+    "spec": Object {
+      "resources": Object {
+        "requests": Object {
+          "storage": "0.5Gi",
+        },
+      },
+      "volumeMode": "Filesystem",
+    },
+  },
+]
+`;
diff --git a/test/pvc.test.ts b/test/pvc.test.ts
index 3b1c1bec..e0619c7f 100644
--- a/test/pvc.test.ts
+++ b/test/pvc.test.ts
@@ -49,6 +49,19 @@ test('custom', () => {
 
 });
 
+test('small size', () => {
+
+  const chart = cdk8s.Testing.chart();
+  const pvc = new kplus.PersistentVolumeClaim(chart, 'PersistentVolumeClaim', {
+    storage: cdk8s.Size.mebibytes(512),
+  });
+
+  expect(pvc.storage).toEqual(cdk8s.Size.mebibytes(512));
+
+  const resources = cdk8s.Testing.synth(chart);
+  expect(resources).toMatchSnapshot();
+});
+
 test('can be imported', () => {
 
   const chart = Testing.chart();
Repository: cdk8s-team/cdk8s-plus
Pull request #5711 (2025-05-08 08:13:44)

feat(pod): support `enableServiceLinks` (backport #5471)
# Backport

This will backport the following commits from `k8s-32/main` to `k8s-30/main`:
 - [feat(pod): support &#x60;enableServiceLinks&#x60; (#5471)](https://github.com/cdk8s-team/cdk8s-plus/pull/5471)

<!--- Backport version: 9.5.1 -->

### Questions ?
Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)


Patch:
diff --git a/src/pod.ts b/src/pod.ts
index 14e4dfd2..d8d93ec2 100644
--- a/src/pod.ts
+++ b/src/pod.ts
@@ -22,6 +22,7 @@ export abstract class AbstractPod extends base.Resource implements IPodSelector,
   public readonly shareProcessNamespace: boolean;
   public readonly hostNetwork?: boolean;
   public readonly terminationGracePeriod?: Duration;
+  public readonly enableServiceLinks?: boolean;
 
   protected readonly isolate: boolean;
 
@@ -45,6 +46,7 @@ export abstract class AbstractPod extends base.Resource implements IPodSelector,
     this.isolate = props.isolate ?? false;
     this.hostNetwork = props.hostNetwork ?? false;
     this.terminationGracePeriod = props.terminationGracePeriod ?? Duration.seconds(30);
+    this.enableServiceLinks = props.enableServiceLinks;
 
     if (props.containers) {
       props.containers.forEach(c => this.addContainer(c));
@@ -254,6 +256,7 @@ export abstract class AbstractPod extends base.Resource implements IPodSelector,
       shareProcessNamespace: this.shareProcessNamespace,
       hostNetwork: this.hostNetwork,
       terminationGracePeriodSeconds: this.terminationGracePeriod?.toSeconds(),
+      enableServiceLinks: this.enableServiceLinks,
     };
 
   }
@@ -469,6 +472,15 @@ export interface AbstractPodProps extends base.ResourceProps {
    * @default Duration.seconds(30)
    */
   readonly terminationGracePeriod?: Duration;
+
+  /**
+   * Indicates whether information about services should be injected into pod's
+   * environment variables, matching the syntax of Docker links.
+   *
+   * @default true
+   * @see https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service
+   */
+  readonly enableServiceLinks?: boolean;
 }
 
 /**


Test patch:
diff --git a/test/pod.test.ts b/test/pod.test.ts
index 17f44567..99ea4830 100644
--- a/test/pod.test.ts
+++ b/test/pod.test.ts
@@ -1605,3 +1605,14 @@ test('Containers should not specify "restartPolicy" field', () => {
   expect(() => Testing.synth(chart)).toThrowError();
 });
 
+test('enableServiceLinks can be disabled', () => {
+  const chart = Testing.chart();
+  new kplus.Pod(chart, 'Pod', {
+    containers: [{ image: 'image' }],
+    enableServiceLinks: false,
+  });
+
+  const spec = Testing.synth(chart)[0].spec;
+  expect(spec.enableServiceLinks).toBeFalsy();
+});
+
Repository: cdk8s-team/cdk8s-plus
Pull request #5712 (2025-05-08 08:13:47)

feat(pod): support `enableServiceLinks` (backport #5471)
# Backport

This will backport the following commits from `k8s-32/main` to `k8s-31/main`:
 - [feat(pod): support &#x60;enableServiceLinks&#x60; (#5471)](https://github.com/cdk8s-team/cdk8s-plus/pull/5471)

<!--- Backport version: 9.5.1 -->

### Questions ?
Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)


Patch:
diff --git a/src/pod.ts b/src/pod.ts
index 14e4dfd2..d8d93ec2 100644
--- a/src/pod.ts
+++ b/src/pod.ts
@@ -22,6 +22,7 @@ export abstract class AbstractPod extends base.Resource implements IPodSelector,
   public readonly shareProcessNamespace: boolean;
   public readonly hostNetwork?: boolean;
   public readonly terminationGracePeriod?: Duration;
+  public readonly enableServiceLinks?: boolean;
 
   protected readonly isolate: boolean;
 
@@ -45,6 +46,7 @@ export abstract class AbstractPod extends base.Resource implements IPodSelector,
     this.isolate = props.isolate ?? false;
     this.hostNetwork = props.hostNetwork ?? false;
     this.terminationGracePeriod = props.terminationGracePeriod ?? Duration.seconds(30);
+    this.enableServiceLinks = props.enableServiceLinks;
 
     if (props.containers) {
       props.containers.forEach(c => this.addContainer(c));
@@ -254,6 +256,7 @@ export abstract class AbstractPod extends base.Resource implements IPodSelector,
       shareProcessNamespace: this.shareProcessNamespace,
       hostNetwork: this.hostNetwork,
       terminationGracePeriodSeconds: this.terminationGracePeriod?.toSeconds(),
+      enableServiceLinks: this.enableServiceLinks,
     };
 
   }
@@ -469,6 +472,15 @@ export interface AbstractPodProps extends base.ResourceProps {
    * @default Duration.seconds(30)
    */
   readonly terminationGracePeriod?: Duration;
+
+  /**
+   * Indicates whether information about services should be injected into pod's
+   * environment variables, matching the syntax of Docker links.
+   *
+   * @default true
+   * @see https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service
+   */
+  readonly enableServiceLinks?: boolean;
 }
 
 /**


Test patch:
diff --git a/test/pod.test.ts b/test/pod.test.ts
index 17f44567..99ea4830 100644
--- a/test/pod.test.ts
+++ b/test/pod.test.ts
@@ -1605,3 +1605,14 @@ test('Containers should not specify "restartPolicy" field', () => {
   expect(() => Testing.synth(chart)).toThrowError();
 });
 
+test('enableServiceLinks can be disabled', () => {
+  const chart = Testing.chart();
+  new kplus.Pod(chart, 'Pod', {
+    containers: [{ image: 'image' }],
+    enableServiceLinks: false,
+  });
+
+  const spec = Testing.synth(chart)[0].spec;
+  expect(spec.enableServiceLinks).toBeFalsy();
+});
+
Repository: OpenMined/PySyft
Pull request #1681 (2018-11-15 09:24:30)

Solved: Add serde logic for range #1664
Added the logic (if necessary) for range serde.

Added a unit test

Added add docstrings for all methods describing their functionality including an example of how to serialize it



Patch:
diff --git a/syft/serde.py b/syft/serde.py
index 09a5878efb..71318e6c79 100644
--- a/syft/serde.py
+++ b/syft/serde.py
@@ -30,6 +30,7 @@ By default, we serialize using msgpack and compress using lz4.
 
 from typing import Collection
 from typing import Dict
+from typing import Tuple
 import pickle
 import torch
 import msgpack
@@ -234,6 +235,47 @@ def _detail_dictionary(my_dict: Dict) -> Dict:
     return pieces
 
 
+# Range
+
+
+def _simplify_range(my_range: range) -> Tuple[int, int, int]:
+    """This function extracts the start, stop and step from the range.
+
+    Args:
+        range: a range object
+
+    Returns:
+        list: a list defining the range parameters [start, stop, step]
+
+    Usage:
+
+        range_parameters = _simplify_range(range(1, 3, 4))
+
+        assert range_parameters == [1, 3, 4]
+
+    """
+
+    return [my_range.start, my_range.stop, my_range.step]
+
+def _detail_range(my_range_params: Tuple[int, int, int]) -> range:
+    """This function extracts the start, stop and step from a tuple.
+
+    Args:
+        list: a list defining the range parameters [start, stop, step]
+
+    Returns:
+        range: a range object
+
+    Usage:
+        new_range = _detail_range([1, 3, 4])
+
+        assert new_range == range(1, 3, 4)
+
+    """
+
+    return range(my_range_params[0], my_range_params[1], my_range_params[2])
+
+
 # High Level Simplification Router
 
 
@@ -283,6 +325,7 @@ simplifiers[tuple] = [1, _simplify_collection]
 simplifiers[list] = [2, _simplify_collection]
 simplifiers[set] = [3, _simplify_collection]
 simplifiers[dict] = [4, _simplify_dictionary]
+simplifiers[range] = [5, _simplify_range]
 
 
 def _detail(obj: object) -> object:


Test patch:
diff --git a/test/test_serde.py b/test/test_serde.py
index a1b2c33676..802c08d700 100644
--- a/test/test_serde.py
+++ b/test/test_serde.py
@@ -42,6 +42,11 @@ class TestSimplify(TestCase):
         target = [4, {"hello": "world"}]
         assert _simplify(input) == target
 
+    def test_range_simplify(self):
+        input = range(1, 3, 4)
+        target = [5, [1, 3, 4]]
+        assert _simplify(input) == target
+
     def test_torch_tensor_simplify(self):
         input = tensor(numpy.random.random((100, 100)))
         output = _simplify(input)
Repository: OpenMined/PySyft
Pull request #1751 (2018-12-06 15:28:49)

Ellipsis serde


Patch:
diff --git a/.gitignore b/.gitignore
index 10379a36a7..cd45641c6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,4 +15,5 @@ syft.egg-info/
 venv/
 **.pytest_cache/
 docs/_modules
-.coverage
\ No newline at end of file
+.coverage
+.vscode/
\ No newline at end of file
diff --git a/syft/serde.py b/syft/serde.py
index 60428a7d86..309f3b190d 100644
--- a/syft/serde.py
+++ b/syft/serde.py
@@ -466,7 +466,17 @@ def _detail_slice(my_slice: Tuple[int, int, int]) -> slice:
     return slice(my_slice[0], my_slice[1], my_slice[2])
 
 
-# High Level Simplification Router
+# ellipsis
+
+
+def _simplify_ellipsis(e: Ellipsis) -> bytes:
+    return b""
+
+
+def _detail_ellipsis(ellipsis: bytes) -> Ellipsis:
+    return ...
+
+    # High Level Simplification Router
 
 
 def _simplify(obj: object) -> object:
@@ -518,6 +528,7 @@ simplifiers = {
     range: [5, _simplify_range],
     numpy.ndarray: [6, _simplify_ndarray],
     slice: [7, _simplify_slice],
+    type(Ellipsis): [8, _simplify_ellipsis],
 }
 
 
@@ -551,4 +562,5 @@ detailers = [
     _detail_range,
     _detail_ndarray,
     _detail_slice,
+    _detail_ellipsis,
 ]


Test patch:
diff --git a/test/test_serde.py b/test/test_serde.py
index 0ab8dd4e51..d1b60ba984 100644
--- a/test/test_serde.py
+++ b/test/test_serde.py
@@ -64,6 +64,9 @@ class TestSimplify(TestCase):
         assert output[1][1] == input.shape
         assert output[1][2] == input.dtype.name
 
+    def test_ellipsis_simplify(self):
+        assert _simplify(Ellipsis)[1] == b""
+
 
 class TestSerde(TestCase):
     def test_torch_Tensor(self):