MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / getFilePath

Function getFilePath

samples/python/downloader.py:205–227  ·  view source on GitHub ↗

Util to get the full path to the downloaded data files. It only works when the sample doesn't have any other command line argument.

(path)

Source from the content-addressed store, hash-verified

203
204
205def getFilePath(path):
206 """Util to get the full path to the downloaded data files.
207
208 It only works when the sample doesn't have any other command line argument.
209 """
210 global TRT_DATA_DIR
211 if not TRT_DATA_DIR:
212 parser = argparse.ArgumentParser(description="Helper of data file download tool")
213 parser.add_argument(
214 "-d",
215 "--data",
216 help="Specify the data directory where it is saved in. $TRT_DATA_DIR will be overwritten by this argument.",
217 )
218 args, _ = parser.parse_known_args()
219 TRT_DATA_DIR = os.environ.get("TRT_DATA_DIR", None) if args.data is None else args.data
220 if TRT_DATA_DIR is None:
221 raise ValueError("Data directory must be specified by either `-d $DATA` or environment variable $TRT_DATA_DIR.")
222
223 fullpath = os.path.join(TRT_DATA_DIR, path)
224 if not os.path.exists(fullpath):
225 raise ValueError("Data file %s doesn't exist!" % fullpath)
226
227 return fullpath

Callers 3

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 1

getMethod · 0.45

Tested by

no test coverage detected