truefoundry 0.5.1rc8__py3-none-any.whl → 0.5.2rc1__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.

Potentially problematic release.


This version of truefoundry might be problematic. Click here for more details.

@@ -30,13 +30,20 @@ from truefoundry.deploy.lib.model.entity import ApplyResult
30
30
  required=True,
31
31
  multiple=True,
32
32
  )
33
+ @click.option(
34
+ "--dry-run",
35
+ "--dry_run",
36
+ is_flag=True,
37
+ show_default=True,
38
+ help="Simulate the process without actually applying the manifest",
39
+ )
33
40
  @handle_exception_wrapper
34
- def apply_command(files: Tuple[str, ...]):
41
+ def apply_command(files: Tuple[str, ...], dry_run: bool = False):
35
42
  apply_results: List[ApplyResult] = []
36
43
  client = ServiceFoundryServiceClient()
37
44
  for file in files:
38
45
  with console.status(PROMPT_APPLYING_MANIFEST.format(file), spinner="dots"):
39
- for apply_result in apply_lib.apply_manifest_file(file, client):
46
+ for apply_result in apply_lib.apply_manifest_file(file, client, dry_run):
40
47
  if apply_result.success:
41
48
  console.print(f"[green]\u2714 {apply_result.message}[/]")
42
49
  else:
@@ -680,9 +680,9 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
680
680
  return parse_obj_as(List[Deployment], response)
681
681
 
682
682
  @check_min_cli_version
683
- def apply(self, manifest: Dict[str, Any]):
683
+ def apply(self, manifest: Dict[str, Any], dry_run: bool = False):
684
684
  url = f"{self._api_server_url}/{VERSION_PREFIX}/apply"
685
- body = {"manifest": manifest}
685
+ body = {"manifest": manifest, "dryRun": dry_run}
686
686
  response = session_with_retries().put(
687
687
  url, headers=self._get_header(), json=body
688
688
  )
@@ -15,6 +15,7 @@ def _apply_manifest(
15
15
  client: Optional[ServiceFoundryServiceClient] = None,
16
16
  filename: Optional[str] = None,
17
17
  index: Optional[int] = None,
18
+ dry_run: bool = False,
18
19
  ) -> ApplyResult:
19
20
  client = client or ServiceFoundryServiceClient()
20
21
 
@@ -32,29 +33,38 @@ def _apply_manifest(
32
33
  message=f"Failed to apply manifest{file_metadata}. Error: {ex}",
33
34
  )
34
35
 
36
+ prefix = "[Dry Run] " if dry_run else ""
37
+ suffix = " (No changes were applied)" if dry_run else ""
35
38
  try:
36
- client.apply(manifest.dict())
39
+ client.apply(manifest.dict(), dry_run)
40
+
37
41
  return ApplyResult(
38
42
  success=True,
39
- message=f"Successfully configured manifest {manifest.name} of type {manifest.type}",
43
+ message=(
44
+ f"{prefix}Successfully configured manifest {manifest.name} of type {manifest.type}.{suffix}"
45
+ ),
40
46
  )
41
47
  except Exception as ex:
42
48
  return ApplyResult(
43
49
  success=False,
44
- message=f"Failed to apply manifest {manifest.name} of type {manifest.type}. Error: {ex}",
50
+ message=(
51
+ f"{prefix}Failed to apply manifest {manifest.name} of type {manifest.type}. Error: {ex}.{suffix}"
52
+ ),
45
53
  )
46
54
 
47
55
 
48
56
  def apply_manifest(
49
57
  manifest: Dict[str, Any],
50
58
  client: Optional[ServiceFoundryServiceClient] = None,
59
+ dry_run: bool = False,
51
60
  ) -> ApplyResult:
52
- return _apply_manifest(manifest=manifest, client=client)
61
+ return _apply_manifest(manifest=manifest, client=client, dry_run=dry_run)
53
62
 
54
63
 
