mattdeitke
commited on
Commit
•
135a36b
1
Parent(s):
d98e404
cleanup code
Browse files- .github/workflows/ci.yaml +51 -0
- .isort.cfg +3 -0
- .pylintrc +331 -0
- Makefile +24 -0
- mypy.ini +5 -0
- objaverse_xl/__init__.py +1 -1
- objaverse_xl/github.py +12 -520
- objaverse_xl/objaverse_v1.py +32 -19
- objaverse_xl/smithsonian.py +2 -1
- objaverse_xl/thingiverse.py +12 -6
- requirements-test.txt +8 -0
- setup.py +1 -3
- tests/test_api.py +519 -0
.github/workflows/ci.yaml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Continuous integration
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- main
|
7 |
+
pull_request:
|
8 |
+
branches:
|
9 |
+
- main
|
10 |
+
|
11 |
+
jobs:
|
12 |
+
lint:
|
13 |
+
runs-on: ubuntu-latest
|
14 |
+
steps:
|
15 |
+
- uses: actions/checkout@v2
|
16 |
+
- name: Set up Python 3.8
|
17 |
+
uses: actions/setup-python@v2
|
18 |
+
with:
|
19 |
+
python-version: 3.8
|
20 |
+
- name: Install
|
21 |
+
run: |
|
22 |
+
python3 -m venv .env
|
23 |
+
source .env/bin/activate
|
24 |
+
python -m pip install -U pip
|
25 |
+
make install-dev
|
26 |
+
- name: Lint
|
27 |
+
run: |
|
28 |
+
source .env/bin/activate
|
29 |
+
make lint
|
30 |
+
tests:
|
31 |
+
runs-on: ubuntu-latest
|
32 |
+
strategy:
|
33 |
+
matrix:
|
34 |
+
python-version: [3.8]
|
35 |
+
|
36 |
+
steps:
|
37 |
+
- uses: actions/checkout@v2
|
38 |
+
- name: Set up Python ${{ matrix.python-version }}
|
39 |
+
uses: actions/setup-python@v2
|
40 |
+
with:
|
41 |
+
python-version: ${{ matrix.python-version }}
|
42 |
+
- name: Install
|
43 |
+
run: |
|
44 |
+
python3 -m venv .env
|
45 |
+
source .env/bin/activate
|
46 |
+
make install
|
47 |
+
make install-dev
|
48 |
+
- name: Unit tests
|
49 |
+
run: |
|
50 |
+
source .env/bin/activate
|
51 |
+
make test
|
.isort.cfg
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[settings]
|
2 |
+
profile = black
|
3 |
+
known_third_party = pandas,numpy # Modify with your actual third party libraries
|
.pylintrc
ADDED
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[MASTER]
|
2 |
+
|
3 |
+
# Specify a configuration file.
|
4 |
+
#rcfile=
|
5 |
+
|
6 |
+
# Python code to execute, usually for sys.path manipulation such as
|
7 |
+
# pygtk.require().
|
8 |
+
#init-hook=
|
9 |
+
|
10 |
+
# Profiled execution.
|
11 |
+
profile=no
|
12 |
+
|
13 |
+
# Add files or directories to the blacklist. They should be base names, not
|
14 |
+
# paths.
|
15 |
+
ignore=CVS
|
16 |
+
|
17 |
+
# Pickle collected data for later comparisons.
|
18 |
+
persistent=yes
|
19 |
+
|
20 |
+
# List of plugins (as comma separated values of python modules names) to load,
|
21 |
+
# usually to register additional checkers.
|
22 |
+
load-plugins=
|
23 |
+
|
24 |
+
|
25 |
+
[MESSAGES CONTROL]
|
26 |
+
|
27 |
+
# Enable the message, report, category or checker with the given id(s). You can
|
28 |
+
# either give multiple identifier separated by comma (,) or put this option
|
29 |
+
# multiple time. See also the "--disable" option for examples.
|
30 |
+
enable=indexing-exception,old-raise-syntax
|
31 |
+
|
32 |
+
# Disable the message, report, category or checker with the given id(s). You
|
33 |
+
# can either give multiple identifiers separated by comma (,) or put this
|
34 |
+
# option multiple times (only on the command line, not in the configuration
|
35 |
+
# file where it should appear only once).You can also use "--disable=all" to
|
36 |
+
# disable everything first and then reenable specific checks. For example, if
|
37 |
+
# you want to run only the similarities checker, you can use "--disable=all
|
38 |
+
# --enable=similarities". If you want to run only the classes checker, but have
|
39 |
+
# no Warning level messages displayed, use"--disable=all --enable=classes
|
40 |
+
# --disable=W"
|
41 |
+
disable=design,similarities,no-self-use,attribute-defined-outside-init,locally-disabled,star-args,pointless-except,bad-option-value,global-statement,fixme,suppressed-message,useless-suppression,locally-enabled,no-member,no-name-in-module,import-error,unsubscriptable-object,unbalanced-tuple-unpacking,undefined-variable,not-context-manager,no-else-return,wrong-import-order,unnecessary-pass,logging-fstring-interpolation,logging-format-interpolation,C0330
|
42 |
+
|
43 |
+
|
44 |
+
# Set the cache size for astng objects.
|
45 |
+
cache-size=500
|
46 |
+
|
47 |
+
|
48 |
+
[REPORTS]
|
49 |
+
|
50 |
+
# Set the output format. Available formats are text, parseable, colorized, msvs
|
51 |
+
# (visual studio) and html. You can also give a reporter class, eg
|
52 |
+
# mypackage.mymodule.MyReporterClass.
|
53 |
+
output-format=text
|
54 |
+
|
55 |
+
# Put messages in a separate file for each module / package specified on the
|
56 |
+
# command line instead of printing them on stdout. Reports (if any) will be
|
57 |
+
# written in a file name "pylint_global.[txt|html]".
|
58 |
+
files-output=no
|
59 |
+
|
60 |
+
# Tells whether to display a full report or only the messages
|
61 |
+
reports=no
|
62 |
+
|
63 |
+
# Python expression which should return a note less than 10 (10 is the highest
|
64 |
+
# note). You have access to the variables errors warning, statement which
|
65 |
+
# respectively contain the number of errors / warnings messages and the total
|
66 |
+
# number of statements analyzed. This is used by the global evaluation report
|
67 |
+
# (RP0004).
|
68 |
+
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
|
69 |
+
|
70 |
+
# Add a comment according to your evaluation note. This is used by the global
|
71 |
+
# evaluation report (RP0004).
|
72 |
+
comment=no
|
73 |
+
|
74 |
+
# Template used to display messages. This is a python new-style format string
|
75 |
+
# used to format the message information. See doc for all details
|
76 |
+
#msg-template=
|
77 |
+
|
78 |
+
|
79 |
+
[TYPECHECK]
|
80 |
+
|
81 |
+
# Tells whether missing members accessed in mixin class should be ignored. A
|
82 |
+
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
83 |
+
ignore-mixin-members=yes
|
84 |
+
|
85 |
+
# List of classes names for which member attributes should not be checked
|
86 |
+
# (useful for classes with attributes dynamically set).
|
87 |
+
ignored-classes=SQLObject
|
88 |
+
|
89 |
+
# When zope mode is activated, add a predefined set of Zope acquired attributes
|
90 |
+
# to generated-members.
|
91 |
+
zope=no
|
92 |
+
|
93 |
+
# List of members which are set dynamically and missed by pylint inference
|
94 |
+
# system, and so shouldn't trigger E0201 when accessed. Python regular
|
95 |
+
# expressions are accepted.
|
96 |
+
generated-members=REQUEST,acl_users,aq_parent
|
97 |
+
|
98 |
+
# List of decorators that create context managers from functions, such as
|
99 |
+
# contextlib.contextmanager.
|
100 |
+
contextmanager-decorators=contextlib.contextmanager,contextlib2.contextmanager
|
101 |
+
|
102 |
+
|
103 |
+
[VARIABLES]
|
104 |
+
|
105 |
+
# Tells whether we should check for unused import in __init__ files.
|
106 |
+
init-import=no
|
107 |
+
|
108 |
+
# A regular expression matching the beginning of the name of dummy variables
|
109 |
+
# (i.e. not used).
|
110 |
+
dummy-variables-rgx=^\*{0,2}(_$|unused_|dummy_)
|
111 |
+
|
112 |
+
# List of additional names supposed to be defined in builtins. Remember that
|
113 |
+
# you should avoid to define new builtins when possible.
|
114 |
+
additional-builtins=
|
115 |
+
|
116 |
+
|
117 |
+
[BASIC]
|
118 |
+
|
119 |
+
# Required attributes for module, separated by a comma
|
120 |
+
required-attributes=
|
121 |
+
|
122 |
+
# List of builtins function names that should not be used, separated by a comma
|
123 |
+
bad-functions=apply,input,reduce
|
124 |
+
|
125 |
+
|
126 |
+
# Disable the report(s) with the given id(s).
|
127 |
+
# All non-Google reports are disabled by default.
|
128 |
+
disable-report=R0001,R0002,R0003,R0004,R0101,R0102,R0201,R0202,R0220,R0401,R0402,R0701,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0921,R0922,R0923
|
129 |
+
|
130 |
+
# Regular expression which should only match correct module names
|
131 |
+
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
132 |
+
|
133 |
+
# Regular expression which should only match correct module level names
|
134 |
+
const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
|
135 |
+
|
136 |
+
# Regular expression which should only match correct class names
|
137 |
+
class-rgx=^_?[A-Z][a-zA-Z0-9]*$
|
138 |
+
|
139 |
+
# Regular expression which should only match correct function names
|
140 |
+
function-rgx=^(?:(?P<camel_case>_?[A-Z][a-zA-Z0-9]*)|(?P<snake_case>_?[a-z][a-z0-9_]*))$
|
141 |
+
|
142 |
+
# Regular expression which should only match correct method names
|
143 |
+
method-rgx=^(?:(?P<exempt>__[a-z0-9_]+__|next)|(?P<camel_case>_{0,2}[A-Z][a-zA-Z0-9]*)|(?P<snake_case>_{0,2}[a-z][a-z0-9_]*))$
|
144 |
+
|
145 |
+
# Regular expression which should only match correct instance attribute names
|
146 |
+
attr-rgx=^_{0,2}[a-z][a-z0-9_]*$
|
147 |
+
|
148 |
+
# Regular expression which should only match correct argument names
|
149 |
+
argument-rgx=^[a-z][a-z0-9_]*$
|
150 |
+
|
151 |
+
# Regular expression which should only match correct variable names
|
152 |
+
variable-rgx=^[a-z][a-z0-9_]*$
|
153 |
+
|
154 |
+
# Regular expression which should only match correct attribute names in class
|
155 |
+
# bodies
|
156 |
+
class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
|
157 |
+
|
158 |
+
# Regular expression which should only match correct list comprehension /
|
159 |
+
# generator expression variable names
|
160 |
+
inlinevar-rgx=^[a-z][a-z0-9_]*$
|
161 |
+
|
162 |
+
# Good variable names which should always be accepted, separated by a comma
|
163 |
+
good-names=main,_
|
164 |
+
|
165 |
+
# Bad variable names which should always be refused, separated by a comma
|
166 |
+
bad-names=
|
167 |
+
|
168 |
+
# Regular expression which should only match function or class names that do
|
169 |
+
# not require a docstring.
|
170 |
+
no-docstring-rgx=(__.*__|main)
|
171 |
+
|
172 |
+
# Minimum line length for functions/classes that require docstrings, shorter
|
173 |
+
# ones are exempt.
|
174 |
+
docstring-min-length=10
|
175 |
+
|
176 |
+
|
177 |
+
[FORMAT]
|
178 |
+
|
179 |
+
# Maximum number of characters on a single line.
|
180 |
+
max-line-length=120
|
181 |
+
|
182 |
+
# Regexp for a line that is allowed to be longer than the limit.
|
183 |
+
ignore-long-lines=(?x)
|
184 |
+
(^\s*(import|from)\s
|
185 |
+
|\$Id:\s\/\/depot\/.+#\d+\s\$
|
186 |
+
|^[a-zA-Z_][a-zA-Z0-9_]*\s*=\s*("[^"]\S+"|'[^']\S+')
|
187 |
+
|^\s*\#\ LINT\.ThenChange
|
188 |
+
|^[^#]*\#\ type:\ [a-zA-Z_][a-zA-Z0-9_.,[\] ]*$
|
189 |
+
|pylint
|
190 |
+
|"""
|
191 |
+
|\#
|
192 |
+
|lambda
|
193 |
+
|(https?|ftp):)
|
194 |
+
|
195 |
+
# Allow the body of an if to be on the same line as the test if there is no
|
196 |
+
# else.
|
197 |
+
single-line-if-stmt=y
|
198 |
+
|
199 |
+
# List of optional constructs for which whitespace checking is disabled
|
200 |
+
no-space-check=
|
201 |
+
|
202 |
+
# Maximum number of lines in a module
|
203 |
+
max-module-lines=99999
|
204 |
+
|
205 |
+
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
206 |
+
# tab).
|
207 |
+
indent-string=' '
|
208 |
+
|
209 |
+
|
210 |
+
[SIMILARITIES]
|
211 |
+
|
212 |
+
# Minimum lines number of a similarity.
|
213 |
+
min-similarity-lines=4
|
214 |
+
|
215 |
+
# Ignore comments when computing similarities.
|
216 |
+
ignore-comments=yes
|
217 |
+
|
218 |
+
# Ignore docstrings when computing similarities.
|
219 |
+
ignore-docstrings=yes
|
220 |
+
|
221 |
+
# Ignore imports when computing similarities.
|
222 |
+
ignore-imports=no
|
223 |
+
|
224 |
+
|
225 |
+
[MISCELLANEOUS]
|
226 |
+
|
227 |
+
# List of note tags to take in consideration, separated by a comma.
|
228 |
+
notes=
|
229 |
+
|
230 |
+
|
231 |
+
[IMPORTS]
|
232 |
+
|
233 |
+
# Deprecated modules which should not be used, separated by a comma
|
234 |
+
deprecated-modules=regsub,TERMIOS,Bastion,rexec,sets
|
235 |
+
|
236 |
+
# Create a graph of every (i.e. internal and external) dependencies in the
|
237 |
+
# given file (report RP0402 must not be disabled)
|
238 |
+
import-graph=
|
239 |
+
|
240 |
+
# Create a graph of external dependencies in the given file (report RP0402 must
|
241 |
+
# not be disabled)
|
242 |
+
ext-import-graph=
|
243 |
+
|
244 |
+
# Create a graph of internal dependencies in the given file (report RP0402 must
|
245 |
+
# not be disabled)
|
246 |
+
int-import-graph=
|
247 |
+
|
248 |
+
extension-pkg-whitelist=_jsonnet
|
249 |
+
|
250 |
+
|
251 |
+
[CLASSES]
|
252 |
+
|
253 |
+
# List of interface methods to ignore, separated by a comma. This is used for
|
254 |
+
# instance to not check methods defines in Zope's Interface base class.
|
255 |
+
ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
|
256 |
+
|
257 |
+
# List of method names used to declare (i.e. assign) instance attributes.
|
258 |
+
defining-attr-methods=__init__,__new__,setUp
|
259 |
+
|
260 |
+
# List of valid names for the first argument in a class method.
|
261 |
+
valid-classmethod-first-arg=cls,class_
|
262 |
+
|
263 |
+
# List of valid names for the first argument in a metaclass class method.
|
264 |
+
valid-metaclass-classmethod-first-arg=mcs
|
265 |
+
|
266 |
+
|
267 |
+
[DESIGN]
|
268 |
+
|
269 |
+
# Maximum number of arguments for function / method
|
270 |
+
max-args=5
|
271 |
+
|
272 |
+
# Argument names that match this expression will be ignored. Default to name
|
273 |
+
# with leading underscore
|
274 |
+
ignored-argument-names=_.*
|
275 |
+
|
276 |
+
# Maximum number of locals for function / method body
|
277 |
+
max-locals=15
|
278 |
+
|
279 |
+
# Maximum number of return / yield for function / method body
|
280 |
+
max-returns=6
|
281 |
+
|
282 |
+
# Maximum number of branch for function / method body
|
283 |
+
max-branches=12
|
284 |
+
|
285 |
+
# Maximum number of statements in function / method body
|
286 |
+
max-statements=50
|
287 |
+
|
288 |
+
# Maximum number of parents for a class (see R0901).
|
289 |
+
max-parents=7
|
290 |
+
|
291 |
+
# Maximum number of attributes for a class (see R0902).
|
292 |
+
max-attributes=7
|
293 |
+
|
294 |
+
# Minimum number of public methods for a class (see R0903).
|
295 |
+
min-public-methods=2
|
296 |
+
|
297 |
+
# Maximum number of public methods for a class (see R0904).
|
298 |
+
max-public-methods=20
|
299 |
+
|
300 |
+
|
301 |
+
[EXCEPTIONS]
|
302 |
+
|
303 |
+
# Exceptions that will emit a warning when being caught. Defaults to
|
304 |
+
# "Exception"
|
305 |
+
overgeneral-exceptions=Exception,StandardError,BaseException
|
306 |
+
|
307 |
+
|
308 |
+
[AST]
|
309 |
+
|
310 |
+
# Maximum line length for lambdas
|
311 |
+
short-func-length=1
|
312 |
+
|
313 |
+
# List of module members that should be marked as deprecated.
|
314 |
+
# All of the string functions are listed in 4.1.4 Deprecated string functions
|
315 |
+
# in the Python 2.4 docs.
|
316 |
+
deprecated-members=string.atof,string.atoi,string.atol,string.capitalize,string.expandtabs,string.find,string.rfind,string.index,string.rindex,string.count,string.lower,string.split,string.rsplit,string.splitfields,string.join,string.joinfields,string.lstrip,string.rstrip,string.strip,string.swapcase,string.translate,string.upper,string.ljust,string.rjust,string.center,string.zfill,string.replace,sys.exitfunc
|
317 |
+
|
318 |
+
|
319 |
+
[DOCSTRING]
|
320 |
+
|
321 |
+
# List of exceptions that do not need to be mentioned in the Raises section of
|
322 |
+
# a docstring.
|
323 |
+
ignore-exceptions=AssertionError,NotImplementedError,StopIteration,TypeError
|
324 |
+
|
325 |
+
|
326 |
+
|
327 |
+
[TOKENS]
|
328 |
+
|
329 |
+
# Number of spaces of indent required when the last token on the preceding line
|
330 |
+
# is an open (, [, or {.
|
331 |
+
indent-after-paren=4
|
Makefile
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
install: ## [Local development] Upgrade pip, install requirements, install package.
|
2 |
+
python -m pip install -U pip
|
3 |
+
python -m pip install -e .
|
4 |
+
|
5 |
+
install-dev: ## [Local development] Install test requirements
|
6 |
+
python -m pip install -r requirements-test.txt
|
7 |
+
|
8 |
+
lint: ## [Local development] Run mypy, pylint and black
|
9 |
+
python -m mypy objaverse_xl
|
10 |
+
python -m pylint objaverse_xl
|
11 |
+
python -m black --check objaverse_xl
|
12 |
+
python -m isort --check-only objaverse_xl
|
13 |
+
|
14 |
+
format: ## [Local development] Auto-format python code using black
|
15 |
+
python -m isort objaverse_xl
|
16 |
+
python -m black objaverse_xl
|
17 |
+
|
18 |
+
test: ## [Local development] Run unit tests
|
19 |
+
python -m pytest -x -s -v tests
|
20 |
+
|
21 |
+
.PHONY: help
|
22 |
+
|
23 |
+
help: # Run `make help` to get help on the make commands
|
24 |
+
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
mypy.ini
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Global options:
|
2 |
+
|
3 |
+
[mypy]
|
4 |
+
python_version = 3.8
|
5 |
+
ignore_missing_imports = True
|
objaverse_xl/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1 |
-
from smithsonian import download_smithsonian_objects, load_smithsonian_metadata
|
|
|
1 |
+
from .smithsonian import download_smithsonian_objects, load_smithsonian_metadata
|
objaverse_xl/github.py
CHANGED
@@ -55,22 +55,24 @@ Note: You'll likely find more objects by
|
|
55 |
|
56 |
"""
|
57 |
|
58 |
-
|
59 |
-
import shutil
|
60 |
import json
|
61 |
-
import
|
62 |
-
from typing import Dict, List, Optional, Literal, Callable
|
63 |
-
from tqdm import tqdm
|
64 |
import os
|
|
|
|
|
|
|
|
|
65 |
import tarfile
|
|
|
|
|
|
|
|
|
66 |
import fsspec
|
|
|
67 |
import requests
|
68 |
-
import tempfile
|
69 |
-
import subprocess
|
70 |
from loguru import logger
|
71 |
-
import
|
72 |
-
from multiprocessing import Pool
|
73 |
-
import multiprocessing
|
74 |
|
75 |
FILE_EXTENSIONS = [
|
76 |
".obj",
|
@@ -410,9 +412,6 @@ def _process_group(group):
|
|
410 |
return key, group_df.set_index("githubUrl")["sha256"].to_dict()
|
411 |
|
412 |
|
413 |
-
# %%
|
414 |
-
|
415 |
-
|
416 |
def download_github_objects(
|
417 |
objects: pd.DataFrame,
|
418 |
processes: Optional[int] = None,
|
@@ -529,510 +528,3 @@ def download_github_objects(
|
|
529 |
)
|
530 |
out_list = [item for sublist in out for item in sublist]
|
531 |
return out_list
|
532 |
-
|
533 |
-
|
534 |
-
def test_process_repo():
|
535 |
-
download_dir = "~/.objaverse-tests"
|
536 |
-
base_download_dir = os.path.join(download_dir, "github")
|
537 |
-
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
538 |
-
fs.makedirs(path, exist_ok=True)
|
539 |
-
|
540 |
-
for save_repo_format in ["tar", "tar.gz", "zip", "files"]:
|
541 |
-
# shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
542 |
-
out = _process_repo(
|
543 |
-
repo_id="mattdeitke/objaverse-xl-test-files",
|
544 |
-
fs=fs,
|
545 |
-
base_dir=path,
|
546 |
-
save_repo_format=save_repo_format, # type: ignore
|
547 |
-
expected_objects=dict(),
|
548 |
-
handle_found_object=None,
|
549 |
-
handle_modified_object=None,
|
550 |
-
handle_missing_object=None,
|
551 |
-
handle_new_object=None,
|
552 |
-
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
553 |
-
)
|
554 |
-
|
555 |
-
# test that the sha256's are correct
|
556 |
-
assert len(out) == 3
|
557 |
-
sha256s = [x["sha256"] for x in out]
|
558 |
-
for sha256 in [
|
559 |
-
"d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
560 |
-
"04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
561 |
-
"7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
562 |
-
]:
|
563 |
-
assert sha256 in sha256s, f"{sha256=} not in {sha256s=}"
|
564 |
-
github_urls = [x["githubUrl"] for x in out]
|
565 |
-
for github_url in [
|
566 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
|
567 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
|
568 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj",
|
569 |
-
]:
|
570 |
-
assert github_url in github_urls, f"{github_url=} not in {github_urls=}"
|
571 |
-
|
572 |
-
# test that the files are correct
|
573 |
-
if save_repo_format != "files":
|
574 |
-
assert fs.exists(
|
575 |
-
os.path.join(
|
576 |
-
path,
|
577 |
-
"repos",
|
578 |
-
"mattdeitke",
|
579 |
-
f"objaverse-xl-test-files.{save_repo_format}",
|
580 |
-
)
|
581 |
-
)
|
582 |
-
else:
|
583 |
-
assert fs.exists(
|
584 |
-
os.path.join(
|
585 |
-
base_download_dir, "repos", "mattdeitke", "objaverse-xl-test-files"
|
586 |
-
)
|
587 |
-
)
|
588 |
-
|
589 |
-
|
590 |
-
def test_handle_new_object():
|
591 |
-
found_objects = []
|
592 |
-
handle_found_object = (
|
593 |
-
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
594 |
-
dict(
|
595 |
-
file=file,
|
596 |
-
github_url=github_url,
|
597 |
-
sha256=sha256,
|
598 |
-
repo=repo,
|
599 |
-
organization=organization,
|
600 |
-
)
|
601 |
-
)
|
602 |
-
)
|
603 |
-
|
604 |
-
missing_objects = []
|
605 |
-
handle_missing_object = (
|
606 |
-
lambda github_url, sha256, repo, organization: missing_objects.append(
|
607 |
-
dict(
|
608 |
-
github_url=github_url,
|
609 |
-
sha256=sha256,
|
610 |
-
repo=repo,
|
611 |
-
organization=organization,
|
612 |
-
)
|
613 |
-
)
|
614 |
-
)
|
615 |
-
|
616 |
-
new_objects = []
|
617 |
-
handle_new_object = (
|
618 |
-
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
619 |
-
dict(
|
620 |
-
file=file,
|
621 |
-
github_url=github_url,
|
622 |
-
sha256=sha256,
|
623 |
-
repo=repo,
|
624 |
-
organization=organization,
|
625 |
-
)
|
626 |
-
)
|
627 |
-
)
|
628 |
-
|
629 |
-
modified_objects = []
|
630 |
-
handle_modified_object = (
|
631 |
-
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
632 |
-
dict(
|
633 |
-
file=file,
|
634 |
-
github_url=github_url,
|
635 |
-
sha256=sha256,
|
636 |
-
repo=repo,
|
637 |
-
organization=organization,
|
638 |
-
)
|
639 |
-
)
|
640 |
-
)
|
641 |
-
|
642 |
-
download_dir = "~/.objaverse-tests"
|
643 |
-
base_download_dir = os.path.join(download_dir, "github")
|
644 |
-
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
645 |
-
fs.makedirs(path, exist_ok=True)
|
646 |
-
|
647 |
-
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
648 |
-
out = _process_repo(
|
649 |
-
repo_id="mattdeitke/objaverse-xl-test-files",
|
650 |
-
fs=fs,
|
651 |
-
base_dir=path,
|
652 |
-
save_repo_format=None,
|
653 |
-
expected_objects=dict(),
|
654 |
-
handle_found_object=handle_found_object,
|
655 |
-
handle_modified_object=handle_modified_object,
|
656 |
-
handle_missing_object=handle_missing_object,
|
657 |
-
handle_new_object=handle_new_object,
|
658 |
-
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
659 |
-
)
|
660 |
-
|
661 |
-
assert len(out) == 3
|
662 |
-
assert len(new_objects) == 3
|
663 |
-
assert len(found_objects) == 0
|
664 |
-
assert len(modified_objects) == 0
|
665 |
-
assert len(missing_objects) == 0
|
666 |
-
|
667 |
-
|
668 |
-
def test_handle_found_object():
|
669 |
-
found_objects = []
|
670 |
-
handle_found_object = (
|
671 |
-
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
672 |
-
dict(
|
673 |
-
file=file,
|
674 |
-
github_url=github_url,
|
675 |
-
sha256=sha256,
|
676 |
-
repo=repo,
|
677 |
-
organization=organization,
|
678 |
-
)
|
679 |
-
)
|
680 |
-
)
|
681 |
-
|
682 |
-
missing_objects = []
|
683 |
-
handle_missing_object = (
|
684 |
-
lambda github_url, sha256, repo, organization: missing_objects.append(
|
685 |
-
dict(
|
686 |
-
github_url=github_url,
|
687 |
-
sha256=sha256,
|
688 |
-
repo=repo,
|
689 |
-
organization=organization,
|
690 |
-
)
|
691 |
-
)
|
692 |
-
)
|
693 |
-
|
694 |
-
new_objects = []
|
695 |
-
handle_new_object = (
|
696 |
-
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
697 |
-
dict(
|
698 |
-
file=file,
|
699 |
-
github_url=github_url,
|
700 |
-
sha256=sha256,
|
701 |
-
repo=repo,
|
702 |
-
organization=organization,
|
703 |
-
)
|
704 |
-
)
|
705 |
-
)
|
706 |
-
|
707 |
-
modified_objects = []
|
708 |
-
handle_modified_object = (
|
709 |
-
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
710 |
-
dict(
|
711 |
-
file=file,
|
712 |
-
github_url=github_url,
|
713 |
-
sha256=sha256,
|
714 |
-
repo=repo,
|
715 |
-
organization=organization,
|
716 |
-
)
|
717 |
-
)
|
718 |
-
)
|
719 |
-
|
720 |
-
download_dir = "~/.objaverse-tests"
|
721 |
-
base_download_dir = os.path.join(download_dir, "github")
|
722 |
-
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
723 |
-
fs.makedirs(path, exist_ok=True)
|
724 |
-
|
725 |
-
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
726 |
-
out = _process_repo(
|
727 |
-
repo_id="mattdeitke/objaverse-xl-test-files",
|
728 |
-
fs=fs,
|
729 |
-
base_dir=path,
|
730 |
-
save_repo_format=None,
|
731 |
-
expected_objects={
|
732 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
733 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
734 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
735 |
-
},
|
736 |
-
handle_found_object=handle_found_object,
|
737 |
-
handle_modified_object=handle_modified_object,
|
738 |
-
handle_missing_object=handle_missing_object,
|
739 |
-
handle_new_object=handle_new_object,
|
740 |
-
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
741 |
-
)
|
742 |
-
|
743 |
-
assert len(out) == 3
|
744 |
-
assert len(found_objects) == 3
|
745 |
-
assert len(missing_objects) == 0
|
746 |
-
assert len(new_objects) == 0
|
747 |
-
assert len(modified_objects) == 0
|
748 |
-
|
749 |
-
|
750 |
-
def test_handle_modified_object():
|
751 |
-
found_objects = []
|
752 |
-
handle_found_object = (
|
753 |
-
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
754 |
-
dict(
|
755 |
-
file=file,
|
756 |
-
github_url=github_url,
|
757 |
-
sha256=sha256,
|
758 |
-
repo=repo,
|
759 |
-
organization=organization,
|
760 |
-
)
|
761 |
-
)
|
762 |
-
)
|
763 |
-
|
764 |
-
missing_objects = []
|
765 |
-
handle_missing_object = (
|
766 |
-
lambda github_url, sha256, repo, organization: missing_objects.append(
|
767 |
-
dict(
|
768 |
-
github_url=github_url,
|
769 |
-
sha256=sha256,
|
770 |
-
repo=repo,
|
771 |
-
organization=organization,
|
772 |
-
)
|
773 |
-
)
|
774 |
-
)
|
775 |
-
|
776 |
-
new_objects = []
|
777 |
-
handle_new_object = (
|
778 |
-
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
779 |
-
dict(
|
780 |
-
file=file,
|
781 |
-
github_url=github_url,
|
782 |
-
sha256=sha256,
|
783 |
-
repo=repo,
|
784 |
-
organization=organization,
|
785 |
-
)
|
786 |
-
)
|
787 |
-
)
|
788 |
-
|
789 |
-
modified_objects = []
|
790 |
-
handle_modified_object = (
|
791 |
-
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
792 |
-
dict(
|
793 |
-
file=file,
|
794 |
-
github_url=github_url,
|
795 |
-
sha256=sha256,
|
796 |
-
repo=repo,
|
797 |
-
organization=organization,
|
798 |
-
)
|
799 |
-
)
|
800 |
-
)
|
801 |
-
|
802 |
-
download_dir = "~/.objaverse-tests"
|
803 |
-
base_download_dir = os.path.join(download_dir, "github")
|
804 |
-
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
805 |
-
fs.makedirs(path, exist_ok=True)
|
806 |
-
|
807 |
-
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
808 |
-
out = _process_repo(
|
809 |
-
repo_id="mattdeitke/objaverse-xl-test-files",
|
810 |
-
fs=fs,
|
811 |
-
base_dir=path,
|
812 |
-
save_repo_format=None,
|
813 |
-
expected_objects={
|
814 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9<modified>",
|
815 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
816 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
817 |
-
},
|
818 |
-
handle_found_object=handle_found_object,
|
819 |
-
handle_modified_object=handle_modified_object,
|
820 |
-
handle_missing_object=handle_missing_object,
|
821 |
-
handle_new_object=handle_new_object,
|
822 |
-
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
823 |
-
)
|
824 |
-
|
825 |
-
assert len(out) == 3
|
826 |
-
assert len(found_objects) == 2
|
827 |
-
assert len(missing_objects) == 0
|
828 |
-
assert len(new_objects) == 0
|
829 |
-
assert len(modified_objects) == 1
|
830 |
-
|
831 |
-
|
832 |
-
def test_handle_missing_object():
|
833 |
-
found_objects = []
|
834 |
-
handle_found_object = (
|
835 |
-
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
836 |
-
dict(
|
837 |
-
file=file,
|
838 |
-
github_url=github_url,
|
839 |
-
sha256=sha256,
|
840 |
-
repo=repo,
|
841 |
-
organization=organization,
|
842 |
-
)
|
843 |
-
)
|
844 |
-
)
|
845 |
-
|
846 |
-
missing_objects = []
|
847 |
-
handle_missing_object = (
|
848 |
-
lambda github_url, sha256, repo, organization: missing_objects.append(
|
849 |
-
dict(
|
850 |
-
github_url=github_url,
|
851 |
-
sha256=sha256,
|
852 |
-
repo=repo,
|
853 |
-
organization=organization,
|
854 |
-
)
|
855 |
-
)
|
856 |
-
)
|
857 |
-
|
858 |
-
new_objects = []
|
859 |
-
handle_new_object = (
|
860 |
-
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
861 |
-
dict(
|
862 |
-
file=file,
|
863 |
-
github_url=github_url,
|
864 |
-
sha256=sha256,
|
865 |
-
repo=repo,
|
866 |
-
organization=organization,
|
867 |
-
)
|
868 |
-
)
|
869 |
-
)
|
870 |
-
|
871 |
-
modified_objects = []
|
872 |
-
handle_modified_object = (
|
873 |
-
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
874 |
-
dict(
|
875 |
-
file=file,
|
876 |
-
github_url=github_url,
|
877 |
-
sha256=sha256,
|
878 |
-
repo=repo,
|
879 |
-
organization=organization,
|
880 |
-
)
|
881 |
-
)
|
882 |
-
)
|
883 |
-
|
884 |
-
download_dir = "~/.objaverse-tests"
|
885 |
-
base_download_dir = os.path.join(download_dir, "github")
|
886 |
-
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
887 |
-
fs.makedirs(path, exist_ok=True)
|
888 |
-
|
889 |
-
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
890 |
-
out = _process_repo(
|
891 |
-
repo_id="mattdeitke/objaverse-xl-test-files",
|
892 |
-
fs=fs,
|
893 |
-
base_dir=path,
|
894 |
-
save_repo_format=None,
|
895 |
-
expected_objects={
|
896 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
897 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example-2.fbx": "<fake-missing-object>",
|
898 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
899 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
900 |
-
},
|
901 |
-
handle_found_object=handle_found_object,
|
902 |
-
handle_modified_object=handle_modified_object,
|
903 |
-
handle_missing_object=handle_missing_object,
|
904 |
-
handle_new_object=handle_new_object,
|
905 |
-
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
906 |
-
)
|
907 |
-
|
908 |
-
assert len(out) == 3
|
909 |
-
assert len(found_objects) == 3
|
910 |
-
assert len(missing_objects) == 1
|
911 |
-
assert len(new_objects) == 0
|
912 |
-
assert len(modified_objects) == 0
|
913 |
-
|
914 |
-
|
915 |
-
def test_handle_missing_object_2():
|
916 |
-
found_objects = []
|
917 |
-
handle_found_object = (
|
918 |
-
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
919 |
-
dict(
|
920 |
-
file=file,
|
921 |
-
github_url=github_url,
|
922 |
-
sha256=sha256,
|
923 |
-
repo=repo,
|
924 |
-
organization=organization,
|
925 |
-
)
|
926 |
-
)
|
927 |
-
)
|
928 |
-
|
929 |
-
missing_objects = []
|
930 |
-
handle_missing_object = (
|
931 |
-
lambda github_url, sha256, repo, organization: missing_objects.append(
|
932 |
-
dict(
|
933 |
-
github_url=github_url,
|
934 |
-
sha256=sha256,
|
935 |
-
repo=repo,
|
936 |
-
organization=organization,
|
937 |
-
)
|
938 |
-
)
|
939 |
-
)
|
940 |
-
|
941 |
-
new_objects = []
|
942 |
-
handle_new_object = (
|
943 |
-
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
944 |
-
dict(
|
945 |
-
file=file,
|
946 |
-
github_url=github_url,
|
947 |
-
sha256=sha256,
|
948 |
-
repo=repo,
|
949 |
-
organization=organization,
|
950 |
-
)
|
951 |
-
)
|
952 |
-
)
|
953 |
-
|
954 |
-
modified_objects = []
|
955 |
-
handle_modified_object = (
|
956 |
-
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
957 |
-
dict(
|
958 |
-
file=file,
|
959 |
-
github_url=github_url,
|
960 |
-
sha256=sha256,
|
961 |
-
repo=repo,
|
962 |
-
organization=organization,
|
963 |
-
)
|
964 |
-
)
|
965 |
-
)
|
966 |
-
|
967 |
-
download_dir = "~/.objaverse-tests"
|
968 |
-
base_download_dir = os.path.join(download_dir, "github")
|
969 |
-
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
970 |
-
fs.makedirs(path, exist_ok=True)
|
971 |
-
|
972 |
-
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
973 |
-
out = _process_repo(
|
974 |
-
repo_id="mattdeitke/objaverse-xl-test-files-does-not-exist",
|
975 |
-
fs=fs,
|
976 |
-
base_dir=path,
|
977 |
-
save_repo_format=None,
|
978 |
-
expected_objects={
|
979 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
980 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example-2.fbx": "<fake-missing-object>",
|
981 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
982 |
-
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
983 |
-
},
|
984 |
-
handle_found_object=handle_found_object,
|
985 |
-
handle_modified_object=handle_modified_object,
|
986 |
-
handle_missing_object=handle_missing_object,
|
987 |
-
handle_new_object=handle_new_object,
|
988 |
-
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
989 |
-
)
|
990 |
-
|
991 |
-
assert len(out) == 0
|
992 |
-
assert len(found_objects) == 0
|
993 |
-
assert len(missing_objects) == 4
|
994 |
-
assert len(new_objects) == 0
|
995 |
-
assert len(modified_objects) == 0
|
996 |
-
|
997 |
-
|
998 |
-
def test_download_cache():
|
999 |
-
objects = pd.DataFrame(
|
1000 |
-
[
|
1001 |
-
{
|
1002 |
-
"githubUrl": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
|
1003 |
-
"license": None,
|
1004 |
-
"sha256": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
1005 |
-
},
|
1006 |
-
{
|
1007 |
-
"githubUrl": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
|
1008 |
-
"license": None,
|
1009 |
-
"sha256": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
1010 |
-
},
|
1011 |
-
{
|
1012 |
-
"githubUrl": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj",
|
1013 |
-
"license": None,
|
1014 |
-
"sha256": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
1015 |
-
},
|
1016 |
-
]
|
1017 |
-
)
|
1018 |
-
|
1019 |
-
# remove the repos directory
|
1020 |
-
for save_repo_format in ["tar", "tar.gz", "zip", "files"]:
|
1021 |
-
repos_dir = "~/.objaverse-tests/github/repos"
|
1022 |
-
shutil.rmtree(os.path.expanduser(repos_dir), ignore_errors=True)
|
1023 |
-
|
1024 |
-
out = download_github_objects(
|
1025 |
-
objects=objects,
|
1026 |
-
processes=1,
|
1027 |
-
download_dir="~/.objaverse-tests",
|
1028 |
-
save_repo_format=save_repo_format, # type: ignore
|
1029 |
-
)
|
1030 |
-
assert len(out) == 3
|
1031 |
-
|
1032 |
-
out = download_github_objects(
|
1033 |
-
objects=objects,
|
1034 |
-
processes=1,
|
1035 |
-
download_dir="~/.objaverse-tests",
|
1036 |
-
save_repo_format=save_repo_format, # type: ignore
|
1037 |
-
)
|
1038 |
-
assert len(out) == 0
|
|
|
55 |
|
56 |
"""
|
57 |
|
58 |
+
import hashlib
|
|
|
59 |
import json
|
60 |
+
import multiprocessing
|
|
|
|
|
61 |
import os
|
62 |
+
|
63 |
+
# %%
|
64 |
+
import shutil
|
65 |
+
import subprocess
|
66 |
import tarfile
|
67 |
+
import tempfile
|
68 |
+
from multiprocessing import Pool
|
69 |
+
from typing import Callable, Dict, List, Literal, Optional
|
70 |
+
|
71 |
import fsspec
|
72 |
+
import pandas as pd
|
73 |
import requests
|
|
|
|
|
74 |
from loguru import logger
|
75 |
+
from tqdm import tqdm
|
|
|
|
|
76 |
|
77 |
FILE_EXTENSIONS = [
|
78 |
".obj",
|
|
|
412 |
return key, group_df.set_index("githubUrl")["sha256"].to_dict()
|
413 |
|
414 |
|
|
|
|
|
|
|
415 |
def download_github_objects(
|
416 |
objects: pd.DataFrame,
|
417 |
processes: Optional[int] = None,
|
|
|
528 |
)
|
529 |
out_list = [item for sublist in out for item in sublist]
|
530 |
return out_list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objaverse_xl/objaverse_v1.py
CHANGED
@@ -21,7 +21,7 @@ def load_annotations(
|
|
21 |
the metadata for all uids.
|
22 |
download_dir: The base directory to download the annotations to. Supports all
|
23 |
file systems supported by fsspec. Defaults to "~/.objaverse".
|
24 |
-
|
25 |
Returns:
|
26 |
A list of dictionaries with the metadata for each object. The keys are the uids
|
27 |
and the values are the metadata for that object.
|
@@ -40,12 +40,16 @@ def load_annotations(
|
|
40 |
)
|
41 |
|
42 |
# get the existing metadata files
|
43 |
-
existing_metadata_files = fs.glob(
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
49 |
downloaded_dir_ids = existing_dir_ids.intersection(dir_ids)
|
50 |
logger.info(f"Found {len(downloaded_dir_ids)} metadata files already downloaded")
|
51 |
|
@@ -89,8 +93,10 @@ def load_annotations(
|
|
89 |
|
90 |
return out
|
91 |
|
|
|
92 |
annotations = load_annotations(download_dir="~/.objaverse-temp-400")
|
93 |
|
|
|
94 |
def _load_object_paths(download_dir: str) -> Dict[str, str]:
|
95 |
"""Load the object paths from the dataset.
|
96 |
|
@@ -152,9 +158,7 @@ def _download_object(
|
|
152 |
Returns:
|
153 |
A tuple of the uid and the path to where the downloaded object.
|
154 |
"""
|
155 |
-
hf_url =
|
156 |
-
f"https://huggingface.co/datasets/allenai/objaverse/resolve/main/{hf_object_path}"
|
157 |
-
)
|
158 |
|
159 |
filename = os.path.join(download_dir, "hf-objaverse-v1", hf_object_path)
|
160 |
fs, path = fsspec.core.url_to_fs(filename)
|
@@ -203,12 +207,16 @@ def load_objects(
|
|
203 |
# file. `glob()` is like walk, but returns a list of files instead of the nested
|
204 |
# directory structure. glob() is also faster than find() / walk() since it doesn't
|
205 |
# need to traverse the entire directory structure.
|
206 |
-
existing_file_paths = fs.glob(
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
212 |
|
213 |
# add the existing downloaded uids to the return dict
|
214 |
out = {}
|
@@ -217,7 +225,7 @@ def load_objects(
|
|
217 |
hf_object_path = hf_object_paths[uid]
|
218 |
fs_abs_object_path = os.path.join(versioned_dirname, hf_object_path)
|
219 |
out[uid] = fs_abs_object_path
|
220 |
-
|
221 |
logger.info(f"Found {len(already_downloaded_uids)} objects already downloaded")
|
222 |
|
223 |
# get the uids that need to be downloaded
|
@@ -251,7 +259,10 @@ def load_objects(
|
|
251 |
# download the objects in parallel
|
252 |
with Pool(download_processes) as pool:
|
253 |
new_object_downloads = list(
|
254 |
-
tqdm(
|
|
|
|
|
|
|
255 |
)
|
256 |
|
257 |
for uid, local_path in new_object_downloads:
|
@@ -274,7 +285,9 @@ def load_lvis_annotations(download_dir: str = "~/.objaverse") -> Dict[str, List[
|
|
274 |
"""
|
275 |
hf_url = f"https://huggingface.co/datasets/allenai/objaverse/resolve/main/lvis-annotations.json.gz"
|
276 |
|
277 |
-
download_path = os.path.join(
|
|
|
|
|
278 |
|
279 |
# use fsspec
|
280 |
fs, path = fsspec.core.url_to_fs(download_path)
|
|
|
21 |
the metadata for all uids.
|
22 |
download_dir: The base directory to download the annotations to. Supports all
|
23 |
file systems supported by fsspec. Defaults to "~/.objaverse".
|
24 |
+
|
25 |
Returns:
|
26 |
A list of dictionaries with the metadata for each object. The keys are the uids
|
27 |
and the values are the metadata for that object.
|
|
|
40 |
)
|
41 |
|
42 |
# get the existing metadata files
|
43 |
+
existing_metadata_files = fs.glob(
|
44 |
+
os.path.join(metadata_path, "*.json.gz"), refresh=True
|
45 |
+
)
|
46 |
+
existing_dir_ids = set(
|
47 |
+
[
|
48 |
+
file.split("/")[-1].split(".")[0]
|
49 |
+
for file in existing_metadata_files
|
50 |
+
if file.endswith(".json.gz") # note partial files end with .json.gz.tmp
|
51 |
+
]
|
52 |
+
)
|
53 |
downloaded_dir_ids = existing_dir_ids.intersection(dir_ids)
|
54 |
logger.info(f"Found {len(downloaded_dir_ids)} metadata files already downloaded")
|
55 |
|
|
|
93 |
|
94 |
return out
|
95 |
|
96 |
+
|
97 |
annotations = load_annotations(download_dir="~/.objaverse-temp-400")
|
98 |
|
99 |
+
|
100 |
def _load_object_paths(download_dir: str) -> Dict[str, str]:
|
101 |
"""Load the object paths from the dataset.
|
102 |
|
|
|
158 |
Returns:
|
159 |
A tuple of the uid and the path to where the downloaded object.
|
160 |
"""
|
161 |
+
hf_url = f"https://huggingface.co/datasets/allenai/objaverse/resolve/main/{hf_object_path}"
|
|
|
|
|
162 |
|
163 |
filename = os.path.join(download_dir, "hf-objaverse-v1", hf_object_path)
|
164 |
fs, path = fsspec.core.url_to_fs(filename)
|
|
|
207 |
# file. `glob()` is like walk, but returns a list of files instead of the nested
|
208 |
# directory structure. glob() is also faster than find() / walk() since it doesn't
|
209 |
# need to traverse the entire directory structure.
|
210 |
+
existing_file_paths = fs.glob(
|
211 |
+
os.path.join(path, "glbs", "*", "*.glb"), refresh=True
|
212 |
+
)
|
213 |
+
existing_uids = set(
|
214 |
+
[
|
215 |
+
file.split("/")[-1].split(".")[0]
|
216 |
+
for file in existing_file_paths
|
217 |
+
if file.endswith(".glb") # note partial files end with .glb.tmp
|
218 |
+
]
|
219 |
+
)
|
220 |
|
221 |
# add the existing downloaded uids to the return dict
|
222 |
out = {}
|
|
|
225 |
hf_object_path = hf_object_paths[uid]
|
226 |
fs_abs_object_path = os.path.join(versioned_dirname, hf_object_path)
|
227 |
out[uid] = fs_abs_object_path
|
228 |
+
|
229 |
logger.info(f"Found {len(already_downloaded_uids)} objects already downloaded")
|
230 |
|
231 |
# get the uids that need to be downloaded
|
|
|
259 |
# download the objects in parallel
|
260 |
with Pool(download_processes) as pool:
|
261 |
new_object_downloads = list(
|
262 |
+
tqdm(
|
263 |
+
pool.imap_unordered(_parallel_download_object, args),
|
264 |
+
total=len(args),
|
265 |
+
)
|
266 |
)
|
267 |
|
268 |
for uid, local_path in new_object_downloads:
|
|
|
285 |
"""
|
286 |
hf_url = f"https://huggingface.co/datasets/allenai/objaverse/resolve/main/lvis-annotations.json.gz"
|
287 |
|
288 |
+
download_path = os.path.join(
|
289 |
+
download_dir, "hf-objaverse-v1", "lvis-annotations.json.gz"
|
290 |
+
)
|
291 |
|
292 |
# use fsspec
|
293 |
fs, path = fsspec.core.url_to_fs(download_path)
|
objaverse_xl/smithsonian.py
CHANGED
@@ -9,7 +9,8 @@ import pandas as pd
|
|
9 |
import requests
|
10 |
from loguru import logger
|
11 |
from tqdm import tqdm
|
12 |
-
|
|
|
13 |
|
14 |
|
15 |
def load_smithsonian_metadata(download_dir: str = "~/.objaverse") -> pd.DataFrame:
|
|
|
9 |
import requests
|
10 |
from loguru import logger
|
11 |
from tqdm import tqdm
|
12 |
+
|
13 |
+
from .utils import get_uid_from_str
|
14 |
|
15 |
|
16 |
def load_smithsonian_metadata(download_dir: str = "~/.objaverse") -> pd.DataFrame:
|
objaverse_xl/thingiverse.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
import os
|
2 |
import multiprocessing
|
|
|
|
|
3 |
from multiprocessing import Pool
|
4 |
from typing import Dict, List, Optional
|
5 |
|
6 |
import fsspec
|
|
|
7 |
import requests
|
8 |
from loguru import logger
|
9 |
-
import pandas as pd
|
10 |
from tqdm import tqdm
|
11 |
-
import time
|
12 |
|
13 |
|
14 |
def _get_response_with_retries(
|
@@ -20,7 +20,7 @@ def _get_response_with_retries(
|
|
20 |
url (str): The URL to get a response from.
|
21 |
max_retries (int, optional): The maximum number of retries. Defaults to 3.
|
22 |
retry_delay (int, optional): The delay between retries in seconds. Defaults to 5.
|
23 |
-
|
24 |
Returns:
|
25 |
Optional[requests.models.Response]: The response from the URL. If there was an error, returns None.
|
26 |
"""
|
@@ -159,7 +159,10 @@ def download_thingiverse_objects(
|
|
159 |
file_path = _download_item(item=item, download_dir=download_dir)
|
160 |
if file_path is not None:
|
161 |
out.append(
|
162 |
-
{
|
|
|
|
|
|
|
163 |
)
|
164 |
else:
|
165 |
args = [(item, download_dir) for item in items_to_download]
|
@@ -173,7 +176,10 @@ def download_thingiverse_objects(
|
|
173 |
)
|
174 |
out.extend(
|
175 |
[
|
176 |
-
{
|
|
|
|
|
|
|
177 |
for item, file_path in items_and_file_paths
|
178 |
if file_path is not None
|
179 |
]
|
|
|
|
|
1 |
import multiprocessing
|
2 |
+
import os
|
3 |
+
import time
|
4 |
from multiprocessing import Pool
|
5 |
from typing import Dict, List, Optional
|
6 |
|
7 |
import fsspec
|
8 |
+
import pandas as pd
|
9 |
import requests
|
10 |
from loguru import logger
|
|
|
11 |
from tqdm import tqdm
|
|
|
12 |
|
13 |
|
14 |
def _get_response_with_retries(
|
|
|
20 |
url (str): The URL to get a response from.
|
21 |
max_retries (int, optional): The maximum number of retries. Defaults to 3.
|
22 |
retry_delay (int, optional): The delay between retries in seconds. Defaults to 5.
|
23 |
+
|
24 |
Returns:
|
25 |
Optional[requests.models.Response]: The response from the URL. If there was an error, returns None.
|
26 |
"""
|
|
|
159 |
file_path = _download_item(item=item, download_dir=download_dir)
|
160 |
if file_path is not None:
|
161 |
out.append(
|
162 |
+
{
|
163 |
+
"filePath": file_path,
|
164 |
+
**item,
|
165 |
+
}
|
166 |
)
|
167 |
else:
|
168 |
args = [(item, download_dir) for item in items_to_download]
|
|
|
176 |
)
|
177 |
out.extend(
|
178 |
[
|
179 |
+
{
|
180 |
+
"filePath": file_path,
|
181 |
+
**item,
|
182 |
+
}
|
183 |
for item, file_path in items_and_file_paths
|
184 |
if file_path is not None
|
185 |
]
|
requirements-test.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
black==22.3.0
|
2 |
+
mypy==0.942
|
3 |
+
pylint==2.13.4
|
4 |
+
pytest-cov==3.0.0
|
5 |
+
pytest-xdist==2.5.0
|
6 |
+
pytest==7.0.1
|
7 |
+
isort==5.12.0
|
8 |
+
types-requests==2.31.0.2
|
setup.py
CHANGED
@@ -23,7 +23,5 @@ setup(
|
|
23 |
"License :: OSI Approved :: Apache Software License",
|
24 |
],
|
25 |
install_requires=requirements,
|
26 |
-
extras_require={
|
27 |
-
"s3": ["s3fs==0.4.2"]
|
28 |
-
}
|
29 |
)
|
|
|
23 |
"License :: OSI Approved :: Apache Software License",
|
24 |
],
|
25 |
install_requires=requirements,
|
26 |
+
extras_require={"s3": ["s3fs==0.4.2"]},
|
|
|
|
|
27 |
)
|
tests/test_api.py
ADDED
@@ -0,0 +1,519 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import shutil
|
3 |
+
|
4 |
+
import fsspec
|
5 |
+
import pandas as pd
|
6 |
+
import pytest
|
7 |
+
|
8 |
+
from objaverse_xl.github import _process_repo, download_github_objects
|
9 |
+
|
10 |
+
# @pytest.mark.parametrize("message", ["hello", "world"])
|
11 |
+
# def test_hello_world(message):
|
12 |
+
# hello_world(message)
|
13 |
+
|
14 |
+
|
15 |
+
def test_github_process_repo():
|
16 |
+
download_dir = "~/.objaverse-tests"
|
17 |
+
base_download_dir = os.path.join(download_dir, "github")
|
18 |
+
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
19 |
+
fs.makedirs(path, exist_ok=True)
|
20 |
+
|
21 |
+
for save_repo_format in ["tar", "tar.gz", "zip", "files"]:
|
22 |
+
# shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
23 |
+
out = _process_repo(
|
24 |
+
repo_id="mattdeitke/objaverse-xl-test-files",
|
25 |
+
fs=fs,
|
26 |
+
base_dir=path,
|
27 |
+
save_repo_format=save_repo_format, # type: ignore
|
28 |
+
expected_objects=dict(),
|
29 |
+
handle_found_object=None,
|
30 |
+
handle_modified_object=None,
|
31 |
+
handle_missing_object=None,
|
32 |
+
handle_new_object=None,
|
33 |
+
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
34 |
+
)
|
35 |
+
|
36 |
+
# test that the sha256's are correct
|
37 |
+
assert len(out) == 3
|
38 |
+
sha256s = [x["sha256"] for x in out]
|
39 |
+
for sha256 in [
|
40 |
+
"d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
41 |
+
"04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
42 |
+
"7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
43 |
+
]:
|
44 |
+
assert sha256 in sha256s, f"{sha256=} not in {sha256s=}"
|
45 |
+
github_urls = [x["githubUrl"] for x in out]
|
46 |
+
for github_url in [
|
47 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
|
48 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
|
49 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj",
|
50 |
+
]:
|
51 |
+
assert github_url in github_urls, f"{github_url=} not in {github_urls=}"
|
52 |
+
|
53 |
+
# test that the files are correct
|
54 |
+
if save_repo_format != "files":
|
55 |
+
assert fs.exists(
|
56 |
+
os.path.join(
|
57 |
+
path,
|
58 |
+
"repos",
|
59 |
+
"mattdeitke",
|
60 |
+
f"objaverse-xl-test-files.{save_repo_format}",
|
61 |
+
)
|
62 |
+
)
|
63 |
+
else:
|
64 |
+
assert fs.exists(
|
65 |
+
os.path.join(
|
66 |
+
base_download_dir, "repos", "mattdeitke", "objaverse-xl-test-files"
|
67 |
+
)
|
68 |
+
)
|
69 |
+
|
70 |
+
|
71 |
+
def test_github_handle_new_object():
|
72 |
+
found_objects = []
|
73 |
+
handle_found_object = (
|
74 |
+
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
75 |
+
dict(
|
76 |
+
file=file,
|
77 |
+
github_url=github_url,
|
78 |
+
sha256=sha256,
|
79 |
+
repo=repo,
|
80 |
+
organization=organization,
|
81 |
+
)
|
82 |
+
)
|
83 |
+
)
|
84 |
+
|
85 |
+
missing_objects = []
|
86 |
+
handle_missing_object = (
|
87 |
+
lambda github_url, sha256, repo, organization: missing_objects.append(
|
88 |
+
dict(
|
89 |
+
github_url=github_url,
|
90 |
+
sha256=sha256,
|
91 |
+
repo=repo,
|
92 |
+
organization=organization,
|
93 |
+
)
|
94 |
+
)
|
95 |
+
)
|
96 |
+
|
97 |
+
new_objects = []
|
98 |
+
handle_new_object = (
|
99 |
+
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
100 |
+
dict(
|
101 |
+
file=file,
|
102 |
+
github_url=github_url,
|
103 |
+
sha256=sha256,
|
104 |
+
repo=repo,
|
105 |
+
organization=organization,
|
106 |
+
)
|
107 |
+
)
|
108 |
+
)
|
109 |
+
|
110 |
+
modified_objects = []
|
111 |
+
handle_modified_object = (
|
112 |
+
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
113 |
+
dict(
|
114 |
+
file=file,
|
115 |
+
github_url=github_url,
|
116 |
+
sha256=sha256,
|
117 |
+
repo=repo,
|
118 |
+
organization=organization,
|
119 |
+
)
|
120 |
+
)
|
121 |
+
)
|
122 |
+
|
123 |
+
download_dir = "~/.objaverse-tests"
|
124 |
+
base_download_dir = os.path.join(download_dir, "github")
|
125 |
+
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
126 |
+
fs.makedirs(path, exist_ok=True)
|
127 |
+
|
128 |
+
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
129 |
+
out = _process_repo(
|
130 |
+
repo_id="mattdeitke/objaverse-xl-test-files",
|
131 |
+
fs=fs,
|
132 |
+
base_dir=path,
|
133 |
+
save_repo_format=None,
|
134 |
+
expected_objects=dict(),
|
135 |
+
handle_found_object=handle_found_object,
|
136 |
+
handle_modified_object=handle_modified_object,
|
137 |
+
handle_missing_object=handle_missing_object,
|
138 |
+
handle_new_object=handle_new_object,
|
139 |
+
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
140 |
+
)
|
141 |
+
|
142 |
+
assert len(out) == 3
|
143 |
+
assert len(new_objects) == 3
|
144 |
+
assert len(found_objects) == 0
|
145 |
+
assert len(modified_objects) == 0
|
146 |
+
assert len(missing_objects) == 0
|
147 |
+
|
148 |
+
|
149 |
+
def test_github_handle_found_object():
|
150 |
+
found_objects = []
|
151 |
+
handle_found_object = (
|
152 |
+
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
153 |
+
dict(
|
154 |
+
file=file,
|
155 |
+
github_url=github_url,
|
156 |
+
sha256=sha256,
|
157 |
+
repo=repo,
|
158 |
+
organization=organization,
|
159 |
+
)
|
160 |
+
)
|
161 |
+
)
|
162 |
+
|
163 |
+
missing_objects = []
|
164 |
+
handle_missing_object = (
|
165 |
+
lambda github_url, sha256, repo, organization: missing_objects.append(
|
166 |
+
dict(
|
167 |
+
github_url=github_url,
|
168 |
+
sha256=sha256,
|
169 |
+
repo=repo,
|
170 |
+
organization=organization,
|
171 |
+
)
|
172 |
+
)
|
173 |
+
)
|
174 |
+
|
175 |
+
new_objects = []
|
176 |
+
handle_new_object = (
|
177 |
+
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
178 |
+
dict(
|
179 |
+
file=file,
|
180 |
+
github_url=github_url,
|
181 |
+
sha256=sha256,
|
182 |
+
repo=repo,
|
183 |
+
organization=organization,
|
184 |
+
)
|
185 |
+
)
|
186 |
+
)
|
187 |
+
|
188 |
+
modified_objects = []
|
189 |
+
handle_modified_object = (
|
190 |
+
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
191 |
+
dict(
|
192 |
+
file=file,
|
193 |
+
github_url=github_url,
|
194 |
+
sha256=sha256,
|
195 |
+
repo=repo,
|
196 |
+
organization=organization,
|
197 |
+
)
|
198 |
+
)
|
199 |
+
)
|
200 |
+
|
201 |
+
download_dir = "~/.objaverse-tests"
|
202 |
+
base_download_dir = os.path.join(download_dir, "github")
|
203 |
+
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
204 |
+
fs.makedirs(path, exist_ok=True)
|
205 |
+
|
206 |
+
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
207 |
+
out = _process_repo(
|
208 |
+
repo_id="mattdeitke/objaverse-xl-test-files",
|
209 |
+
fs=fs,
|
210 |
+
base_dir=path,
|
211 |
+
save_repo_format=None,
|
212 |
+
expected_objects={
|
213 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
214 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
215 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
216 |
+
},
|
217 |
+
handle_found_object=handle_found_object,
|
218 |
+
handle_modified_object=handle_modified_object,
|
219 |
+
handle_missing_object=handle_missing_object,
|
220 |
+
handle_new_object=handle_new_object,
|
221 |
+
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
222 |
+
)
|
223 |
+
|
224 |
+
assert len(out) == 3
|
225 |
+
assert len(found_objects) == 3
|
226 |
+
assert len(missing_objects) == 0
|
227 |
+
assert len(new_objects) == 0
|
228 |
+
assert len(modified_objects) == 0
|
229 |
+
|
230 |
+
|
231 |
+
def test_github_handle_modified_object():
|
232 |
+
found_objects = []
|
233 |
+
handle_found_object = (
|
234 |
+
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
235 |
+
dict(
|
236 |
+
file=file,
|
237 |
+
github_url=github_url,
|
238 |
+
sha256=sha256,
|
239 |
+
repo=repo,
|
240 |
+
organization=organization,
|
241 |
+
)
|
242 |
+
)
|
243 |
+
)
|
244 |
+
|
245 |
+
missing_objects = []
|
246 |
+
handle_missing_object = (
|
247 |
+
lambda github_url, sha256, repo, organization: missing_objects.append(
|
248 |
+
dict(
|
249 |
+
github_url=github_url,
|
250 |
+
sha256=sha256,
|
251 |
+
repo=repo,
|
252 |
+
organization=organization,
|
253 |
+
)
|
254 |
+
)
|
255 |
+
)
|
256 |
+
|
257 |
+
new_objects = []
|
258 |
+
handle_new_object = (
|
259 |
+
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
260 |
+
dict(
|
261 |
+
file=file,
|
262 |
+
github_url=github_url,
|
263 |
+
sha256=sha256,
|
264 |
+
repo=repo,
|
265 |
+
organization=organization,
|
266 |
+
)
|
267 |
+
)
|
268 |
+
)
|
269 |
+
|
270 |
+
modified_objects = []
|
271 |
+
handle_modified_object = (
|
272 |
+
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
273 |
+
dict(
|
274 |
+
file=file,
|
275 |
+
github_url=github_url,
|
276 |
+
sha256=sha256,
|
277 |
+
repo=repo,
|
278 |
+
organization=organization,
|
279 |
+
)
|
280 |
+
)
|
281 |
+
)
|
282 |
+
|
283 |
+
download_dir = "~/.objaverse-tests"
|
284 |
+
base_download_dir = os.path.join(download_dir, "github")
|
285 |
+
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
286 |
+
fs.makedirs(path, exist_ok=True)
|
287 |
+
|
288 |
+
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
289 |
+
out = _process_repo(
|
290 |
+
repo_id="mattdeitke/objaverse-xl-test-files",
|
291 |
+
fs=fs,
|
292 |
+
base_dir=path,
|
293 |
+
save_repo_format=None,
|
294 |
+
expected_objects={
|
295 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9<modified>",
|
296 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
297 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
298 |
+
},
|
299 |
+
handle_found_object=handle_found_object,
|
300 |
+
handle_modified_object=handle_modified_object,
|
301 |
+
handle_missing_object=handle_missing_object,
|
302 |
+
handle_new_object=handle_new_object,
|
303 |
+
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
304 |
+
)
|
305 |
+
|
306 |
+
assert len(out) == 3
|
307 |
+
assert len(found_objects) == 2
|
308 |
+
assert len(missing_objects) == 0
|
309 |
+
assert len(new_objects) == 0
|
310 |
+
assert len(modified_objects) == 1
|
311 |
+
|
312 |
+
|
313 |
+
def test_github_handle_missing_object():
|
314 |
+
found_objects = []
|
315 |
+
handle_found_object = (
|
316 |
+
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
317 |
+
dict(
|
318 |
+
file=file,
|
319 |
+
github_url=github_url,
|
320 |
+
sha256=sha256,
|
321 |
+
repo=repo,
|
322 |
+
organization=organization,
|
323 |
+
)
|
324 |
+
)
|
325 |
+
)
|
326 |
+
|
327 |
+
missing_objects = []
|
328 |
+
handle_missing_object = (
|
329 |
+
lambda github_url, sha256, repo, organization: missing_objects.append(
|
330 |
+
dict(
|
331 |
+
github_url=github_url,
|
332 |
+
sha256=sha256,
|
333 |
+
repo=repo,
|
334 |
+
organization=organization,
|
335 |
+
)
|
336 |
+
)
|
337 |
+
)
|
338 |
+
|
339 |
+
new_objects = []
|
340 |
+
handle_new_object = (
|
341 |
+
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
342 |
+
dict(
|
343 |
+
file=file,
|
344 |
+
github_url=github_url,
|
345 |
+
sha256=sha256,
|
346 |
+
repo=repo,
|
347 |
+
organization=organization,
|
348 |
+
)
|
349 |
+
)
|
350 |
+
)
|
351 |
+
|
352 |
+
modified_objects = []
|
353 |
+
handle_modified_object = (
|
354 |
+
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
355 |
+
dict(
|
356 |
+
file=file,
|
357 |
+
github_url=github_url,
|
358 |
+
sha256=sha256,
|
359 |
+
repo=repo,
|
360 |
+
organization=organization,
|
361 |
+
)
|
362 |
+
)
|
363 |
+
)
|
364 |
+
|
365 |
+
download_dir = "~/.objaverse-tests"
|
366 |
+
base_download_dir = os.path.join(download_dir, "github")
|
367 |
+
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
368 |
+
fs.makedirs(path, exist_ok=True)
|
369 |
+
|
370 |
+
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
371 |
+
out = _process_repo(
|
372 |
+
repo_id="mattdeitke/objaverse-xl-test-files",
|
373 |
+
fs=fs,
|
374 |
+
base_dir=path,
|
375 |
+
save_repo_format=None,
|
376 |
+
expected_objects={
|
377 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
378 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example-2.fbx": "<fake-missing-object>",
|
379 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
380 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
381 |
+
},
|
382 |
+
handle_found_object=handle_found_object,
|
383 |
+
handle_modified_object=handle_modified_object,
|
384 |
+
handle_missing_object=handle_missing_object,
|
385 |
+
handle_new_object=handle_new_object,
|
386 |
+
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
387 |
+
)
|
388 |
+
|
389 |
+
assert len(out) == 3
|
390 |
+
assert len(found_objects) == 3
|
391 |
+
assert len(missing_objects) == 1
|
392 |
+
assert len(new_objects) == 0
|
393 |
+
assert len(modified_objects) == 0
|
394 |
+
|
395 |
+
|
396 |
+
def test_github_handle_missing_object_2():
|
397 |
+
found_objects = []
|
398 |
+
handle_found_object = (
|
399 |
+
lambda file, github_url, sha256, repo, organization: found_objects.append(
|
400 |
+
dict(
|
401 |
+
file=file,
|
402 |
+
github_url=github_url,
|
403 |
+
sha256=sha256,
|
404 |
+
repo=repo,
|
405 |
+
organization=organization,
|
406 |
+
)
|
407 |
+
)
|
408 |
+
)
|
409 |
+
|
410 |
+
missing_objects = []
|
411 |
+
handle_missing_object = (
|
412 |
+
lambda github_url, sha256, repo, organization: missing_objects.append(
|
413 |
+
dict(
|
414 |
+
github_url=github_url,
|
415 |
+
sha256=sha256,
|
416 |
+
repo=repo,
|
417 |
+
organization=organization,
|
418 |
+
)
|
419 |
+
)
|
420 |
+
)
|
421 |
+
|
422 |
+
new_objects = []
|
423 |
+
handle_new_object = (
|
424 |
+
lambda file, github_url, sha256, repo, organization: new_objects.append(
|
425 |
+
dict(
|
426 |
+
file=file,
|
427 |
+
github_url=github_url,
|
428 |
+
sha256=sha256,
|
429 |
+
repo=repo,
|
430 |
+
organization=organization,
|
431 |
+
)
|
432 |
+
)
|
433 |
+
)
|
434 |
+
|
435 |
+
modified_objects = []
|
436 |
+
handle_modified_object = (
|
437 |
+
lambda file, github_url, sha256, repo, organization: modified_objects.append(
|
438 |
+
dict(
|
439 |
+
file=file,
|
440 |
+
github_url=github_url,
|
441 |
+
sha256=sha256,
|
442 |
+
repo=repo,
|
443 |
+
organization=organization,
|
444 |
+
)
|
445 |
+
)
|
446 |
+
)
|
447 |
+
|
448 |
+
download_dir = "~/.objaverse-tests"
|
449 |
+
base_download_dir = os.path.join(download_dir, "github")
|
450 |
+
fs, path = fsspec.core.url_to_fs(base_download_dir)
|
451 |
+
fs.makedirs(path, exist_ok=True)
|
452 |
+
|
453 |
+
shutil.rmtree(os.path.join(path, "repos"), ignore_errors=True)
|
454 |
+
out = _process_repo(
|
455 |
+
repo_id="mattdeitke/objaverse-xl-test-files-does-not-exist",
|
456 |
+
fs=fs,
|
457 |
+
base_dir=path,
|
458 |
+
save_repo_format=None,
|
459 |
+
expected_objects={
|
460 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
461 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example-2.fbx": "<fake-missing-object>",
|
462 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
463 |
+
"https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
464 |
+
},
|
465 |
+
handle_found_object=handle_found_object,
|
466 |
+
handle_modified_object=handle_modified_object,
|
467 |
+
handle_missing_object=handle_missing_object,
|
468 |
+
handle_new_object=handle_new_object,
|
469 |
+
commit_hash="6928b08a2501aa7a4a4aabac1f888b66e7782056",
|
470 |
+
)
|
471 |
+
|
472 |
+
assert len(out) == 0
|
473 |
+
assert len(found_objects) == 0
|
474 |
+
assert len(missing_objects) == 4
|
475 |
+
assert len(new_objects) == 0
|
476 |
+
assert len(modified_objects) == 0
|
477 |
+
|
478 |
+
|
479 |
+
def test_github_download_cache():
|
480 |
+
objects = pd.DataFrame(
|
481 |
+
[
|
482 |
+
{
|
483 |
+
"githubUrl": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.fbx",
|
484 |
+
"license": None,
|
485 |
+
"sha256": "7037575f47816118e5a34e7c0da9927e1be7be3f5b4adfac337710822eb50fa9",
|
486 |
+
},
|
487 |
+
{
|
488 |
+
"githubUrl": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.glb",
|
489 |
+
"license": None,
|
490 |
+
"sha256": "04e6377317d6818e32c5cbd1951e76deb3641bbf4f6db6933046221d5fbf1c5c",
|
491 |
+
},
|
492 |
+
{
|
493 |
+
"githubUrl": "https://github.com/mattdeitke/objaverse-xl-test-files/blob/6928b08a2501aa7a4a4aabac1f888b66e7782056/example.obj",
|
494 |
+
"license": None,
|
495 |
+
"sha256": "d2b9a5d7c47dc93526082c9b630157ab6bce4fd8669610d942176f4a36444e71",
|
496 |
+
},
|
497 |
+
]
|
498 |
+
)
|
499 |
+
|
500 |
+
# remove the repos directory
|
501 |
+
for save_repo_format in ["tar", "tar.gz", "zip", "files"]:
|
502 |
+
repos_dir = "~/.objaverse-tests/github/repos"
|
503 |
+
shutil.rmtree(os.path.expanduser(repos_dir), ignore_errors=True)
|
504 |
+
|
505 |
+
out = download_github_objects(
|
506 |
+
objects=objects,
|
507 |
+
processes=1,
|
508 |
+
download_dir="~/.objaverse-tests",
|
509 |
+
save_repo_format=save_repo_format, # type: ignore
|
510 |
+
)
|
511 |
+
assert len(out) == 3
|
512 |
+
|
513 |
+
out = download_github_objects(
|
514 |
+
objects=objects,
|
515 |
+
processes=1,
|
516 |
+
download_dir="~/.objaverse-tests",
|
517 |
+
save_repo_format=save_repo_format, # type: ignore
|
518 |
+
)
|
519 |
+
assert len(out) == 0
|