Skip to content
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

Make the split keyword optional for load_partition #2423

Merged
merged 9 commits into from
Nov 15, 2023

Conversation

adam-narozniak
Copy link
Member

@adam-narozniak adam-narozniak commented Sep 26, 2023

Issue

Currently, when you create the FederatedDataset object and want to load a partition, you need to do the following.

fds = FederatedDataset(dataset="mnist", partitioners={"train": 10})
partition = fds.load_partition(idx=0, split="train")

Yet it is clear that there is only one instance of Partitioner. Therefore, the call can be simplified. To say it differently, if when specyfing the split keyword in the load_partitition(idx=idx, split="train") train is the only possibility since you denote which partitioner will be used and only a single partitioner was used.

Proposal

Make the split keyword optional for load_partition in case of having just one partitioner:

fds = FederatedDataset(dataset="mnist", partitioners={"train": 10})
partition = fds.load_partition(idx=0) # no need to give the split here, it will be taken from "train"

Explanation

This PR does the following:

  • make the split optional - code modification of FederatedDataset,
  • check if it works - add tests
  • (create a utility function to compare the Datasets objects).

datasets/flwr_datasets/federated_dataset.py Outdated Show resolved Hide resolved
datasets/flwr_datasets/federated_dataset.py Outdated Show resolved Hide resolved
danieljanes
danieljanes previously approved these changes Nov 15, 2023
@danieljanes danieljanes enabled auto-merge (squash) November 15, 2023 13:03
@danieljanes danieljanes merged commit 3c89754 into main Nov 15, 2023
29 checks passed
@danieljanes danieljanes deleted the fds-simply-load-partition branch November 15, 2023 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants