Datasets:

Modalities:
Text
Formats:
json
Languages:
English
Libraries:
Datasets
pandas
License:
michaelmior commited on
Commit
27cd921
·
verified ·
1 Parent(s): e7ea59f

Refetch with licenses

Browse files
.gitattributes CHANGED
@@ -1,3 +1,4 @@
1
  *.jsonl.gz filter=lfs diff=lfs merge=lfs -text
2
  commits.json filter=lfs diff=lfs merge=lfs -text
3
  licenses.json filter=lfs diff=lfs merge=lfs -text
 
 
1
  *.jsonl.gz filter=lfs diff=lfs merge=lfs -text
2
  commits.json filter=lfs diff=lfs merge=lfs -text
3
  licenses.json filter=lfs diff=lfs merge=lfs -text
4
+ repos.csv filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -21,7 +21,7 @@ We fetch every revision of each JSON Schema file.
21
  Before downloading the files, we use the GitHub API to get the list of commit hashes.
22
  The resulting data is saved to `commits.json`.
23
 
24
- pipenv run python fetch_history.py
25
 
26
  # Step 3: Download the JSON Schema files
27
 
 
21
  Before downloading the files, we use the GitHub API to get the list of commit hashes.
22
  The resulting data is saved to `commits.json`.
23
 
24
+ pipenv run python fetch_history.py > commits.json
25
 
26
  # Step 3: Download the JSON Schema files
27
 
commits.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f34aef7778a01ff7372caa93cb643cb813da1f4155c002934d31ccdbfcb6f70d
3
- size 16160542
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:614728e256bc1d24dc755da12a9d7203a9f908e1ae45bf7dadc7ed73de251ba5
3
+ size 16166511
get_licenses.py CHANGED
@@ -52,7 +52,10 @@ def main():
52
  with open("repos.csv", "r") as csvfile:
53
  # Count number of rows and reset
54
  reader = csv.DictReader(csvfile)
55
- repos = set(row["repository"].split("/", maxsplit=1)[1] for row in reader) - fetched_repos
 
 
 
56
 
57
  for repo in tqdm.tqdm(repos):
58
  license = get_license(session, repo)
 
52
  with open("repos.csv", "r") as csvfile:
53
  # Count number of rows and reset
54
  reader = csv.DictReader(csvfile)
55
+ repos = (
56
+ set(row["repository"].split("/", maxsplit=1)[1] for row in reader)
57
+ - fetched_repos
58
+ )
59
 
60
  for repo in tqdm.tqdm(repos):
61
  license = get_license(session, repo)
