|
99 | 99 | from rich.table import Table |
100 | 100 |
|
101 | 101 | from ..api import API |
| 102 | +from ..framework.comet.download_manager import sanitize_filename |
102 | 103 | from ..utils import remove_extra_slashes |
103 | 104 | from .copy_utils import upload_single_offline_experiment |
104 | 105 |
|
@@ -544,6 +545,7 @@ def __init__(self, max_concurrent_uploads=None, debug=False, path=None): |
544 | 545 | self.progress_ui = ProgressUI( |
545 | 546 | quiet=debug, max_workers=self.max_concurrent_uploads |
546 | 547 | ) # Show UI by default, hide when debug=True |
| 548 | + self.missing_files_count = 0 |
547 | 549 |
|
548 | 550 | # Register signal handler for cursor reset on interruption |
549 | 551 | if not debug: # Only register signal handler when not in debug mode |
@@ -1043,7 +1045,12 @@ def copy_experiment_to( |
1043 | 1045 | experiment = self.create_experiment(workspace_dst, project_dst) |
1044 | 1046 | # copy experiment_folder stuff to experiment |
1045 | 1047 | # copy all resources to existing or new experiment |
| 1048 | + self.missing_files_count = 0 |
1046 | 1049 | self.log_all(experiment, experiment_folder) |
| 1050 | + if self.missing_files_count > 0: |
| 1051 | + print( |
| 1052 | + f"WARNING: {self.missing_files_count} asset file(s) were missing and could not be copied" |
| 1053 | + ) |
1047 | 1054 | experiment.end() |
1048 | 1055 |
|
1049 | 1056 | archive_path = os.path.join( |
@@ -1200,16 +1207,14 @@ def _log_asset( |
1200 | 1207 | old_asset_id = assets_metadata[log_filename].get("assetId") |
1201 | 1208 | if asset_type in self.ignore: |
1202 | 1209 | return |
1203 | | - if log_filename.startswith("/"): |
1204 | | - filename = os.path.join(path, asset_type, log_filename[1:]) |
1205 | | - else: |
1206 | | - filename = os.path.join(path, asset_type, log_filename) |
1207 | | - |
1208 | | - filename = filename.replace(":", "-") |
| 1210 | + sanitized_filename = sanitize_filename(log_filename) |
| 1211 | + filename = os.path.join(path, asset_type, sanitized_filename) |
1209 | 1212 |
|
1210 | 1213 | if not os.path.isfile(filename): |
1211 | | - with experiment.context_manager("ignore"): |
1212 | | - print("Missing file %r: unable to copy" % filename) |
| 1214 | + self.missing_files_count += 1 |
| 1215 | + if self.debug: |
| 1216 | + with experiment.context_manager("ignore"): |
| 1217 | + print("Missing file %r: unable to copy" % filename) |
1213 | 1218 | return |
1214 | 1219 |
|
1215 | 1220 | metadata = assets_metadata[log_filename].get("metadata") |
|
0 commit comments