@@ -131,32 +131,35 @@ async def import_model(
131131 reporter: ProgressReporter for tracking progress
132132 storage_step_mappings: Mapping of import steps to storage names
133133 """
134- if model .revision is None :
135- raise ArtifactRevisionEmptyError (f"Revision must be specified for model: { model } " )
136-
137- # Create import context
138- context = ImportStepContext (
139- model = model ,
140- registry_name = registry_name ,
141- storage_pool = self ._storage_pool ,
142- progress_reporter = reporter ,
143- storage_step_mappings = storage_step_mappings ,
144- step_metadata = {},
145- )
146-
147- # Execute import pipeline
148- await pipeline .execute (context )
149-
150- log .info (f"Model import completed: { model } " )
134+ success = False
135+ try :
136+ if model .revision is None :
137+ raise ArtifactRevisionEmptyError (f"Revision must be specified for model: { model } " )
151138
152- await self ._event_producer .anycast_event (
153- ModelImportDoneEvent (
154- model_id = model .model_id ,
155- revision = model .resolve_revision (ArtifactRegistryType .RESERVOIR ),
139+ # Create import context
140+ context = ImportStepContext (
141+ model = model ,
156142 registry_name = registry_name ,
157- registry_type = ArtifactRegistryType .RESERVOIR ,
143+ storage_pool = self ._storage_pool ,
144+ progress_reporter = reporter ,
145+ storage_step_mappings = storage_step_mappings ,
146+ step_metadata = {},
147+ )
148+
149+ # Execute import pipeline
150+ await pipeline .execute (context )
151+ log .info (f"Model import completed: { model } " )
152+ success = True
153+ finally :
154+ await self ._event_producer .anycast_event (
155+ ModelImportDoneEvent (
156+ success = success ,
157+ model_id = model .model_id ,
158+ revision = model .resolve_revision (ArtifactRegistryType .RESERVOIR ),
159+ registry_name = registry_name ,
160+ registry_type = ArtifactRegistryType .RESERVOIR ,
161+ )
158162 )
159- )
160163
161164 async def import_models_batch (
162165 self ,
0 commit comments