Spaces:
Build error
Build error
Julian Bilcke commited on
Commit ·
76a0a50
1
Parent(s): 7f039e5
attempting salvage after Claude Code deleted all my precious data
Browse filesFiles changed (2)
1117 unmodified lines11181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149534 unmodified lines16841685168616871117 unmodified linesstep_num = int(checkpoint_dir.name.split("_")[-1])logger.info(f"Validating checkpoint at step {step_num}: {checkpoint_dir}")# Check if the .metadata file existsmetadata_file = checkpoint_dir / ".metadata"if not metadata_file.exists():logger.warning(f"Checkpoint {checkpoint_dir.name} is corrupted: missing .metadata file")corrupted_checkpoints.append(checkpoint_dir)continue# Try to read the metadata file to ensure it's not corruptedtry:with open(metadata_file, 'r') as f:metadata = json.load(f)# Basic validation - metadata should have expected structureif not isinstance(metadata, dict):raise ValueError("Invalid metadata format")logger.info(f"Checkpoint {checkpoint_dir.name} is valid")# Clean up any corrupted checkpoints we found before this valid oneif corrupted_checkpoints:self.cleanup_corrupted_checkpoints(corrupted_checkpoints)return str(checkpoint_dir)except (json.JSONDecodeError, IOError, ValueError) as e:logger.warning(f"Checkpoint {checkpoint_dir.name} is corrupted: failed to read .metadata: {e}")corrupted_checkpoints.append(checkpoint_dir)continue# If we reach here, all checkpoints are corruptedif corrupted_checkpoints:534 unmodified linesreturn temp_zip_pathexcept Exception as e:print(f"Failed to create zip: {str(e)}")raise gr.Error(f"Failed to create zip: {str(e)}")1117 unmodified lines1118111911201121112211231124112511261127112811291130113111321133113411351136113711381139534 unmodified lines16741675167616771678167916801681168216831684168516861687168816891690169116921693169416951117 unmodified linesstep_num = int(checkpoint_dir.name.split("_")[-1])logger.info(f"Validating checkpoint at step {step_num}: {checkpoint_dir}")# Check if the .metadata file exists (indicator of complete checkpoint)metadata_file = checkpoint_dir / ".metadata"if not metadata_file.exists():logger.warning(f"Checkpoint {checkpoint_dir.name} is corrupted: missing .metadata file")corrupted_checkpoints.append(checkpoint_dir)continue# .metadata file exists, checkpoint is considered valid# We don't read the file contents to avoid encoding/parsing issueslogger.info(f"Checkpoint {checkpoint_dir.name} is valid")# Clean up any corrupted checkpoints we found before this valid oneif corrupted_checkpoints:self.cleanup_corrupted_checkpoints(corrupted_checkpoints)return str(checkpoint_dir)# If we reach here, all checkpoints are corruptedif corrupted_checkpoints:534 unmodified linesreturn temp_zip_pathexcept Exception as e:print(f"Failed to create zip: {str(e)}")raise gr.Error(f"Failed to create zip: {str(e)}")def create_output_directory_zip(self) -> str:"""Create a ZIP file containing all output data (checkpoints, models, etc.)Returns:Path to created ZIP file"""# Create temporary zip filewith tempfile.NamedTemporaryFile(suffix='.zip', delete=False) as temp_zip:temp_zip_path = str(temp_zip.name)print(f"Creating zip file for {self.app.output_path}..")try:make_archive(self.app.output_path, temp_zip_path)print(f"Output zip file created!")return temp_zip_pathexcept Exception as e:print(f"Failed to create output zip: {str(e)}")raise gr.Error(f"Failed to create output zip: {str(e)}")
74 unmodified lines757677787980132 unmodified lines21321421521621721874 unmodified linesvariant="secondary",size="lg")with gr.Row():with gr.Column():gr.Markdown("## 📡 Publish your model")132 unmodified linesoutputs=[self.components["download_model_btn"]])# Dataset deletion with modalself.components["delete_dataset_btn"].click(fn=lambda: Modal(visible=True),74 unmodified lines757677787980818283848586132 unmodified lines21922022122222322422522622722822974 unmodified linesvariant="secondary",size="lg")self.components["download_output_btn"] = gr.DownloadButton("📁 Download output directory (.zip)",variant="secondary",size="lg")with gr.Row():with gr.Column():gr.Markdown("## 📡 Publish your model")132 unmodified linesoutputs=[self.components["download_model_btn"]])self.components["download_output_btn"].click(fn=self.app.training.create_output_directory_zip,outputs=[self.components["download_output_btn"]])# Dataset deletion with modalself.components["delete_dataset_btn"].click(fn=lambda: Modal(visible=True),
vms/ui/project/services/training.py+29-21
vms/ui/project/tabs/manage_tab.py+11