MCPcopy
hub / github.com/deezer/spleeter / download

Method download

spleeter/model/provider/github.py:124–156  ·  view source on GitHub ↗

Download model denoted by the given name to disk. Parameters: name (str): Name of the model to download. path (str): Path of the directory to save model into.

(self, name: str, path: str)

Source from the content-addressed store, hash-verified

122 return index[name]
123
124 def download(self, name: str, path: str) -> None:
125 """
126 Download model denoted by the given name to disk.
127
128 Parameters:
129 name (str):
130 Name of the model to download.
131 path (str):
132 Path of the directory to save model into.
133 """
134 url: str = "/".join(
135 (self._host, self._repository, self.RELEASE_PATH, self._release, name)
136 )
137 url = f"{url}.tar.gz"
138 logger.info(f"Downloading model archive {url}")
139 with httpx.Client(http2=True) as client:
140 with client.stream("GET", url) as response:
141 response.raise_for_status()
142 archive = NamedTemporaryFile(delete=False)
143 try:
144 with archive as stream:
145 for chunk in response.iter_raw():
146 stream.write(chunk)
147 logger.info("Validating archive checksum")
148 checksum: str = compute_file_checksum(archive.name)
149 if checksum != self.checksum(name):
150 raise IOError("Downloaded file is corrupted, please retry")
151 logger.info(f"Extracting downloaded {name} archive")
152 with tarfile.open(name=archive.name) as tar:
153 tar.extractall(path=path)
154 finally:
155 os.unlink(archive.name)
156 logger.info(f"{name} model file(s) extracted")

Callers

nothing calls this directly

Calls 3

checksumMethod · 0.95
compute_file_checksumFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected