frogml 1.2.50__py3-none-any.whl → 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. frogml/__init__.py +1 -1
  2. frogml/core/clients/batch_job_management/client.py +269 -257
  3. frogml/core/clients/batch_job_management/executions_config.py +10 -3
  4. frogml/core/clients/build_orchestrator/build_model_request_getter.py +7 -1
  5. frogml/core/clients/build_orchestrator/client.py +108 -67
  6. frogml/core/clients/build_orchestrator/internal_client.py +42 -38
  7. frogml/core/clients/feature_store/management_client.py +58 -39
  8. frogml/core/clients/feature_store/operator_client.py +6 -4
  9. frogml/core/clients/model_group_management/client.py +5 -2
  10. frogml/core/clients/model_management/client.py +25 -8
  11. frogml/core/clients/model_version_manager/build_model_version_dto.py +4 -1
  12. frogml/core/clients/model_version_manager/client.py +67 -68
  13. frogml/core/exceptions/__init__.py +20 -2
  14. frogml/core/exceptions/frogml_exception.py +35 -5
  15. frogml/core/exceptions/frogml_general_build_exception.py +19 -11
  16. frogml/core/exceptions/frogml_grpc_address_exception.py +15 -4
  17. frogml/core/exceptions/frogml_http_exception.py +3 -1
  18. frogml/core/exceptions/frogml_login_exception.py +16 -5
  19. frogml/core/exceptions/frogml_not_found_exception.py +16 -3
  20. frogml/core/exceptions/frogml_remote_build_failed.py +1 -1
  21. frogml/core/exceptions/frogml_token_exception.py +17 -5
  22. frogml/core/exceptions/grpc_status_mapping.py +43 -0
  23. frogml/core/inner/build_logic/phases/phase_010_fetch_model/fetch_strategy_manager/strategy/git/git_strategy.py +10 -2
  24. frogml/core/inner/build_logic/phases/phase_010_fetch_model/pre_fetch_validation_step.py +3 -2
  25. frogml/core/inner/build_logic/phases/phase_020_remote_register_frogml_build/upload_step.py +13 -10
  26. frogml/core/inner/build_logic/run_handlers/programmatic_phase_run_handler.py +8 -3
  27. frogml/core/inner/build_logic/tools/files.py +1 -2
  28. frogml/core/inner/model_loggers_utils.py +21 -8
  29. frogml/core/inner/tool/auth/auth_client.py +1 -1
  30. frogml/core/inner/tool/grpc/grpc_try_wrapping.py +51 -72
  31. frogml/core/inner/tool/protobuf_factory.py +8 -2
  32. frogml/sdk/frogml_client/client.py +29 -10
  33. frogml/sdk/model/adapters/input_adapters/numpy_input_adapter.py +6 -1
  34. frogml/sdk/model/adapters/output_adapters/numpy_output_adapter.py +4 -1
  35. frogml/sdk/model/decorators/api.py +6 -1
  36. frogml/sdk/model/tools/adapters/output.py +6 -2
  37. frogml/sdk/model_version/catboost/__init__.py +4 -1
  38. frogml/sdk/model_version/huggingface/__init__.py +4 -1
  39. frogml/sdk/model_version/model_loggers/catboost_model_version_manager.py +4 -1
  40. frogml/sdk/model_version/model_loggers/huggingface_model_version_manager.py +10 -2
  41. frogml/sdk/model_version/model_loggers/onnx_model_version_manager.py +4 -1
  42. frogml/sdk/model_version/model_loggers/pytorch_model_version_manager.py +4 -1
  43. frogml/sdk/model_version/model_loggers/scikit_learn_model_version_manager.py +4 -1
  44. frogml/sdk/model_version/onnx/__init__.py +4 -1
  45. frogml/sdk/model_version/pytorch/__init__.py +4 -1
  46. frogml/sdk/model_version/scikit_learn/__init__.py +4 -1
  47. frogml/sdk/model_version/utils/jml/customer_client.py +1 -1
  48. frogml/sdk/model_version/utils/storage.py +4 -1
  49. frogml/sdk/model_version/utils/validations.py +10 -2
  50. {frogml-1.2.50.dist-info → frogml-2.0.0.dist-info}/METADATA +1 -1
  51. {frogml-1.2.50.dist-info → frogml-2.0.0.dist-info}/RECORD +58 -61
  52. frogml_services_mock/mocks/batch_job_manager_service.py +11 -9
  53. frogml_services_mock/mocks/build_orchestrator_service_api.py +4 -0
  54. frogml_services_mock/mocks/ecosystem_service_api.py +1 -2
  55. frogml_services_mock/mocks/model_group_management_service.py +20 -9
  56. frogml_services_mock/mocks/model_version_manager_service.py +3 -1
  57. frogml_services_mock/mocks/project_manager_service.py +6 -2
  58. frogml/core/exceptions/frogml_decode_exception.py +0 -7
  59. frogml/core/exceptions/frogml_external_exception.py +0 -11
  60. frogml/core/exceptions/frogml_load_model_failed_exception.py +0 -10
  61. frogml/core/exceptions/quiet_error.py +0 -22
  62. {frogml-1.2.50.dist-info → frogml-2.0.0.dist-info}/WHEEL +0 -0
