Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,31 +102,31 @@ class Bergamot:
|
|
| 102 |
print('input text type:', type(self.input_text), len(self.all_files), 'installed_pairs', self.installed_pairs, 'defaultlocalfolder', self.localfolder)
|
| 103 |
try:
|
| 104 |
for branch in self.branches:
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
except Exception as downloaderror:
|
| 131 |
response, message_text = str(downloaderror), f"Error downloading {self.model_name}: {downloaderror}."
|
| 132 |
print(downloaderror)
|
|
|
|
| 102 |
print('input text type:', type(self.input_text), len(self.all_files), 'installed_pairs', self.installed_pairs, 'defaultlocalfolder', self.localfolder)
|
| 103 |
try:
|
| 104 |
for branch in self.branches:
|
| 105 |
+
branch_files = [f for f in self.all_files if f.startswith(branch)]
|
| 106 |
+
fullmodel_files = [f for f in branch_files if f.startswith(self.model_name)]
|
| 107 |
+
print('branch_files', len(branch_files), 'fullmodel_files', fullmodel_files)
|
| 108 |
+
model_files = [f.split(f'{self.model_name}/')[1] for f in fullmodel_files]
|
| 109 |
+
print('branch_files', len(branch_files), 'model_files', model_files)
|
| 110 |
+
for file_path in model_files:
|
| 111 |
+
if localfolder not in installed_pairs:
|
| 112 |
+
# local_files_only (bool, optional, defaults to False) — If True, avoid downloading the file and return the path to the local cached file if it exists.
|
| 113 |
+
# dry_run (bool, optional, defaults to False) — If True, perform a dry run without actually downloading the file. Returns a DryRunFileInfo object containing information about what would be downloaded.
|
| 114 |
+
local_path = hf_hub_download(repo_id=self.repo_id, subfolder=self.model_name, filename=file_path, local_dir=self.subfolder)
|
| 115 |
+
print(f"Downloaded to: {local_path}") # Downloaded to: deen/base/deen/config.yml
|
| 116 |
+
## Check if model/localfolder in repo files, add to set if exists
|
| 117 |
+
modelcheck = [i for i in all_files if self.model_name in i]
|
| 118 |
+
print('Modelcheck', modelcheck)
|
| 119 |
+
if modelcheck:
|
| 120 |
+
print('Add to set after modelcheck', modelcheck)
|
| 121 |
+
self.installed_pairs.add(self.localfolder)
|
| 122 |
+
try:
|
| 123 |
+
dry_run = hf_hub_download(repo_id=self.repo_id, subfolder=self.model_name, filename='config.yml', local_dir=self.subfolder)
|
| 124 |
+
print('installed_pairs', self.installed_pairs, 'localfolder', self.localfolder, 'dry_run', type(dry_run), dry_run)
|
| 125 |
+
if isinstance(dry_run, str):
|
| 126 |
+
print('Add to set after dryrun', dry_run)
|
| 127 |
+
self.installed_pairs.add(localfolder)
|
| 128 |
+
except Exception as dryrunerror:
|
| 129 |
+
print('installed_pairs', self.installed_pairs, 'localfolder', self.localfolder, 'dry_runerror', dryrunerror)
|
| 130 |
except Exception as downloaderror:
|
| 131 |
response, message_text = str(downloaderror), f"Error downloading {self.model_name}: {downloaderror}."
|
| 132 |
print(downloaderror)
|