55
64
  def apply_manifest_file(
56
65
  filepath: str,
57
66
  client: Optional[ServiceFoundryServiceClient] = None,
67
+ dry_run: bool = False,
58
68
  ) -> Iterator[ApplyResult]:
59
69
  client = client or ServiceFoundryServiceClient()
60
70
  filename = Path(filepath).name
@@ -67,14 +77,19 @@ def apply_manifest_file(
67
77
  message=f"Failed to read file {filepath} as a valid YAML file. Error: {ex}",
68
78
  )
69
79
  else:
80
+ prefix = "[Dry Run] " if dry_run else ""
70
81
  for index, manifest in enumerate(manifests_it):
71
82
  if not isinstance(manifest, dict):
72
83
  yield ApplyResult(
73
84
  success=False,
74
- message=f"Failed to apply manifest at index {index} from file {filename}. Error: A manifest must be a dict, got type {type(manifest)}",
85
+ message=f"{prefix}Failed to apply manifest at index {index} from file {filename}. Error: A manifest must be a dict, got type {type(manifest)}",
75
86
  )
76
87
  continue
77
88
 
78
89
  yield _apply_manifest(
79
- manifest=manifest, client=client, filename=filename, index=index
90
+ manifest=manifest,
91
+ client=client,
92
+ filename=filename,
93
+ index=index,
94
+ dry_run=dry_run,
80
95
  )
