truefoundry 0.5.1rc2__py3-none-any.whl → 0.5.1rc4__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.
- truefoundry/common/auth_service_client.py +2 -2
- truefoundry/ml/__init__.py +11 -6
- truefoundry/ml/autogen/client/__init__.py +4 -0
- truefoundry/ml/autogen/client/models/__init__.py +4 -0
- truefoundry/ml/autogen/client/models/infer_method_name.py +1 -1
- truefoundry/ml/autogen/client/models/model_version_manifest.py +0 -6
- truefoundry/ml/autogen/client/models/sklearn_framework.py +12 -15
- truefoundry/ml/autogen/client/models/sklearn_model_schema.py +82 -0
- truefoundry/ml/autogen/client/models/xg_boost_framework.py +11 -1
- truefoundry/ml/autogen/client/models/xg_boost_model_schema.py +82 -0
- truefoundry/ml/autogen/client_README.md +2 -0
- truefoundry/ml/autogen/entities/artifacts.py +70 -49
- truefoundry/ml/autogen/models/signature.py +6 -3
- truefoundry/ml/autogen/models/utils.py +12 -7
- truefoundry/ml/log_types/artifacts/model.py +1 -28
- truefoundry/ml/mlfoundry_api.py +0 -2
- truefoundry/ml/mlfoundry_run.py +0 -2
- truefoundry/ml/model_framework.py +51 -1
- {truefoundry-0.5.1rc2.dist-info → truefoundry-0.5.1rc4.dist-info}/METADATA +1 -1
- {truefoundry-0.5.1rc2.dist-info → truefoundry-0.5.1rc4.dist-info}/RECORD +22 -20
- {truefoundry-0.5.1rc2.dist-info → truefoundry-0.5.1rc4.dist-info}/WHEEL +0 -0
- {truefoundry-0.5.1rc2.dist-info → truefoundry-0.5.1rc4.dist-info}/entry_points.txt +0 -0
|
@@ -51,7 +51,7 @@ class ServiceFoundryServerAuthServiceClient(AuthServiceClient):
|
|
|
51
51
|
self._api_server_url = url
|
|
52
52
|
|
|
53
53
|
def refresh_token(self, token: Token, host: Optional[str] = None) -> Token:
|
|
54
|
-
host_arg_str =
|
|
54
|
+
host_arg_str = host if host else "HOST"
|
|
55
55
|
if not token.refresh_token:
|
|
56
56
|
# TODO: Add a way to propagate error messages without traceback to the output interface side
|
|
57
57
|
raise Exception(
|
|
@@ -128,7 +128,7 @@ class AuthServerServiceClient(AuthServiceClient):
|
|
|
128
128
|
self._auth_server_url = url
|
|
129
129
|
|
|
130
130
|
def refresh_token(self, token: Token, host: Optional[str] = None) -> Token:
|
|
131
|
-
host_arg_str =
|
|
131
|
+
host_arg_str = host if host else "HOST"
|
|
132
132
|
if not token.refresh_token:
|
|
133
133
|
# TODO: Add a way to propagate error messages without traceback to the output interface side
|
|
134
134
|
raise Exception(
|
truefoundry/ml/__init__.py
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
from truefoundry.ml.autogen.client.models import
|
|
1
|
+
from truefoundry.ml.autogen.client.models import (
|
|
2
|
+
LibraryName,
|
|
3
|
+
ModelVersionEnvironment,
|
|
4
|
+
SklearnModelSchema,
|
|
5
|
+
XGBoostModelSchema,
|
|
6
|
+
)
|
|
2
7
|
from truefoundry.ml.enums import (
|
|
3
8
|
DataSlice,
|
|
4
9
|
FileFormat,
|
|
@@ -14,10 +19,7 @@ from truefoundry.ml.log_types.artifacts.artifact import (
|
|
|
14
19
|
BlobStorageDirectory,
|
|
15
20
|
)
|
|
16
21
|
from truefoundry.ml.log_types.artifacts.dataset import DataDirectory, DataDirectoryPath
|
|
17
|
-
from truefoundry.ml.log_types.artifacts.model import
|
|
18
|
-
ModelVersion,
|
|
19
|
-
infer_signature,
|
|
20
|
-
)
|
|
22
|
+
from truefoundry.ml.log_types.artifacts.model import ModelVersion
|
|
21
23
|
from truefoundry.ml.logger import init_logger
|
|
22
24
|
from truefoundry.ml.mlfoundry_api import get_client
|
|
23
25
|
from truefoundry.ml.mlfoundry_run import MlFoundryRun
|
|
@@ -37,6 +39,7 @@ from truefoundry.ml.model_framework import (
|
|
|
37
39
|
TensorFlowFramework,
|
|
38
40
|
TransformersFramework,
|
|
39
41
|
XGBoostFramework,
|
|
42
|
+
sklearn_infer_schema,
|
|
40
43
|
)
|
|
41
44
|
|
|
42
45
|
__all__ = [
|
|
@@ -66,14 +69,16 @@ __all__ = [
|
|
|
66
69
|
"Plot",
|
|
67
70
|
"PyTorchFramework",
|
|
68
71
|
"SklearnFramework",
|
|
72
|
+
"SklearnModelSchema",
|
|
69
73
|
"SpaCyFramework",
|
|
70
74
|
"StatsModelsFramework",
|
|
71
75
|
"TensorFlowFramework",
|
|
72
76
|
"TransformersFramework",
|
|
73
77
|
"ViewType",
|
|
74
78
|
"XGBoostFramework",
|
|
79
|
+
"XGBoostModelSchema",
|
|
75
80
|
"get_client",
|
|
76
|
-
"
|
|
81
|
+
"sklearn_infer_schema",
|
|
77
82
|
]
|
|
78
83
|
|
|
79
84
|
init_logger()
|
|
@@ -372,6 +372,7 @@ from truefoundry.ml.autogen.client.models.set_experiment_tag_request_dto import
|
|
|
372
372
|
from truefoundry.ml.autogen.client.models.set_tag_request_dto import SetTagRequestDto
|
|
373
373
|
from truefoundry.ml.autogen.client.models.signed_url_dto import SignedURLDto
|
|
374
374
|
from truefoundry.ml.autogen.client.models.sklearn_framework import SklearnFramework
|
|
375
|
+
from truefoundry.ml.autogen.client.models.sklearn_model_schema import SklearnModelSchema
|
|
375
376
|
from truefoundry.ml.autogen.client.models.source import Source
|
|
376
377
|
from truefoundry.ml.autogen.client.models.source1 import Source1
|
|
377
378
|
from truefoundry.ml.autogen.client.models.spa_cy_framework import SpaCyFramework
|
|
@@ -427,3 +428,6 @@ from truefoundry.ml.autogen.client.models.validation_error_loc_inner import (
|
|
|
427
428
|
ValidationErrorLocInner,
|
|
428
429
|
)
|
|
429
430
|
from truefoundry.ml.autogen.client.models.xg_boost_framework import XGBoostFramework
|
|
431
|
+
from truefoundry.ml.autogen.client.models.xg_boost_model_schema import (
|
|
432
|
+
XGBoostModelSchema,
|
|
433
|
+
)
|
|
@@ -343,6 +343,7 @@ from truefoundry.ml.autogen.client.models.set_experiment_tag_request_dto import
|
|
|
343
343
|
from truefoundry.ml.autogen.client.models.set_tag_request_dto import SetTagRequestDto
|
|
344
344
|
from truefoundry.ml.autogen.client.models.signed_url_dto import SignedURLDto
|
|
345
345
|
from truefoundry.ml.autogen.client.models.sklearn_framework import SklearnFramework
|
|
346
|
+
from truefoundry.ml.autogen.client.models.sklearn_model_schema import SklearnModelSchema
|
|
346
347
|
from truefoundry.ml.autogen.client.models.source import Source
|
|
347
348
|
from truefoundry.ml.autogen.client.models.source1 import Source1
|
|
348
349
|
from truefoundry.ml.autogen.client.models.spa_cy_framework import SpaCyFramework
|
|
@@ -398,3 +399,6 @@ from truefoundry.ml.autogen.client.models.validation_error_loc_inner import (
|
|
|
398
399
|
ValidationErrorLocInner,
|
|
399
400
|
)
|
|
400
401
|
from truefoundry.ml.autogen.client.models.xg_boost_framework import XGBoostFramework
|
|
402
|
+
from truefoundry.ml.autogen.client.models.xg_boost_model_schema import (
|
|
403
|
+
XGBoostModelSchema,
|
|
404
|
+
)
|
|
@@ -53,10 +53,6 @@ class ModelVersionManifest(BaseModel):
|
|
|
53
53
|
step: Optional[conint(strict=True, ge=0)] = Field(
|
|
54
54
|
default=0, description="+label=Step"
|
|
55
55
|
)
|
|
56
|
-
model_schema: Optional[Dict[str, Any]] = Field(
|
|
57
|
-
default=None,
|
|
58
|
-
description="+label=Model Schema +usage=Schema of the model +uiType=JsonInput",
|
|
59
|
-
)
|
|
60
56
|
__properties = [
|
|
61
57
|
"description",
|
|
62
58
|
"metadata",
|
|
@@ -65,7 +61,6 @@ class ModelVersionManifest(BaseModel):
|
|
|
65
61
|
"framework",
|
|
66
62
|
"environment",
|
|
67
63
|
"step",
|
|
68
|
-
"model_schema",
|
|
69
64
|
]
|
|
70
65
|
|
|
71
66
|
@validator("type")
|
|
@@ -137,7 +132,6 @@ class ModelVersionManifest(BaseModel):
|
|
|
137
132
|
if obj.get("environment") is not None
|
|
138
133
|
else None,
|
|
139
134
|
"step": obj.get("step") if obj.get("step") is not None else 0,
|
|
140
|
-
"model_schema": obj.get("model_schema"),
|
|
141
135
|
}
|
|
142
136
|
)
|
|
143
137
|
return _obj
|
|
@@ -18,10 +18,10 @@ import pprint
|
|
|
18
18
|
import re # noqa: F401
|
|
19
19
|
from typing import Optional
|
|
20
20
|
|
|
21
|
-
from truefoundry.ml.autogen.client.models.infer_method_name import InferMethodName
|
|
22
21
|
from truefoundry.ml.autogen.client.models.serialization_format import (
|
|
23
22
|
SerializationFormat,
|
|
24
23
|
)
|
|
24
|
+
from truefoundry.ml.autogen.client.models.sklearn_model_schema import SklearnModelSchema
|
|
25
25
|
from truefoundry.pydantic_v1 import BaseModel, Field, StrictStr, validator
|
|
26
26
|
|
|
27
27
|
|
|
@@ -34,24 +34,16 @@ class SklearnFramework(BaseModel):
|
|
|
34
34
|
default=...,
|
|
35
35
|
description="+label=Type +usage=Type of the framework +value=sklearn",
|
|
36
36
|
)
|
|
37
|
-
serialization_format: Optional[SerializationFormat] = Field(
|
|
38
|
-
default=None,
|
|
39
|
-
description="+label=Serialization format +usage=Serialization format used for the model",
|
|
40
|
-
)
|
|
41
37
|
model_filepath: Optional[StrictStr] = Field(
|
|
42
38
|
default=None,
|
|
43
39
|
description="+label=Model file path +usage=Relative path to the model file",
|
|
44
40
|
)
|
|
45
|
-
|
|
41
|
+
serialization_format: Optional[SerializationFormat] = Field(
|
|
46
42
|
default=None,
|
|
47
|
-
description="+label=
|
|
43
|
+
description="+label=Serialization format +usage=Serialization format used for the model",
|
|
48
44
|
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"serialization_format",
|
|
52
|
-
"model_filepath",
|
|
53
|
-
"infer_method_name",
|
|
54
|
-
]
|
|
45
|
+
model_schema: Optional[SklearnModelSchema] = None
|
|
46
|
+
__properties = ["type", "model_filepath", "serialization_format", "model_schema"]
|
|
55
47
|
|
|
56
48
|
@validator("type")
|
|
57
49
|
def type_validate_enum(cls, value):
|
|
@@ -82,6 +74,9 @@ class SklearnFramework(BaseModel):
|
|
|
82
74
|
def to_dict(self):
|
|
83
75
|
"""Returns the dictionary representation of the model using alias"""
|
|
84
76
|
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
|
77
|
+
# override the default output from truefoundry.pydantic_v1 by calling `to_dict()` of model_schema
|
|
78
|
+
if self.model_schema:
|
|
79
|
+
_dict["model_schema"] = self.model_schema.to_dict()
|
|
85
80
|
return _dict
|
|
86
81
|
|
|
87
82
|
@classmethod
|
|
@@ -96,9 +91,11 @@ class SklearnFramework(BaseModel):
|
|
|
96
91
|
_obj = SklearnFramework.parse_obj(
|
|
97
92
|
{
|
|
98
93
|
"type": obj.get("type"),
|
|
99
|
-
"serialization_format": obj.get("serialization_format"),
|
|
100
94
|
"model_filepath": obj.get("model_filepath"),
|
|
101
|
-
"
|
|
95
|
+
"serialization_format": obj.get("serialization_format"),
|
|
96
|
+
"model_schema": SklearnModelSchema.from_dict(obj.get("model_schema"))
|
|
97
|
+
if obj.get("model_schema") is not None
|
|
98
|
+
else None,
|
|
102
99
|
}
|
|
103
100
|
)
|
|
104
101
|
return _obj
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
FastAPI
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
from typing import Any, Dict
|
|
20
|
+
|
|
21
|
+
from truefoundry.ml.autogen.client.models.infer_method_name import InferMethodName
|
|
22
|
+
from truefoundry.pydantic_v1 import BaseModel, Field, conlist
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class SklearnModelSchema(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
SklearnModelSchema
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
infer_method_name: InferMethodName = Field(
|
|
31
|
+
default=...,
|
|
32
|
+
description="+label=Inference Method Name +usage=Name of the method used for inference",
|
|
33
|
+
)
|
|
34
|
+
inputs: conlist(Dict[str, Any]) = Field(
|
|
35
|
+
default=..., description="+label= Input Schema +usage=Schema of the input"
|
|
36
|
+
)
|
|
37
|
+
outputs: conlist(Dict[str, Any]) = Field(
|
|
38
|
+
default=..., description="+label= Output Schema +usage=Schema of the output"
|
|
39
|
+
)
|
|
40
|
+
__properties = ["infer_method_name", "inputs", "outputs"]
|
|
41
|
+
|
|
42
|
+
class Config:
|
|
43
|
+
"""Pydantic configuration"""
|
|
44
|
+
|
|
45
|
+
allow_population_by_field_name = True
|
|
46
|
+
validate_assignment = True
|
|
47
|
+
|
|
48
|
+
def to_str(self) -> str:
|
|
49
|
+
"""Returns the string representation of the model using alias"""
|
|
50
|
+
return pprint.pformat(self.dict(by_alias=True))
|
|
51
|
+
|
|
52
|
+
def to_json(self) -> str:
|
|
53
|
+
"""Returns the JSON representation of the model using alias"""
|
|
54
|
+
return json.dumps(self.to_dict())
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_json(cls, json_str: str) -> SklearnModelSchema:
|
|
58
|
+
"""Create an instance of SklearnModelSchema from a JSON string"""
|
|
59
|
+
return cls.from_dict(json.loads(json_str))
|
|
60
|
+
|
|
61
|
+
def to_dict(self):
|
|
62
|
+
"""Returns the dictionary representation of the model using alias"""
|
|
63
|
+
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
|
64
|
+
return _dict
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def from_dict(cls, obj: dict) -> SklearnModelSchema:
|
|
68
|
+
"""Create an instance of SklearnModelSchema from a dict"""
|
|
69
|
+
if obj is None:
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
if not isinstance(obj, dict):
|
|
73
|
+
return SklearnModelSchema.parse_obj(obj)
|
|
74
|
+
|
|
75
|
+
_obj = SklearnModelSchema.parse_obj(
|
|
76
|
+
{
|
|
77
|
+
"infer_method_name": obj.get("infer_method_name"),
|
|
78
|
+
"inputs": obj.get("inputs"),
|
|
79
|
+
"outputs": obj.get("outputs"),
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
return _obj
|
|
@@ -21,6 +21,9 @@ from typing import Optional
|
|
|
21
21
|
from truefoundry.ml.autogen.client.models.serialization_format import (
|
|
22
22
|
SerializationFormat,
|
|
23
23
|
)
|
|
24
|
+
from truefoundry.ml.autogen.client.models.xg_boost_model_schema import (
|
|
25
|
+
XGBoostModelSchema,
|
|
26
|
+
)
|
|
24
27
|
from truefoundry.pydantic_v1 import BaseModel, Field, StrictStr, validator
|
|
25
28
|
|
|
26
29
|
|
|
@@ -41,7 +44,8 @@ class XGBoostFramework(BaseModel):
|
|
|
41
44
|
default=None,
|
|
42
45
|
description="+label=Model file path +usage=Relative path to the model file",
|
|
43
46
|
)
|
|
44
|
-
|
|
47
|
+
model_schema: Optional[XGBoostModelSchema] = None
|
|
48
|
+
__properties = ["type", "serialization_format", "model_filepath", "model_schema"]
|
|
45
49
|
|
|
46
50
|
@validator("type")
|
|
47
51
|
def type_validate_enum(cls, value):
|
|
@@ -72,6 +76,9 @@ class XGBoostFramework(BaseModel):
|
|
|
72
76
|
def to_dict(self):
|
|
73
77
|
"""Returns the dictionary representation of the model using alias"""
|
|
74
78
|
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
|
79
|
+
# override the default output from truefoundry.pydantic_v1 by calling `to_dict()` of model_schema
|
|
80
|
+
if self.model_schema:
|
|
81
|
+
_dict["model_schema"] = self.model_schema.to_dict()
|
|
75
82
|
return _dict
|
|
76
83
|
|
|
77
84
|
@classmethod
|
|
@@ -88,6 +95,9 @@ class XGBoostFramework(BaseModel):
|
|
|
88
95
|
"type": obj.get("type"),
|
|
89
96
|
"serialization_format": obj.get("serialization_format"),
|
|
90
97
|
"model_filepath": obj.get("model_filepath"),
|
|
98
|
+
"model_schema": XGBoostModelSchema.from_dict(obj.get("model_schema"))
|
|
99
|
+
if obj.get("model_schema") is not None
|
|
100
|
+
else None,
|
|
91
101
|
}
|
|
92
102
|
)
|
|
93
103
|
return _obj
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
FastAPI
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
from typing import Any, Dict
|
|
20
|
+
|
|
21
|
+
from truefoundry.ml.autogen.client.models.infer_method_name import InferMethodName
|
|
22
|
+
from truefoundry.pydantic_v1 import BaseModel, Field, conlist
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class XGBoostModelSchema(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
XGBoostModelSchema
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
infer_method_name: InferMethodName = Field(
|
|
31
|
+
default=...,
|
|
32
|
+
description="+label=Inference Method Name +usage=Name of the method used for inference",
|
|
33
|
+
)
|
|
34
|
+
inputs: conlist(Dict[str, Any]) = Field(
|
|
35
|
+
default=..., description="+label= Input Schema +usage=Schema of the input"
|
|
36
|
+
)
|
|
37
|
+
outputs: conlist(Dict[str, Any]) = Field(
|
|
38
|
+
default=..., description="+label= Output Schema +usage=Schema of the output"
|
|
39
|
+
)
|
|
40
|
+
__properties = ["infer_method_name", "inputs", "outputs"]
|
|
41
|
+
|
|
42
|
+
class Config:
|
|
43
|
+
"""Pydantic configuration"""
|
|
44
|
+
|
|
45
|
+
allow_population_by_field_name = True
|
|
46
|
+
validate_assignment = True
|
|
47
|
+
|
|
48
|
+
def to_str(self) -> str:
|
|
49
|
+
"""Returns the string representation of the model using alias"""
|
|
50
|
+
return pprint.pformat(self.dict(by_alias=True))
|
|
51
|
+
|
|
52
|
+
def to_json(self) -> str:
|
|
53
|
+
"""Returns the JSON representation of the model using alias"""
|
|
54
|
+
return json.dumps(self.to_dict())
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_json(cls, json_str: str) -> XGBoostModelSchema:
|
|
58
|
+
"""Create an instance of XGBoostModelSchema from a JSON string"""
|
|
59
|
+
return cls.from_dict(json.loads(json_str))
|
|
60
|
+
|
|
61
|
+
def to_dict(self):
|
|
62
|
+
"""Returns the dictionary representation of the model using alias"""
|
|
63
|
+
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
|
|
64
|
+
return _dict
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def from_dict(cls, obj: dict) -> XGBoostModelSchema:
|
|
68
|
+
"""Create an instance of XGBoostModelSchema from a dict"""
|
|
69
|
+
if obj is None:
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
if not isinstance(obj, dict):
|
|
73
|
+
return XGBoostModelSchema.parse_obj(obj)
|
|
74
|
+
|
|
75
|
+
_obj = XGBoostModelSchema.parse_obj(
|
|
76
|
+
{
|
|
77
|
+
"infer_method_name": obj.get("infer_method_name"),
|
|
78
|
+
"inputs": obj.get("inputs"),
|
|
79
|
+
"outputs": obj.get("outputs"),
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
return _obj
|
|
@@ -304,6 +304,7 @@ Class | Method | HTTP request | Description
|
|
|
304
304
|
- [SetTagRequestDto](truefoundry/ml/autogen/client/docs/SetTagRequestDto.md)
|
|
305
305
|
- [SignedURLDto](truefoundry/ml/autogen/client/docs/SignedURLDto.md)
|
|
306
306
|
- [SklearnFramework](truefoundry/ml/autogen/client/docs/SklearnFramework.md)
|
|
307
|
+
- [SklearnModelSchema](truefoundry/ml/autogen/client/docs/SklearnModelSchema.md)
|
|
307
308
|
- [Source](truefoundry/ml/autogen/client/docs/Source.md)
|
|
308
309
|
- [Source1](truefoundry/ml/autogen/client/docs/Source1.md)
|
|
309
310
|
- [SpaCyFramework](truefoundry/ml/autogen/client/docs/SpaCyFramework.md)
|
|
@@ -331,6 +332,7 @@ Class | Method | HTTP request | Description
|
|
|
331
332
|
- [ValidationError](truefoundry/ml/autogen/client/docs/ValidationError.md)
|
|
332
333
|
- [ValidationErrorLocInner](truefoundry/ml/autogen/client/docs/ValidationErrorLocInner.md)
|
|
333
334
|
- [XGBoostFramework](truefoundry/ml/autogen/client/docs/XGBoostFramework.md)
|
|
335
|
+
- [XGBoostModelSchema](truefoundry/ml/autogen/client/docs/XGBoostModelSchema.md)
|
|
334
336
|
|
|
335
337
|
|
|
336
338
|
<a id="documentation-for-authorization"></a>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# generated by datamodel-codegen:
|
|
2
2
|
# filename: artifacts.json
|
|
3
|
-
# timestamp: 2024-12-
|
|
3
|
+
# timestamp: 2024-12-05T14:45:34+00:00
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
@@ -60,6 +60,19 @@ class BaseArtifactVersion(BaseModel):
|
|
|
60
60
|
)
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
class BaseModelSchema(BaseModel):
|
|
64
|
+
infer_method_name: str = Field(
|
|
65
|
+
...,
|
|
66
|
+
description="+label=Inference Method Name\n+usage=Name of the method used for inference",
|
|
67
|
+
)
|
|
68
|
+
inputs: List[Dict[str, Any]] = Field(
|
|
69
|
+
..., description="+label= Input Schema\n+usage=Schema of the input"
|
|
70
|
+
)
|
|
71
|
+
outputs: List[Dict[str, Any]] = Field(
|
|
72
|
+
..., description="+label= Output Schema\n+usage=Schema of the output"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
63
76
|
class MimeType(str, Enum):
|
|
64
77
|
"""
|
|
65
78
|
+label=MIME Type
|
|
@@ -289,7 +302,7 @@ class SerializationFormat(str, Enum):
|
|
|
289
302
|
|
|
290
303
|
class InferMethodName(str, Enum):
|
|
291
304
|
"""
|
|
292
|
-
+label=Inference
|
|
305
|
+
+label=Inference Method Name
|
|
293
306
|
+usage=Name of the method used for inference
|
|
294
307
|
"""
|
|
295
308
|
|
|
@@ -297,26 +310,10 @@ class InferMethodName(str, Enum):
|
|
|
297
310
|
predict_proba = "predict_proba"
|
|
298
311
|
|
|
299
312
|
|
|
300
|
-
class
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
"""
|
|
305
|
-
|
|
306
|
-
type: Literal["sklearn"] = Field(
|
|
307
|
-
..., description="+label=Type\n+usage=Type of the framework\n+value=sklearn"
|
|
308
|
-
)
|
|
309
|
-
serialization_format: Optional[SerializationFormat] = Field(
|
|
310
|
-
None,
|
|
311
|
-
description="+label=Serialization format\n+usage=Serialization format used for the model",
|
|
312
|
-
)
|
|
313
|
-
model_filepath: Optional[str] = Field(
|
|
314
|
-
None,
|
|
315
|
-
description="+label=Model file path\n+usage=Relative path to the model file",
|
|
316
|
-
)
|
|
317
|
-
infer_method_name: Optional[InferMethodName] = Field(
|
|
318
|
-
None,
|
|
319
|
-
description="+label=Inference method name\n+usage=Name of the method used for inference",
|
|
313
|
+
class SklearnModelSchema(BaseModelSchema):
|
|
314
|
+
infer_method_name: InferMethodName = Field(
|
|
315
|
+
...,
|
|
316
|
+
description="+label=Inference Method Name\n+usage=Name of the method used for inference",
|
|
320
317
|
)
|
|
321
318
|
|
|
322
319
|
|
|
@@ -451,22 +448,10 @@ class UserMessage(BaseModel):
|
|
|
451
448
|
)
|
|
452
449
|
|
|
453
450
|
|
|
454
|
-
class
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
"""
|
|
459
|
-
|
|
460
|
-
type: Literal["xgboost"] = Field(
|
|
461
|
-
..., description="+label=Type\n+usage=Type of the framework\n+value=xgboost"
|
|
462
|
-
)
|
|
463
|
-
serialization_format: Optional[SerializationFormat] = Field(
|
|
464
|
-
None,
|
|
465
|
-
description="+label=Serialization format\n+usage=Serialization format used for the model",
|
|
466
|
-
)
|
|
467
|
-
model_filepath: Optional[str] = Field(
|
|
468
|
-
None,
|
|
469
|
-
description="+label=Model file path\n+usage=Relative path to the model file",
|
|
451
|
+
class XGBoostModelSchema(BaseModelSchema):
|
|
452
|
+
infer_method_name: InferMethodName = Field(
|
|
453
|
+
...,
|
|
454
|
+
description="+label=Inference Method Name\n+usage=Name of the method used for inference",
|
|
470
455
|
)
|
|
471
456
|
|
|
472
457
|
|
|
@@ -563,6 +548,53 @@ class ChatPrompt(BasePrompt):
|
|
|
563
548
|
)
|
|
564
549
|
|
|
565
550
|
|
|
551
|
+
class SklearnFramework(BaseModel):
|
|
552
|
+
"""
|
|
553
|
+
+docs=Scikit-learn framework for the model version
|
|
554
|
+
+label=Sklearn
|
|
555
|
+
"""
|
|
556
|
+
|
|
557
|
+
type: Literal["sklearn"] = Field(
|
|
558
|
+
..., description="+label=Type\n+usage=Type of the framework\n+value=sklearn"
|
|
559
|
+
)
|
|
560
|
+
model_filepath: Optional[str] = Field(
|
|
561
|
+
None,
|
|
562
|
+
description="+label=Model file path\n+usage=Relative path to the model file",
|
|
563
|
+
)
|
|
564
|
+
serialization_format: Optional[SerializationFormat] = Field(
|
|
565
|
+
None,
|
|
566
|
+
description="+label=Serialization format\n+usage=Serialization format used for the model",
|
|
567
|
+
)
|
|
568
|
+
model_schema: Optional[SklearnModelSchema] = None
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
class XGBoostFramework(BaseModel):
|
|
572
|
+
"""
|
|
573
|
+
+docs=XGBoost framework for the model version
|
|
574
|
+
+label=XGBoost
|
|
575
|
+
"""
|
|
576
|
+
|
|
577
|
+
type: Literal["xgboost"] = Field(
|
|
578
|
+
..., description="+label=Type\n+usage=Type of the framework\n+value=xgboost"
|
|
579
|
+
)
|
|
580
|
+
serialization_format: Optional[SerializationFormat] = Field(
|
|
581
|
+
None,
|
|
582
|
+
description="+label=Serialization format\n+usage=Serialization format used for the model",
|
|
583
|
+
)
|
|
584
|
+
model_filepath: Optional[str] = Field(
|
|
585
|
+
None,
|
|
586
|
+
description="+label=Model file path\n+usage=Relative path to the model file",
|
|
587
|
+
)
|
|
588
|
+
model_schema: Optional[XGBoostModelSchema] = None
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
class AgentApp(BaseModel):
|
|
592
|
+
type: Literal["agent-app"] = Field(..., description="+value=agent-app")
|
|
593
|
+
tools: List[AgentOpenAPIToolWithFQN]
|
|
594
|
+
agents: List[AgentWithFQN]
|
|
595
|
+
root_agent: constr(min_length=1)
|
|
596
|
+
|
|
597
|
+
|
|
566
598
|
class ModelVersion(BaseArtifactVersion):
|
|
567
599
|
type: Literal["model-version"] = Field(
|
|
568
600
|
..., description='+label=Type\n+usage=Model Version\n+value="model-version"'
|
|
@@ -593,17 +625,6 @@ class ModelVersion(BaseArtifactVersion):
|
|
|
593
625
|
)
|
|
594
626
|
environment: Optional[ModelVersionEnvironment] = None
|
|
595
627
|
step: conint(ge=0) = Field(0, description="+label=Step")
|
|
596
|
-
model_schema: Optional[Dict[str, Any]] = Field(
|
|
597
|
-
None,
|
|
598
|
-
description="+label=Model Schema\n+usage=Schema of the model\n+uiType=JsonInput",
|
|
599
|
-
)
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
class AgentApp(BaseModel):
|
|
603
|
-
type: Literal["agent-app"] = Field(..., description="+value=agent-app")
|
|
604
|
-
tools: List[AgentOpenAPIToolWithFQN]
|
|
605
|
-
agents: List[AgentWithFQN]
|
|
606
|
-
root_agent: constr(min_length=1)
|
|
607
628
|
|
|
608
629
|
|
|
609
630
|
class VersionedArtifactType(BaseModel):
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
from dataclasses import dataclass, is_dataclass
|
|
2
|
-
from typing import Any, Dict, Optional, Union
|
|
2
|
+
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
|
|
3
3
|
|
|
4
4
|
import numpy as np
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
from .schema import ParamSchema, Schema, convert_dataclass_to_schema
|
|
8
11
|
from .utils import infer_param_schema, infer_schema
|
|
9
12
|
|
|
10
|
-
MlflowInferableDataset = Union[pd.DataFrame, np.ndarray, Dict[str, np.ndarray]]
|
|
13
|
+
MlflowInferableDataset = Union["pd.DataFrame", "np.ndarray", Dict[str, "np.ndarray"]]
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
class ModelSignature:
|
|
@@ -4,7 +4,12 @@ from collections import defaultdict
|
|
|
4
4
|
from typing import Any, Dict, List, Optional, Union
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
import pandas as pd
|
|
10
|
+
except ImportError:
|
|
11
|
+
pd = None
|
|
12
|
+
|
|
8
13
|
|
|
9
14
|
from .exceptions import MlflowException
|
|
10
15
|
from .schema import (
|
|
@@ -330,7 +335,7 @@ def infer_schema(data: Any) -> Schema: # noqa: C901
|
|
|
330
335
|
]
|
|
331
336
|
)
|
|
332
337
|
# pandas.Series
|
|
333
|
-
elif isinstance(data, pd.Series):
|
|
338
|
+
elif pd and isinstance(data, pd.Series):
|
|
334
339
|
name = getattr(data, "name", None)
|
|
335
340
|
schema = Schema(
|
|
336
341
|
[
|
|
@@ -342,7 +347,7 @@ def infer_schema(data: Any) -> Schema: # noqa: C901
|
|
|
342
347
|
]
|
|
343
348
|
)
|
|
344
349
|
# pandas.DataFrame
|
|
345
|
-
elif isinstance(data, pd.DataFrame):
|
|
350
|
+
elif pd and isinstance(data, pd.DataFrame):
|
|
346
351
|
schema = Schema(
|
|
347
352
|
[
|
|
348
353
|
ColSpec(
|
|
@@ -473,13 +478,13 @@ def _is_none_or_nan(x):
|
|
|
473
478
|
|
|
474
479
|
|
|
475
480
|
def _infer_required(col) -> bool:
|
|
476
|
-
if isinstance(col, (list, pd.Series)):
|
|
481
|
+
if pd and isinstance(col, (list, pd.Series)):
|
|
477
482
|
return not any(_is_none_or_nan(x) for x in col)
|
|
478
483
|
return not _is_none_or_nan(col)
|
|
479
484
|
|
|
480
485
|
|
|
481
|
-
def _infer_pandas_column(col: pd.Series) -> DataType:
|
|
482
|
-
if not isinstance(col, pd.Series):
|
|
486
|
+
def _infer_pandas_column(col: "pd.Series") -> DataType:
|
|
487
|
+
if pd and not isinstance(col, pd.Series):
|
|
483
488
|
raise TypeError(f"Expected pandas.Series, got '{type(col)}'.")
|
|
484
489
|
if len(col.values.shape) > 1:
|
|
485
490
|
raise MlflowException(f"Expected 1d array, got array with shape {col.shape}")
|
|
@@ -496,7 +501,7 @@ def _infer_pandas_column(col: pd.Series) -> DataType:
|
|
|
496
501
|
# For backwards compatibility, we fall back to string
|
|
497
502
|
# if the provided array is of string type
|
|
498
503
|
# This is for diviner test where df field is ('key2', 'key1', 'key0')
|
|
499
|
-
if pd.api.types.is_string_dtype(col):
|
|
504
|
+
if pd and pd.api.types.is_string_dtype(col):
|
|
500
505
|
return DataType.string
|
|
501
506
|
raise MlflowException(
|
|
502
507
|
f"Failed to infer schema for pandas.Series {col}. Error: {e}"
|
|
@@ -31,6 +31,7 @@ from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
|
|
|
31
31
|
TrueFoundryArtifactSource,
|
|
32
32
|
UpdateModelVersionRequestDto,
|
|
33
33
|
)
|
|
34
|
+
from truefoundry.ml.autogen.models import infer_signature as _infer_signature
|
|
34
35
|
from truefoundry.ml.enums import ModelFramework
|
|
35
36
|
from truefoundry.ml.exceptions import MlFoundryException
|
|
36
37
|
from truefoundry.ml.log_types.artifacts.artifact import BlobStorageDirectory
|
|
@@ -105,7 +106,6 @@ class ModelVersion:
|
|
|
105
106
|
self._deleted = False
|
|
106
107
|
self._description: str = ""
|
|
107
108
|
self._metadata: Dict[str, Any] = {}
|
|
108
|
-
self._model_schema: Optional[Dict[str, Any]] = None
|
|
109
109
|
self._environment: Optional[ModelVersionEnvironment] = None
|
|
110
110
|
self._framework: Optional[ModelFrameworkType] = None
|
|
111
111
|
self._set_mutable_attrs()
|
|
@@ -149,9 +149,6 @@ class ModelVersion:
|
|
|
149
149
|
if self._model_version.manifest:
|
|
150
150
|
self._description = self._model_version.manifest.description or ""
|
|
151
151
|
self._metadata = copy.deepcopy(self._model_version.manifest.metadata)
|
|
152
|
-
self._model_schema = copy.deepcopy(
|
|
153
|
-
self._model_version.manifest.model_schema
|
|
154
|
-
)
|
|
155
152
|
self._environment = copy.deepcopy(self._model_version.manifest.environment)
|
|
156
153
|
self._framework = (
|
|
157
154
|
copy.deepcopy(self._model_version.manifest.framework.actual_instance)
|
|
@@ -161,7 +158,6 @@ class ModelVersion:
|
|
|
161
158
|
else:
|
|
162
159
|
self._description = self._model_version.description or ""
|
|
163
160
|
self._metadata = copy.deepcopy(self._model_version.artifact_metadata)
|
|
164
|
-
self._model_schema = None
|
|
165
161
|
self._environment = None
|
|
166
162
|
self._framework = _ModelFramework.to_model_framework_type(
|
|
167
163
|
self._model_version.model_framework
|
|
@@ -235,23 +231,6 @@ class ModelVersion:
|
|
|
235
231
|
_validate_artifact_metadata(value)
|
|
236
232
|
self._metadata = copy.deepcopy(value)
|
|
237
233
|
|
|
238
|
-
@property
|
|
239
|
-
def model_schema(self) -> Optional[Dict[str, Any]]:
|
|
240
|
-
"""Get model_schema for the current model"""
|
|
241
|
-
return self._model_schema
|
|
242
|
-
|
|
243
|
-
@model_schema.setter
|
|
244
|
-
def model_schema(self, value: Optional[Dict[str, Any]]):
|
|
245
|
-
"""set the model_schema for current model"""
|
|
246
|
-
if not self._model_version.manifest:
|
|
247
|
-
warnings.warn(
|
|
248
|
-
message="This model version was created using an older serialization format. model_schema will not be updated",
|
|
249
|
-
category=DeprecationWarning,
|
|
250
|
-
stacklevel=2,
|
|
251
|
-
)
|
|
252
|
-
return
|
|
253
|
-
self._model_schema = copy.deepcopy(value)
|
|
254
|
-
|
|
255
234
|
@property
|
|
256
235
|
def environment(self) -> Optional[ModelVersionEnvironment]:
|
|
257
236
|
"""Get the environment details for the model"""
|
|
@@ -466,7 +445,6 @@ class ModelVersion:
|
|
|
466
445
|
if self._model_version.manifest:
|
|
467
446
|
self._model_version.manifest.description = self.description
|
|
468
447
|
self._model_version.manifest.metadata = self.metadata
|
|
469
|
-
self._model_version.manifest.model_schema = self.model_schema
|
|
470
448
|
self._model_version.manifest.environment = self.environment
|
|
471
449
|
self._model_version.manifest.framework = (
|
|
472
450
|
Framework.from_dict(self.framework.dict()) if self.framework else None
|
|
@@ -501,7 +479,6 @@ def _log_model_version( # noqa: C901
|
|
|
501
479
|
progress: Optional[bool] = None,
|
|
502
480
|
framework: Optional[Union[str, ModelFramework, "ModelFrameworkType"]] = None,
|
|
503
481
|
environment: Optional[ModelVersionEnvironment] = None,
|
|
504
|
-
model_schema: Optional[Dict[str, Any]] = None,
|
|
505
482
|
) -> ModelVersion:
|
|
506
483
|
if (run and mlfoundry_artifacts_api) or (not run and not mlfoundry_artifacts_api):
|
|
507
484
|
raise MlFoundryException(
|
|
@@ -613,7 +590,6 @@ def _log_model_version( # noqa: C901
|
|
|
613
590
|
framework=Framework.from_dict(framework.dict()) if framework else None,
|
|
614
591
|
environment=environment,
|
|
615
592
|
step=step,
|
|
616
|
-
model_schema=model_schema,
|
|
617
593
|
)
|
|
618
594
|
artifact_version_response = mlfoundry_artifacts_api.finalize_artifact_version_post(
|
|
619
595
|
finalize_artifact_version_request_dto=FinalizeArtifactVersionRequestDto(
|
|
@@ -636,9 +612,6 @@ def infer_signature(
|
|
|
636
612
|
] = None,
|
|
637
613
|
params: Optional[Dict[str, Any]] = None,
|
|
638
614
|
):
|
|
639
|
-
# TODO: Importing this globally causes hard dependencies on some libraries like pandas
|
|
640
|
-
from truefoundry.ml.autogen.models import infer_signature as _infer_signature
|
|
641
|
-
|
|
642
615
|
return _infer_signature(
|
|
643
616
|
model_input=model_input, model_output=model_output, params=params
|
|
644
617
|
)
|
truefoundry/ml/mlfoundry_api.py
CHANGED
|
@@ -1265,7 +1265,6 @@ class MlFoundry:
|
|
|
1265
1265
|
progress: Optional[bool] = None,
|
|
1266
1266
|
framework: Optional[Union[str, ModelFramework, "ModelFrameworkType"]] = None,
|
|
1267
1267
|
environment: Optional[ModelVersionEnvironment] = None,
|
|
1268
|
-
model_schema: Optional[Dict[str, Any]] = None,
|
|
1269
1268
|
) -> ModelVersion:
|
|
1270
1269
|
"""
|
|
1271
1270
|
Serialize and log a versioned model under the current ml_repo. Each logged model generates a new version
|
|
@@ -1390,7 +1389,6 @@ class MlFoundry:
|
|
|
1390
1389
|
progress=progress,
|
|
1391
1390
|
framework=framework,
|
|
1392
1391
|
environment=environment,
|
|
1393
|
-
model_schema=model_schema,
|
|
1394
1392
|
)
|
|
1395
1393
|
logger.info(f"Logged model successfully with fqn {model_version.fqn!r}")
|
|
1396
1394
|
return model_version
|
truefoundry/ml/mlfoundry_run.py
CHANGED
|
@@ -934,7 +934,6 @@ class MlFoundryRun:
|
|
|
934
934
|
progress: Optional[bool] = None,
|
|
935
935
|
framework: Optional[Union[str, ModelFramework, "ModelFrameworkType"]] = None,
|
|
936
936
|
environment: Optional[ModelVersionEnvironment] = None,
|
|
937
|
-
model_schema: Optional[Dict[str, Any]] = None,
|
|
938
937
|
) -> ModelVersion:
|
|
939
938
|
# TODO (chiragjn): Document mapping of framework to list of valid model save kwargs
|
|
940
939
|
# TODO (chiragjn): Add more examples
|
|
@@ -1061,7 +1060,6 @@ class MlFoundryRun:
|
|
|
1061
1060
|
progress=progress,
|
|
1062
1061
|
framework=framework,
|
|
1063
1062
|
environment=environment,
|
|
1064
|
-
model_schema=model_schema,
|
|
1065
1063
|
)
|
|
1066
1064
|
logger.info(f"Logged model successfully with fqn {model_version.fqn!r}")
|
|
1067
1065
|
return model_version
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import os
|
|
2
3
|
import warnings
|
|
3
4
|
from collections import OrderedDict
|
|
4
5
|
from pickle import load as pickle_load
|
|
5
|
-
from typing import
|
|
6
|
+
from typing import (
|
|
7
|
+
TYPE_CHECKING,
|
|
8
|
+
Any,
|
|
9
|
+
Callable,
|
|
10
|
+
Dict,
|
|
11
|
+
List,
|
|
12
|
+
Literal,
|
|
13
|
+
Optional,
|
|
14
|
+
Type,
|
|
15
|
+
Union,
|
|
16
|
+
get_args,
|
|
17
|
+
)
|
|
6
18
|
|
|
7
19
|
from truefoundry.common.utils import (
|
|
8
20
|
get_python_version_major_minor,
|
|
@@ -10,6 +22,7 @@ from truefoundry.common.utils import (
|
|
|
10
22
|
)
|
|
11
23
|
from truefoundry.ml.autogen.client import SerializationFormat
|
|
12
24
|
from truefoundry.ml.autogen.entities import artifacts as autogen_artifacts
|
|
25
|
+
from truefoundry.ml.autogen.models import infer_signature
|
|
13
26
|
from truefoundry.ml.enums import ModelFramework
|
|
14
27
|
from truefoundry.ml.log_types.artifacts.utils import (
|
|
15
28
|
get_single_file_path_if_only_one_in_directory,
|
|
@@ -17,6 +30,9 @@ from truefoundry.ml.log_types.artifacts.utils import (
|
|
|
17
30
|
)
|
|
18
31
|
from truefoundry.pydantic_v1 import BaseModel, Field
|
|
19
32
|
|
|
33
|
+
if TYPE_CHECKING:
|
|
34
|
+
from sklearn.base import BaseEstimator
|
|
35
|
+
|
|
20
36
|
# Map serialization format to corresponding pip packages
|
|
21
37
|
SERIALIZATION_FORMAT_TO_PACKAGES_NAME_MAP = {
|
|
22
38
|
SerializationFormat.JOBLIB: ["joblib"],
|
|
@@ -421,3 +437,37 @@ def auto_update_model_framework_details(
|
|
|
421
437
|
model_file_path=absolute_model_filepath
|
|
422
438
|
)
|
|
423
439
|
)
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
def sklearn_infer_schema(
|
|
443
|
+
model_input: Any,
|
|
444
|
+
model: "BaseEstimator",
|
|
445
|
+
infer_method_name: str = "predict",
|
|
446
|
+
) -> autogen_artifacts.SklearnModelSchema:
|
|
447
|
+
"""
|
|
448
|
+
Infer the schema of a Sklearn model.
|
|
449
|
+
|
|
450
|
+
Args:
|
|
451
|
+
model_input (Any): The input data to be used for schema inference.
|
|
452
|
+
model (Any): The Sklearn model instance.
|
|
453
|
+
infer_method_name (str): The name of the method to be used for schema inference.
|
|
454
|
+
Eg: predict (default), predict_proba
|
|
455
|
+
Returns:
|
|
456
|
+
SklearnModelSchema: The inferred schema of the Sklearn model.
|
|
457
|
+
"""
|
|
458
|
+
if not hasattr(model, infer_method_name):
|
|
459
|
+
raise ValueError(
|
|
460
|
+
f"Model does not have the method '{infer_method_name}' to infer the schema."
|
|
461
|
+
)
|
|
462
|
+
model_infer_method = getattr(model, infer_method_name)
|
|
463
|
+
model_output = model_infer_method(model_input)
|
|
464
|
+
|
|
465
|
+
model_signature = infer_signature(
|
|
466
|
+
model_input=model_input, model_output=model_output
|
|
467
|
+
)
|
|
468
|
+
model_signature_json = model_signature.to_dict()
|
|
469
|
+
return autogen_artifacts.SklearnModelSchema(
|
|
470
|
+
infer_method_name=infer_method_name,
|
|
471
|
+
inputs=json.loads(model_signature_json["inputs"]),
|
|
472
|
+
outputs=json.loads(model_signature_json["outputs"]),
|
|
473
|
+
)
|
|
@@ -26,7 +26,7 @@ truefoundry/autodeploy/utils/pydantic_compat.py,sha256=hEAUy5kLjhPdzw7yGZ2iXGMXb
|
|
|
26
26
|
truefoundry/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
27
|
truefoundry/cli/__main__.py,sha256=-NkhYlT3mC5MhtekueKAvCw-sWvguj0LJRpXWzvvFjc,727
|
|
28
28
|
truefoundry/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
-
truefoundry/common/auth_service_client.py,sha256=
|
|
29
|
+
truefoundry/common/auth_service_client.py,sha256=RRiGUqITxeVYwKZLc923zJP-61UAvFtVlMaG2HJBvXc,7940
|
|
30
30
|
truefoundry/common/constants.py,sha256=OwT8CJxGDhnrfgXCiKG5d5pkGbrd1UGGY-y672Et07Y,2310
|
|
31
31
|
truefoundry/common/credential_file_manager.py,sha256=1yEk1Zm2xS4G0VDFwKSZ4w0VUrcPWQ1nJnoBaz9xyKA,4251
|
|
32
32
|
truefoundry/common/credential_provider.py,sha256=Aht7hFLsnyRgMR34dRbzln7dor0WYSeA8ej8ApNmnKM,4148
|
|
@@ -107,11 +107,11 @@ 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=
|
|
110
|
+
truefoundry/ml/__init__.py,sha256=VtP0B3DNFFV_1b4WHkAo_XRMvWHmyeEwDu984t4cy8s,2040
|
|
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
|
|
114
|
-
truefoundry/ml/autogen/client/__init__.py,sha256=
|
|
114
|
+
truefoundry/ml/autogen/client/__init__.py,sha256=uf2QeBvpQi38iGSPkAmSRki2b8nJIBx-3AnJOo9_mHM,19571
|
|
115
115
|
truefoundry/ml/autogen/client/api/__init__.py,sha256=NyMBxBmIzB1o5LzZZwz9LiydHB3-hPqc_sevsnY6Jrw,746
|
|
116
116
|
truefoundry/ml/autogen/client/api/auth_api.py,sha256=zpWzJhUmW6HHMY_atlUf0B25k77E1kue2hmix5I5Ih0,7017
|
|
117
117
|
truefoundry/ml/autogen/client/api/deprecated_api.py,sha256=mu5x_skNcwz8v1Tr6VP72-tVP7pmBV9muyKy_2NH3F0,38824
|
|
@@ -126,7 +126,7 @@ truefoundry/ml/autogen/client/api_client.py,sha256=M31IycWorn10FYS8WbO_Whaipr0tV
|
|
|
126
126
|
truefoundry/ml/autogen/client/api_response.py,sha256=KRyvecPMXF05PaxILHZ8JHoP4rgKBjKONMgG83aU-rM,844
|
|
127
127
|
truefoundry/ml/autogen/client/configuration.py,sha256=V1oaEnxt-NfpaNmp-EZpf2glovzVhM2coWYt8HBNB4M,15723
|
|
128
128
|
truefoundry/ml/autogen/client/exceptions.py,sha256=XbCbDHhYT3BVejdoGNPgEa4oS56ypkwFdxk1iOc_tFY,5355
|
|
129
|
-
truefoundry/ml/autogen/client/models/__init__.py,sha256=
|
|
129
|
+
truefoundry/ml/autogen/client/models/__init__.py,sha256=iX7kGG97Ly93SQfSwFFbggcXAf2OnO9ubNPl0OhN7W4,18193
|
|
130
130
|
truefoundry/ml/autogen/client/models/add_custom_metrics_to_model_version_request_dto.py,sha256=_ISDspicTGjBCYYXubKfRYYSSQVyW3AvG-jFh47-Zfc,2163
|
|
131
131
|
truefoundry/ml/autogen/client/models/add_features_to_model_version_request_dto.py,sha256=OT1-98DyWNfAHz_EgD2gMX2XkrGQ4Re945fhoAl8qSE,2099
|
|
132
132
|
truefoundry/ml/autogen/client/models/agent.py,sha256=lUAbs092yo9hZmqzX6atKebDNf1uEwTf5jLvjOdvoeM,3872
|
|
@@ -206,7 +206,7 @@ truefoundry/ml/autogen/client/models/h2_o_framework.py,sha256=5X-0Xbt4tpecV_q6Ww
|
|
|
206
206
|
truefoundry/ml/autogen/client/models/http_validation_error.py,sha256=bU-uUlz_qeFba3iHdBT7cHjLu6WZ-JmImYqgZ-kCvxM,2466
|
|
207
207
|
truefoundry/ml/autogen/client/models/image_content_part.py,sha256=m_LE5XqD_UD0f8jtWt0adRgz_FoLEvgZbCDTSYORnCc,2717
|
|
208
208
|
truefoundry/ml/autogen/client/models/image_url.py,sha256=TN8iEdBUmtKdTFlApUodaC4o6X_Ggd3OSOKVPv7laJE,2170
|
|
209
|
-
truefoundry/ml/autogen/client/models/infer_method_name.py,sha256=
|
|
209
|
+
truefoundry/ml/autogen/client/models/infer_method_name.py,sha256=Cpg3aRGrZCG_6JypR0RMvH0cUqRvpMXxr9rabUGxFuY,788
|
|
210
210
|
truefoundry/ml/autogen/client/models/internal_metadata.py,sha256=6OizrIzA3QxlEnwNFXCZGOMJuUDSYHctl_30q27uBDI,6232
|
|
211
211
|
truefoundry/ml/autogen/client/models/keras_framework.py,sha256=sBKDT4Dzkvr3Rf7c8YKRbtzaO_KrPNsW8tdWI_n701Q,2150
|
|
212
212
|
truefoundry/ml/autogen/client/models/latest_run_log_dto.py,sha256=wE8T8bANTb9u14Jv7DNyKWekZiUAvrzvTcE_H1cRhn4,2326
|
|
@@ -247,7 +247,7 @@ truefoundry/ml/autogen/client/models/model_response_dto.py,sha256=osrTxfygkuhxWj
|
|
|
247
247
|
truefoundry/ml/autogen/client/models/model_server.py,sha256=N5mcWmnX0KzTMtTH8A9h_FmiQcMld3B8CXD_UYeDKaA,700
|
|
248
248
|
truefoundry/ml/autogen/client/models/model_version_dto.py,sha256=9Mh4d8V33gEGYr4sys5lYYDA3bHKajR3oAZLZMAy_io,7094
|
|
249
249
|
truefoundry/ml/autogen/client/models/model_version_environment.py,sha256=wTayQjMen24eJCqXQugzoXLANY5NXdVsAvZSh-QIhJA,2827
|
|
250
|
-
truefoundry/ml/autogen/client/models/model_version_manifest.py,sha256=
|
|
250
|
+
truefoundry/ml/autogen/client/models/model_version_manifest.py,sha256=gRsrZzfLm1cHk5cbHmYQtShXGLLxPKcxRMPDWCqWTZc,4657
|
|
251
251
|
truefoundry/ml/autogen/client/models/model_version_response_dto.py,sha256=D6XOCyggxqTkbePuypqYSHYh1PYeDv7R_J32q61sDM0,2320
|
|
252
252
|
truefoundry/ml/autogen/client/models/multi_part_upload_dto.py,sha256=Ckq405vud8RQmMyKCJQJBlW5iXO7Y2mlgo8eVkiMvxg,3738
|
|
253
253
|
truefoundry/ml/autogen/client/models/multi_part_upload_response_dto.py,sha256=VjH0kvl7rMjgDHjYGHnsh7KsZ5-qn-k3ksdGLJ49nIM,2431
|
|
@@ -274,7 +274,8 @@ truefoundry/ml/autogen/client/models/serialization_format.py,sha256=CYq9DR1yipEG
|
|
|
274
274
|
truefoundry/ml/autogen/client/models/set_experiment_tag_request_dto.py,sha256=nrmi_NxLD1fI2gwlpdqFSMnBS11gRkjS4_GQFHgBcXs,2118
|
|
275
275
|
truefoundry/ml/autogen/client/models/set_tag_request_dto.py,sha256=IRgAdMcWBxmjNV6nZJej4pcNfLmZwrelEZ3otwt7eeE,2144
|
|
276
276
|
truefoundry/ml/autogen/client/models/signed_url_dto.py,sha256=9oHoXBj07xTdc04rqOqJO3eOjQWXCyWPhfHg-6qX60w,1897
|
|
277
|
-
truefoundry/ml/autogen/client/models/sklearn_framework.py,sha256=
|
|
277
|
+
truefoundry/ml/autogen/client/models/sklearn_framework.py,sha256=eWpv-CNyxsD9pIBKga568DpQvCn5Nn_GvNMzY1ElRW4,3424
|
|
278
|
+
truefoundry/ml/autogen/client/models/sklearn_model_schema.py,sha256=RJIbkzvIDxkFTyygQLvUfeg7sCrkhwm9Euo7FaNnrLw,2526
|
|
278
279
|
truefoundry/ml/autogen/client/models/source.py,sha256=ZG2-3oIs_M8mZNPjoIRPzhHqlm63vLCVQC9idUxQ0XU,5180
|
|
279
280
|
truefoundry/ml/autogen/client/models/source1.py,sha256=io35b9uVzqSvOHw6RlCXxM30thN-vHm1upaSiN2i0II,5183
|
|
280
281
|
truefoundry/ml/autogen/client/models/spa_cy_framework.py,sha256=Kyrvhdalnl1uQLoPMGMry2PuFGCcQ8AGp4Cx4B9AGXQ,2150
|
|
@@ -301,15 +302,16 @@ truefoundry/ml/autogen/client/models/url.py,sha256=zMyOmdVkp1ANnQnc9GrHt42xlVwES
|
|
|
301
302
|
truefoundry/ml/autogen/client/models/user_message.py,sha256=3TEM8qH_zT3dgM197bl44uV7m20IWn6sWeLGfStsN90,2784
|
|
302
303
|
truefoundry/ml/autogen/client/models/validation_error.py,sha256=mFjwoc8g2-Usu1HXZhOQKQ4TGvLy4lwCzk8dHrJ69aA,2597
|
|
303
304
|
truefoundry/ml/autogen/client/models/validation_error_loc_inner.py,sha256=nThJ5Gmy8W2Wok-ZOI4sK7uRe1BAkLS0qzq-XZbq8zs,4915
|
|
304
|
-
truefoundry/ml/autogen/client/models/xg_boost_framework.py,sha256=
|
|
305
|
+
truefoundry/ml/autogen/client/models/xg_boost_framework.py,sha256=ZTvdmfX5eB_ZbA7Yy62NYAzbYKOQkPtA-zF5xxRnVfE,3429
|
|
306
|
+
truefoundry/ml/autogen/client/models/xg_boost_model_schema.py,sha256=5bzi5NEeR9HetiHFJwwkmeC4LE2WvGF9hp9dTLPfEJ4,2526
|
|
305
307
|
truefoundry/ml/autogen/client/rest.py,sha256=9goba8qHjQuVx5O_yRaTKu7PvBnb7r7swfy3dwuTEgk,14281
|
|
306
|
-
truefoundry/ml/autogen/client_README.md,sha256=
|
|
307
|
-
truefoundry/ml/autogen/entities/artifacts.py,sha256=
|
|
308
|
+
truefoundry/ml/autogen/client_README.md,sha256=8M-8txeNhpwAiXx7z5UEjPYSq2SoqA1EqtCkkKZDCMc,36276
|
|
309
|
+
truefoundry/ml/autogen/entities/artifacts.py,sha256=x3DxHXPS5OpNb1vmuy6p44g2hymq6BXnivFqv6mQ-ds,20113
|
|
308
310
|
truefoundry/ml/autogen/models/__init__.py,sha256=--TGRea9SQBWFfwtcl3ekb1XGfFTdEkQGSG8a2SJ60I,187
|
|
309
311
|
truefoundry/ml/autogen/models/exceptions.py,sha256=q3n7FGBrg_hUy1UyoefhMnhcXUAaqXlLIGHoOVzn_d8,1390
|
|
310
312
|
truefoundry/ml/autogen/models/schema.py,sha256=IhpO9qbygLqEamP3NIt3m90SseJXCOm1ZTqNbNbW-M0,55772
|
|
311
|
-
truefoundry/ml/autogen/models/signature.py,sha256=
|
|
312
|
-
truefoundry/ml/autogen/models/utils.py,sha256=
|
|
313
|
+
truefoundry/ml/autogen/models/signature.py,sha256=rBjpxUIsEeWM0sIyYG5uCJB18DKHR4k5yZw8TzuoP48,4987
|
|
314
|
+
truefoundry/ml/autogen/models/utils.py,sha256=c7RtSLXhOLcP8rjuUtfnMdaKVTZvvbsmw98gPAkAFrs,24371
|
|
313
315
|
truefoundry/ml/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
314
316
|
truefoundry/ml/cli/cli.py,sha256=ckBcjUpqfhgrPE1okqT_G2iouOLt-0KjpLhHp2YdVFU,256
|
|
315
317
|
truefoundry/ml/cli/commands/__init__.py,sha256=diDUiRUX4l6TtNLI4iF-ZblczkELM7FRViJ-8gGNJQY,82
|
|
@@ -331,7 +333,7 @@ truefoundry/ml/log_types/artifacts/artifact.py,sha256=6X4lO23DwM7yTgUOY4RRoYMrf9
|
|
|
331
333
|
truefoundry/ml/log_types/artifacts/constants.py,sha256=qKxQ5mMvJE4j83BvGW3qNTKunxCiBg_EEjTdgbgJtyE,1036
|
|
332
334
|
truefoundry/ml/log_types/artifacts/dataset.py,sha256=a4dxd2EN8p7Ci-cLGGiDOboN3t0395_XhWE1dmTw1Q4,13112
|
|
333
335
|
truefoundry/ml/log_types/artifacts/general_artifact.py,sha256=B4XErLr-m6RmQWtxMTu3wlFRFcqSwPYp6J0OL4Ng6L0,3179
|
|
334
|
-
truefoundry/ml/log_types/artifacts/model.py,sha256=
|
|
336
|
+
truefoundry/ml/log_types/artifacts/model.py,sha256=sOqMptIpr2YRv7VC6AntFDvDUg5eQLsS7jQ_4TUB5Ds,22724
|
|
335
337
|
truefoundry/ml/log_types/artifacts/utils.py,sha256=yhIZYe3Y-J0rG0Wcwql_Qjxe9hlefFbXUfRFqg4E9cM,7502
|
|
336
338
|
truefoundry/ml/log_types/image/__init__.py,sha256=fcOq8yQnNj1rkLcPeIjLXBpdA1WIeiPsXOlAAvMxx7M,76
|
|
337
339
|
truefoundry/ml/log_types/image/constants.py,sha256=wLtGEOA4T5fZHSlOXPuNDLX3lpbCtwlvGKPFk_1fah0,255
|
|
@@ -342,9 +344,9 @@ truefoundry/ml/log_types/plot.py,sha256=HuYvvRA5r8V0xAIuuqMME2IHb9d3SfGHUiuEkOP3
|
|
|
342
344
|
truefoundry/ml/log_types/pydantic_base.py,sha256=eBlw_AEyAz4iJKDP4zgJOCFWcldwQqpf7FADW1jzIQY,272
|
|
343
345
|
truefoundry/ml/log_types/utils.py,sha256=xjJ21jdPScvFmw3TbVh5NCzbzJwaqiXJyiiT4xxX1EI,335
|
|
344
346
|
truefoundry/ml/logger.py,sha256=VT-BF3BnBYTWVq87O58F0c8uXMu94gYzsiFlGY3_7Ao,458
|
|
345
|
-
truefoundry/ml/mlfoundry_api.py,sha256=
|
|
346
|
-
truefoundry/ml/mlfoundry_run.py,sha256=
|
|
347
|
-
truefoundry/ml/model_framework.py,sha256=
|
|
347
|
+
truefoundry/ml/mlfoundry_api.py,sha256=PefznXwBPBv8TD4RYid9aiE8WWEkZQAHoaAbvklFoRs,62364
|
|
348
|
+
truefoundry/ml/mlfoundry_run.py,sha256=RLTZGz3htyxNmG1Xat9WevawEIjDoUCbWrSNql8WynI,44597
|
|
349
|
+
truefoundry/ml/model_framework.py,sha256=I04pbczUh6bBmxWI-fzWgpUSY_ab7Js2zDB6fX4zvYM,16458
|
|
348
350
|
truefoundry/ml/run_utils.py,sha256=0W208wSLUrbdfk2pjNcZlkUi9bNxG2JORqoe-5rVqHI,2423
|
|
349
351
|
truefoundry/ml/session.py,sha256=F83GTC5WwGBjnJ69Ct8MqMnlutYc56JCc6YhEY1Wl-A,5394
|
|
350
352
|
truefoundry/ml/validation_utils.py,sha256=J5atNhcJLvKj64ralSV9Y5Fv1Rt4SE237ICdP9-7sP4,12149
|
|
@@ -365,7 +367,7 @@ truefoundry/workflow/remote_filesystem/tfy_signed_url_client.py,sha256=5mBCIc-ON
|
|
|
365
367
|
truefoundry/workflow/remote_filesystem/tfy_signed_url_fs.py,sha256=Hf6Dk6Fu6P7DqsK5ULgraf9DStjgigf-kjaRAMBW-RU,8680
|
|
366
368
|
truefoundry/workflow/task.py,sha256=ToitYiKcNzFCtOVQwz1W8sRjbR97eVS7vQBdbgUQtKg,1779
|
|
367
369
|
truefoundry/workflow/workflow.py,sha256=WaTqUjhwfAXDWu4E5ehuwAxrCbDJkoAf1oWmR2E9Qy0,4575
|
|
368
|
-
truefoundry-0.5.
|
|
369
|
-
truefoundry-0.5.
|
|
370
|
-
truefoundry-0.5.
|
|
371
|
-
truefoundry-0.5.
|
|
370
|
+
truefoundry-0.5.1rc4.dist-info/METADATA,sha256=Ue5yEWML5oNGt2BGDDCq3YHVdj5hP1smJEUv3hMLbT8,2887
|
|
371
|
+
truefoundry-0.5.1rc4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
372
|
+
truefoundry-0.5.1rc4.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
|
|
373
|
+
truefoundry-0.5.1rc4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|