Skip to content

Commit 4472a87

Browse files
authored
Fix unused DatasetInfosDict code in push_to_hub (#6042)
* remove unused DatasetInfosDict * minor typing fix
1 parent a1a9c00 commit 4472a87

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/datasets/arrow_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5551,7 +5551,7 @@ def push_to_hub(
55515551
download_config=download_config,
55525552
)
55535553
with open(dataset_infos_path, encoding="utf-8") as f:
5554-
dataset_infos: DatasetInfosDict = json.load(f)
5554+
dataset_infos: dict = json.load(f)
55555555
dataset_infos[config_name] = asdict(info_to_dump)
55565556
buffer = BytesIO()
55575557
buffer.write(json.dumps(dataset_infos, indent=4).encode("utf-8"))

src/datasets/dataset_dict.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,23 +1677,12 @@ def push_to_hub(
16771677
)
16781678
dataset_card = DatasetCard.load(Path(dataset_readme_path))
16791679
dataset_card_data = dataset_card.data
1680-
dataset_infos: DatasetInfosDict = DatasetInfosDict.from_dataset_card_data(dataset_card_data)
16811680
metadata_configs = MetadataConfigs.from_dataset_card_data(dataset_card_data)
16821681
# get the deprecated dataset_infos.json to update them
16831682
elif config.DATASETDICT_INFOS_FILENAME in repo_files:
16841683
dataset_card = None
16851684
dataset_card_data = DatasetCardData()
16861685
metadata_configs = MetadataConfigs()
1687-
download_config = DownloadConfig()
1688-
download_config.download_desc = "Downloading metadata"
1689-
download_config.token = token
1690-
dataset_infos_path = cached_path(
1691-
hf_hub_url(repo_id, config.DATASETDICT_INFOS_FILENAME),
1692-
download_config=download_config,
1693-
)
1694-
with open(dataset_infos_path, encoding="utf-8") as f:
1695-
dataset_infos: dict = json.load(f)
1696-
dataset_infos.get(config_name, None) if dataset_infos else None
16971686
else:
16981687
dataset_card = None
16991688
dataset_card_data = DatasetCardData()
@@ -1722,8 +1711,15 @@ def push_to_hub(
17221711
MetadataConfigs({"default": default_metadata_configs_to_dump}).to_dataset_card_data(dataset_card_data)
17231712
# push to the deprecated dataset_infos.json
17241713
if config.DATASETDICT_INFOS_FILENAME in repo_files:
1714+
download_config = DownloadConfig()
1715+
download_config.download_desc = "Downloading metadata"
1716+
download_config.token = token
1717+
dataset_infos_path = cached_path(
1718+
hf_hub_url(repo_id, config.DATASETDICT_INFOS_FILENAME),
1719+
download_config=download_config,
1720+
)
17251721
with open(dataset_infos_path, encoding="utf-8") as f:
1726-
dataset_infos: DatasetInfosDict = json.load(f)
1722+
dataset_infos: dict = json.load(f)
17271723
dataset_infos[config_name] = asdict(info_to_dump)
17281724
buffer = BytesIO()
17291725
buffer.write(json.dumps(dataset_infos, indent=4).encode("utf-8"))

0 commit comments

Comments
 (0)