atlasai-dstoolkit-client 0.0.10__py3-none-any.whl → 0.0.12__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.
atlasai/toolkit/model.py CHANGED
@@ -12,13 +12,13 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- import json
16
15
  import pandas as pd
17
16
  from typing import Union
18
17
 
19
18
  from atlasai.mlhub import client
20
19
 
21
20
  from .api import _get_access_token
21
+ from .utils import is_notebook
22
22
 
23
23
 
24
24
  def search(name=None, version=None, source=None, tags=None, aliases=None):
@@ -32,6 +32,12 @@ class ModelPredictWrapper:
32
32
  def __init__(self, model):
33
33
  self._model = model
34
34
 
35
+ def __repr__(self):
36
+ return f'Model {self._model.name} - version: {self._model.version}'
37
+
38
+ def __str__(self):
39
+ return f'Model {self._model.name} - version: {self._model.version}'
40
+
35
41
  def predict(
36
42
  self,
37
43
  data: Union[dict, str, pd.DataFrame] = None,
@@ -67,16 +73,29 @@ class ModelResults:
67
73
  def __iter__(self):
68
74
  return iter(self.results)
69
75
 
76
+ def __getitem__(self, index):
77
+ return self.results[index]
78
+
79
+ def display_tags(self, tags):
80
+ if not isinstance(tags, dict):
81
+ return tags
82
+ return '\n'.join([f'{k}:{v}' for k, v in tags.items()])
83
+
70
84
  def display(self):
71
85
  data = [
72
86
  {
73
87
  'name': r.name,
74
88
  'version': r.version,
75
89
  'aliases': r.aliases if r.aliases else '',
76
- 'tags': json.dumps(r.tags) if isinstance(r.tags, dict) else r.tags
90
+ 'tags': self.display_tags(r.tags)
77
91
  } for r in self.results
78
92
  ]
79
- return pd.DataFrame(data)
93
+ df = pd.DataFrame(data)
94
+ if is_notebook():
95
+ from IPython.display import display, HTML
96
+ html = df.to_html().replace("\\n", "<br>")
97
+ display(HTML(html))
98
+ return df
80
99
 
81
100
  def first(self):
82
101
  return self.results[0]
@@ -100,19 +119,19 @@ class ModelSearch:
100
119
  self.aliases = aliases if isinstance(aliases, list) else [aliases]
101
120
 
102
121
  def search(self):
103
- search = {}
122
+ _search = {}
104
123
  filters = ['name', 'version', 'source', 'tags', 'aliases']
105
124
  for f in filters:
106
125
  if not getattr(self, f, None):
107
126
  continue
108
- search[f] = getattr(self, f)
127
+ _search[f] = getattr(self, f)
109
128
 
110
129
  _get_access_token()
111
- results = client.get_models(search=search, tabular=False)
130
+ results = client.get_models(search=_search, tabular=False)
112
131
  return ModelResults([ModelPredictWrapper(r) for r in results])
113
132
 
114
133
  class ModelGet:
115
- def __init__(self, name, version='latest'):
134
+ def __init__(self, name, version=None):
116
135
  self.name = name
117
136
  self.version = version
118
137
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atlasai-dstoolkit-client
3
- Version: 0.0.10
3
+ Version: 0.0.12
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  Author: AtlasAI SWE
@@ -6,11 +6,11 @@ atlasai/toolkit/fabric.py,sha256=6aFR2PGQc9P3Qa07WdBg9eKoUzU8n2y_-gGjYcyMrWY,192
6
6
  atlasai/toolkit/feature.py,sha256=VKwX_yAwwMo1WuLZ_RbKVJEH4L1PAoYEPzWa0lH9ats,2828
7
7
  atlasai/toolkit/init.py,sha256=JkdJ6QGdYWrq65jgz2pn5RYXUeUe2Ez88_-eMf5CNi0,1100
8
8
  atlasai/toolkit/login.py,sha256=n4ydfo9qCsmbZq6er1xeljBD76vdTJGjbhYHMmOyDbQ,3061
9
- atlasai/toolkit/model.py,sha256=6gmIVx7joCpVxSQbXlmjkxAjreL_J104laAgKKgGOo0,3525
9
+ atlasai/toolkit/model.py,sha256=RUe0HbDpzvHOV9A4rzG3PgN9boMWDHQ2tR7IKHXzbx8,4126
10
10
  atlasai/toolkit/requests.py,sha256=X86nIo07hAjUlilZcZ1lV8RB7KOsTKbTGtcY_SpFEXY,1223
11
11
  atlasai/toolkit/utils.py,sha256=lYh3P2XOshRgHCjFeXJ0FOJWQW64sddgx8c2kL6Wqwc,1566
12
- atlasai_dstoolkit_client-0.0.10.dist-info/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
13
- atlasai_dstoolkit_client-0.0.10.dist-info/METADATA,sha256=h9oUexHohAl4WiRMqQX2UiXytdzdYmBeGPJ5BhM4thg,1405
14
- atlasai_dstoolkit_client-0.0.10.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
15
- atlasai_dstoolkit_client-0.0.10.dist-info/top_level.txt,sha256=HRTbErU8nmHFDaJJ5R_XYbwpt21dqdjDpSva8xyy_0k,8
16
- atlasai_dstoolkit_client-0.0.10.dist-info/RECORD,,
12
+ atlasai_dstoolkit_client-0.0.12.dist-info/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
13
+ atlasai_dstoolkit_client-0.0.12.dist-info/METADATA,sha256=2vdA8hWTJEIvSm1OgPRt9wmsTtZO_5oR_znxLDNuDbI,1405
14
+ atlasai_dstoolkit_client-0.0.12.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
15
+ atlasai_dstoolkit_client-0.0.12.dist-info/top_level.txt,sha256=HRTbErU8nmHFDaJJ5R_XYbwpt21dqdjDpSva8xyy_0k,8
16
+ atlasai_dstoolkit_client-0.0.12.dist-info/RECORD,,