@@ -1,9 +1,10 @@
1
- from truefoundry.ml.autogen.client.models import (
2
- LibraryName,
1
+ from truefoundry.ml.autogen.client.models import ( # type: ignore[attr-defined]
2
+ InferMethodName,
3
3
  ModelVersionEnvironment,
4
4
  SklearnModelSchema,
5
5
  XGBoostModelSchema,
6
6
  )
7
+ from truefoundry.ml.autogen.entities.artifacts import LibraryName
7
8
  from truefoundry.ml.enums import (
8
9
  DataSlice,
9
10
  FileFormat,
@@ -40,6 +41,7 @@ from truefoundry.ml.model_framework import (
40
41
  TransformersFramework,
41
42
  XGBoostFramework,
42
43
  sklearn_infer_schema,
44
+ xgboost_infer_schema,
43
45
  )
44
46
 
45
47
  __all__ = [
@@ -51,9 +53,11 @@ __all__ = [
51
53
  "DataSlice",
52
54
  "FastAIFramework",
53
55
  "FileFormat",
56
+ "get_client",
54
57
  "GluonFramework",
55
58
  "H2OFramework",
56
59
  "Image",
60
+ "InferMethodName",
57
61
  "KerasFramework",
58
62
  "LibraryName",
59
63
  "LightGBMFramework",
@@ -68,6 +72,7 @@ __all__ = [
68
72
  "PaddleFramework",
69
73
  "Plot",
70
74
  "PyTorchFramework",
75
+ "sklearn_infer_schema",
71
76
  "SklearnFramework",
72
77
  "SklearnModelSchema",
73
78
  "SpaCyFramework",
@@ -75,10 +80,9 @@ __all__ = [
75
80
  "TensorFlowFramework",
76
81
  "TransformersFramework",
77
82
  "ViewType",
83
+ "xgboost_infer_schema",
78
84
  "XGBoostFramework",
79
85
  "XGBoostModelSchema",
80
- "get_client",
81
- "sklearn_infer_schema",
82
86
  ]
83
87
 
84
88
  init_logger()
@@ -6,7 +6,7 @@ import rich_click as click
6
6
  from truefoundry.deploy.cli.console import console
7
7
  from truefoundry.deploy.cli.const import COMMAND_CLS
8
8
  from truefoundry.deploy.cli.util import handle_exception_wrapper
9
- from truefoundry.ml.autogen.client.models import ModelServer
9
+ from truefoundry.ml.autogen.client import ModelServer # type: ignore[attr-defined]
10
10
  from truefoundry.ml.cli.utils import (
11
11
  AppName,
12
12
  NonEmptyString,
@@ -18,7 +18,7 @@ from typing import (
18
18
  import coolname
19
19
 
20
20
  from truefoundry.common.utils import ContextualDirectoryManager, relogin_error_message
21
- from truefoundry.ml import ModelVersionEnvironment, constants
21
+ from truefoundry.ml import constants
22
22
  from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
23
23
  ArtifactDto,
24
24
  ArtifactType,
@@ -35,6 +35,7 @@ from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
35
35
  MlfoundryArtifactsApi,
36
36
  ModelDto,
37
37
  ModelServer,
38
+ ModelVersionEnvironment,
38
39
  RunsApi,
39
40
  RunTagDto,
40
41
  SearchRunsRequestDto,
@@ -18,7 +18,7 @@ from urllib.parse import urljoin, urlsplit
18
18
 
19
19
  from truefoundry import version
20
20
  from truefoundry.common.utils import relogin_error_message
21
- from truefoundry.ml import ModelVersionEnvironment, constants
21
+ from truefoundry.ml import constants
22
22
  from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
23
23
  ArtifactType,
24
24
  DeleteRunRequest,
@@ -29,6 +29,7 @@ from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
29
29
  MetricDto,
30
30
  MetricsApi,
31
31
  MlfoundryArtifactsApi,
32
+ ModelVersionEnvironment,
32
33
  ParamDto,
33
34
  RunDataDto,
34
35
  RunDto,
@@ -35,6 +35,7 @@ from truefoundry.pydantic_v1 import BaseModel, Field
35
35
 
36
36
  if TYPE_CHECKING:
37
37
  from sklearn.base import BaseEstimator
38
+ from xgboost import Booster, XGBModel
38
39
 
39
40
  # Map serialization format to corresponding pip packages
40
41
  SERIALIZATION_FORMAT_TO_PACKAGES_NAME_MAP = {
@@ -467,6 +468,24 @@ def auto_update_model_framework_details(
467
468
  )
468
469
 
469
470
 
471
+ def _infer_schema(
472
+ model_input: Any,
473
+ model: Union["BaseEstimator", "Booster", "XGBModel"],
474
+ infer_method_name: str = "predict",
475
+ ) -> Dict[str, Any]:
476
+ if not hasattr(model, infer_method_name):
477
+ raise ValueError(
478
+ f"Model does not have the method '{infer_method_name}' to infer the schema."
479
+ )
480
+ model_infer_method = getattr(model, infer_method_name)
481
+ model_output = model_infer_method(model_input)
482
+
483
+ model_signature = infer_signature(
484
+ model_input=model_input, model_output=model_output
485
+ )
486
+ return model_signature.to_dict()
487
+
488
+
470
489
  def sklearn_infer_schema(
471
490
  model_input: Any,
472
491
  model: "BaseEstimator",
@@ -483,19 +502,37 @@ def sklearn_infer_schema(
483
502
  Returns:
484
503
  SklearnModelSchema: The inferred schema of the Sklearn model.
485
504
  """
486
- if not hasattr(model, infer_method_name):
487
- raise ValueError(
488
- f"Model does not have the method '{infer_method_name}' to infer the schema."
489
- )
490
- model_infer_method = getattr(model, infer_method_name)
491
- model_output = model_infer_method(model_input)
492
-
493
- model_signature = infer_signature(
494
- model_input=model_input, model_output=model_output
505
+ model_signature_json = _infer_schema(
506
+ model_input=model_input, model=model, infer_method_name=infer_method_name
495
507
  )
496
- model_signature_json = model_signature.to_dict()
497
508
  return autogen_artifacts.SklearnModelSchema(
498
509
  infer_method_name=infer_method_name,
499
510
  inputs=json.loads(model_signature_json["inputs"]),
500
511
  outputs=json.loads(model_signature_json["outputs"]),
501
512
  )
513
+
514
+
515
+ def xgboost_infer_schema(
516
+ model_input: Any,
517
+ model: Union["Booster", "XGBModel"],
518
+ infer_method_name: str = "predict",
519
+ ) -> autogen_artifacts.XGBoostModelSchema:
520
+ """
521
+ Infer the schema of an XGBoost model.
522
+
523
+ Args:
524
+ model_input (Any): The input data to be used for schema inference.
525
+ model (Any): The XGBoost model instance.
526
+ infer_method_name (str): The name of the method to be used for schema inference.
527
+ Eg: predict (default), predict_proba
528
+ Returns:
529
+ XGBoostModelSchema: The inferred schema of the XGBoost model.
530
+ """
531
+ model_signature_json = _infer_schema(
532
+ model_input=model_input, model=model, infer_method_name=infer_method_name
533
+ )
534
+ return autogen_artifacts.XGBoostModelSchema(
535
+ infer_method_name=infer_method_name,
536
+ inputs=json.loads(model_signature_json["inputs"]),
537
+ outputs=json.loads(model_signature_json["outputs"]),
538
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: truefoundry
3
- Version: 0.5.1rc8
3
+ Version: 0.5.2rc1
4
4
  Summary: Truefoundry CLI
5
5
  Author: Abhishek Choudhary
6
6
  Author-email: abhishek@truefoundry.com
@@ -50,7 +50,7 @@ truefoundry/deploy/builder/utils.py,sha256=D68-bqM0NQx-Elg-56mtkENyVyg9faZ9tgTmB
50
50
  truefoundry/deploy/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  truefoundry/deploy/cli/cli.py,sha256=BuAW-R98oz1wzPDg00fPgrK1UDoCfy0Tu6pWW9Ud1Ns,2887
52
52
  truefoundry/deploy/cli/commands/__init__.py,sha256=-i3ltscehEO0hy-Cf6gPLaiobfv8tZetPKaaCyR9B3M,1364
53
- truefoundry/deploy/cli/commands/apply_command.py,sha256=FdTeuyOPEoPSU6GP_aQGNOJV0S0rm7PkxrAlXiNvoX8,1864
53
+ truefoundry/deploy/cli/commands/apply_command.py,sha256=AL8LBv2ZO01efG97_q9kYG2XjukyadUBw5huyhw_k64,2060
54
54
  truefoundry/deploy/cli/commands/build_command.py,sha256=DQ7NARgkIgV4z0Zdnl3zMDKU_fSkN5-FkjCQypgmWpo,1255
55
55
  truefoundry/deploy/cli/commands/build_logs_command.py,sha256=WrPOlFec_wwuzdJmKZ8mjca-oFVvxgfblcqj2LlhWJA,2804
56
56
  truefoundry/deploy/cli/commands/create_command.py,sha256=ZjA4EP1jHYuVE1zx0kN-giBr3y0sEiXnu8xMsNyD2Rg,1850
@@ -82,11 +82,11 @@ truefoundry/deploy/json_util.py,sha256=x_-7YYQ4_HUIJ8ofOcclAp9JWhgTWjR9Th6Q0FuRq
82
82
  truefoundry/deploy/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
83
  truefoundry/deploy/lib/auth/servicefoundry_session.py,sha256=5TCYPunAygtn5mb0mp_VcWKEalKMKPbyWMWer-Vty2g,1916
84
84
  truefoundry/deploy/lib/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
85
- truefoundry/deploy/lib/clients/servicefoundry_client.py,sha256=tkuPNbo9vDTgXPHD4p3d-t6HigBvKNfML1pTQXBwJfY,26170
85
+ truefoundry/deploy/lib/clients/servicefoundry_client.py,sha256=yhHsHo9T0mTbum7X2sOuNVf-am1AdtzyK0KBQkdC0io,26212
86
86
  truefoundry/deploy/lib/const.py,sha256=repGJLuoMqtzeq5tCjjkN4bH187FVHVKI30BricOlvc,244
87
87
  truefoundry/deploy/lib/dao/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
88
  truefoundry/deploy/lib/dao/application.py,sha256=xUqF34abde71YZo9gkR-WvVJi1C6nBeGBNw4kL5FdIo,9226
89
- truefoundry/deploy/lib/dao/apply.py,sha256=sXnQY6RVzLVm1fX2BKuWHAoKlKISirrcByHEhY3x4zo,2570
89
+ truefoundry/deploy/lib/dao/apply.py,sha256=Jadfa3DcbIRz-Bb4Tlixed179HLDnmDXOlrvSxfEgQ0,3021
90
90
  truefoundry/deploy/lib/dao/version.py,sha256=AtdW_4O1DPUKdfv2qy6iUJsZ_95vM6z0AqeEy3WDKs8,1130
91
91
  truefoundry/deploy/lib/dao/workspace.py,sha256=jm8UWytwVajVcrYyHSTCwWYDYl-RHuk0zAf9Caj4GzQ,2356
92
92
  truefoundry/deploy/lib/exceptions.py,sha256=ZT2o3mar3BYtnjKHn2wf4rBGEaFIgf-zkQmzDicg6Ps,236
@@ -107,7 +107,7 @@ truefoundry/deploy/v2/lib/models.py,sha256=pSolLMTArDuYpeNsmeeS5DWliloN_iCDfZSpR
107
107
  truefoundry/deploy/v2/lib/patched_models.py,sha256=NTU8J_CwdvEuF9zNXwFyN3suOp_196Wrm75DDy5qcXE,14184
108
108
  truefoundry/deploy/v2/lib/source.py,sha256=VHKuFREiixUP40D3Mrz-TA70spu1M0RbCzl--qwlFaY,9263
109
109
  truefoundry/logger.py,sha256=u-YCNjg5HBwE70uQcpjIG64Ghos-K2ulTWaxC03BSj4,714
110
- truefoundry/ml/__init__.py,sha256=VtP0B3DNFFV_1b4WHkAo_XRMvWHmyeEwDu984t4cy8s,2040
110
+ truefoundry/ml/__init__.py,sha256=ssUEIs8BixPWxynKoeSh-dkRl6AtLXG0PBGYnUR5Az8,2217
111
111
  truefoundry/ml/artifact/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
112
112
  truefoundry/ml/artifact/truefoundry_artifact_repo.py,sha256=FksxhUpRHb9pgWZmAB16DhXqkAL6UIAPA1S3RJUApQU,46201
113
113
  truefoundry/ml/autogen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -319,7 +319,7 @@ truefoundry/ml/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
319
319
  truefoundry/ml/cli/cli.py,sha256=ckBcjUpqfhgrPE1okqT_G2iouOLt-0KjpLhHp2YdVFU,256
320
320
  truefoundry/ml/cli/commands/__init__.py,sha256=diDUiRUX4l6TtNLI4iF-ZblczkELM7FRViJ-8gGNJQY,82
321
321
  truefoundry/ml/cli/commands/download.py,sha256=cbz9KijiLKXj4-twlig3xZLTVRNm4fnjwpy0leZr31w,2342
322
- truefoundry/ml/cli/commands/model_init.py,sha256=LzHYHDOT3MackBIRLi3t18zmrV0E3gCNFLmZSlwwTlk,2661
322
+ truefoundry/ml/cli/commands/model_init.py,sha256=cKqXPWS_uxHnWJE-Nye6VE2Ct_-tgmfyTRVqXyCnROA,2684
323
323
  truefoundry/ml/cli/utils.py,sha256=j6_mZ4Spn114mz3P4QQ8jx0tmorXIuyQnHXVUSDvZi4,1035
324
324
  truefoundry/ml/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
325
325
  truefoundry/ml/clients/entities.py,sha256=sNP4DnAVdQoMfc06s0r3VTzKHTo7jmxAOuTlQOVmsMs,151
@@ -347,9 +347,9 @@ truefoundry/ml/log_types/plot.py,sha256=HuYvvRA5r8V0xAIuuqMME2IHb9d3SfGHUiuEkOP3
347
347
  truefoundry/ml/log_types/pydantic_base.py,sha256=eBlw_AEyAz4iJKDP4zgJOCFWcldwQqpf7FADW1jzIQY,272
348
348
  truefoundry/ml/log_types/utils.py,sha256=xjJ21jdPScvFmw3TbVh5NCzbzJwaqiXJyiiT4xxX1EI,335
349
349
  truefoundry/ml/logger.py,sha256=VT-BF3BnBYTWVq87O58F0c8uXMu94gYzsiFlGY3_7Ao,458
350
- truefoundry/ml/mlfoundry_api.py,sha256=PefznXwBPBv8TD4RYid9aiE8WWEkZQAHoaAbvklFoRs,62364
351
- truefoundry/ml/mlfoundry_run.py,sha256=RLTZGz3htyxNmG1Xat9WevawEIjDoUCbWrSNql8WynI,44597
352
- truefoundry/ml/model_framework.py,sha256=trqqzy1-BpW3bF4V7wETiOlRBdlcQi2Lk7MXORngmoU,17585
350
+ truefoundry/ml/mlfoundry_api.py,sha256=avuGgjbRnQXk774Vd3Dx7n99bbrOkL9pob9DI-vNvWE,62368
351
+ truefoundry/ml/mlfoundry_run.py,sha256=scHjdjojRGbE4ZZlByZTFrcBTamRbm_JGidaSX9Gi9o,44601
352
+ truefoundry/ml/model_framework.py,sha256=xHmVFI3Xcd6z6BH9TyZY8kFiw3Fp70423_M_wTYxd5Y,18841
353
353
  truefoundry/ml/run_utils.py,sha256=0W208wSLUrbdfk2pjNcZlkUi9bNxG2JORqoe-5rVqHI,2423
354
354
  truefoundry/ml/session.py,sha256=F83GTC5WwGBjnJ69Ct8MqMnlutYc56JCc6YhEY1Wl-A,5394
355
355
  truefoundry/ml/validation_utils.py,sha256=J5atNhcJLvKj64ralSV9Y5Fv1Rt4SE237ICdP9-7sP4,12149
@@ -370,7 +370,7 @@ truefoundry/workflow/remote_filesystem/tfy_signed_url_client.py,sha256=5mBCIc-ON
370
370
  truefoundry/workflow/remote_filesystem/tfy_signed_url_fs.py,sha256=Hf6Dk6Fu6P7DqsK5ULgraf9DStjgigf-kjaRAMBW-RU,8680
371
371
  truefoundry/workflow/task.py,sha256=ToitYiKcNzFCtOVQwz1W8sRjbR97eVS7vQBdbgUQtKg,1779
372
372
  truefoundry/workflow/workflow.py,sha256=WaTqUjhwfAXDWu4E5ehuwAxrCbDJkoAf1oWmR2E9Qy0,4575
373
- truefoundry-0.5.1rc8.dist-info/METADATA,sha256=0XwCMcuY2axlt1JUfIhogw1uNn0rRn0edV5HUigM6oc,2887
374
- truefoundry-0.5.1rc8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
375
- truefoundry-0.5.1rc8.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
376
- truefoundry-0.5.1rc8.dist-info/RECORD,,
373
+ truefoundry-0.5.2rc1.dist-info/METADATA,sha256=U7jLn1N-Cv3EkpRaIK3ud2UVOc4VjBBQK6VXX0EL16Y,2887
374
+ truefoundry-0.5.2rc1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
375
+ truefoundry-0.5.2rc1.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
376
+ truefoundry-0.5.2rc1.dist-info/RECORD,,