Skip to content

Commit 31ca937

Browse files
committed
python SDK release 0.2.1 - including the cryptolib
1 parent 7f1198f commit 31ca937

File tree

190 files changed

+9317
-1595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+9317
-1595
lines changed

PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: tuneinsight
3-
Version: 0.1.1
3+
Version: 0.2.1
44
Summary: Diapason is the official Python SDK for the Tune Insight Agent API
55
License: Apache-2.0
66
Author: Tune Insight SA

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tuneinsight"
3-
version = "0.1.1"
3+
version = "0.2.1"
44
description = "Diapason is the official Python SDK for the Tune Insight Agent API"
55
authors = ["Tune Insight SA"]
66
license = "Apache-2.0"
@@ -15,7 +15,6 @@ pandas = "^1.4.2"
1515
matplotlib = "^3.6.0"
1616
#cloudpickle = "^2.0.0" // TODO: to add in the future to run python on backend
1717
scikit-learn = "^1.1.3"
18-
#cryptolib = { file = "../../geco/internal/python/dist/cryptolib-0.1.0-cp39-cp39-linux_x86_64.whl" } // TODO: to add in the future for client side crypto
1918
wheel = "^0.37.1"
2019
pylint = "^2.15.2"
2120
docker = "^6.0.1"

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'tuneinsight.api.sdk.api.api_log',
1717
'tuneinsight.api.sdk.api.api_ml',
1818
'tuneinsight.api.sdk.api.api_network',
19+
'tuneinsight.api.sdk.api.api_private_search',
1920
'tuneinsight.api.sdk.api.api_project',
2021
'tuneinsight.api.sdk.api.api_protocols',
2122
'tuneinsight.api.sdk.api.api_query',
@@ -25,6 +26,7 @@
2526
'tuneinsight.api.sdk.models',
2627
'tuneinsight.client',
2728
'tuneinsight.computations',
29+
'tuneinsight.cryptolib',
2830
'tuneinsight.utils']
2931

3032
package_data = \
@@ -50,9 +52,9 @@
5052

