|
19 | 19 | from ai.backend.common.config import ( |
20 | 20 | ModelConfig, |
21 | 21 | ModelDefinition, |
22 | | - ModelHealthCheck, |
23 | | - ModelMetadata, |
24 | 22 | ModelServiceConfig, |
25 | | - PreStartAction, |
26 | 23 | ) |
27 | 24 | from ai.backend.common.contexts.user import current_user |
28 | 25 | from ai.backend.common.data.endpoint.types import EndpointLifecycle |
@@ -352,63 +349,55 @@ def _tristate_from_input[T](value: T | Sentinel | None) -> TriState[T]: |
352 | 349 | return TriState[T].update(value) |
353 | 350 |
|
354 | 351 |
|
355 | | -def _pre_start_action_to_dto(action: PreStartAction) -> PreStartActionInfoDTO: |
356 | | - return PreStartActionInfoDTO(action=action.action, args=action.args) |
357 | | - |
358 | | - |
359 | | -def _model_health_check_to_dto(check: ModelHealthCheck) -> ModelHealthCheckInfoDTO: |
360 | | - return ModelHealthCheckInfoDTO( |
361 | | - enable=check.enable, |
362 | | - interval=check.interval, |
363 | | - path=check.path, |
364 | | - max_retries=check.max_retries, |
365 | | - max_wait_time=check.max_wait_time, |
366 | | - expected_status_code=check.expected_status_code, |
367 | | - initial_delay=check.initial_delay, |
368 | | - ) |
369 | | - |
370 | | - |
371 | 352 | def _model_service_config_to_dto(service: ModelServiceConfig) -> ModelServiceConfigInfoDTO: |
| 353 | + health_check = None |
| 354 | + if service.health_check is not None: |
| 355 | + health_check = ModelHealthCheckInfoDTO( |
| 356 | + enable=service.health_check.enable, |
| 357 | + interval=service.health_check.interval, |
| 358 | + path=service.health_check.path, |
| 359 | + max_retries=service.health_check.max_retries, |
| 360 | + max_wait_time=service.health_check.max_wait_time, |
| 361 | + expected_status_code=service.health_check.expected_status_code, |
| 362 | + initial_delay=service.health_check.initial_delay, |
| 363 | + ) |
372 | 364 | return ModelServiceConfigInfoDTO( |
373 | | - pre_start_actions=[_pre_start_action_to_dto(a) for a in service.pre_start_actions], |
| 365 | + pre_start_actions=[ |
| 366 | + PreStartActionInfoDTO(action=a.action, args=a.args) for a in service.pre_start_actions |
| 367 | + ], |
374 | 368 | command=service.start_command, |
375 | 369 | start_command=to_legacy_start_command(service.start_command), |
376 | 370 | shell=service.shell, |
377 | 371 | port=service.port, |
378 | | - health_check=( |
379 | | - _model_health_check_to_dto(service.health_check) |
380 | | - if service.health_check is not None |
381 | | - else None |
382 | | - ), |
383 | | - ) |
384 | | - |
385 | | - |
386 | | -def _model_metadata_to_dto(metadata: ModelMetadata) -> ModelMetadataInfoDTO: |
387 | | - return ModelMetadataInfoDTO( |
388 | | - author=metadata.author, |
389 | | - title=metadata.title, |
390 | | - version=metadata.version, |
391 | | - created=metadata.created, |
392 | | - last_modified=metadata.last_modified, |
393 | | - description=metadata.description, |
394 | | - task=metadata.task, |
395 | | - category=metadata.category, |
396 | | - architecture=metadata.architecture, |
397 | | - framework=metadata.framework, |
398 | | - label=metadata.label, |
399 | | - license=metadata.license, |
400 | | - min_resource=metadata.min_resource, |
| 372 | + health_check=health_check, |
401 | 373 | ) |
402 | 374 |
|
403 | 375 |
|
404 | 376 | def _model_config_to_dto(config: ModelConfig) -> ModelConfigInfoDTO: |
| 377 | + metadata = None |
| 378 | + if config.metadata is not None: |
| 379 | + metadata = ModelMetadataInfoDTO( |
| 380 | + author=config.metadata.author, |
| 381 | + title=config.metadata.title, |
| 382 | + version=config.metadata.version, |
| 383 | + created=config.metadata.created, |
| 384 | + last_modified=config.metadata.last_modified, |
| 385 | + description=config.metadata.description, |
| 386 | + task=config.metadata.task, |
| 387 | + category=config.metadata.category, |
| 388 | + architecture=config.metadata.architecture, |
| 389 | + framework=config.metadata.framework, |
| 390 | + label=config.metadata.label, |
| 391 | + license=config.metadata.license, |
| 392 | + min_resource=config.metadata.min_resource, |
| 393 | + ) |
405 | 394 | return ModelConfigInfoDTO( |
406 | 395 | name=config.name, |
407 | 396 | model_path=config.model_path, |
408 | 397 | service=( |
409 | 398 | _model_service_config_to_dto(config.service) if config.service is not None else None |
410 | 399 | ), |
411 | | - metadata=(_model_metadata_to_dto(config.metadata) if config.metadata is not None else None), |
| 400 | + metadata=metadata, |
412 | 401 | ) |
413 | 402 |
|
414 | 403 |
|
|
0 commit comments