Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/datasets/arrow_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5547,7 +5547,7 @@ def push_to_hub(
download_config=download_config,
)
with open(dataset_infos_path, encoding="utf-8") as f:
dataset_infos: DatasetInfosDict = json.load(f)
dataset_infos: dict = json.load(f)
dataset_infos[config_name] = asdict(info_to_dump)
buffer = BytesIO()
buffer.write(json.dumps(dataset_infos, indent=4).encode("utf-8"))
Expand Down
20 changes: 8 additions & 12 deletions src/datasets/dataset_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,23 +1677,12 @@ def push_to_hub(
)
dataset_card = DatasetCard.load(Path(dataset_readme_path))
dataset_card_data = dataset_card.data
dataset_infos: DatasetInfosDict = DatasetInfosDict.from_dataset_card_data(dataset_card_data)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not used so I removed this line

metadata_configs = MetadataConfigs.from_dataset_card_data(dataset_card_data)
# get the deprecated dataset_infos.json to update them
elif config.DATASETDICT_INFOS_FILENAME in repo_files:
dataset_card = None
dataset_card_data = DatasetCardData()
metadata_configs = MetadataConfigs()
download_config = DownloadConfig()
download_config.download_desc = "Downloading metadata"
download_config.token = token
dataset_infos_path = cached_path(
hf_hub_url(repo_id, config.DATASETDICT_INFOS_FILENAME),
download_config=download_config,
)
with open(dataset_infos_path, encoding="utf-8") as f:
dataset_infos: dict = json.load(f)
dataset_infos.get(config_name, None) if dataset_infos else None
else:
dataset_card = None
dataset_card_data = DatasetCardData()
Expand Down Expand Up @@ -1722,8 +1711,15 @@ def push_to_hub(
MetadataConfigs({"default": default_metadata_configs_to_dump}).to_dataset_card_data(dataset_card_data)
# push to the deprecated dataset_infos.json
if config.DATASETDICT_INFOS_FILENAME in repo_files:
download_config = DownloadConfig()
download_config.download_desc = "Downloading metadata"
download_config.token = token
dataset_infos_path = cached_path(
hf_hub_url(repo_id, config.DATASETDICT_INFOS_FILENAME),
download_config=download_config,
)
Comment on lines +1714 to +1720
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code needs to be here, because in the previous location it would be run only if there is no README.md and if there is a json file. But it needs to run if there is a json file, no matter if there is a README.md or not

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah lol true good catch!

with open(dataset_infos_path, encoding="utf-8") as f:
dataset_infos: DatasetInfosDict = json.load(f)
dataset_infos: dict = json.load(f)
dataset_infos[config_name] = asdict(info_to_dump)
buffer = BytesIO()
buffer.write(json.dumps(dataset_infos, indent=4).encode("utf-8"))
Expand Down