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 lines111811191120112111211122112311241125112611271128112911301131113211331134113511361137113811391140114111281129113011311132113311341135113611421143114411451146113711381139534 unmodified lines167416751676168716771678167916801681168216831684168516861687168816891690169116921693169416951117 unmodified lines step_num = int(checkpoint_dir.name.split("_")[-1]) logger.info(f"Validating checkpoint at step {step_num}: {checkpoint_dir}") # Check if the .metadata file exists # 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 # Try to read the metadata file to ensure it's not corrupted try: with open(metadata_file, 'r') as f: metadata = json.load(f) # Basic validation - metadata should have expected structure if 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 one if corrupted_checkpoints: self.cleanup_corrupted_checkpoints(corrupted_checkpoints) return str(checkpoint_dir) # .metadata file exists, checkpoint is considered valid # We don't read the file contents to avoid encoding/parsing issues logger.info(f"Checkpoint {checkpoint_dir.name} is valid") # Clean up any corrupted checkpoints we found before this valid one if 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 corrupted if corrupted_checkpoints:534 unmodified lines return temp_zip_path except Exception as e: print(f"Failed to create zip: {str(e)}") raise gr.Error(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 file with 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_path except 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 lines757677787980818283848586132 unmodified lines21922022122222322422522622722822974 unmodified lines variant="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 lines outputs=[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 modal self.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