xplainable-client 1.2.1.post4__tar.gz → 1.2.2__tar.gz
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.
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/PKG-INFO +3 -3
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/pyproject.toml +3 -3
- xplainable_client-1.2.2/xplainable_client/client/__init__.py +33 -0
- xplainable_client-1.2.2/xplainable_client/client/_client_cog_base.py +7 -0
- xplainable_client-1.2.2/xplainable_client/client/_collections.py +213 -0
- xplainable_client-1.2.2/xplainable_client/client/_datasets.py +51 -0
- xplainable_client-1.2.2/xplainable_client/client/_deployments.py +390 -0
- xplainable_client-1.2.2/xplainable_client/client/_gpt.py +36 -0
- xplainable_client-1.2.2/xplainable_client/client/_inference.py +29 -0
- xplainable_client-1.2.2/xplainable_client/client/_misc.py +210 -0
- xplainable_client-1.2.2/xplainable_client/client/_models.py +494 -0
- xplainable_client-1.2.2/xplainable_client/client/_preprocessing.py +250 -0
- xplainable_client-1.2.2/xplainable_client/client/_session.py +108 -0
- xplainable_client-1.2.2/xplainable_client/models/ebm.py +111 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client.egg-info/PKG-INFO +3 -3
- xplainable_client-1.2.2/xplainable_client.egg-info/SOURCES.txt +25 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client.egg-info/requires.txt +2 -2
- xplainable-client-1.2.1.post4/xplainable_client/__init__.py +0 -2
- xplainable-client-1.2.1.post4/xplainable_client/client.py +0 -929
- xplainable-client-1.2.1.post4/xplainable_client/datasets.py +0 -32
- xplainable-client-1.2.1.post4/xplainable_client.egg-info/SOURCES.txt +0 -16
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/README.md +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/setup.cfg +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client/utils/__init__.py +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client/utils/encoders.py +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client/utils/exceptions.py +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client/utils/helpers.py +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client/utils/metrics.py +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client/utils/model_parsers.py +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client.egg-info/dependency_links.txt +0 -0
- {xplainable-client-1.2.1.post4 → xplainable_client-1.2.2}/xplainable_client.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xplainable-client
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: The client for persisting and deploying models to Xplainable cloud.
|
|
5
5
|
Author-email: xplainable pty ltd <contact@xplainable.io>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3.8
|
|
@@ -11,14 +11,14 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
Requires-Dist: ipywidgets==8.0.6
|
|
14
|
-
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: numpy>=1.20.3
|
|
15
15
|
Requires-Dist: pandas<=1.9.0,>=1.5.2
|
|
16
16
|
Requires-Dist: pyperclip==1.8.2
|
|
17
17
|
Requires-Dist: Requests==2.31.0
|
|
18
18
|
Requires-Dist: scikit_learn
|
|
19
19
|
Requires-Dist: setuptools
|
|
20
20
|
Requires-Dist: urllib3==2.2.0
|
|
21
|
-
Requires-Dist: xplainable
|
|
21
|
+
Requires-Dist: xplainable
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
<div align="center">
|
|
@@ -7,7 +7,7 @@ find = {}
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "xplainable-client"
|
|
10
|
-
version = "1.2.
|
|
10
|
+
version = "1.2.2"
|
|
11
11
|
authors = [
|
|
12
12
|
{ name="xplainable pty ltd", email="contact@xplainable.io" },
|
|
13
13
|
]
|
|
@@ -26,12 +26,12 @@ classifiers = [
|
|
|
26
26
|
|
|
27
27
|
dependencies = [
|
|
28
28
|
"ipywidgets==8.0.6",
|
|
29
|
-
"numpy
|
|
29
|
+
"numpy>=1.20.3",
|
|
30
30
|
"pandas>=1.5.2,<=1.9.0",
|
|
31
31
|
"pyperclip==1.8.2",
|
|
32
32
|
"Requests==2.31.0",
|
|
33
33
|
"scikit_learn",
|
|
34
34
|
"setuptools",
|
|
35
35
|
"urllib3==2.2.0",
|
|
36
|
-
"xplainable
|
|
36
|
+
"xplainable"
|
|
37
37
|
]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from .datasets import *
|
|
2
|
+
from functools import cached_property
|
|
3
|
+
|
|
4
|
+
from ._models import *
|
|
5
|
+
from ._misc import *
|
|
6
|
+
from requests.packages.urllib3.util.retry import Retry
|
|
7
|
+
from ._session import Session
|
|
8
|
+
from ._misc import Misc
|
|
9
|
+
from ._models import Models
|
|
10
|
+
from ._preprocessing import Preprocessing
|
|
11
|
+
from ._deployments import Deployments
|
|
12
|
+
from ._gpt import GPT
|
|
13
|
+
from ._collections import Collections
|
|
14
|
+
from ._datasets import Datasets
|
|
15
|
+
from ._inference import Inference
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Client(Misc, Models, Preprocessing, GPT, Collections):
|
|
19
|
+
|
|
20
|
+
def __init__(self, api_key=None, hostname='https://api.xplainable.io', silent_mode=False):
|
|
21
|
+
self.session = Session(api_key=api_key, hostname=hostname, silent_mode=silent_mode)
|
|
22
|
+
Misc.__init__(self, self.session)
|
|
23
|
+
Models.__init__(self, self.session)
|
|
24
|
+
Preprocessing.__init__(self, self.session)
|
|
25
|
+
Deployments.__init__(self, self.session)
|
|
26
|
+
GPT.__init__(self, self.session)
|
|
27
|
+
Collections.__init__(self, self.session)
|
|
28
|
+
Datasets.__init__(self, self.session)
|
|
29
|
+
Inference.__init__(self, self.session)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
from ._client_cog_base import *
|
|
2
|
+
from ._models import Models
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Collections(Client_Cog):
|
|
6
|
+
|
|
7
|
+
def create_collection(self, model_id: str, name: str, description: str):
|
|
8
|
+
""" Creates a new collection.
|
|
9
|
+
Args:
|
|
10
|
+
model_id (str): The model id.
|
|
11
|
+
name (str): The name of the collection.
|
|
12
|
+
description (str): The description of the collection.
|
|
13
|
+
Returns:
|
|
14
|
+
int: The id of the collection created.
|
|
15
|
+
"""
|
|
16
|
+
payload = {
|
|
17
|
+
"name": name,
|
|
18
|
+
"description": description
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
response = self.session._session.put(
|
|
22
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/create-collection",
|
|
23
|
+
json=payload
|
|
24
|
+
)
|
|
25
|
+
data = self.session.get_response_content(response)
|
|
26
|
+
return data
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_model_collections(self, model_id: str):
|
|
30
|
+
""" Gets all collections of a model.
|
|
31
|
+
Args:
|
|
32
|
+
model_id (str): The model id.
|
|
33
|
+
Returns:
|
|
34
|
+
dict: Dictionary of collections.
|
|
35
|
+
"""
|
|
36
|
+
response = self.session._session.get(
|
|
37
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections"
|
|
38
|
+
)
|
|
39
|
+
data = self.session.get_response_content(response)
|
|
40
|
+
return data
|
|
41
|
+
|
|
42
|
+
def get_team_collections(self):
|
|
43
|
+
""" Gets all collections of a team.
|
|
44
|
+
Returns:
|
|
45
|
+
dict: Dictionary of collections.
|
|
46
|
+
"""
|
|
47
|
+
response = self.session._session.get(
|
|
48
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/collections"
|
|
49
|
+
)
|
|
50
|
+
data = self.session.get_response_content(response)
|
|
51
|
+
return data
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def edit_collection_name(self, model_id: str, collections_id: str, name: str):
|
|
55
|
+
""" Edits the name of a collection.
|
|
56
|
+
Args:
|
|
57
|
+
model_id (str): The model id.
|
|
58
|
+
collections_id (str): The collection id.
|
|
59
|
+
name (str): The new name of the collection.
|
|
60
|
+
Returns:
|
|
61
|
+
json: A json payload.
|
|
62
|
+
"""
|
|
63
|
+
payload = {
|
|
64
|
+
"name": name
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
response = self.session._session.patch(
|
|
68
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections/{collections_id}/name",
|
|
69
|
+
json=payload
|
|
70
|
+
)
|
|
71
|
+
return response
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def edit_collection_description(self, model_id: str, collections_id: str, description: str):
|
|
75
|
+
""" Edits the description of a collection.
|
|
76
|
+
Args:
|
|
77
|
+
model_id (str): The model id.
|
|
78
|
+
collections_id (str): The collection id.
|
|
79
|
+
description (str): The new description of the collection.
|
|
80
|
+
Returns:
|
|
81
|
+
json: A json payload.
|
|
82
|
+
"""
|
|
83
|
+
payload = {
|
|
84
|
+
"description": description
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
response = self.session._session.patch(
|
|
88
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections/{collections_id}/description",
|
|
89
|
+
json=payload
|
|
90
|
+
)
|
|
91
|
+
return response
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def delete_collection(self, model_id: str, collections_id: str):
|
|
95
|
+
""" Deletes a collection.
|
|
96
|
+
Args:
|
|
97
|
+
model_id (str): The model id.
|
|
98
|
+
collections_id (str): The collection id.
|
|
99
|
+
Returns:
|
|
100
|
+
json: A json payload.
|
|
101
|
+
"""
|
|
102
|
+
response = self.session._session.delete(
|
|
103
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections/{collections_id}"
|
|
104
|
+
)
|
|
105
|
+
return response
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def delete_model_collections(self, model_id: str):
|
|
109
|
+
""" Deletes all collections of a model.
|
|
110
|
+
Args:
|
|
111
|
+
model_id (str): The model id.
|
|
112
|
+
Returns:
|
|
113
|
+
json: A json payload.
|
|
114
|
+
"""
|
|
115
|
+
response = self.session._session.delete(
|
|
116
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections"
|
|
117
|
+
)
|
|
118
|
+
return response
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def restore_collection(self, model_id: str, collection_id: str):
|
|
122
|
+
""" Restores a collection.
|
|
123
|
+
Args:
|
|
124
|
+
model_id (str): The model id.
|
|
125
|
+
collections_id (str): The collection id.
|
|
126
|
+
Returns:
|
|
127
|
+
json: A json payload.
|
|
128
|
+
"""
|
|
129
|
+
response = self.session._session.patch(
|
|
130
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections/{collection_id}/restore"
|
|
131
|
+
)
|
|
132
|
+
return response
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def get_collection(self, model_id: str, collection_id: str):
|
|
136
|
+
""" Gets a collection.
|
|
137
|
+
Args:
|
|
138
|
+
model_id (str): The model id.
|
|
139
|
+
collections_id (str): The collection id.
|
|
140
|
+
Returns:
|
|
141
|
+
dict: Dictionary of collection.
|
|
142
|
+
"""
|
|
143
|
+
response = self.session._session.get(
|
|
144
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections/{collection_id}"
|
|
145
|
+
)
|
|
146
|
+
data = self.session.get_response_content(response)
|
|
147
|
+
return data
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
#TODO: Implement.
|
|
151
|
+
# def add_scenario(self, model_id: str, version_id: str, collection_id: str):
|
|
152
|
+
# try:
|
|
153
|
+
# response = self.session._session.get(
|
|
154
|
+
# url=f'{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/versions/{version_id}'
|
|
155
|
+
# )
|
|
156
|
+
# return self.session.get_response_content(response)
|
|
157
|
+
# except Exception as e:
|
|
158
|
+
# raise ValueError(f'Model with ID {model_id}:{version_id} does not exist')
|
|
159
|
+
# return
|
|
160
|
+
|
|
161
|
+
# add_scenario
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def edit_scenario_notes(self, model_id: str, collection_id: str, scenario_id: str, notes: str):
|
|
165
|
+
""" Edits the notes of a scenario.
|
|
166
|
+
Args:
|
|
167
|
+
model_id (str): The model id.
|
|
168
|
+
collections_id (str): The collection id.
|
|
169
|
+
scenario_id (str): The scenario id.
|
|
170
|
+
notes (str): The new notes of the scenario.
|
|
171
|
+
Returns:
|
|
172
|
+
json: A json payload.
|
|
173
|
+
"""
|
|
174
|
+
payload = {
|
|
175
|
+
"notes": notes
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
response = self.session._session.patch(
|
|
179
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections/{collection_id}/scenarios/{scenario_id}/notes",
|
|
180
|
+
json=payload
|
|
181
|
+
)
|
|
182
|
+
return response
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def delete_scenario(self, model_id: str, collection_id: str, scenario_id: str):
|
|
186
|
+
"""" Deletes a scenario.
|
|
187
|
+
Args:
|
|
188
|
+
model_id (str): The model id.
|
|
189
|
+
collections_id (str): The collection id.
|
|
190
|
+
scenario_id (str): The scenario id.
|
|
191
|
+
Returns:
|
|
192
|
+
json: A json payload.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
response = self.session._session.delete(
|
|
196
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections/{collection_id}/scenarios/{scenario_id}"
|
|
197
|
+
)
|
|
198
|
+
return response
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def restore_scenario(self, model_id: str, collection_id: str, scenario_id: str):
|
|
202
|
+
""" Restores a scenario.
|
|
203
|
+
Args:
|
|
204
|
+
model_id (str): The model id.
|
|
205
|
+
collections_id (str): The collection id.
|
|
206
|
+
scenario_id (str): The scenario id.
|
|
207
|
+
Returns:
|
|
208
|
+
json: A json payload.
|
|
209
|
+
"""
|
|
210
|
+
response = self.session._session.patch(
|
|
211
|
+
url=f"{self.session.hostname}/v1/{self.session.__ext}/models/{model_id}/collections/{collection_id}/scenarios/{scenario_id}/restore"
|
|
212
|
+
)
|
|
213
|
+
return response
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from ._client_cog_base import *
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Datasets(Client_Cog):
|
|
8
|
+
|
|
9
|
+
# upload_dataset
|
|
10
|
+
|
|
11
|
+
def list_datasets(self):
|
|
12
|
+
|
|
13
|
+
response = requests.get('https://api.xplainable.io/v1/public-datasets')
|
|
14
|
+
|
|
15
|
+
if response.status_code != 200:
|
|
16
|
+
raise ValueError(f'Unable to list datasets. Check your connection and try again.')
|
|
17
|
+
|
|
18
|
+
return response.json()
|
|
19
|
+
|
|
20
|
+
def _get_url_path(self, name):
|
|
21
|
+
_base = 'xplainablepublic'
|
|
22
|
+
_type = 'blob.core.windows.net'
|
|
23
|
+
_loc = 'asset-repository/datasets'
|
|
24
|
+
|
|
25
|
+
return f'https://{_base}.{_type}/{_loc}/{name}/data.csv'
|
|
26
|
+
|
|
27
|
+
def load_dataset(self, name):
|
|
28
|
+
|
|
29
|
+
datasets = self.list_datasets()
|
|
30
|
+
|
|
31
|
+
if name not in datasets:
|
|
32
|
+
raise ValueError(f'{name} is not available. Run xp.list_datasets() to see available datasets.')
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
url = self._get_url_path(name)
|
|
36
|
+
df = pd.read_csv(url)
|
|
37
|
+
|
|
38
|
+
return df
|
|
39
|
+
|
|
40
|
+
except Exception as e:
|
|
41
|
+
raise ValueError(f'Unable to load dataset {name}. Check your connection and try again.')
|
|
42
|
+
|
|
43
|
+
# update_dataset
|
|
44
|
+
|
|
45
|
+
# detele_dataset
|
|
46
|
+
|
|
47
|
+
# list_dataset_children
|
|
48
|
+
|
|
49
|
+
# preview_dataset
|
|
50
|
+
|
|
51
|
+
# list_pub_datasets
|