datagrok-api 0.0.1__tar.gz → 0.0.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.
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/PKG-INFO +5 -6
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/README.md +4 -5
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/datagrok_api/datagrok_client.py +11 -0
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/example.py +2 -2
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/pyproject.toml +1 -1
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/.gitignore +0 -0
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/datagrok_api/__init__.py +0 -0
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/iris.csv +0 -0
- {datagrok_api-0.0.1 → datagrok_api-0.0.2}/iris.layout +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: datagrok-api
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Client library for integration with datagrok API
|
|
5
5
|
Project-URL: Homepage, https://github.com/datagrok-ai/public
|
|
6
6
|
Project-URL: Issues, https://github.com/datagrok-ai/public/issues
|
|
@@ -15,6 +15,8 @@ Description-Content-Type: text/markdown
|
|
|
15
15
|
|
|
16
16
|
This library can be used for integration with datagrok. It is a python wrapper for public API, that has OpenAPI specification available [here](http://public.datagrok.ai/api/public/api.yaml).
|
|
17
17
|
|
|
18
|
+
Refer to [Help](http://datagrok.ai/help) for more information.
|
|
19
|
+
|
|
18
20
|
## Installation
|
|
19
21
|
|
|
20
22
|
To install package, use [pip](https://pypi.org/project/pip/).
|
|
@@ -42,12 +44,9 @@ See [License.md](https://github.com/datagrok-ai/public/blob/master/LICENSE.md).
|
|
|
42
44
|
The package uses Pandas for representation of tables and dataframes.
|
|
43
45
|
|
|
44
46
|
```python
|
|
45
|
-
from datagrok_api import DatagrokClient
|
|
46
47
|
import pandas as pd
|
|
47
48
|
from sklearn.datasets import load_iris
|
|
48
49
|
|
|
49
|
-
api = DatagrokClient('your token', 'datagrok url')
|
|
50
|
-
|
|
51
50
|
# Calls a Datagrok function
|
|
52
51
|
# Dataframes, columns and primitive data types are supported
|
|
53
52
|
api.call_function('Abs', {
|
|
@@ -59,7 +58,7 @@ res = api.download_file('system.demofiles', 'demog.csv')
|
|
|
59
58
|
print(res.head())
|
|
60
59
|
|
|
61
60
|
# Uploads iris dataset as a table
|
|
62
|
-
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))
|
|
61
|
+
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
63
62
|
|
|
64
63
|
# Iris also can be uploaded as a file
|
|
65
64
|
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
@@ -69,7 +68,7 @@ res = api.download_table(iris_id)
|
|
|
69
68
|
print(res.head())
|
|
70
69
|
|
|
71
70
|
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
72
|
-
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')
|
|
71
|
+
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
73
72
|
|
|
74
73
|
# Shares dashboard with admin
|
|
75
74
|
api.share_dashboard(dashboard_id, 'Test')
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
This library can be used for integration with datagrok. It is a python wrapper for public API, that has OpenAPI specification available [here](http://public.datagrok.ai/api/public/api.yaml).
|
|
4
4
|
|
|
5
|
+
Refer to [Help](http://datagrok.ai/help) for more information.
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
To install package, use [pip](https://pypi.org/project/pip/).
|
|
@@ -29,12 +31,9 @@ See [License.md](https://github.com/datagrok-ai/public/blob/master/LICENSE.md).
|
|
|
29
31
|
The package uses Pandas for representation of tables and dataframes.
|
|
30
32
|
|
|
31
33
|
```python
|
|
32
|
-
from datagrok_api import DatagrokClient
|
|
33
34
|
import pandas as pd
|
|
34
35
|
from sklearn.datasets import load_iris
|
|
35
36
|
|
|
36
|
-
api = DatagrokClient('your token', 'datagrok url')
|
|
37
|
-
|
|
38
37
|
# Calls a Datagrok function
|
|
39
38
|
# Dataframes, columns and primitive data types are supported
|
|
40
39
|
api.call_function('Abs', {
|
|
@@ -46,7 +45,7 @@ res = api.download_file('system.demofiles', 'demog.csv')
|
|
|
46
45
|
print(res.head())
|
|
47
46
|
|
|
48
47
|
# Uploads iris dataset as a table
|
|
49
|
-
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))
|
|
48
|
+
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
50
49
|
|
|
51
50
|
# Iris also can be uploaded as a file
|
|
52
51
|
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
@@ -56,7 +55,7 @@ res = api.download_table(iris_id)
|
|
|
56
55
|
print(res.head())
|
|
57
56
|
|
|
58
57
|
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
59
|
-
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')
|
|
58
|
+
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
60
59
|
|
|
61
60
|
# Shares dashboard with admin
|
|
62
61
|
api.share_dashboard(dashboard_id, 'Test')
|
|
@@ -42,6 +42,7 @@ class DatagrokClient:
|
|
|
42
42
|
pandas.DataFrame
|
|
43
43
|
Dataframe with table data
|
|
44
44
|
'''
|
|
45
|
+
name = name.replace(':', '.')
|
|
45
46
|
endpoint = f"/public/v1/tables/{name}"
|
|
46
47
|
response = self._request('GET', endpoint, content_type="text/plain")
|
|
47
48
|
return pd.read_csv(StringIO(response.text))
|
|
@@ -63,6 +64,7 @@ class DatagrokClient:
|
|
|
63
64
|
object
|
|
64
65
|
set of identifiers for the uploaded table
|
|
65
66
|
'''
|
|
67
|
+
name = name.replace(':', '.')
|
|
66
68
|
endpoint = f"/public/v1/tables/{name}"
|
|
67
69
|
csv_data = dataframe.to_csv(index=False)
|
|
68
70
|
response = self._request('POST', endpoint, content_type="text/csv", data=csv_data)
|
|
@@ -85,6 +87,7 @@ class DatagrokClient:
|
|
|
85
87
|
If requested file is csv, returns corresponding pd.Datafrme.
|
|
86
88
|
Otherwise returns list of bytes with file content.
|
|
87
89
|
'''
|
|
90
|
+
connector = connector.replace(':', '.')
|
|
88
91
|
endpoint = f"/public/v1/files/{connector}/{path}"
|
|
89
92
|
response = self._request('GET', endpoint, content_type="application/octet-stream")
|
|
90
93
|
if path.endswith('.csv'):
|
|
@@ -104,6 +107,7 @@ class DatagrokClient:
|
|
|
104
107
|
file_path: str
|
|
105
108
|
Path to local file that needs to be uploaded
|
|
106
109
|
'''
|
|
110
|
+
connector = connector.replace(':', '.')
|
|
107
111
|
endpoint = f"/public/v1/files/{connector}/{path}"
|
|
108
112
|
with open(file_path, 'rb') as file:
|
|
109
113
|
self._request('POST', endpoint, content_type="application/octet-stream", data=file)
|
|
@@ -121,6 +125,7 @@ class DatagrokClient:
|
|
|
121
125
|
access: str
|
|
122
126
|
Either 'View' or 'Edit'
|
|
123
127
|
'''
|
|
128
|
+
id = id.replace(':', '.')
|
|
124
129
|
endpoint = f"/public/v1/dashboards/{id}/shares"
|
|
125
130
|
params = {
|
|
126
131
|
'groups': groups,
|
|
@@ -146,6 +151,8 @@ class DatagrokClient:
|
|
|
146
151
|
object
|
|
147
152
|
Identifiers of a project.
|
|
148
153
|
'''
|
|
154
|
+
name = name.replace(':', '.')
|
|
155
|
+
table_ids = table_ids.replace(':', '.')
|
|
149
156
|
endpoint = f"/public/v1/dashboards/{name}/{table_ids}"
|
|
150
157
|
if layout_filename:
|
|
151
158
|
with open(layout_filename, 'r') as layout_file:
|
|
@@ -171,6 +178,7 @@ class DatagrokClient:
|
|
|
171
178
|
object
|
|
172
179
|
Result of invocation: either a single value or a list or outputs.
|
|
173
180
|
'''
|
|
181
|
+
name = name.replace(':', '.')
|
|
174
182
|
endpoint = f"/public/v1/{name}/call"
|
|
175
183
|
response = self._request('POST', endpoint, json=invocation_parameters, content_type="application/json")
|
|
176
184
|
return response.json()
|
|
@@ -181,4 +189,7 @@ class DatagrokClient:
|
|
|
181
189
|
headers["Content-Type"] = content_type
|
|
182
190
|
response = requests.request(method, url, headers=headers, **kwargs)
|
|
183
191
|
response.raise_for_status()
|
|
192
|
+
content = response.content.decode()
|
|
193
|
+
if 'ApiError' in content:
|
|
194
|
+
raise Exception(content)
|
|
184
195
|
return response
|
|
@@ -15,7 +15,7 @@ res = api.download_file('system.demofiles', 'demog.csv')
|
|
|
15
15
|
print(res.head())
|
|
16
16
|
|
|
17
17
|
# Uploads iris dataset as a table
|
|
18
|
-
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))
|
|
18
|
+
iris_id = api.upload_table('iris', pd.DataFrame(load_iris()['data']))['ID']
|
|
19
19
|
|
|
20
20
|
# Iris also can be uploaded as a file
|
|
21
21
|
# api.upload_file('system.demofiles', 'iris.csv', 'iris.csv')
|
|
@@ -25,7 +25,7 @@ res = api.download_table(iris_id)
|
|
|
25
25
|
print(res.head())
|
|
26
26
|
|
|
27
27
|
# Creates dashboard from iris table with layout uploaded from file "iris.layout"
|
|
28
|
-
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')
|
|
28
|
+
dashboard_id = api.create_dashboard('python-test', iris_id, layout_filename='iris.layout')['ID']
|
|
29
29
|
|
|
30
30
|
# Shares dashboard with admin
|
|
31
31
|
api.share_dashboard(dashboard_id, 'Test')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|