27
27
TOKEN = environ ["GH_TOKEN" ]
28
28
AUTHORIZATION = {"Authorization" : f"token { TOKEN } " }
29
29
30
+ DATA_LOAD_RECOMMENDATION = """
30
31
31
- def build_dataset_descriptions ():
32
+ === "Python"
33
+
34
+ ``` python
35
+ from relational_datasets import load
36
+ train, test = load("{dataset_name}", "{version}")
37
+ ```
38
+
39
+ === "Julia"
40
+
41
+ ``` julia
42
+ using RelationalDatasets
43
+ train, test = load("{dataset_name}", "{version}")
44
+ ```
45
+
46
+ """
47
+
48
+
49
+ def build_dataset_descriptions (latest_version : str ):
32
50
33
51
req = Request (
34
52
"https://api.github.com/repos/srlearn/datasets/releases/latest" ,
@@ -47,11 +65,19 @@ def build_dataset_descriptions():
47
65
)
48
66
49
67
with urlopen (req ) as url :
50
- with open (f"dataset_descriptions/{ name } .md" , "w" ) as fh :
51
- fh .write (url .read ().decode ("utf-8" ))
68
+ description = url .read ().decode ("utf-8" ).splitlines ()
69
+
70
+ # Insert dataset loading instructions at the third position in the list.
71
+ description .insert (
72
+ 2 , DATA_LOAD_RECOMMENDATION .format (dataset_name = name , version = latest_version )
73
+ )
52
74
75
+ with open (f"dataset_descriptions/{ name } .md" , "w" ) as fh :
76
+ for line in description :
77
+ fh .write (line + "\n " )
53
78
54
- def build_downloads_page ():
79
+
80
+ def build_downloads_page () -> str :
55
81
56
82
req = Request (
57
83
"https://api.github.com/repos/srlearn/datasets/git/refs/tags" ,
@@ -108,7 +134,10 @@ def build_downloads_page():
108
134
with open ("downloads.md" , "w" ) as fh :
109
135
fh .write (markdown_string )
110
136
137
+ # The first entry of `all_versions` should be the most recent one.
138
+ return all_versions [0 ]
139
+
111
140
112
141
if __name__ == "__main__" :
113
- build_downloads_page ()
114
- build_dataset_descriptions ()
142
+ latest_version = build_downloads_page ()
143
+ build_dataset_descriptions (latest_version )
0 commit comments