licenses.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f04854dd486decac89335f6e547ea20820e3f2020c1452fcfdda080172751d7c
3
- size 93380
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de0342d512d5c8baa9ef2fe025e1ae355bcaa8f2d596827fe84a1a38fc5cdae9
3
+ size 129943
permissive_licenses.json ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ "MIT",
3
+ "Apache-2.0",
4
+ "BSD-3-Clause",
5
+ "Unlicense",
6
+ "CC0-1.0",
7
+ "BSD-2-Clause",
8
+ "CC-BY-4.0",
9
+ "CC-BY-3.0",
10
+ "0BSD",
11
+ "RSA-MD",
12
+ "WTFPL",
13
+ "MIT-0",
14
+ "ISC",
15
+ "ADSL",
16
+ "BSL-1.0",
17
+ "Zlib",
18
+ "Artistic-2.0",
19
+ "FTL",
20
+ "MS-PL",
21
+ "BSD-2-Clause-FreeBSD",
22
+ "FSFAP",
23
+ "BSD-Source-Code",
24
+ "Apache-1.1",
25
+ "BSD-4-Clause",
26
+ "Ruby",
27
+ "Artistic-1.0",
28
+ "MulanPSL-1.0",
29
+ "BSD-1-Clause",
30
+ "X11",
31
+ "CNRI-Python",
32
+ "Beerware",
33
+ "Condor-1.1",
34
+ "PostgreSQL",
35
+ "CECILL-B",
36
+ "Intel",
37
+ "Vim",
38
+ "Naumen",
39
+ "OML",
40
+ "BSD-3-Clause-Clear",
41
+ "AML",
42
+ "PHP-3.01",
43
+ "OpenSSL",
44
+ "PSF-2.0",
45
+ "Xnet",
46
+ "Linux-OpenIB",
47
+ "BSD-3-Clause-LBNL",
48
+ "UPL-1.0",
49
+ "AFL-3.0",
50
+ "BlueOak-1.0.0",
51
+ "Info-ZIP",
52
+ "BSD-4-Clause-UC",
53
+ "AAL",
54
+ "LPPL-1.3c",
55
+ "bzip2-1.0.6",
56
+ "W3C",
57
+ "W3C-20150513",
58
+ "AFL-1.1",
59
+ "DOC",
60
+ "ICU",
61
+ "CC-BY-2.0",
62
+ "curl",
63
+ "MTLL",
64
+ "OLDAP-2.2.1",
65
+ "ECL-2.0",
66
+ "Adobe-Glyph",
67
+ "CNRI-Python-GPL-Compatible",
68
+ "BSD-2-Clause-Patent",
69
+ "IJG",
70
+ "PHP-3.0",
71
+ "ZPL-2.1",
72
+ "MIT-advertising",
73
+ "NCSA",
74
+ "Fair",
75
+ "BSD-3-Clause-Attribution",
76
+ "OLDAP-2.3",
77
+ "NLPL",
78
+ "BSD-3-Clause-Open-MPI",
79
+ "ClArtistic",
80
+ "Python-2.0",
81
+ "NASA-1.3",
82
+ "TCL",
83
+ "Artistic-1.0-Perl",
84
+ "blessing",
85
+ "BSD-3-Clause-No-Nuclear-Warranty",
86
+ "ImageMagick",
87
+ "Net-SNMP",
88
+ "Artistic-1.0-cl8",
89
+ "OLDAP-2.5",
90
+ "MIT-feh",
91
+ "OLDAP-2.4",
92
+ "MITNFA",
93
+ "AFL-2.1",
94
+ "libpng-2.0",
95
+ "EFL-2.0",
96
+ "OLDAP-2.7",
97
+ "IBM-pibs",
98
+ "libtiff",
99
+ "OLDAP-2.8",
100
+ "Cube",
101
+ "Adobe-2006",
102
+ "BSD-2-Clause-NetBSD",
103
+ "zlib-acknowledgement",
104
+ "OLDAP-2.6",
105
+ "BSD-3-Clause-No-Nuclear-License-2014",
106
+ "OLDAP-1.4",
107
+ "Libpng",
108
+ "MIT-CMU",
109
+ "AFL-2.0",
110
+ "JasPer-2.0",
111
+ "LPL-1.02",
112
+ "Zend-2.0",
113
+ "TCP-wrappers",
114
+ "XFree86-1.1",
115
+ "FSFUL",
116
+ "OLDAP-1.3",
117
+ "SGI-B-2.0",
118
+ "NetCDF",
119
+ "CNRI-Jython",
120
+ "Zed",
121
+ "ZPL-2.0",
122
+ "AFL-1.2",
123
+ "Apache-1.0",
124
+ "CC-BY-1.0",
125
+ "OLDAP-2.1",
126
+ "OLDAP-1.2",
127
+ "OLDAP-2.0",
128
+ "NTP",
129
+ "LPL-1.0",
130
+ "AMPAS",
131
+ "Barr",
132
+ "mpich2",
133
+ "ANTLR-PD",
134
+ "Xerox",
135
+ "Spencer-94",
136
+ "AMDPLPA",
137
+ "BSD-3-Clause-No-Nuclear-License",
138
+ "HPND",
139
+ "ECL-1.0",
140
+ "MirOS",
141
+ "Qhull",
142
+ "ZPL-1.1",
143
+ "TU-Berlin-2.0",
144
+ "Spencer-86",
145
+ "SMLNJ",
146
+ "xinetd",
147
+ "OLDAP-2.2.2",
148
+ "OGTSL",
149
+ "MIT-enna",
150
+ "Font-exception-2.0",
151
+ "FSFULLR",
152
+ "TU-Berlin-1.0",
153
+ "xpp",
154
+ "NRL",
155
+ "W3C-19980720",
156
+ "EFL-1.0",
157
+ "eGenix",
158
+ "Unicode-DFS-2016",
159
+ "SWL",
160
+ "Spencer-99",
161
+ "Plexus",
162
+ "VSL-1.0",
163
+ "Leptonica",
164
+ "Unicode-DFS-2015",
165
+ "Mup",
166
+ "Giftware",
167
+ "OLDAP-2.2",
168
+ "APAFML",
169
+ "NBPL-1.0",
170
+ "OLDAP-1.1",
171
+ "Entessa",
172
+ "Multics",
173
+ "Newsletr",
174
+ "psutils",
175
+ "bzip2-1.0.5",
176
+ "Afmparse",
177
+ "diffmark",
178
+ "BSD-2-Clause-Views",
179
+ "DSDP",
180
+ "MIT-Modern-Variant",
181
+ "ANTLR-PD-fallback",
182
+ "Bahyph",
183
+ "BSD-3-Clause-Modification",
184
+ "BSD-4-Clause-Shortened",
185
+ "HTMLTIDY",
186
+ "MIT-open-group",
187
+ "MulanPSL-2.0",
188
+ "OLDAP-2.0.1",
189
+ "Saxpath",
190
+ "Borceux",
191
+ "Crossword",
192
+ "CrystalStacker",
193
+ "Rdisc",
194
+ "Wsuipa"
195
+ ]
repos.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0b87cc1de6088952129cf61cedd7114b19f562ebeb93938468c57430af7d43e1
3
- size 11891067
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1efe43b4eddd1e73ba3fe8e3408365bfbca9daa1418c69f6097c131e92b7539
3
+ size 12699153
test.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:58d2374d03fc37794559df99f336c83b6631e0e565548e7e3b2ada2a72f083b7
3
- size 2525492
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2e793b316e775246697fbbc449c9370dbd75b68f19f109e85448ebdcf6a23f7
3
+ size 2506162
train.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:94046ca1146e3160cef4e57b3592b6405f6e6fc6f204abefee45670fdf876051
3
- size 44357058
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26c4295b8905c2ed91b8501c672cf2b0e978ddce43e6ec694377587b299e2991
3
+ size 13000669
train_split.py CHANGED
@@ -14,12 +14,17 @@ import unionfind
14
  import Levenshtein