5153
setup_kwargs = {
5254
'name': 'tuneinsight',
53-
'version': '0.1.0',
55+
'version': '0.2.1',
5456
'description': 'Diapason is the official Python SDK for the Tune Insight Agent API',
55-
'long_description': '# Tune Insight Python SDK\n\nDiapason is the Tune Insight Python SDK\n\n## Getting Started\n\n### Installing\n\n```bash\npip install tuneinsight-0.1.0.tar.gz\n```\n\n## Usage\n\nTo use the SDK you must be able to connect to a *Tune Insight* Agent.\n\n\n### Creating a client to the agents\n\nTo create a new client to one of the running agents, simply run:\n```python\nfrom tuneinsight.client.diapason import Diapason\nclient = Diapason.from_config_path(\'conf.yml\')\n```\n\n### Features\n#### Computations\n#### Preprocessing\nPreprocessing operations should be defined in relation to a computation. The preprocessing when the computation is ran.\nFor example:\n```\naggregation = project.new_enc_aggregation()\naggregation.preprocessing.one_hot_encoding(target_column=\'gender\', prefix=\'\', specified_types=[\'Male\', \'Female\'])\n```\n\nPreprocessing operations can be applied to all nodes or specific nodes if the data format is different across nodes. This requires using the `nodes` argument, as follows:\n```\naggregation.preprocessing.one_hot_encoding(target_column=\'gender\', prefix=\'\', specified_types=[\'Male\', \'Female\'], nodes=[\'Organization_A\'])\naggregation.preprocessing.one_hot_encoding(target_column=\'genre\', prefix=\'\', specified_types=[\'Male\', \'Female\'], nodes=[\'Organization_B\'])\naggregation.preprocessing.one_hot_encoding(target_column=\'genero\', prefix=\'\', specified_types=[\'Male\', \'Female\'], nodes=[\'Organization_C\'])\n```\n\n##### Select\nSelect specified columns from data.\n```\nselect(columns, create_if_missing, dummy_value, nodes)\n```\n* `columns` : list of column names to be selected (`List[str]`)\n* `create_if_missing` : whether to create the columns if they do not exist, default = False (`bool`)\n* `dummy_value` : what to fill the created columns with, default = "" (`str`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### One Hot Encoding\nEncodes a target column into one hot encoding and extends the table with these columns\n```\none_hot_encoding(target_column, prefix, specified_types, nodes)\n```\n* `target_column` : name of column to convert to one-hot-encoding (`str`)\n* `prefix` : prefix string to prepend to one-hot column names (`str`)\n* `specified_types` : specified types to one-hot encode, if specified, then possible missing columns will be added (`List[str]`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### Filter\nFilters rows from the data under a given condition\n```\nfilter(target_column, comparator, value, numerical, nodes)\n```\n* `target_column` : name of column to filter on (`str`)\n* `comparator` : type of comparison (`ComparisonType` enum)\n\n\t* equal\n\t* nEqual\n\t* greater\n\t* greaterEq\n\t* less\n\t* lessEq\n\t* in\n\n* `value` : value with which to compare (`str`)\n* `numerical` : whether the comparison is on numerical values, default = False (`bool`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### Counts\nConcatenates a new column containing 1 for each row in order to count the number of rows\n```\ncounts(output_column_name, nodes)\n```\n* `output_column_name` : name of the column to store the counts. If not specified, the name \'count\' will be used. (`str`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### Transpose\nTranspose index and columns\n```\ntranspose(copy, nodes)\n```\n* `copy` : Whether to copy the data after transposing. default False (`bool`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### Set Index\nSet the DataFrame index using existing columns.\n```\nset_index(cols, drop, append, nodes)\n```\n* `columns` : list of column names to set as index (`List[str]`)\n* `drop` : Delete columns to be used as the new index. default True (`bool`)\n* `append` : Whether to append columns to existing index. default False (`bool`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### Reset Index\nReset the index, or a level of it.\n```\nreset_index(level, drop, nodes)\n```\n* `level` : list of column names to remove from index (`List[str]`)\n* `drop` : Do not try to insert index into dataframe columns. This resets the index to the default integer index. default False (`bool`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### Rename\nAlter axes labels.\n```\nrename(mapper, axis, copy, errors, nodes)\n```\n* `mapper` : Dict of transformations to apply to that axis’ values. (`dict`)\n* `axis` : Axis to target with `mapper`. Should be the axis name (‘index’, ‘columns’). The default is ‘index’. (`RenameAxis`)\n* `copy` : Also copy underlying data. default True (`bool`)\n* `errors` : If True raise a KeyError when a dict-like mapper, index, or columns contains labels that are not present in the Index being transformed. If False existing keys will be renamed and extra keys will be ignored.(`bool`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### As Type\nCast column types\n```\nastype(type_map, copy, errors, nodes)\n```\n* `mapper` : Dict which maps column names to dtypes. (`dict`)\n* `copy` : Return a copy. default True (`bool`)\n* `errors` : If True raise a KeyError when a dict-like mapper, index, or columns contains labels that are not present in the Index being transformed. If False existing keys will be renamed and extra keys will be ignored.(`bool`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n##### Extract Dict Field\nExtract field value from dict-like columns\n```\nextract(field, columns, names, nodes)\n```\n* `field` : dict field to extract (`str`)\n* `columns` : list of column names from which to extract field (`List[str]`)\n* `names`: names of resulting columns, if None, no new columns are created (`List[str]`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\nFor example given:\n | id | dict_col |\n | -- | -- |\n | 0 | { \'foo\' : 3, \'bar\' : 0.56} |\n | 1 | { \'foo\' : 8, \'bar\' : 0.22} |\n | 2 | { \'foo\' : 5, \'bar\' : 0.13} |\n\n`extract(field=\'foo\', columns=[\'dict_col\'])` yields:\n | id | dict_col |\n | -- | -- |\n | 0 | 3 |\n | 1 | 8 |\n | 2 | 5 |\n\n##### Apply RegEx\nApply a RegEx mapping to columns\n```\napply_regex(regex, columns, regex_type, names, nodes)\n```\n* `regex` : regular expression to apply (`str`)\n* `columns` : list of column names from which to extract field (`List[str]`)\n* `regex_type` : defines what we want to retrieve from the regex (`ApplyRegExType`)\n\t* `ApplyRegExType.MATCH` : return the first match\n\t* `ApplyRegExType.FINDALL`: return list of matching values\n\t* `ApplyRegExType.POSITION`: return position of first match\n* `names`: names of resulting columns, if None, no new columns are created (`List[str]`)\n* `nodes` : which nodes to apply the preprocessing operation to, if `None` it will apply to all (`List[str]`)\n\n\n## License\nApache License 2.0',
57+
'long_description': "# Tune Insight Python SDK\n\nDiapason is the Tune Insight Python SDK\n\n## Getting Started\n\n### Installing\n\n```bash\npip install tuneinsight-0.1.1.tar.gz\n```\n\n## Usage\n\nTo use the SDK you must be able to connect to a *Tune Insight* Agent.\n\n\n### Creating a client to the agents\n\nTo create a new client to one of the running agents, simply run:\n```python\nfrom tuneinsight.client.diapason import Diapason\nclient = Diapason.from_config_path('conf.yml')\n```\n\n## Documentation\nThe complete documentation for Diapason is available [here](https://docs.tuneinsight.com/docs/python-sdk).\n\n\n## License\nApache License 2.0",
5658
'author': 'Tune Insight SA',
5759
'author_email': 'None',
5860
'maintainer': 'None',
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
""" A client library for accessing GeCo REST API """
1+
""" A client library for accessing Tune Insight API """
22
from .client import AuthenticatedClient, Client
3+
4+
__all__ = (
5+
"AuthenticatedClient",
6+
"Client",
7+
)

src/tuneinsight/api/sdk/api/api_admin/post_storage.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from http import HTTPStatus
12
from typing import Any, Dict, Optional, Union, cast
23

34
import httpx
45

6+
from ... import errors
57
from ...client import Client
68
from ...models.post_storage_response_403 import PostStorageResponse403
79
from ...models.storage_definition import StorageDefinition
@@ -30,32 +32,35 @@ def _get_kwargs(
3032
}
3133

3234

33-
def _parse_response(*, response: httpx.Response) -> Optional[Union[PostStorageResponse403, str]]:
34-
if response.status_code == 200:
35+
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[PostStorageResponse403, str]]:
36+
if response.status_code == HTTPStatus.OK:
3537
response_200 = cast(str, response.json())
3638
return response_200
37-
if response.status_code == 400:
39+
if response.status_code == HTTPStatus.BAD_REQUEST:
3840
response_400 = cast(str, response.json())
3941
return response_400
40-
if response.status_code == 403:
42+
if response.status_code == HTTPStatus.FORBIDDEN:
4143
response_403 = PostStorageResponse403.from_dict(response.json())
4244

