@@ -45,36 +45,30 @@ def write_registry(
4545 if is_zip := url .endswith ((".zip" , ".tar" )):
4646 registry [url .rpartition ("/" )[2 ]] = {"hash" : None , "url" : url }
4747
48- def _find_examples_dir (p ):
49- while p .name != "examples" :
50- p = p .parent
51- return p
52-
5348 model_paths = get_model_paths (path )
5449 for model_path in model_paths :
5550 # TODO: the renaming is only necessary because we're attaching auto-
5651 # generated functions to the models module. If we can live without,
5752 # and get by with a single function that takes model name as an arg,
5853 # then the model names could correspond directly to directory names.
5954 model_path = model_path .expanduser ().absolute ()
60- base_path = _find_examples_dir (model_path ) if is_zip else path
61- rel_path = model_path .relative_to (base_path )
55+ rel_path = model_path .relative_to (path )
6256 model_name = "/" .join (rel_path .parts )
6357 modelmap [model_name ] = []
6458 if is_zip :
6559 if rel_path .parts [0 ] not in examples :
6660 examples [rel_path .parts [0 ]] = []
6761 examples [rel_path .parts [0 ]].append (model_name )
68- for p in model_path .glob ("*" ):
62+ for p in model_path .rglob ("*" ):
6963 if not p .is_file () or any (e in p .name for e in exclude ):
7064 continue
7165 if is_zip :
72- relpath = p .expanduser ().absolute ().relative_to (base_path )
66+ relpath = p .expanduser ().absolute ().relative_to (path )
7367 name = "/" .join (relpath .parts )
7468 url_ = url
7569 hash = None
7670 else :
77- relpath = p .expanduser ().absolute ().relative_to (base_path )
71+ relpath = p .expanduser ().absolute ().relative_to (path )
7872 name = "/" .join (relpath .parts )
7973 url_ = f"{ url } /{ relpath !s} "
8074 hash = _sha256 (p )
0 commit comments