fiddler-client 2.1.0.dev2__py3-none-any.whl → 2.1.0.dev4__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.
fiddler/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '2.1.0.dev2'
1
+ __version__ = '2.1.0.dev4'
@@ -1,5 +1,5 @@
1
1
  from http import HTTPStatus
2
- from typing import List
2
+ from typing import List, Optional
3
3
 
4
4
  from pydantic import parse_obj_as
5
5
 
@@ -22,7 +22,12 @@ class CustomMetricsMixin:
22
22
 
23
23
  @handle_api_error_response
24
24
  def add_custom_metric(
25
- self, name: str, project_id: str, model_id: str, fql: str
25
+ self,
26
+ name: str,
27
+ project_id: str,
28
+ model_id: str,
29
+ definition: str,
30
+ description: Optional[str] = None,
26
31
  ) -> CustomMetric:
27
32
  """
28
33
  Add a new `Custom Metric`.
@@ -30,7 +35,8 @@ class CustomMetricsMixin:
30
35
  :params name: name of custom metric
31
36
  :params project_id: name of project
32
37
  :params model_id: name of model
33
- :params fql: The FQL expression describing the metric
38
+ :params definition: The FQL expression describing the metric
39
+ :params description: description of custom metric
34
40
 
35
41
  :returns: Created `CustomMetric` object.
36
42
  """
@@ -39,7 +45,8 @@ class CustomMetricsMixin:
39
45
  'project_name': project_id,
40
46
  'model_name': model_id,
41
47
  'name': name,
42
- 'fql': fql,
48
+ 'definition': definition,
49
+ 'description': description,
43
50
  }