4345
return response_403
44-
if response.status_code == 422:
46+
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
4547
response_422 = cast(str, response.json())
4648
return response_422
47-
if response.status_code == 500:
49+
if response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR:
4850
response_500 = cast(str, response.json())
4951
return response_500
50-
return None
52+
if client.raise_on_unexpected_status:
53+
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
54+
else:
55+
return None
5156

5257

53-
def _build_response(*, response: httpx.Response) -> Response[Union[PostStorageResponse403, str]]:
58+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[PostStorageResponse403, str]]:
5459
return Response(
55-
status_code=response.status_code,
60+
status_code=HTTPStatus(response.status_code),
5661
content=response.content,
5762
headers=response.headers,
58-
parsed=_parse_response(response=response),
63+
parsed=_parse_response(client=client, response=response),
5964
)
6065

6166

@@ -69,6 +74,10 @@ def sync_detailed(
6974
Args:
7075
json_body (StorageDefinition): specification of the storage operation
7176
77+
Raises:
78+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
79+
httpx.TimeoutException: If the request takes longer than Client.timeout.
80+
7281
Returns:
7382
Response[Union[PostStorageResponse403, str]]
7483
"""
@@ -83,7 +92,7 @@ def sync_detailed(
8392
**kwargs,
8493
)
8594

86-
return _build_response(response=response)
95+
return _build_response(client=client, response=response)
8796

8897

8998
def sync(
@@ -96,6 +105,10 @@ def sync(
96105
Args:
97106
json_body (StorageDefinition): specification of the storage operation
98107
108+
Raises:
109+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
110+
httpx.TimeoutException: If the request takes longer than Client.timeout.
111+
99112
Returns:
100113
Response[Union[PostStorageResponse403, str]]
101114
"""
@@ -116,6 +129,10 @@ async def asyncio_detailed(
116129
Args:
117130
json_body (StorageDefinition): specification of the storage operation
118131
132+
Raises:
133+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134+
httpx.TimeoutException: If the request takes longer than Client.timeout.
135+
119136
Returns:
120137
Response[Union[PostStorageResponse403, str]]
121138
"""
@@ -128,7 +145,7 @@ async def asyncio_detailed(
128145
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
129146
response = await _client.request(**kwargs)
130147

131-
return _build_response(response=response)
148+
return _build_response(client=client, response=response)
132149

133150

134151
async def asyncio(
@@ -141,6 +158,10 @@ async def asyncio(
141158
Args:
142159
json_body (StorageDefinition): specification of the storage operation
143160
161+
Raises:
162+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
163+
httpx.TimeoutException: If the request takes longer than Client.timeout.
164+
144165
Returns:
145166
Response[Union[PostStorageResponse403, str]]
146167
"""

0 commit comments

Comments
 (0)