klamike mtanneau commited on
Commit
7893974
·
verified ·
1 Parent(s): 8685b51

download instructions (#2)

Browse files

- Add download instructions (2f4cf72e3d71044d058e2fa27bddf72217d46ade)


Co-authored-by: Mathieu Tanneau <[email protected]>

Files changed (1) hide show
  1. README.md +66 -0
README.md CHANGED
@@ -19,6 +19,72 @@ This dataset contains input data and solutions for small-size Optimal Power Flow
19
  Original case files are based on instances from Power Grid Lib -- Optimal Power Flow ([PGLib OPF](https://github.com/power-grid-lib/pglib-opf));
20
  this dataset comprises instances corresponding to systems with up to 300 buses.
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  ## Contents
23
 
24
  For each system (e.g., `14_ieee`, `118_ieee`), the dataset provides multiple OPF instances,
 
19
  Original case files are based on instances from Power Grid Lib -- Optimal Power Flow ([PGLib OPF](https://github.com/power-grid-lib/pglib-opf));
20
  this dataset comprises instances corresponding to systems with up to 300 buses.
21
 
22
+ ## Download instructions
23
+
24
+ The recommended way to download this dataset is through the [HuggingFace client library](https://huggingface.co/docs/hub/datasets-downloading#using-the-hugging-face-client-library).
25
+
26
+ ### Downloading the entire dataset
27
+
28
+ 1. Install `huggingface_hub` (see official [installation instructions](https://huggingface.co/docs/huggingface_hub/installation))
29
+ ```bash
30
+ pip install --upgrade huggingface_hub
31
+ ```
32
+ 2. Download the dataset.
33
+ It is recommended to save files to a local directory
34
+ ```py
35
+ from huggingface_hub import snapshot_download
36
+ REPO_ID = "PGLearn/PGLearn-Small"
37
+ LOCAL_DIR = "<path/to/local/directory>"
38
+ snapshot_download(repo_id=REPO_ID, repo_type="dataset", local_dir=LOCAL_DIR)
39
+ ```
40
+ Note that by default, `snapshot_download` saves files to a local cache.
41
+ 3. De-compress all the files
42
+ ```bash
43
+ cd <path/to/local/directory>
44
+ find ./ -type f -name "*.gz" -exec unpigz -v {} +
45
+ ```
46
+
47
+ ### Downloading individual files
48
+
49
+ The entire PGLearn-Small collection takes about 180GB of disk space (compressed).
50
+
51
+ To avoid large disk usage and long download times, it is possible to download only a subset of the files.
52
+ This approach is recommended for users who only require a subset of the dataset, for instance:
53
+ * a subset of cases
54
+ * a specific OPF formulation (e.g. only ACOPF)
55
+ * only primal solutions (as opposed to primal and dual)
56
+
57
+ This can be achieved by using the `allow_patterns` and `ignore_patterns` parameters (see [official documentation](https://huggingface.co/docs/huggingface_hub/guides/download#filter-files-to-download)),
58
+ in lieu of step 2. above.
59
+
60
+ * To download only the `14_ieee` and `30_ieee` cases:
61
+ ```py
62
+ REPO_ID = "PGLearn/PGLearn-Small"
63
+ CASES = ["14_ieee", "30_ieee"]
64
+ LOCAL_DIR = "<path/to/local/dir>"
65
+
66
+ snapshot_download(repo_id=REPO_ID, allow_patterns=[f"{case}/" for case in CASES], repo_type="dataset", local_dir=LOCAL_DIR)
67
+ ```
68
+ * To download a specific OPF formulation
69
+ (the repository structure makes it simpler to exclude non-desired OPF formulations)
70
+ ```py
71
+ REPO_ID = "PGLearn/PGLearn-Small"
72
+ ALL_OPFS = ["ACOPF", "DCOPF", "SOCOPF"]
73
+ SELECTED_OPFS = ["ACOPF", "DCOPF"]
74
+ LOCAL_DIR = "<path/to/local/dir>"
75
+
76
+ snapshot_download(repo_id=REPO_ID, ignore_patterns=[f"*/{opf}/*" for opf in ALL_OPFS if opf not in SELECTED_OPFS], repo_type="dataset", local_dir=LOCAL_DIR)
77
+ ```
78
+
79
+ * To download only primal solutions
80
+ ```py
81
+ REPO_ID = "PGLearn/PGLearn-Small"
82
+ LOCAL_DIR = "<path/to/local/dir>"
83
+
84
+ snapshot_download(repo_id=REPO_ID, ignore_patterns="*dual.h5.gz", repo_type="dataset", local_dir=LOCAL_DIR)
85
+ ```
86
+
87
+
88
  ## Contents
89
 
90
  For each system (e.g., `14_ieee`, `118_ieee`), the dataset provides multiple OPF instances,