Spaces:
				
			
			
	
			
			
		Build error
		
	
	
	
			
			
	
	
	
	
		
		
		Build error
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -84,12 +84,11 @@ class S3DirectStream: | |
| 84 | 
             
                        if not model_files:
         | 
| 85 | 
             
                            raise HTTPException(status_code=404, detail=f"Archivos del modelo {model_name} no encontrados en S3.")
         | 
| 86 |  | 
| 87 | 
            -
                        # Verificar que existe el archivo config.json
         | 
| 88 | 
             
                        config_stream = await self.stream_from_s3(f"{model_prefix}/config.json")
         | 
| 89 | 
             
                        config_data = config_stream.read()
         | 
| 90 |  | 
| 91 | 
             
                        if not config_data:
         | 
| 92 | 
            -
                            raise HTTPException(status_code=500, detail=f"El archivo de configuraci贸n {model_prefix}/config.json est谩 vac铆o | 
| 93 |  | 
| 94 | 
             
                        config_text = config_data.decode("utf-8")
         | 
| 95 | 
             
                        config_json = json.loads(config_text)
         | 
| @@ -120,7 +119,6 @@ class S3DirectStream: | |
| 120 | 
             
                        for i in range(1, len(folder_keys)):
         | 
| 121 | 
             
                            folder_key = '/'.join(folder_keys[:i]) + '/'
         | 
| 122 | 
             
                            if not await self.file_exists_in_s3(folder_key):
         | 
| 123 | 
            -
                                logger.info(f"Creando carpeta en S3: {folder_key}")
         | 
| 124 | 
             
                                self.s3_client.put_object(Bucket=self.bucket_name, Key=folder_key, Body='')
         | 
| 125 |  | 
| 126 | 
             
                    except Exception as e:
         | 
| @@ -162,9 +160,6 @@ async def predict(model_request: dict): | |
| 162 | 
             
                        raise HTTPException(status_code=400, detail="Faltan par谩metros en la solicitud.")
         | 
| 163 |  | 
| 164 | 
             
                    streamer = S3DirectStream(S3_BUCKET_NAME)
         | 
| 165 | 
            -
                    
         | 
| 166 | 
            -
                    await streamer.create_s3_folders(model_name)  # Crear las carpetas si no existen
         | 
| 167 | 
            -
             | 
| 168 | 
             
                    model = await streamer.load_model_from_s3(model_name)
         | 
| 169 | 
             
                    tokenizer = await streamer.load_tokenizer_from_s3(model_name)
         | 
| 170 |  | 
| @@ -190,4 +185,4 @@ async def predict(model_request: dict): | |
| 190 |  | 
| 191 | 
             
            if __name__ == "__main__":
         | 
| 192 | 
             
                import uvicorn
         | 
| 193 | 
            -
                uvicorn.run(app, host="0.0.0.0", port=7860)
         | 
|  | |
| 84 | 
             
                        if not model_files:
         | 
| 85 | 
             
                            raise HTTPException(status_code=404, detail=f"Archivos del modelo {model_name} no encontrados en S3.")
         | 
| 86 |  | 
|  | |
| 87 | 
             
                        config_stream = await self.stream_from_s3(f"{model_prefix}/config.json")
         | 
| 88 | 
             
                        config_data = config_stream.read()
         | 
| 89 |  | 
| 90 | 
             
                        if not config_data:
         | 
| 91 | 
            +
                            raise HTTPException(status_code=500, detail=f"El archivo de configuraci贸n {model_prefix}/config.json est谩 vac铆o.")
         | 
| 92 |  | 
| 93 | 
             
                        config_text = config_data.decode("utf-8")
         | 
| 94 | 
             
                        config_json = json.loads(config_text)
         | 
|  | |
| 119 | 
             
                        for i in range(1, len(folder_keys)):
         | 
| 120 | 
             
                            folder_key = '/'.join(folder_keys[:i]) + '/'
         | 
| 121 | 
             
                            if not await self.file_exists_in_s3(folder_key):
         | 
|  | |
| 122 | 
             
                                self.s3_client.put_object(Bucket=self.bucket_name, Key=folder_key, Body='')
         | 
| 123 |  | 
| 124 | 
             
                    except Exception as e:
         | 
|  | |
| 160 | 
             
                        raise HTTPException(status_code=400, detail="Faltan par谩metros en la solicitud.")
         | 
| 161 |  | 
| 162 | 
             
                    streamer = S3DirectStream(S3_BUCKET_NAME)
         | 
|  | |
|  | |
|  | |
| 163 | 
             
                    model = await streamer.load_model_from_s3(model_name)
         | 
| 164 | 
             
                    tokenizer = await streamer.load_tokenizer_from_s3(model_name)
         | 
| 165 |  | 
|  | |
| 185 |  | 
| 186 | 
             
            if __name__ == "__main__":
         | 
| 187 | 
             
                import uvicorn
         | 
| 188 | 
            +
                uvicorn.run(app, host="0.0.0.0", port=7860)
         |