mattdeitke
commited on
Commit
•
b9e7719
1
Parent(s):
1a65e11
update tests with new api
Browse files- Makefile +1 -1
- objaverse_xl/github.py +1 -1
- tests/test_api.py +110 -128
Makefile
CHANGED
@@ -20,7 +20,7 @@ format: ## [Local development] Auto-format python code using black, don't includ
|
|
20 |
python -m black scripts --exclude scripts/rendering/blender-3.2.2-linux-x64/
|
21 |
|
22 |
test: ## [Local development] Run unit tests
|
23 |
-
python -m pytest -x -s -v tests
|
24 |
|
25 |
.PHONY: help
|
26 |
|
|
|
20 |
python -m black scripts --exclude scripts/rendering/blender-3.2.2-linux-x64/
|
21 |
|
22 |
test: ## [Local development] Run unit tests
|
23 |
+
JUPYTER_PLATFORM_DIRS=1 python -m pytest -x -s -v tests
|
24 |
|
25 |
.PHONY: help
|
26 |
|
objaverse_xl/github.py
CHANGED
@@ -141,7 +141,7 @@ class GitHubDownloader(ObjaverseSource):
|
|
141 |
expected_objects (Dict[str, str]): Dictionary of objects that one expects to
|
142 |
find in the repo. Keys are the "fileIdentifier" (i.e., the GitHub URL in
|
143 |
this case) and values are the "sha256" of the objects.
|
144 |
-
{and the rest of the args are the same as
|
145 |
|
146 |
Returns:
|
147 |
List[Dict[str, str]]: List of dictionaries with the keys "fileIdentifier"
|
|
|
141 |
expected_objects (Dict[str, str]): Dictionary of objects that one expects to
|
142 |
find in the repo. Keys are the "fileIdentifier" (i.e., the GitHub URL in
|
143 |
this case) and values are the "sha256" of the objects.
|
144 |
+
{and the rest of the args are the same as download_objects}
|
145 |
|
146 |
Returns:
|
147 |
List[Dict[str, str]]: List of dictionaries with the keys "fileIdentifier"
|
tests/test_api.py
CHANGED
@@ -4,10 +4,11 @@ import shutil
|
|
4 |
import fsspec
|
5 |
import pandas as pd
|
6 |
|
7 |
-
from objaverse_xl.github import
|
8 |
|
9 |
|
10 |
def test_github_process_repo():
|
|
|
11 |
download_dir = "~/.objaverse-tests"
|
12 |
base_download_dir = os.path.join(download_dir, "github")
|
13 |
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
@@ -15,7 +16,7 @@ def test_github_process_repo():
|
|
15 |
|
16 |
for save_repo_format in ["tar", "tar.gz", "zip", "files"]:
|
17 |
# shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
18 |
-
out = _process_repo(
|
19 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
20 |
fs=fs,
|
21 |
base_dir=path,
|
@@ -37,7 +38,7 @@ def test_github_process_repo():
|
|
37 |
"7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
38 |
]:
|
39 |
assert sha256 in sha256s, f"{sha256=} not in {sha256s=}"
|
40 |
-
github_urls = [x["
|
41 |
for github_url in [
|
42 |
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
|
43 |
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
|
@@ -64,54 +65,50 @@ def test_github_process_repo():
|
|
64 |
|
65 |
|
66 |
def test_github_handle_new_object():
|
|
|
67 |
found_objects = []
|
68 |
handle_found_object = (
|
69 |
-
lambda
|
70 |
dict(
|
71 |
-
|
72 |
-
|
73 |
sha256=sha256,
|
74 |
-
|
75 |
-
organization=organization,
|
76 |
)
|
77 |
)
|
78 |
)
|
79 |
|
80 |
missing_objects = []
|
81 |
handle_missing_object = (
|
82 |
-
lambda
|
83 |
dict(
|
84 |
-
|
85 |
sha256=sha256,
|
86 |
-
|
87 |
-
organization=organization,
|
88 |
)
|
89 |
)
|
90 |
)
|
91 |
|
92 |
new_objects = []
|
93 |
handle_new_object = (
|
94 |
-
lambda
|
95 |
dict(
|
96 |
-
|
97 |
-
|
98 |
sha256=sha256,
|
99 |
-
|
100 |
-
organization=organization,
|
101 |
)
|
102 |
)
|
103 |
)
|
104 |
|
105 |
modified_objects = []
|
106 |
-
handle_modified_object = (
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
organization=organization,
|
114 |
-
)
|
115 |
)
|
116 |
)
|
117 |
|
@@ -121,7 +118,7 @@ def test_github_handle_new_object():
|
|
121 |
fs.makedirs(path, exist_ok=True)
|
122 |
|
123 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
124 |
-
out = _process_repo(
|
125 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
126 |
fs=fs,
|
127 |
base_dir=path,
|
@@ -142,54 +139,50 @@ def test_github_handle_new_object():
|
|
142 |
|
143 |
|
144 |
def test_github_handle_found_object():
|
|
|
145 |
found_objects = []
|
146 |
handle_found_object = (
|
147 |
-
lambda
|
148 |
dict(
|
149 |
-
|
150 |
-
|
151 |
sha256=sha256,
|
152 |
-
|
153 |
-
organization=organization,
|
154 |
)
|
155 |
)
|
156 |
)
|
157 |
|
158 |
missing_objects = []
|
159 |
handle_missing_object = (
|
160 |
-
lambda
|
161 |
dict(
|
162 |
-
|
163 |
sha256=sha256,
|
164 |
-
|
165 |
-
organization=organization,
|
166 |
)
|
167 |
)
|
168 |
)
|
169 |
|
170 |
new_objects = []
|
171 |
handle_new_object = (
|
172 |
-
lambda
|
173 |
dict(
|
174 |
-
|
175 |
-
|
176 |
sha256=sha256,
|
177 |
-
|
178 |
-
organization=organization,
|
179 |
)
|
180 |
)
|
181 |
)
|
182 |
|
183 |
modified_objects = []
|
184 |
-
handle_modified_object = (
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
organization=organization,
|
192 |
-
)
|
193 |
)
|
194 |
)
|
195 |
|
@@ -199,7 +192,7 @@ def test_github_handle_found_object():
|
|
199 |
fs.makedirs(path, exist_ok=True)
|
200 |
|
201 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
202 |
-
out = _process_repo(
|
203 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
204 |
fs=fs,
|
205 |
base_dir=path,
|
@@ -224,54 +217,50 @@ def test_github_handle_found_object():
|
|
224 |
|
225 |
|
226 |
def test_github_handle_modified_object():
|
|
|
227 |
found_objects = []
|
228 |
handle_found_object = (
|
229 |
-
lambda
|
230 |
dict(
|
231 |
-
|
232 |
-
|
233 |
sha256=sha256,
|
234 |
-
|
235 |
-
organization=organization,
|
236 |
)
|
237 |
)
|
238 |
)
|
239 |
|
240 |
missing_objects = []
|
241 |
handle_missing_object = (
|
242 |
-
lambda
|
243 |
dict(
|
244 |
-
|
245 |
sha256=sha256,
|
246 |
-
|
247 |
-
organization=organization,
|
248 |
)
|
249 |
)
|
250 |
)
|
251 |
|
252 |
new_objects = []
|
253 |
handle_new_object = (
|
254 |
-
lambda
|
255 |
dict(
|
256 |
-
|
257 |
-
|
258 |
sha256=sha256,
|
259 |
-
|
260 |
-
organization=organization,
|
261 |
)
|
262 |
)
|
263 |
)
|
264 |
|
265 |
modified_objects = []
|
266 |
-
handle_modified_object = (
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
organization=organization,
|
274 |
-
)
|
275 |
)
|
276 |
)
|
277 |
|
@@ -281,7 +270,7 @@ def test_github_handle_modified_object():
|
|
281 |
fs.makedirs(path, exist_ok=True)
|
282 |
|
283 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
284 |
-
out = _process_repo(
|
285 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
286 |
fs=fs,
|
287 |
base_dir=path,
|
@@ -306,54 +295,50 @@ def test_github_handle_modified_object():
|
|
306 |
|
307 |
|
308 |
def test_github_handle_missing_object():
|
|
|
309 |
found_objects = []
|
310 |
handle_found_object = (
|
311 |
-
lambda
|
312 |
dict(
|
313 |
-
|
314 |
-
|
315 |
sha256=sha256,
|
316 |
-
|
317 |
-
organization=organization,
|
318 |
)
|
319 |
)
|
320 |
)
|
321 |
|
322 |
missing_objects = []
|
323 |
handle_missing_object = (
|
324 |
-
lambda
|
325 |
dict(
|
326 |
-
|
327 |
sha256=sha256,
|
328 |
-
|
329 |
-
organization=organization,
|
330 |
)
|
331 |
)
|
332 |
)
|
333 |
|
334 |
new_objects = []
|
335 |
handle_new_object = (
|
336 |
-
lambda
|
337 |
dict(
|
338 |
-
|
339 |
-
|
340 |
sha256=sha256,
|
341 |
-
|
342 |
-
organization=organization,
|
343 |
)
|
344 |
)
|
345 |
)
|
346 |
|
347 |
modified_objects = []
|
348 |
-
handle_modified_object = (
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
organization=organization,
|
356 |
-
)
|
357 |
)
|
358 |
)
|
359 |
|
@@ -363,7 +348,7 @@ def test_github_handle_missing_object():
|
|
363 |
fs.makedirs(path, exist_ok=True)
|
364 |
|
365 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
366 |
-
out = _process_repo(
|
367 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
368 |
fs=fs,
|
369 |
base_dir=path,
|
@@ -389,54 +374,50 @@ def test_github_handle_missing_object():
|
|
389 |
|
390 |
|
391 |
def test_github_handle_missing_object_2():
|
|
|
392 |
found_objects = []
|
393 |
handle_found_object = (
|
394 |
-
lambda
|
395 |
dict(
|
396 |
-
|
397 |
-
|
398 |
sha256=sha256,
|
399 |
-
|
400 |
-
organization=organization,
|
401 |
)
|
402 |
)
|
403 |
)
|
404 |
|
405 |
missing_objects = []
|
406 |
handle_missing_object = (
|
407 |
-
lambda
|
408 |
dict(
|
409 |
-
|
410 |
sha256=sha256,
|
411 |
-
|
412 |
-
organization=organization,
|
413 |
)
|
414 |
)
|
415 |
)
|
416 |
|
417 |
new_objects = []
|
418 |
handle_new_object = (
|
419 |
-
lambda
|
420 |
dict(
|
421 |
-
|
422 |
-
|
423 |
sha256=sha256,
|
424 |
-
|
425 |
-
organization=organization,
|
426 |
)
|
427 |
)
|
428 |
)
|
429 |
|
430 |
modified_objects = []
|
431 |
-
handle_modified_object = (
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
organization=organization,
|
439 |
-
)
|
440 |
)
|
441 |
)
|
442 |
|
@@ -446,7 +427,7 @@ def test_github_handle_missing_object_2():
|
|
446 |
fs.makedirs(path, exist_ok=True)
|
447 |
|
448 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
449 |
-
out = _process_repo(
|
450 |
repo_id="mattdeitke/objaverse-xl-test-files-does-not-exist",
|
451 |
fs=fs,
|
452 |
base_dir=path,
|
@@ -472,20 +453,21 @@ def test_github_handle_missing_object_2():
|
|
472 |
|
473 |
|
474 |
def test_github_download_cache():
|
|
|
475 |
objects = pd.DataFrame(
|
476 |
[
|
477 |
{
|
478 |
-
"
|
479 |
"license": None,
|
480 |
"sha256": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
481 |
},
|
482 |
{
|
483 |
-
"
|
484 |
"license": None,
|
485 |
"sha256": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
486 |
},
|
487 |
{
|
488 |
-
"
|
489 |
"license": None,
|
490 |
"sha256": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
491 |
},
|
@@ -497,7 +479,7 @@ def test_github_download_cache():
|
|
497 |
repos_dir = "~/.objaverse-tests/github/repos"
|
498 |
shutil.rmtree(os.path.expanduser(repos_dir), ignore_errors=True)
|
499 |
|
500 |
-
out =
|
501 |
objects=objects,
|
502 |
processes=1,
|
503 |
download_dir="~/.objaverse-tests",
|
@@ -505,7 +487,7 @@ def test_github_download_cache():
|
|
505 |
)
|
506 |
assert len(out) == 3
|
507 |
|
508 |
-
out =
|
509 |
objects=objects,
|
510 |
processes=1,
|
511 |
download_dir="~/.objaverse-tests",
|
|
|
4 |
import fsspec
|
5 |
import pandas as pd
|
6 |
|
7 |
+
from objaverse_xl.github import GitHubDownloader
|
8 |
|
9 |
|
10 |
def test_github_process_repo():
|
11 |
+
github_downloader = GitHubDownloader()
|
12 |
download_dir = "~/.objaverse-tests"
|
13 |
base_download_dir = os.path.join(download_dir, "github")
|
14 |
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
|
|
16 |
|
17 |
for save_repo_format in ["tar", "tar.gz", "zip", "files"]:
|
18 |
# shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
19 |
+
out = github_downloader._process_repo(
|
20 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
21 |
fs=fs,
|
22 |
base_dir=path,
|
|
|
38 |
"7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
39 |
]:
|
40 |
assert sha256 in sha256s, f"{sha256=} not in {sha256s=}"
|
41 |
+
github_urls = [x["fileIdentifier"] for x in out]
|
42 |
for github_url in [
|
43 |
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
|
44 |
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
|
|
|
65 |
|
66 |
|
67 |
def test_github_handle_new_object():
|
68 |
+
github_downloader = GitHubDownloader()
|
69 |
found_objects = []
|
70 |
handle_found_object = (
|
71 |
+
lambda local_path, file_identifier, sha256, metadata: found_objects.append(
|
72 |
dict(
|
73 |
+
local_path=local_path,
|
74 |
+
file_identifier=file_identifier,
|
75 |
sha256=sha256,
|
76 |
+
metadata=metadata,
|
|
|
77 |
)
|
78 |
)
|
79 |
)
|
80 |
|
81 |
missing_objects = []
|
82 |
handle_missing_object = (
|
83 |
+
lambda file_identifier, sha256, metadata: missing_objects.append(
|
84 |
dict(
|
85 |
+
file_identifier=file_identifier,
|
86 |
sha256=sha256,
|
87 |
+
metadata=metadata,
|
|
|
88 |
)
|
89 |
)
|
90 |
)
|
91 |
|
92 |
new_objects = []
|
93 |
handle_new_object = (
|
94 |
+
lambda local_path, file_identifier, sha256, metadata: new_objects.append(
|
95 |
dict(
|
96 |
+
local_path=local_path,
|
97 |
+
file_identifier=file_identifier,
|
98 |
sha256=sha256,
|
99 |
+
metadata=metadata,
|
|
|
100 |
)
|
101 |
)
|
102 |
)
|
103 |
|
104 |
modified_objects = []
|
105 |
+
handle_modified_object = lambda local_path, file_identifier, new_sha256, old_sha256, metadata: modified_objects.append(
|
106 |
+
dict(
|
107 |
+
local_path=local_path,
|
108 |
+
file_identifier=file_identifier,
|
109 |
+
new_sha256=new_sha256,
|
110 |
+
old_sha256=old_sha256,
|
111 |
+
metadata=metadata,
|
|
|
|
|
112 |
)
|
113 |
)
|
114 |
|
|
|
118 |
fs.makedirs(path, exist_ok=True)
|
119 |
|
120 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
121 |
+
out = github_downloader._process_repo(
|
122 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
123 |
fs=fs,
|
124 |
base_dir=path,
|
|
|
139 |
|
140 |
|
141 |
def test_github_handle_found_object():
|
142 |
+
github_downloader = GitHubDownloader()
|
143 |
found_objects = []
|
144 |
handle_found_object = (
|
145 |
+
lambda local_path, file_identifier, sha256, metadata: found_objects.append(
|
146 |
dict(
|
147 |
+
local_path=local_path,
|
148 |
+
file_identifier=file_identifier,
|
149 |
sha256=sha256,
|
150 |
+
metadata=metadata,
|
|
|
151 |
)
|
152 |
)
|
153 |
)
|
154 |
|
155 |
missing_objects = []
|
156 |
handle_missing_object = (
|
157 |
+
lambda file_identifier, sha256, metadata: missing_objects.append(
|
158 |
dict(
|
159 |
+
file_identifier=file_identifier,
|
160 |
sha256=sha256,
|
161 |
+
metadata=metadata,
|
|
|
162 |
)
|
163 |
)
|
164 |
)
|
165 |
|
166 |
new_objects = []
|
167 |
handle_new_object = (
|
168 |
+
lambda local_path, file_identifier, sha256, metadata: new_objects.append(
|
169 |
dict(
|
170 |
+
local_path=local_path,
|
171 |
+
file_identifier=file_identifier,
|
172 |
sha256=sha256,
|
173 |
+
metadata=metadata,
|
|
|
174 |
)
|
175 |
)
|
176 |
)
|
177 |
|
178 |
modified_objects = []
|
179 |
+
handle_modified_object = lambda local_path, file_identifier, new_sha256, old_sha256, metadata: modified_objects.append(
|
180 |
+
dict(
|
181 |
+
local_path=local_path,
|
182 |
+
file_identifier=file_identifier,
|
183 |
+
new_sha256=new_sha256,
|
184 |
+
old_sha256=old_sha256,
|
185 |
+
metadata=metadata,
|
|
|
|
|
186 |
)
|
187 |
)
|
188 |
|
|
|
192 |
fs.makedirs(path, exist_ok=True)
|
193 |
|
194 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
195 |
+
out = github_downloader._process_repo(
|
196 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
197 |
fs=fs,
|
198 |
base_dir=path,
|
|
|
217 |
|
218 |
|
219 |
def test_github_handle_modified_object():
|
220 |
+
github_downloader = GitHubDownloader()
|
221 |
found_objects = []
|
222 |
handle_found_object = (
|
223 |
+
lambda local_path, file_identifier, sha256, metadata: found_objects.append(
|
224 |
dict(
|
225 |
+
local_path=local_path,
|
226 |
+
file_identifier=file_identifier,
|
227 |
sha256=sha256,
|
228 |
+
metadata=metadata,
|
|
|
229 |
)
|
230 |
)
|
231 |
)
|
232 |
|
233 |
missing_objects = []
|
234 |
handle_missing_object = (
|
235 |
+
lambda file_identifier, sha256, metadata: missing_objects.append(
|
236 |
dict(
|
237 |
+
file_identifier=file_identifier,
|
238 |
sha256=sha256,
|
239 |
+
metadata=metadata,
|
|
|
240 |
)
|
241 |
)
|
242 |
)
|
243 |
|
244 |
new_objects = []
|
245 |
handle_new_object = (
|
246 |
+
lambda local_path, file_identifier, sha256, metadata: new_objects.append(
|
247 |
dict(
|
248 |
+
local_path=local_path,
|
249 |
+
file_identifier=file_identifier,
|
250 |
sha256=sha256,
|
251 |
+
metadata=metadata,
|
|
|
252 |
)
|
253 |
)
|
254 |
)
|
255 |
|
256 |
modified_objects = []
|
257 |
+
handle_modified_object = lambda local_path, file_identifier, new_sha256, old_sha256, metadata: modified_objects.append(
|
258 |
+
dict(
|
259 |
+
local_path=local_path,
|
260 |
+
file_identifier=file_identifier,
|
261 |
+
new_sha256=new_sha256,
|
262 |
+
old_sha256=old_sha256,
|
263 |
+
metadata=metadata,
|
|
|
|
|
264 |
)
|
265 |
)
|
266 |
|
|
|
270 |
fs.makedirs(path, exist_ok=True)
|
271 |
|
272 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
273 |
+
out = github_downloader._process_repo(
|
274 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
275 |
fs=fs,
|
276 |
base_dir=path,
|
|
|
295 |
|
296 |
|
297 |
def test_github_handle_missing_object():
|
298 |
+
github_downloader = GitHubDownloader()
|
299 |
found_objects = []
|
300 |
handle_found_object = (
|
301 |
+
lambda local_path, file_identifier, sha256, metadata: found_objects.append(
|
302 |
dict(
|
303 |
+
local_path=local_path,
|
304 |
+
file_identifier=file_identifier,
|
305 |
sha256=sha256,
|
306 |
+
metadata=metadata,
|
|
|
307 |
)
|
308 |
)
|
309 |
)
|
310 |
|
311 |
missing_objects = []
|
312 |
handle_missing_object = (
|
313 |
+
lambda file_identifier, sha256, metadata: missing_objects.append(
|
314 |
dict(
|
315 |
+
file_identifier=file_identifier,
|
316 |
sha256=sha256,
|
317 |
+
metadata=metadata,
|
|
|
318 |
)
|
319 |
)
|
320 |
)
|
321 |
|
322 |
new_objects = []
|
323 |
handle_new_object = (
|
324 |
+
lambda local_path, file_identifier, sha256, metadata: new_objects.append(
|
325 |
dict(
|
326 |
+
local_path=local_path,
|
327 |
+
file_identifier=file_identifier,
|
328 |
sha256=sha256,
|
329 |
+
metadata=metadata,
|
|
|
330 |
)
|
331 |
)
|
332 |
)
|
333 |
|
334 |
modified_objects = []
|
335 |
+
handle_modified_object = lambda local_path, file_identifier, new_sha256, old_sha256, metadata: modified_objects.append(
|
336 |
+
dict(
|
337 |
+
local_path=local_path,
|
338 |
+
file_identifier=file_identifier,
|
339 |
+
new_sha256=new_sha256,
|
340 |
+
old_sha256=old_sha256,
|
341 |
+
metadata=metadata,
|
|
|
|
|
342 |
)
|
343 |
)
|
344 |
|
|
|
348 |
fs.makedirs(path, exist_ok=True)
|
349 |
|
350 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
351 |
+
out = github_downloader._process_repo(
|
352 |
repo_id="mattdeitke/objaverse-xl-test-files",
|
353 |
fs=fs,
|
354 |
base_dir=path,
|
|
|
374 |
|
375 |
|
376 |
def test_github_handle_missing_object_2():
|
377 |
+
github_downloader = GitHubDownloader()
|
378 |
found_objects = []
|
379 |
handle_found_object = (
|
380 |
+
lambda local_path, file_identifier, sha256, metadata: found_objects.append(
|
381 |
dict(
|
382 |
+
local_path=local_path,
|
383 |
+
file_identifier=file_identifier,
|
384 |
sha256=sha256,
|
385 |
+
metadata=metadata,
|
|
|
386 |
)
|
387 |
)
|
388 |
)
|
389 |
|
390 |
missing_objects = []
|
391 |
handle_missing_object = (
|
392 |
+
lambda file_identifier, sha256, metadata: missing_objects.append(
|
393 |
dict(
|
394 |
+
file_identifier=file_identifier,
|
395 |
sha256=sha256,
|
396 |
+
metadata=metadata,
|
|
|
397 |
)
|
398 |
)
|
399 |
)
|
400 |
|
401 |
new_objects = []
|
402 |
handle_new_object = (
|
403 |
+
lambda local_path, file_identifier, sha256, metadata: new_objects.append(
|
404 |
dict(
|
405 |
+
local_path=local_path,
|
406 |
+
file_identifier=file_identifier,
|
407 |
sha256=sha256,
|
408 |
+
metadata=metadata,
|
|
|
409 |
)
|
410 |
)
|
411 |
)
|
412 |
|
413 |
modified_objects = []
|
414 |
+
handle_modified_object = lambda local_path, file_identifier, new_sha256, old_sha256, metadata: modified_objects.append(
|
415 |
+
dict(
|
416 |
+
local_path=local_path,
|
417 |
+
file_identifier=file_identifier,
|
418 |
+
new_sha256=new_sha256,
|
419 |
+
old_sha256=old_sha256,
|
420 |
+
metadata=metadata,
|
|
|
|
|
421 |
)
|
422 |
)
|
423 |
|
|
|
427 |
fs.makedirs(path, exist_ok=True)
|
428 |
|
429 |
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
430 |
+
out = github_downloader._process_repo(
|
431 |
repo_id="mattdeitke/objaverse-xl-test-files-does-not-exist",
|
432 |
fs=fs,
|
433 |
base_dir=path,
|
|
|
453 |
|
454 |
|
455 |
def test_github_download_cache():
|
456 |
+
github_downloader = GitHubDownloader()
|
457 |
objects = pd.DataFrame(
|
458 |
[
|
459 |
{
|
460 |
+
"fileIdentifier": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
|
461 |
"license": None,
|
462 |
"sha256": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
463 |
},
|
464 |
{
|
465 |
+
"fileIdentifier": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
|
466 |
"license": None,
|
467 |
"sha256": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
468 |
},
|
469 |
{
|
470 |
+
"fileIdentifier": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj",
|
471 |
"license": None,
|
472 |
"sha256": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
473 |
},
|
|
|
479 |
repos_dir = "~/.objaverse-tests/github/repos"
|
480 |
shutil.rmtree(os.path.expanduser(repos_dir), ignore_errors=True)
|
481 |
|
482 |
+
out = github_downloader.download_objects(
|
483 |
objects=objects,
|
484 |
processes=1,
|
485 |
download_dir="~/.objaverse-tests",
|
|
|
487 |
)
|
488 |
assert len(out) == 3
|
489 |
|
490 |
+
out = github_downloader.download_objects(
|
491 |
objects=objects,
|
492 |
processes=1,
|
493 |
download_dir="~/.objaverse-tests",
|