15
 
16
 
17
- def files_list():
 
 
 
18
  data_path = Path("valid_data")
19
  files = [
20
  f
21
  for f in data_path.rglob("*.json")
22
- if f.is_file() and "node_modules" not in f.parts
 
 
23
  ]
24
  return files
25
 
@@ -29,7 +34,13 @@ def write_schemas(filename, schema_list, schema_data):
29
  with gzip.open(filename, "wt") as f:
30
  for schema in tqdm.tqdm(list(schema_list)):
31
  filename = str(os.path.join(*Path(schema).parts[1:]))
32
- data = schema_data[filename]
 
 
 
 
 
 
33
  schema = open(schema).read()
34
 
35
  # Get stars or null if missing
@@ -51,8 +62,19 @@ def write_schemas(filename, schema_list, schema_data):
51
  f.write("\n")
52
 
53
 
54
- def main(similarity, split, seed, commits_file):
55
- files = files_list()
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  # Prepare a BK Tree if we're doing similarity grouping
58
  if similarity:
@@ -126,6 +148,7 @@ def main(similarity, split, seed, commits_file):
126
  filename = os.path.join(obj["repository"], commit["sha"], obj["path"])
127
  obj["commit"] = commit["sha"]
128
  obj["commitDate"] = commit["date"]
 
129
  schema_data[filename] = obj
130
 
131
  # Write the train and test sets
@@ -137,8 +160,9 @@ def main(similarity, split, seed, commits_file):
137
  if __name__ == "__main__":
138
  parser = argparse.ArgumentParser()
139
  parser.add_argument("--similarity", default=None, type=float)
140
- parser.add_argument("--seed", default=384, type=int)
141
  parser.add_argument("--split", default=0.8, type=float)
142
  parser.add_argument("--commits_file", default="commits.json")
 