@@ -1,5 +1,6 @@
1
1
  from collections import defaultdict
2
2
  from dataclasses import dataclass, field
3
+ from http import HTTPStatus
3
4
  from typing import Dict, List, Tuple, Union
4
5
 
5
6
  from frogml._proto.qwak.batch_job.v1.batch_job_resources_pb2 import (
@@ -127,11 +128,15 @@ class ExecutionConfig(YamlConfigMixin, FrogmlConfigBase):
127
128
 
128
129
  if not self.execution.source_bucket:
129
130
  raise FrogmlException(
130
- "Must supply either --bucket or --source-bucket parameter"
131
+ error_message="Must supply either --bucket or --source-bucket parameter",
132
+ status_code=HTTPStatus.BAD_REQUEST,
133
+ operation="Validate Batch Execution Config",
131
134
  )
132
135
  if not self.execution.destination_bucket:
133
136
  raise FrogmlException(
134
- "Must supply either --bucket or --destination-bucket parameter"
137
+ error_message="Must supply either --bucket or --destination-bucket parameter",
138
+ status_code=HTTPStatus.BAD_REQUEST,
139
+ operation="Validate Batch Execution Config",
135
140
  )
136
141
 
137
142
  @property
@@ -195,7 +200,9 @@ def dictify_params(parameters: Union[Dict[str, str], List[str], Tuple[str]]):
195
200
  for param in parameters:
196
201
  if "=" not in param:
197
202
  raise FrogmlException(
198
- f'The parameter definition passed {param} is invalid. Format is "KEY=VALUE"'
203
+ error_message=f'The parameter definition passed {param} is invalid. Format is "KEY=VALUE"',
204
+ status_code=HTTPStatus.BAD_REQUEST,
205
+ operation="Parse Batch Parameters",
199
206
  )
200
207
  split_param = param.split("=")
201
208
  result[split_param[0]] = split_param[1]
@@ -1,5 +1,6 @@
1
1
  import json
2
2
  import re
3
+ from http import HTTPStatus
3
4
  from typing import List, Optional, TYPE_CHECKING
4
5
 
5
6
  import yaml
@@ -23,6 +24,7 @@ from frogml._proto.qwak.user_application.common.v0.resources_pb2 import (
23
24
  )
24
25
  from frogml.core.exceptions import FrogmlException
25
26
 
27
+ BUILD_MODEL_OPERATION = "Build Model"
26
28
 
27
29
  if TYPE_CHECKING:
28
30
  from frogml.core.inner.build_config.build_config_v1 import BuildConfigV1
@@ -139,4 +141,8 @@ def _purchase_option_to_enum(purchase_option: Optional[str]) -> PurchaseOption:
139
141
  elif purchase_option == "spot":
140
142
  return PurchaseOption.SPOT_PURCHASE_OPTION
141
143
  else:
142
- raise FrogmlException("Purchase option must be either 'ondemand' or 'spot'")
144
+ raise FrogmlException(
145
+ error_message="Purchase option must be either 'ondemand' or 'spot'",
146
+ status_code=HTTPStatus.BAD_REQUEST,
147
+ operation=BUILD_MODEL_OPERATION,
148
+ )
@@ -1,5 +1,6 @@
1
1
  from dataclasses import dataclass
2
2
  from enum import IntEnum
3
+ from http import HTTPStatus
3
4
  from typing import Dict, List, Optional, TYPE_CHECKING
4
5
 
5
6
  import grpc
@@ -40,7 +41,11 @@ from frogml._proto.qwak.build_settings.build_settings_api_pb2 import (
40
41
  from frogml._proto.qwak.build_settings.build_settings_api_pb2_grpc import (
41
42
  BuildSettingsApiStub,
42
43
  )
43
- from frogml._proto.qwak.builds.build_pb2 import BaseDockerImageType, DataTableDefinition
44
+ from frogml._proto.qwak.builds.build_pb2 import (
45
+ BaseDockerImageType,
46
+ DataTableDefinition,
47
+ RemoteBuildSpec,
48
+ )
44
49
  from frogml._proto.qwak.builds.build_url_pb2 import (
45
50
  BuildVersioningTagsType,
46
51
  BuildVersioningUrlParams,
@@ -63,6 +68,7 @@ from frogml._proto.qwak.builds.builds_orchestrator_service_pb2_grpc import (
63
68
  BuildsOrchestratorServiceStub,
64
69
  )
65
70
  from frogml.core.clients.build_orchestrator.build_model_request_getter import (
71
+ BUILD_MODEL_OPERATION,
66
72
  _get_build_model_spec,
67
73
  )
68
74
  from frogml.core.exceptions import FrogmlException
@@ -73,6 +79,8 @@ from frogml.core.inner.tool.grpc.grpc_try_wrapping import grpc_try_catch_wrapper
73
79
  if TYPE_CHECKING:
74
80
  from frogml.core.inner.build_config.build_config_v1 import BuildConfigV1
75
81
 
82
+ _GET_BUILD_VERSIONING_DOWNLOAD_URL_OPERATION = "Get Build Versioning Download URL"
83
+
76
84
 
77
85
  @dataclass
78
86
  class FrameworkModelDataClass:
@@ -124,14 +132,20 @@ class BuildOrchestratorClient:
124
132
  self._builds_orchestrator_stub = BuildsOrchestratorServiceStub(grpc_channel)
125
133
  self._build_settings_stub = BuildSettingsApiStub(grpc_channel)
126
134
 
127
- @grpc_try_catch_wrapper("Failed to update build status")
135
+ @grpc_try_catch_wrapper(
136
+ error_message="Failed to update build status for build '{build_id}'",
137
+ operation="Update Build Status",
138
+ )
128
139
  def update_build_status(
129
140
  self, build_id: str, build_status: BuildStatus
130
141
  ) -> UpdateBuildStatusResponse:
131
142
  request = UpdateBuildStatusRequest(buildId=build_id, build_status=build_status)
132
143
  return self._builds_orchestrator_stub_build_api.UpdateBuildStatus(request)
133
144
 
134
- @grpc_try_catch_wrapper("Failed to register model schema")
145
+ @grpc_try_catch_wrapper(
146
+ error_message="Failed to register model schema",
147
+ operation="Register Build Model Schema",
148
+ )
135
149
  def register_model_schema(
136
150
  self, build_id: str, model_schema: ModelSchema
137
151
  ) -> RegisterModelSchemaResponse:
@@ -140,7 +154,10 @@ class BuildOrchestratorClient:
140
154
  )
141
155
  return self._builds_orchestrator_stub_build_api.RegisterModelSchema(request)
142
156
 
143
- @grpc_try_catch_wrapper("Failed to register experiment tracking values")
157
+ @grpc_try_catch_wrapper(
158
+ error_message="Failed to register experiment tracking values",
159
+ operation="Register Build Experiment Tracking",
160
+ )
144
161
  def register_experiment_tracking(
145
162
  self,
146
163
  build_id: str,
@@ -160,7 +177,10 @@ class BuildOrchestratorClient:
160
177
  request
161
178
  )
162
179
 
163
- @grpc_try_catch_wrapper("Failed to save framework models")
180
+ @grpc_try_catch_wrapper(
181
+ error_message="Failed to save framework models",
182
+ operation="Save Build Framework Models",
183
+ )
164
184
  def save_framework_models(
165
185
  self, build_id: str, frameworks_model_data_class: List[FrameworkModelDataClass]
166
186
  ) -> SaveFrameworkModelsResponse:
@@ -190,7 +210,10 @@ class BuildOrchestratorClient:
190
210
 
191
211
  return self._builds_orchestrator_stub_build_api.SaveFrameworkModels(request)
192
212
 
193
- @grpc_try_catch_wrapper("Failed to save framework models")
213
+ @grpc_try_catch_wrapper(
214
+ error_message="Failed to save framework models",
215
+ operation="Save Build Framework Models",
216
+ )
194
217
  def save_used_framework_models(
195
218
  self, build_id: str, models: List[HuggingFaceModel]
196
219
  ) -> SaveFrameworkModelsResponse:
@@ -215,7 +238,9 @@ class BuildOrchestratorClient:
215
238
 
216
239
  return self._builds_orchestrator_stub_build_api.SaveFrameworkModels(request)
217
240
 
218
- @grpc_try_catch_wrapper("Failed to register tags")
241
+ @grpc_try_catch_wrapper(
242
+ error_message="Failed to register tags", operation="Register Build Tags"
243
+ )
219
244
  def register_tags(
220
245
  self,
221
246
  build_id: str,
@@ -224,18 +249,26 @@ class BuildOrchestratorClient:
224
249
  request = RegisterTagsRequest(build_id=build_id, tags=tags)
225
250
  return self._builds_orchestrator_stub_build_api.RegisterTags(request)
226
251
 
227
- @grpc_try_catch_wrapper("Failed to list builds")
252
+ @grpc_try_catch_wrapper(
253
+ error_message="Failed to list builds", operation="List Builds"
254
+ )
228
255
  def list_builds(
229
- self, model_uuid: str = "", build_filter: BuildFilter = None, **kwargs
256
+ self, model_uuid: str = "", build_filter: Optional[BuildFilter] = None, **kwargs
230
257
  ) -> ListBuildsResponse:
231
258
  _model_uuid = model_uuid if model_uuid else kwargs.get("branch_id")
232
259
  if not _model_uuid:
233
- raise FrogmlException("missing argument model uuid or branch id.")
260
+ raise FrogmlException(
261
+ error_message="Missing argument model uuid or branch id",
262
+ status_code=HTTPStatus.BAD_REQUEST,
263
+ operation="List Builds",
264
+ )
234
265
 
235
266
  request = ListBuildsRequest(model_uuid=_model_uuid, filter=build_filter)
236
267
  return self._builds_orchestrator_stub_build_api.ListBuilds(request)
237
268
 
238
- @grpc_try_catch_wrapper("Failed to get build")
269
+ @grpc_try_catch_wrapper(
270
+ error_message="Failed to get build '{build_id}'", operation="Get Build"
271
+ )
239
272
  def get_build(self, build_id: str) -> GetBuildResponse:
240
273
  request = GetBuildRequest(build_id=build_id)
241
274
  return self._builds_orchestrator_stub_build_api.GetBuild(request)
@@ -250,10 +283,14 @@ class BuildOrchestratorClient:
250
283
  if e.code() == grpc.StatusCode.NOT_FOUND:
251
284
  return False
252
285
  raise FrogmlException(
253
- f"Failed to check if build {build_id} is exists, error is {e.details()}"
286
+ error_message=f"Failed to check if build {build_id} exists: {e.details()}",
287
+ operation="Check Build Exists",
254
288
  )
255
289
 
256
- @grpc_try_catch_wrapper("Failed to get build versioning upload urls {url_infos}")
290
+ @grpc_try_catch_wrapper(
291
+ error_message="Failed to get build versioning upload urls {url_infos}",
292
+ operation="Get Build Versioning Upload URLs",
293
+ )
257
294
  def get_build_versioning_upload_urls(
258
295
  self, url_infos: list[UrlInfo]
259
296
  ) -> GetBuildVersioningUploadUrlsResponse:
@@ -271,7 +308,10 @@ class BuildOrchestratorClient:
271
308
  GetBuildVersioningUploadUrlsRequest(params=params)
272
309
  )
273
310
 
274
- @grpc_try_catch_wrapper("Failed to get build versioning upload url")
311
+ @grpc_try_catch_wrapper(
312
+ error_message="Failed to get build versioning upload url",
313
+ operation="Get Build Versioning Upload URL",
314
+ )
275
315
  def get_build_versioning_upload_url(
276
316
  self,
277
317
  build_id: str,
@@ -329,25 +369,26 @@ class BuildOrchestratorClient:
329
369
  )
330
370
  except grpc.RpcError as e:
331
371
  if e.code() == grpc.StatusCode.NOT_FOUND:
332
- print(
333
- "The specified file cannot be found. Please verify the file name before trying again"
334
- )
335
372
  raise FrogmlException(
336
- "The specified file cannot be found. Please verify the file name before trying again"
373
+ error_message="The specified file cannot be found. Please verify the file name before trying again",
374
+ status_code=HTTPStatus.NOT_FOUND,
375
+ operation=_GET_BUILD_VERSIONING_DOWNLOAD_URL_OPERATION,
337
376
  )
338
377
  else:
339
- print(f"Failed to get build versioning download url. Error is {e}")
340
378
  raise FrogmlException(
341
- f"The specified file cannot be loaded. Error is {e}"
379
+ error_message=f"The specified file cannot be loaded: {e.details()}",
380
+ operation=_GET_BUILD_VERSIONING_DOWNLOAD_URL_OPERATION,
342
381
  )
343
382
 
344
383
  except Exception as e:
345
- print(f"Failed to get build versioning download url. Error is {e}")
346
384
  raise FrogmlException(
347
- f"Failed to get build versioning download url. Error is {e}"
385
+ error_message=f"Failed to get build versioning download url: {e}",
386
+ operation=_GET_BUILD_VERSIONING_DOWNLOAD_URL_OPERATION,
348
387
  )
349
388
 
350
- @grpc_try_catch_wrapper("Failed to get build settings")
389
+ @grpc_try_catch_wrapper(
390
+ error_message="Failed to get build settings", operation="Get Build Settings"
391
+ )
351
392
  def get_build_settings(self, environment_id: str) -> GetBuildSettingsResponse:
352
393
  """Get BuildSettings
353
394
 
@@ -363,7 +404,10 @@ class BuildOrchestratorClient:
363
404
  )
364
405
  )
365
406
 
366
- @grpc_try_catch_wrapper("Failed to define a table for the data")
407
+ @grpc_try_catch_wrapper(
408
+ error_message="Failed to define a table for the data",
409
+ operation="Define Build Data Table",
410
+ )
367
411
  def define_build_data_table(
368
412
  self, build_id: str, model_id: str, tag: str, table: DataTableDefinition
369
413
  ) -> CreateDataTableResponse:
@@ -387,7 +431,10 @@ class BuildOrchestratorClient:
387
431
  )
388
432
  )
389
433
 
390
- @grpc_try_catch_wrapper("Failed to log build phase status")
434
+ @grpc_try_catch_wrapper(
435
+ error_message="Failed to log build phase status",
436
+ operation="Log Build Phase Status",
437
+ )
391
438
  def log_phase_status(
392
439
  self,
393
440
  build_id: str,
@@ -441,34 +488,34 @@ class BuildOrchestratorClient:
441
488
  """
442
489
  build_steps = build_steps if build_steps else []
443
490
 
444
- try:
445
- build_spec = _get_build_model_spec(
446
- build_conf,
447
- verbose,
448
- git_commit_id,
449
- resolved_model_url,
450
- build_code_path,
451
- build_v1_flag,
452
- build_config_url,
453
- frogml_cli_wheel_url,
454
- frogml_cli_version_url,
455
- build_steps,
456
- cli_version,
457
- )
458
- self._builds_orchestrator_stub.BuildModel(
459
- BuildModelRequest(build_spec=build_spec)
460
- )
461
- except grpc.RpcError as e:
462
- message = (
463
- f"Failed to build model, status [{e.code()}] details [{e.details()}]"
464
- )
465
- raise FrogmlException(message)
491
+ build_spec = _get_build_model_spec(
492
+ build_conf,
493
+ verbose,
494
+ git_commit_id,
495
+ resolved_model_url,
496
+ build_code_path,
497
+ build_v1_flag,
498
+ build_config_url,
499
+ frogml_cli_wheel_url,
500
+ frogml_cli_version_url,
501
+ build_steps,
502
+ cli_version,
503
+ )
466
504
 
467
- except Exception as e:
468
- message = f"Failed to build model, details [{e}]"
469
- raise FrogmlException(message)
505
+ self._build_model_request(build_spec)
506
+
507
+ @grpc_try_catch_wrapper(
508
+ error_message="Failed to build model", operation=BUILD_MODEL_OPERATION
509
+ )
510
+ def _build_model_request(self, build_spec: RemoteBuildSpec) -> None:
511
+ self._builds_orchestrator_stub.BuildModel(
512
+ BuildModelRequest(build_spec=build_spec)
513
+ )
470
514
 
471
- def cancel_build_model(self, build_id: str):
515
+ @grpc_try_catch_wrapper(
516
+ error_message="Failed to cancel build '{build_id}'", operation="Cancel Build"
517
+ )
518
+ def cancel_build_model(self, build_id: str) -> None:
472
519
  """cancel remote build process
473
520
 
474
521
  Args:
@@ -477,15 +524,14 @@ class BuildOrchestratorClient:
477
524
  Raises:
478
525
  FrogmlException: In case of failing to connect the service
479
526
  """
480
- try:
481
- self._builds_orchestrator_stub.CancelBuildModel(
482
- CancelBuildModelRequest(build_id=build_id)
483
- )
484
- except grpc.RpcError as e:
485
- raise FrogmlException(
486
- f"Failed to cancel build, status [{e.code()}] details [{e.details()}]"
487
- )
527
+ self._builds_orchestrator_stub.CancelBuildModel(
528
+ CancelBuildModelRequest(build_id=build_id)
529
+ )
488
530
 
531
+ @grpc_try_catch_wrapper(
532
+ error_message="Failed to retrieve base docker image name",
533
+ operation="Get Build Base Docker Image Name",
534
+ )
489
535
  def fetch_base_docker_image_name(
490
536
  self, image_type: BaseDockerImageType
491
537
  ) -> GetBaseDockerImageNameResponse:
@@ -497,11 +543,6 @@ class BuildOrchestratorClient:
497
543
  Raises:
498
544
  FrogmlException: In case of failing to connect the service
499
545
  """
500
- try:
501
- return self._builds_orchestrator_stub.GetBaseDockerImageName(
502
- GetBaseDockerImageNameRequest(base_docker_image_type=image_type)
503
- )
504
- except grpc.RpcError as e:
505
- raise FrogmlException(
506
- f"Failed to retrieve base docker image name, status [{e.code()}] details [{e.details()}]"
507
- )
546
+ return self._builds_orchestrator_stub.GetBaseDockerImageName(
547
+ GetBaseDockerImageNameRequest(base_docker_image_type=image_type)
548
+ )
@@ -1,8 +1,9 @@
1
+ from http import HTTPStatus
1
2
  from typing import List, Optional
2
3
 
3
- import grpc
4
4
  from dependency_injector.wiring import Provide
5
5
 
6
+ from frogml import __version__ as frogml_version
6
7
  from frogml._proto.qwak.builds.build_pb2 import BuildInitiator, RemoteBuildSpec
7
8
  from frogml._proto.qwak.builds.internal_builds_orchestrator_service_pb2 import (
8
9
  BuildInitDetails,
@@ -12,12 +13,13 @@ from frogml._proto.qwak.builds.internal_builds_orchestrator_service_pb2_grpc imp
12
13
  InternalBuildsOrchestratorServiceStub,
13
14
  )
14
15
  from frogml.core.clients.build_orchestrator.build_model_request_getter import (
16
+ BUILD_MODEL_OPERATION,
15
17
  _get_build_model_spec,
16
18
  )
17
19
  from frogml.core.exceptions import FrogmlException
18
- from frogml.core.inner.di_configuration import FrogmlContainer
19
- from frogml import __version__ as frogml_version
20
20
  from frogml.core.inner.const import FrogMLConstants
21
+ from frogml.core.inner.di_configuration import FrogmlContainer
22
+ from frogml.core.inner.tool.grpc.grpc_try_wrapping import grpc_try_catch_wrapper
21
23
 
22
24
 
23
25
  class InternalBuildOrchestratorClient:
@@ -48,9 +50,9 @@ class InternalBuildOrchestratorClient:
48
50
  frogml_cli_wheel_url: str = "",
49
51
  frogml_cli_version_url: str = "",
50
52
  build_steps: Optional[List[str]] = None,
51
- build_initiator: BuildInitiator = None,
53
+ build_initiator: Optional[BuildInitiator] = None,
52
54
  cli_version: str = "",
53
- ):
55
+ ) -> None:
54
56
  """Initiate remote build
55
57
 
56
58
  Args:
@@ -80,42 +82,44 @@ class InternalBuildOrchestratorClient:
80
82
  )
81
83
 
82
84
  if not self._internal_builds_orchestrator_stub:
83
- raise FrogmlException("Internal GRPC channel is not available.")
85
+ raise FrogmlException(
86
+ error_message="Internal gRPC channel is not available",
87
+ status_code=HTTPStatus.SERVICE_UNAVAILABLE,
88
+ operation=BUILD_MODEL_OPERATION,
89
+ )
84
90
 
85
91
  build_steps = build_steps if build_steps else []
86
92
 
87
- try:
88
- if not cli_version:
89
- cli_version = f"{FrogMLConstants.FROGML_CLI}/{frogml_version}"
90
- elif not cli_version.startswith(FrogMLConstants.FROGML_CLI):
91
- cli_version = f"{FrogMLConstants.FROGML_CLI}/{cli_version}"
93
+ if not cli_version:
94
+ cli_version = f"{FrogMLConstants.FROGML_CLI}/{frogml_version}"
95
+ elif not cli_version.startswith(FrogMLConstants.FROGML_CLI):
96
+ cli_version = f"{FrogMLConstants.FROGML_CLI}/{cli_version.lstrip('/')}"
92
97
 
93
- build_spec: RemoteBuildSpec = _get_build_model_spec(
94
- build_conf,
95
- verbose,
96
- git_commit_id,
97
- resolved_model_url,
98
- build_code_path,
99
- build_v1_flag,
100
- build_config_url,
101
- frogml_cli_wheel_url,
102
- frogml_cli_version_url,
103
- build_steps,
104
- cli_version,
105
- )
106
- self._internal_builds_orchestrator_stub.BuildModel(
107
- InternalBuildModelRequest(
108
- build_init_details=BuildInitDetails(
109
- build_spec=build_spec, initiator=build_initiator
110
- )
98
+ build_spec: RemoteBuildSpec = _get_build_model_spec(
99
+ build_conf,
100
+ verbose,
101
+ git_commit_id,
102
+ resolved_model_url,
103
+ build_code_path,
104
+ build_v1_flag,
105
+ build_config_url,
106
+ frogml_cli_wheel_url,
107
+ frogml_cli_version_url,
108
+ build_steps,
109
+ cli_version,
110
+ )
111
+ self._build_model_request(build_spec, build_initiator)
112
+
113
+ @grpc_try_catch_wrapper(
114
+ error_message="Failed to build model", operation=BUILD_MODEL_OPERATION
115
+ )
116
+ def _build_model_request(
117
+ self, build_spec: RemoteBuildSpec, build_initiator: Optional[BuildInitiator]
118
+ ) -> None:
119
+ self._internal_builds_orchestrator_stub.BuildModel(
120
+ InternalBuildModelRequest(
121
+ build_init_details=BuildInitDetails(
122
+ build_spec=build_spec, initiator=build_initiator
111
123
  )
112
124
  )
113
- except grpc.RpcError as e:
114
- message = (
115
- f"Failed to build model, status [{e.code()}] details [{e.details()}]"
116
- )
117
- raise FrogmlException(message)
118
-
119
- except Exception as e:
120
- message = f"Failed to build model, details [{e}]"
121
- raise FrogmlException(message)
125
+ )