44
51
  response = self.client.post(
45
52
  url='custom-metrics',
@@ -51,7 +58,7 @@ class CustomMetricsMixin:
51
58
  return CustomMetric.parse_obj(attrs)
52
59
 
53
60
  @handle_api_error_response
54
- def delete_custom_metric(self, metric_id: str = None) -> None:
61
+ def delete_custom_metric(self, metric_id: str) -> None:
55
62
  """
56
63
  Delete a custom metric
57
64
 
@@ -95,3 +102,15 @@ class CustomMetricsMixin:
95
102
  )
96
103
  items = PaginatedResponseHandler(response).get_pagination_items()
97
104
  return parse_obj_as(List[CustomMetric], items)
105
+
106
+ @handle_api_error_response
107
+ def get_custom_metric(self, metric_id: str) -> CustomMetric:
108
+ """
109
+ Get a `CustomMetric` object.
110
+
111
+ :params metric_id: id of the custom metric
112
+
113
+ :returns: a `CustomMetric` object
114
+ """
115
+ response = self.client.get(url=f'custom-metrics/{metric_id}')
116
+ return CustomMetric.deserialize(APIResponseHandler(response))
@@ -1,4 +1,8 @@
1
+ from typing import Optional
2
+
1
3
  from fiddler.schema.base import BaseDataSchema
4
+ from fiddler.schema.user import UserCompact
5
+ from datetime import datetime
2
6
 
3
7
 
4
8
  class CustomMetric(BaseDataSchema):
@@ -7,4 +11,8 @@ class CustomMetric(BaseDataSchema):
7
11
  project_name: str
8
12
  organization_name: str
9
13
  name: str
10
- fql: str
14
+ definition: str
15
+ description: Optional[str]
16
+ created_at: Optional[datetime]
17
+ created_by: Optional[UserCompact]
18
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fiddler-client
3
- Version: 2.1.0.dev2
3
+ Version: 2.1.0.dev4
4
4
  Summary: Python client for Fiddler Service
5
5
  Home-page: https://fiddler.ai
6
6
  Author: Fiddler Labs
@@ -14,7 +14,7 @@ Description-Content-Type: text/markdown
14
14
  Requires-Dist: deprecated (==1.2.13)
15
15
  Requires-Dist: pandas (>=1.2.5)
16
16
  Requires-Dist: pip (>=21.0)
17
- Requires-Dist: pyarrow (>=12.0.1)
17
+ Requires-Dist: pyarrow (>=13.0.0)
18
18
  Requires-Dist: pydantic (==1.9.0)
19
19
  Requires-Dist: pyyaml
20
20
  Requires-Dist: requests-toolbelt
@@ -48,8 +48,22 @@ Version History
48
48
  - #### **New Features**
49
49
  - Introduce Model Tasks `NOT_SET` and `LLM`
50
50
  - Relax Target / Output specification for model tasks `NOT_SET` and `LLM`
51
+ - Support custom metrics
51
52
 
52
- ### 2.0.0
53
+ ### 2.0.4
54
+ - #### **Modifications**
55
+ - Update `pyarrow` requirement to `13.0.0`.
56
+
57
+ ### 2.0.3
58
+ - #### **Modifications**
59
+ - Relax pandas version for 2.0.
60
+ - get_slice() `query` parameter reverted to `sql_query`
61
+
62
+ ### 2.0.2
63
+ - #### **Modifications**
64
+ - Fix Parquet conversion issue in `upload_dataset` and `publish_event_batch`
65
+
66
+ ### 2.0.1
53
67
  - #### **Removed**
54
68
  - Following methods are removed
55
69
  - register_model
@@ -66,16 +80,24 @@ Version History
66
80
  - process_avro
67
81
  - process_csv
68
82
  - #### **New Features**
69
- - Add `monitor_components` as an attribute of `CustomFeature`. Default to `False`
83
+ - Add `monitor_components` as an attribute for `CustomFeature` of type `FROM_COLUMNS`. Default as `False`
84
+ - Adds new statistic type `SUM` to supported alert metrics
85
+ - Support `CustomFeature` of type `FROM_VECTOR` `FROM_TEXT_EMBEDDING` and `FROM_IMAGE_EMBEDDING`
86
+ - #### **Modificatiosn**
70
87
  - Remove `column` as a parameter in `add_alert_rule` and `get_alert_rules` functions
71
- - Adds new statistic type SUM to supported alert metrics
88
+ - Default `FileType` Parquet in `upload_dataset` and `publish_event_batch`
89
+ - get_slice() `sql_query` parameter changed to `query`
90
+
91
+ ### 1.8.6
92
+ - #### **Modifications**
93
+ - Relax pandas version for 2.0.
72
94
 
73
95
  ### 1.8.4
74
96
  - #### **New Features**
75
- - New DeploymentType enum for MANUAL deployment
97
+ - New DeploymentType enum for `MANUAL` deployment
76
98
 
77
99
  ### 1.8.3
78
- - ### **Modifications**
100
+ - #### **Modifications**
79
101
  - New `columns` parameter in add_alert_rule and get_alert_rules to support multiple columns to be used for server version >= 23.3.0
80
102
  - get_triggered_alerts supports `alert_value` as a float as well as a dict
81
103
 
@@ -1,5 +1,5 @@
1
1
  fiddler/__init__.py,sha256=N0S2NzC1P0Dl7SE9IRRzJpSDvyyqT9Pmlk2SaW24NGc,2018
2
- fiddler/_version.py,sha256=wNJAWxZJ5nqnvr7CcRnjak-Pcnydu3AaK30sXJNnIZU,27
2
+ fiddler/_version.py,sha256=RShHDU6VmHiby-18I-reafFfkORbcfCW2afHTL4C6MY,27
3
3
  fiddler/constants.py,sha256=kXJX771B9UoQKh-umPnPfDXGeCRdC8TmTAi40hSK0Cs,1886
4
4
  fiddler/core_objects.py,sha256=Qe8wxak6tfn9rpIb7jdN5tXYpUJs_sJHPMGf9cDg6MU,114079
5
5
  fiddler/exceptions.py,sha256=vjdZ0v51NAy_pPcj_MaD4o5y-lUToHeids-waTfZb8k,2557
@@ -7,7 +7,7 @@ fiddler/api/__init__.py,sha256=Na9WlUxg8FmKHBzzVJ-CzlYNm7-LClVH5f313SqJx4A,108
7
7
  fiddler/api/alert_mixin.py,sha256=lBc08-wcvF3bO_XdcVSXqmgR9i54UtKwUCn56brokCw,17873
8
8
  fiddler/api/api.py,sha256=pR5eE7Vq5OWGom8MZmZkkU2bmVOznJ45jiB4pwnXd6g,3506
9
9
  fiddler/api/baseline_mixin.py,sha256=2DKur2oIrn0TNTQPbpwSMyC1WOzhScHXWwX8QK8ubig,6810
10
- fiddler/api/custom_metrics_mixin.py,sha256=S5TIg4BW-CZecYbJDKyMS3EuPJj9edG3aype5TF-bHE,2861
10
+ fiddler/api/custom_metrics_mixin.py,sha256=7fpZx_4jSzhELbU1TYyvgDqP8NUMg62NWqlgRwKjkDQ,3459
11
11
  fiddler/api/dataset_mixin.py,sha256=cN5GfOTX5uOKzmvxHj-uLuv049EI_BQqhJ6uw1VX-7o,15319
12
12
  fiddler/api/events_mixin.py,sha256=RiKwS-EDE0SJKS-rgYd13Bav1wStyM0r29FA0WHi48I,22009
13
13
  fiddler/api/explainability_mixin.py,sha256=W2GLDfSYaxe06VS9_ZGQmPfFzkwPcWtrt5JIyJ23ZxY,15405
@@ -32,7 +32,7 @@ fiddler/schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  fiddler/schema/alert.py,sha256=aC96q5nDBVuR4nqPbWSgQ0nLRgGLtyCmnGerbLwfsFE,5230
33
33
  fiddler/schema/base.py,sha256=VvuBEGZ_AMVQhT6AlkV7kMlOQcwsMbLIjvX0_cyMcQQ,359
34
34
  fiddler/schema/baseline.py,sha256=h8SyR32L1AMo2DrcwgEOqWN-U538-XFngjAtQQfMklI,487
35
- fiddler/schema/custom_metric.py,sha256=u-RNI33YB6lWR8arQ1yO7Bw_5sw72sVkZkQvLscORUc,187
35
+ fiddler/schema/custom_metric.py,sha256=bLoOVoF6nRMLLv5cekTTalGXHm1KOZRzNMpYp7c81gs,402
36
36
  fiddler/schema/dataset.py,sha256=JVeLXyqlEgiqYVX7fVkk0bLzXSRkKSTuoAsK3tnvR-s,3259
37
37
  fiddler/schema/events.py,sha256=QvCuXWH-quT-MVzMU8-CvQM2rRgNcvGAof4v_RiiqZk,879
38
38
  fiddler/schema/job.py,sha256=mDQ3ZevsFT2ZW1wri9BeQSiB7G4ZyoA_3tzuoBvl5ow,157
@@ -72,7 +72,7 @@ tests/fiddler/test_alert.py,sha256=vM8MRsTsV9zovFiUYN2pXwEcH453EN2HHIoGV_i7cx4,5
72
72
  tests/fiddler/test_baseline.py,sha256=V7VFg2hqAC98cdZCsoqcNcKouDlQdHMdpifqcwJyYOM,10077
73
73
  tests/fiddler/test_check_version_decorator.py,sha256=MGcrIX7nscVpIYy1thuLrSvsXBC6KDXfdsHCEST5Xnw,906
74
74
  tests/fiddler/test_custom_features.py,sha256=yjz-5Aq_Ey7FoDJiIzugLPcbh_5QdazE6trwpT38rEw,3028
75
- tests/fiddler/test_custom_metrics.py,sha256=aXS0jLkO3MT-DUw040-iJjfZkLthSNr3orpIiQOvpXw,5039
75
+ tests/fiddler/test_custom_metrics.py,sha256=txNS-RTltdAublF0xWhkS_YOgdu-C6AxRKubFpYR8ds,8103
76
76
  tests/fiddler/test_dataset_api.py,sha256=XrSsyhJubBUKEjl6qHSDBE9_-VnHOCgiL0Mq12IZav0,6306
77
77
  tests/fiddler/test_events_api.py,sha256=l41OGatQzNCc95qvLXOpcQ0r7IPRw-N1Uw_bEkRZhf0,11770
78
78
  tests/fiddler/test_exceptions.py,sha256=3dUe85gqf8MVxEM_9D1wrNRU8jvmu1-ja36jaDKgOQk,2801
@@ -91,8 +91,8 @@ tests/fiddler/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
91
91
  tests/fiddler/utils/test_general_checks.py,sha256=kxG8n4UdBWXBGchA0SvV7o4t28a7YAc8viorEBpzzcE,1451
92
92
  tests/fiddler/utils/test_pandas.py,sha256=ihNRe9mCteqeV70o-zWEf62fJHL3qE8nDIijYlUEHv4,8825
93
93
  tests/fiddler/utils/tests_utils.py,sha256=kPmMoOlaSIWw6Gk7QnAnn8QJvEyqtd2Rz32kS6RGEc8,1800
94
- fiddler_client-2.1.0.dev2.dist-info/LICENSE.txt,sha256=w8-LUAb_VLBWSsCNmih0pAqLIicJfGu8OJXpDjkIg_o,559
95
- fiddler_client-2.1.0.dev2.dist-info/METADATA,sha256=0p9S-QYPUpqiHYNtIw089F-SWJPVnlk8zEMwDN1bdz8,18143
96
- fiddler_client-2.1.0.dev2.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
97
- fiddler_client-2.1.0.dev2.dist-info/top_level.txt,sha256=GdJimrE4Q9O20-dA6QljDHm5KBrlz25oQTdbMHu41So,14
98
- fiddler_client-2.1.0.dev2.dist-info/RECORD,,
94
+ fiddler_client-2.1.0.dev4.dist-info/LICENSE.txt,sha256=w8-LUAb_VLBWSsCNmih0pAqLIicJfGu8OJXpDjkIg_o,559
95
+ fiddler_client-2.1.0.dev4.dist-info/METADATA,sha256=BSvVWbPFKm9zuQkffazhM26k4SjqfeX5jMfxuhKJ2zQ,18875
96
+ fiddler_client-2.1.0.dev4.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
97
+ fiddler_client-2.1.0.dev4.dist-info/top_level.txt,sha256=GdJimrE4Q9O20-dA6QljDHm5KBrlz25oQTdbMHu41So,14
98
+ fiddler_client-2.1.0.dev4.dist-info/RECORD,,
@@ -27,17 +27,32 @@ class TestCustomMetric(BaseTestCase):
27
27
  "project_name": "bank_churn",
28
28
  "name": "tp_0.8",
29
29
  "model_name": "churn_classifier",
30
- "fql": "sum(age)",
30
+ "definition": "sum(age)",
31
31
  "id": "fbba0596-1d49-4159-a5ea-e1c2f57c9c32",
32
- "organization_name": "test_organization"
32
+ "organization_name": "test_organization",
33
+ "description": "test description",
34
+ "extra_field_from_future": "should_not_break",
35
+ "created_at": "2021-03-03T18:30:00.000Z",
36
+ "created_by": {
37
+ "id": "1",
38
+ "full_name": "test user",
39
+ "email": "testuser@fiddler.ai"
40
+ }
33
41
  },
34
42
  {
35
43
  "project_name": "bank_churn",
36
44
  "name": "tp_0.6",
37
45
  "model_name": "churn_classifier",
38
- "fql": "sum(credit_score)",
46
+ "definition": "sum(credit_score)",
39
47
  "id": "3a352397-a89a-495d-a095-440f1d21a58a",
40
- "organization_name": "test_organization"
48
+ "organization_name": "test_organization",
49
+ "description": "test description",
50
+ "created_at": "2021-03-03T18:30:00.000Z",
51
+ "created_by": {
52
+ "id": "2",
53
+ "full_name": "test user",
54
+ "email": "testuser@fiddler.ai"
55
+ }
41
56
  }
42
57
  ]
43
58
  },
@@ -65,18 +80,32 @@ class TestCustomMetric(BaseTestCase):
65
80
  CustomMetric(
66
81
  id='fbba0596-1d49-4159-a5ea-e1c2f57c9c32',
67
82
  name='tp_0.8',
68
- fql='sum(age)',
83
+ definition='sum(age)',
69
84
  organization_name='test_organization',
70
85
  project_name='bank_churn',
71
86
  model_name='churn_classifier',
87
+ description='test description',
88
+ created_at='2021-03-03T18:30:00.000Z',
89
+ created_by={
90
+ "id": "1",
91
+ "full_name": "test user",
92
+ "email": "testuser@fiddler.ai"
93
+ }
72
94
  ),
73
95
  CustomMetric(
74
96
  id='3a352397-a89a-495d-a095-440f1d21a58a',
75
97
  name='tp_0.6',
76
- fql='sum(credit_score)',
98
+ definition='sum(credit_score)',
77
99
  organization_name='test_organization',
78
100
  project_name='bank_churn',
79
101
  model_name='churn_classifier',
102
+ description='test description',
103
+ created_at='2021-03-03T18:30:00.000Z',
104
+ created_by={
105
+ "id": "2",
106
+ "full_name": "test user",
107
+ "email": "testuser@fiddler.ai"
108
+ }
80
109
  ),
81
110
  ]
82
111
 
@@ -95,17 +124,19 @@ class TestCustomMetric(BaseTestCase):
95
124
 
96
125
  custom_metric = self.client.add_custom_metric(
97
126
  name='my custom',
98
- fql='sum(age)',
127
+ definition='sum(age)',
99
128
  project_id='bank_churn',
100
129
  model_id='churn_classifier',
130
+ description='test description',
101
131
  )
102
132
  assert custom_metric == CustomMetric(
103
133
  id='fbba0596-1d49-4159-a5ea-e1c2f57c9c32',
104
134
  name='my custom',
105
- fql='sum(age)',
135
+ definition='sum(age)',
106
136
  organization_name='test_organization',
107
137
  project_name='bank_churn',
108
138
  model_name='churn_classifier',
139
+ description='test description',
109
140
  )
110
141
 
111
142
  def test_add_custom_metric_error(self):
@@ -131,7 +162,7 @@ class TestCustomMetric(BaseTestCase):
131
162
  with self.assertRaises(BadRequest) as context:
132
163
  self.client.add_custom_metric(
133
164
  name='my custom',
134
- fql='sum(unknown)',
165
+ definition='sum(unknown)',
135
166
  project_id='bank_churn',
136
167
  model_id='churn_classifier',
137
168
  )
@@ -140,6 +171,50 @@ class TestCustomMetric(BaseTestCase):
140
171
  "Column unknown not found in model churn_classifier"
141
172
  )
142
173
 
174
+ def test_get_custom_metric(self):
175
+ uuid = 'fbba0596-1d49-4159-a5ea-e1c2f57c9c32'
176
+ response = {
177
+ "data": {
178
+ "project_name": "bank_churn",
179
+ "name": "tp_0.8",
180
+ "model_name": "churn_classifier",
181
+ "definition": "sum(age)",
182
+ "id": "fbba0596-1d49-4159-a5ea-e1c2f57c9c32",
183
+ "organization_name": "test_organization",
184
+ "description": "test description",
185
+ "extra_field_from_future": "should_not_break",
186
+ "created_at": "2021-03-03T18:30:00.000Z",
187
+ "created_by": {
188
+ "id": "1",
189
+ "full_name": "test user",
190
+ "email": "testuser@fiddler.ai"
191
+ }
192
+ },
193
+ "api_version": "2.0",
194
+ "kind": "NORMAL"
195
+ }
196
+ url = self._get_url(uuid)
197
+
198
+ self.requests_mock.get(url, json=response)
199
+ cm = self.client.get_custom_metric(
200
+ metric_id='fbba0596-1d49-4159-a5ea-e1c2f57c9c32'
201
+ )
202
+ assert cm == CustomMetric(
203
+ id='fbba0596-1d49-4159-a5ea-e1c2f57c9c32',
204
+ name='tp_0.8',
205
+ definition='sum(age)',
206
+ organization_name='test_organization',
207
+ project_name='bank_churn',
208
+ model_name='churn_classifier',
209
+ description='test description',
210
+ created_at='2021-03-03T18:30:00.000Z',
211
+ created_by={
212
+ "id": "1",
213
+ "full_name": "test user",
214
+ "email": "testuser@fiddler.ai"
215
+ }
216
+ )
217
+
143
218
  def test_delete_custom_metric(self):
144
219
  uuid = 'fbba0596-1d49-4159-a5ea-e1c2f57c9c32'
145
220
  url = self._get_url(uuid)