MCPcopy Create free account
hub / github.com/CSAILVision/gandissect / load_projects

Function load_projects

netdissect/server.py:126–153  ·  view source on GitHub ↗

searches for CONFIG_FILE_NAME in all subdirectories of directory and creates data handlers for all of them :param directory: scan directory :return: null

(directory)

Source from the content-addressed store, hash-verified

124
125
126def load_projects(directory):
127 """
128 searches for CONFIG_FILE_NAME in all subdirectories of directory
129 and creates data handlers for all of them
130
131 :param directory: scan directory
132 :return: null
133 """
134 project_dirs = []
135 # Don't search more than 2 dirs deep.
136 search_depth = 2 + directory.count(os.path.sep)
137 for root, dirs, files in os.walk(directory):
138 if CONFIG_FILE_NAME in files:
139 project_dirs.append(root)
140 # Don't get subprojects under a project dir.
141 del dirs[:]
142 elif root.count(os.path.sep) >= search_depth:
143 del dirs[:]
144 for p_dir in project_dirs:
145 print('Loading %s' % os.path.join(p_dir, CONFIG_FILE_NAME))
146 with open(os.path.join(p_dir, CONFIG_FILE_NAME), 'r') as jf:
147 config = EasyDict(json.load(jf))
148 dh_id = os.path.split(p_dir)[1]
149 projects[dh_id] = DissectionProject(
150 config=config,
151 project_dir=p_dir,
152 path_url='data/' + os.path.relpath(p_dir, directory),
153 public_host=args.public_host)
154
155app.add_api('server.yaml')
156

Callers 1

server.pyFile · 0.85

Calls 3

EasyDictClass · 0.90
DissectionProjectClass · 0.90
joinMethod · 0.80

Tested by

no test coverage detected