Datasets:
Correct mcq_carbon size metadata
Browse files- README.md +2 -2
- scripts/create_mcq_carbon.py +17 -8
README.md
CHANGED
|
@@ -74,10 +74,10 @@ dataset_info:
|
|
| 74 |
dtype: string
|
| 75 |
splits:
|
| 76 |
- name: train
|
| 77 |
-
num_bytes:
|
| 78 |
num_examples: 2600
|
| 79 |
download_size: 11786125
|
| 80 |
-
dataset_size:
|
| 81 |
- config_name: eukaryote_cls
|
| 82 |
features:
|
| 83 |
- name: id
|
|
|
|
| 74 |
dtype: string
|
| 75 |
splits:
|
| 76 |
- name: train
|
| 77 |
+
num_bytes: 15000459
|
| 78 |
num_examples: 2600
|
| 79 |
download_size: 11786125
|
| 80 |
+
dataset_size: 15000459
|
| 81 |
- config_name: eukaryote_cls
|
| 82 |
features:
|
| 83 |
- name: id
|
scripts/create_mcq_carbon.py
CHANGED
|
@@ -6,7 +6,7 @@ import random
|
|
| 6 |
from collections import defaultdict
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
-
from datasets import concatenate_datasets, load_dataset
|
| 10 |
from huggingface_hub import CommitOperationAdd, HfApi, hf_hub_download
|
| 11 |
|
| 12 |
|
|
@@ -61,12 +61,12 @@ def main() -> None:
|
|
| 61 |
parquet_path = args.output_dir / PARQUET_PATH
|
| 62 |
parquet_path.parent.mkdir(parents=True, exist_ok=True)
|
| 63 |
combined.to_parquet(parquet_path)
|
|
|
|
| 64 |
|
| 65 |
api = HfApi()
|
| 66 |
head = api.repo_info(args.output_dataset, repo_type="dataset").sha
|
| 67 |
card = Path(hf_hub_download(args.output_dataset, "README.md", repo_type="dataset", revision=head)).read_text()
|
| 68 |
-
|
| 69 |
-
info = f"""- config_name: mcq_carbon
|
| 70 |
features:
|
| 71 |
- name: id
|
| 72 |
dtype: int64
|
|
@@ -84,12 +84,21 @@ def main() -> None:
|
|
| 84 |
dtype: string
|
| 85 |
splits:
|
| 86 |
- name: train
|
| 87 |
-
num_bytes: {
|
| 88 |
-
num_examples: {len(
|
| 89 |
download_size: {parquet_path.stat().st_size}
|
| 90 |
-
dataset_size: {
|
| 91 |
"""
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
config = """- config_name: mcq_carbon
|
| 94 |
data_files:
|
| 95 |
- split: train
|
|
@@ -128,7 +137,7 @@ The script publishes the Parquet file, this card, and the builder script togethe
|
|
| 128 |
repo_id=args.output_dataset,
|
| 129 |
repo_type="dataset",
|
| 130 |
parent_commit=head,
|
| 131 |
-
commit_message=
|
| 132 |
operations=[
|
| 133 |
CommitOperationAdd(path_in_repo=PARQUET_PATH, path_or_fileobj=parquet_path),
|
| 134 |
CommitOperationAdd(path_in_repo="README.md", path_or_fileobj=card_path),
|
|
|
|
| 6 |
from collections import defaultdict
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
+
from datasets import Dataset, concatenate_datasets, load_dataset
|
| 10 |
from huggingface_hub import CommitOperationAdd, HfApi, hf_hub_download
|
| 11 |
|
| 12 |
|
|
|
|
| 61 |
parquet_path = args.output_dir / PARQUET_PATH
|
| 62 |
parquet_path.parent.mkdir(parents=True, exist_ok=True)
|
| 63 |
combined.to_parquet(parquet_path)
|
| 64 |
+
materialized = Dataset.from_parquet(str(parquet_path))
|
| 65 |
|
| 66 |
api = HfApi()
|
| 67 |
head = api.repo_info(args.output_dataset, repo_type="dataset").sha
|
| 68 |
card = Path(hf_hub_download(args.output_dataset, "README.md", repo_type="dataset", revision=head)).read_text()
|
| 69 |
+
info = f"""- config_name: mcq_carbon
|
|
|
|
| 70 |
features:
|
| 71 |
- name: id
|
| 72 |
dtype: int64
|
|
|
|
| 84 |
dtype: string
|
| 85 |
splits:
|
| 86 |
- name: train
|
| 87 |
+
num_bytes: {materialized.info.splits['train'].num_bytes}
|
| 88 |
+
num_examples: {len(materialized)}
|
| 89 |
download_size: {parquet_path.stat().st_size}
|
| 90 |
+
dataset_size: {materialized.info.dataset_size}
|
| 91 |
"""
|
| 92 |
+
marker = "- config_name: eukaryote_cls\n features:"
|
| 93 |
+
existing = "- config_name: mcq_carbon\n features:"
|
| 94 |
+
if existing in card:
|
| 95 |
+
start = card.index(existing)
|
| 96 |
+
end = card.index(marker, start)
|
| 97 |
+
card = card[:start] + info + card[end:]
|
| 98 |
+
commit_message = "Correct mcq_carbon size metadata"
|
| 99 |
+
else:
|
| 100 |
+
card = card.replace(marker, info + marker, 1)
|
| 101 |
+
commit_message = "Add stratified mcq_carbon configuration"
|
| 102 |
config = """- config_name: mcq_carbon
|
| 103 |
data_files:
|
| 104 |
- split: train
|
|
|
|
| 137 |
repo_id=args.output_dataset,
|
| 138 |
repo_type="dataset",
|
| 139 |
parent_commit=head,
|
| 140 |
+
commit_message=commit_message,
|
| 141 |
operations=[
|
| 142 |
CommitOperationAdd(path_in_repo=PARQUET_PATH, path_or_fileobj=parquet_path),
|
| 143 |
CommitOperationAdd(path_in_repo="README.md", path_or_fileobj=card_path),
|