Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Changelog
==========


13.3.3 (2025-01-27)
---------------------

* Initial release for DSS 13.3.3

13.3.2 (2025-01-15)
---------------------
Expand Down
3 changes: 0 additions & 3 deletions dataikuapi/apinode_client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import warnings

from .utils import DataikuException
from .base_client import DSSBaseClient


class APINodeClient(DSSBaseClient):
"""Entry point for the DSS API Node client
This is an API client for the user-facing API of DSS API Node server (user facing API)
Expand Down
12 changes: 4 additions & 8 deletions dataikuapi/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from requests import exceptions
from requests.auth import HTTPBasicAuth
from .auth import HTTPBearerAuth
from .utils import DataikuException
from .utils import handle_http_exception

class DSSBaseClient(object):
def __init__(self, base_uri, api_key=None, internal_ticket=None, bearer_token=None, no_check_certificate=False, **kwargs):
Expand Down Expand Up @@ -36,16 +36,12 @@ def _perform_http(self, method, path, params=None, body=None, stream=False):
elif self.bearer_token:
auth = HTTPBearerAuth(self.bearer_token)

try:
http_res = self._session.request(
http_res = self._session.request(
method, "%s/%s" % (self.base_uri, path),
params=params, data=body, headers=headers,
auth=auth, stream = stream)
http_res.raise_for_status()
return http_res
except exceptions.HTTPError:
ex = http_res.json()
raise DataikuException("%s: %s" % (ex.get("errorType", "Unknown error"), ex.get("message", "No message")))
handle_http_exception(http_res)
return http_res

def _perform_empty(self, method, path, params=None, body=None):
self._perform_http(method, path, params, body, False)
Expand Down
1 change: 0 additions & 1 deletion dataikuapi/dss/analysis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from ..utils import DataikuException
from ..utils import DataikuUTF8CSVReader
from ..utils import DataikuStreamedHttpUTF8CSVReader
import json
Expand Down
40 changes: 15 additions & 25 deletions dataikuapi/dssclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .dss.utils import DSSInfoMessages, Enum
from .dss.workspace import DSSWorkspace
import os.path as osp
from .utils import DataikuException, dku_basestring_type
from .utils import dku_basestring_type, handle_http_exception
from .govern_client import GovernClient


Expand Down Expand Up @@ -1503,21 +1503,14 @@ def _perform_http(self, method, path, params=None, body=None, stream=False, file
if raw_body is not None:
body = raw_body

try:
http_res = self._session.request(
method, "%s/dip/publicapi%s" % (self.host, path),
params=params, data=body,
files=files,
stream=stream,
headers=headers)
http_res.raise_for_status()
return http_res
except exceptions.HTTPError:
try:
ex = http_res.json()
except ValueError:
ex = {"message": http_res.text}
raise DataikuException("%s: %s" % (ex.get("errorType", "Unknown error"), ex.get("detailedMessage", ex.get("message", "No message"))))
http_res = self._session.request(
method, "%s/dip/publicapi%s" % (self.host, path),
params=params, data=body,
files=files,
stream=stream,
headers=headers)
handle_http_exception(http_res)
return http_res

def _perform_empty(self, method, path, params=None, body=None, files = None, raw_body=None):
self._perform_http(method, path, params=params, body=body, files=files, stream=False, raw_body=raw_body)
Expand All @@ -1532,15 +1525,12 @@ def _perform_raw(self, method, path, params=None, body=None,files=None, raw_body
return self._perform_http(method, path, params=params, body=body, files=files, stream=True, raw_body=raw_body)

def _perform_json_upload(self, method, path, name, f):
try:
http_res = self._session.request(
method, "%s/dip/publicapi%s" % (self.host, path),
files = {'file': (name, f, {'Expires': '0'})} )
http_res.raise_for_status()
return http_res
except exceptions.HTTPError:
ex = http_res.json()
raise DataikuException("%s: %s" % (ex.get("errorType", "Unknown error"), ex.get("message", "No message")))
http_res = self._session.request(
method, "%s/dip/publicapi%s" % (self.host, path),
files = {'file': (name, f, {'Expires': '0'})} )

handle_http_exception(http_res)
return http_res

########################################################
# Discussions
Expand Down
23 changes: 6 additions & 17 deletions dataikuapi/fmclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os.path as osp
import warnings

from .utils import DataikuException
from .utils import handle_http_exception

from .iam.settings import FMSSOSettings, FMLDAPSettings, FMAzureADSettings

Expand Down Expand Up @@ -360,29 +360,18 @@ def _perform_http(
body = json.dumps(body)
if raw_body is not None:
body = raw_body
try:
http_res = self._session.request(


http_res = self._session.request(
method,
"%s/api/public%s" % (self.host, path),
params=params,
data=body,
files=files,
stream=stream,
)
http_res.raise_for_status()
return http_res
except exceptions.HTTPError:
try:
ex = http_res.json()
except ValueError:
ex = {"message": http_res.text}
raise DataikuException(
"%s: %s"
% (
ex.get("errorType", "Unknown error"),
ex.get("message", "No message"),
)
)
handle_http_exception(http_res)
return http_res

def _perform_empty(
self, method, path, params=None, body=None, files=None, raw_body=None
Expand Down
25 changes: 7 additions & 18 deletions dataikuapi/govern_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from dataikuapi.govern.custom_page import GovernCustomPageListItem, GovernCustomPage
from dataikuapi.govern.time_series import GovernTimeSeries
from dataikuapi.govern.uploaded_file import GovernUploadedFile
from dataikuapi.utils import DataikuException
from dataikuapi.utils import handle_http_exception


class GovernClient(object):
Expand Down Expand Up @@ -62,21 +62,14 @@ def _perform_http(self, method, path, params=None, body=None, stream=False, file
if raw_body is not None:
body = raw_body

try:
http_res = self._session.request(
http_res = self._session.request(
method, "%s/dip/publicapi%s" % (self.host, path),
params=params, data=body,
files=files,
stream=stream,
headers=headers)
http_res.raise_for_status()
return http_res
except exceptions.HTTPError:
try:
ex = http_res.json()
except ValueError:
ex = {"message": http_res.text}
raise DataikuException("%s: %s" % (ex.get("errorType", "Unknown error"), ex.get("message", "No message")))
handle_http_exception(http_res)
return http_res

def _perform_empty(self, method, path, params=None, body=None, files=None, raw_body=None):
self._perform_http(method, path, params=params, body=body, files=files, stream=False, raw_body=raw_body)
Expand All @@ -91,15 +84,11 @@ def _perform_raw(self, method, path, params=None, body=None, files=None, raw_bod
return self._perform_http(method, path, params=params, body=body, files=files, stream=True, raw_body=raw_body)

def _perform_json_upload(self, method, path, name, f):
try:
http_res = self._session.request(
http_res = self._session.request(
method, "%s/dip/publicapi%s" % (self.host, path),
files={'file': (name, f, {'Expires': '0'})})
http_res.raise_for_status()
return http_res
except exceptions.HTTPError:
ex = http_res.json()
raise DataikuException("%s: %s" % (ex.get("errorType", "Unknown error"), ex.get("message", "No message")))
handle_http_exception(http_res)
return http_res

########################################################
# Blueprint Designer
Expand Down
9 changes: 9 additions & 0 deletions dataikuapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
class DataikuException(Exception):
"""Exception launched by the Dataiku API clients when an error occurs"""

def handle_http_exception(http_res):
if http_res.status_code >= 400:
try:
ex = http_res.json()
except ValueError:
ex = {"message": http_res.text}
raise DataikuException("%s: %s" % (ex.get("errorType", "Unknown error"), ex.get("detailedMessage", ex.get("message", "No message"))))


class DataikuUTF8CSVReader(object):
"""
A CSV reader which will iterate over lines in the CSV file "f",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup

VERSION = "13.3.2"
VERSION = "13.3.3"

long_description = (open('README').read() + '\n\n' +
open('HISTORY.txt').read())
Expand Down