# tff.program.ClientIdDataSourceIterator

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

A [`tff.program.FederatedDataSourceIterator`](https://www.tensorflow.org/federated/api_docs/python/tff/program/FederatedDataSourceIterator) backed by client ids.

Inherits From: [`FederatedDataSourceIterator`](https://www.tensorflow.org/federated/api_docs/python/tff/program/FederatedDataSourceIterator)

    tff.program.ClientIdDataSourceIterator(
        client_ids: Sequence[str]
    )

A [`tff.program.FederatedDataSourceIterator`](https://www.tensorflow.org/federated/api_docs/python/tff/program/FederatedDataSourceIterator) backed by sequence of client ids,
one client id per client. It selects client ids uniformly at random, with
replacement over successive calls of `select()` but without replacement within
a single call of `select()`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `client_ids` | A sequence of client ids to use to yield the ids from this data source. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `client_ids` is empty. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `federated_type` | The type of the data returned by calling `select`. |

<br />

## Methods

### `from_bytes`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @classmethod
    from_bytes(
        buffer: bytes
    ) -> 'ClientIdDataSourceIterator'

Deserializes the object from bytes.

### `select`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    select(
        k: Optional[int] = None
    ) -> object

Returns a new selection of client ids from this iterator.

<br />

<br />

<br />

| Args ||
|---|---|
| `k` | A number of elements to select. Must be a positive integer and less than the number of `client_ids`. |

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If `k` is not a positive integer or if `k` is not less than the number of `client_ids`. |

<br />

### `to_bytes`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    to_bytes() -> bytes

Serializes the object to bytes.

### `__eq__`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    __eq__(
        other: object
    ) -> bool

Return self==value.