143
  args = parser.parse_args()
144
- main(args.similarity, args.split, args.seed, args.commits_file)
 
14
  import Levenshtein
15
 
16
 
17
+ PERMISSIVE_LICENSES = set(json.load(open("permissive_licenses.json")))
18
+
19
+
20
+ def files_list(licenses):
21
  data_path = Path("valid_data")
22
  files = [
23
  f
24
  for f in data_path.rglob("*.json")
25
+ if f.is_file()
26
+ and "node_modules" not in f.parts
27
+ and licenses["/".join(f.parts[1:3])] in PERMISSIVE_LICENSES
28
  ]
29
  return files
30
 
 
34
  with gzip.open(filename, "wt") as f:
35
  for schema in tqdm.tqdm(list(schema_list)):
36
  filename = str(os.path.join(*Path(schema).parts[1:]))
37
+
38
+ # Skip schemas that have not been fetched this run
39
+ try:
40
+ data = schema_data[filename]
41
+ except KeyError:
42
+ continue
43
+
44
  schema = open(schema).read()
45
 
46
  # Get stars or null if missing
 
62
  f.write("\n")
63
 
64
 
65
+ def get_licenses(licenses_file):
66
+ licenses = {}
67
+ with open(licenses_file, "r") as f:
68
+ for line in f:
69
+ obj = json.loads(line)
70
+ licenses[obj["repository"]] = obj["license"]
71
+
72
+ return licenses
73
+
74
+
75
+ def main(similarity, split, seed, commits_file, licenses_file):
76
+ licenses = get_licenses(licenses_file)
77
+ files = files_list(licenses)
78
 
79
  # Prepare a BK Tree if we're doing similarity grouping
80
  if similarity:
 
148
  filename = os.path.join(obj["repository"], commit["sha"], obj["path"])
149
  obj["commit"] = commit["sha"]
150
  obj["commitDate"] = commit["date"]
151
+ obj["license"] = licenses[obj["repository"]]
152
  schema_data[filename] = obj
153
 
154
  # Write the train and test sets
 
160
  if __name__ == "__main__":
161
  parser = argparse.ArgumentParser()
162
  parser.add_argument("--similarity", default=None, type=float)
163
+ parser.add_argument("--seed", default=282, type=int)
164
  parser.add_argument("--split", default=0.8, type=float)
165
  parser.add_argument("--commits_file", default="commits.json")
166
+ parser.add_argument("--licenses_file", default="licenses.json")
167
  args = parser.parse_args()
168
+ main(args.similarity, args.split, args.seed, args.commits_file, args.licenses_file)
validate_schemas.py CHANGED
@@ -1,6 +1,7 @@
1
  import json
2
  import os
3
  from pathlib import Path
 
4
 
5
  import json5
6
  import jsonschema
@@ -30,6 +31,10 @@ def process_file(schema_file):
30
  Path.mkdir(new_schema_file.parent, parents=True, exist_ok=True)
31
  json.dump(schema, open(new_schema_file, "w"), sort_keys=True, indent=2)
32
 
 
33
  if __name__ == "__main__":
 
 
 
34
  data_path = Path("data")
35
  process_map(process_file, list(data_path.rglob("*.json")), chunksize=10)
 
1
  import json
2
  import os
3
  from pathlib import Path
4
+ import sys
5
 
6
  import json5
7
  import jsonschema
 
31
  Path.mkdir(new_schema_file.parent, parents=True, exist_ok=True)
32
  json.dump(schema, open(new_schema_file, "w"), sort_keys=True, indent=2)
33
 
34
+
35
  if __name__ == "__main__":
36
+ # Increase the recursion limit to handle large schemas
37
+ sys.setrecursionlimit(10000)
38
+
39
  data_path = Path("data")
40
  process_map(process_file, list(data_path.rglob("*.json")), chunksize=10)
validation.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5b00077250cbf3e7a876ae95f7cf1d5ab0b0c01957bf45cbcbebe9fb8ff79fbd
3
- size 4581789
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:495dd178891ec40fbb99f449b128c1f6f7e458210488b5d1d0ba0872f1c5fa9b
3
+ size 1648577