Skip to content

Commit 050aae3

Browse files
committed
Merge remote-tracking branch 'origin/release/5.1'
2 parents 1845b45 + c9ddd5d commit 050aae3

File tree

4 files changed

+108
-10
lines changed

4 files changed

+108
-10
lines changed

dataikuapi/dss/project.py

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,14 +646,14 @@ def get_scenario(self, scenario_id):
646646
"""
647647
return DSSScenario(self.client, self.project_key, scenario_id)
648648

649-
def create_scenario(self, scenario_name, type, definition={}):
649+
def create_scenario(self, scenario_name, type, definition={'params': {}}):
650650
"""
651651
Create a new scenario in the project, and return a handle to interact with it
652652
653653
:param str scenario_name: The name for the new scenario. This does not need to be unique
654654
(although this is strongly recommended)
655655
:param str type: The type of the scenario. MUst be one of 'step_based' or 'custom_python'
656-
:param object definition: the JSON definition of the scenario. Use ``get_definition`` on an
656+
:param object definition: the JSON definition of the scenario. Use ``get_definition(with_status=False)`` on an
657657
existing ``DSSScenario`` object in order to get a sample definition object
658658
659659
:returns: a :class:`.scenario.DSSScenario` handle to interact with the newly-created scenario
@@ -820,6 +820,82 @@ def get_object_discussions(self):
820820
"""
821821
return DSSObjectDiscussions(self.client, self.project_key, "PROJECT", self.project_key)
822822

823+
########################################################
824+
# Tables import
825+
########################################################
826+
827+
def init_tables_import(self):
828+
"""
829+
Start an operation to import Hive or SQL tables as datasets into this project
830+
831+
:returns: a :class:`TablesImportDefinition` to add tables to import
832+
:rtype: :class:`TablesImportDefinition`
833+
"""
834+
return TablesImportDefinition(self.client, self.project_key)
835+
836+
class TablesImportDefinition(object):
837+
"""
838+
Temporary structure holding the list of tables to import
839+
"""
840+
841+
def __init__(self, client, project_key):
842+
"""Do not call this directly, use :meth:`DSSProject.init_tables_import`"""
843+
self.client = client
844+
self.project_key = project_key
845+
self.keys = []
846+
847+
def add_hive_table(self, hive_database, hive_table):
848+
"""Add a Hive table to the list of tables to import"""
849+
self.keys.append({
850+
"connectionName" : "@virtual(hive-jdbc):" + hive_database,
851+
"name" : hive_table
852+
})
853+
854+
def add_sql_table(self, connection, schema, table):
855+
"""Add a SQL table to the list of table to import"""
856+
self.keys.append({
857+
"connectionName" : connection,
858+
"schema": schema,
859+
"name" : table
860+
})
861+
862+
def prepare(self):
863+
"""
864+
Run the first step of the import process. In this step, DSS will check
865+
the tables whose import you have requested and prepare dataset names and
866+
target connections
867+
868+
:returns: a :class:`TablesPreparedImport` object that allows you to finalize the import process
869+
:rtype: :class:`TablesPreparedImport`
870+
871+
"""
872+
ret = self.client._perform_json("POST", "/projects/%s/datasets/tables-import/actions/prepare-from-keys" % (self.project_key),
873+
body = {"keys": self.keys} )
874+
875+
future = self.client.get_future(ret["jobId"])
876+
future.wait_for_result()
877+
return TablesPreparedImport(self.client, self.project_key, future.get_result())
878+
879+
class TablesPreparedImport(object):
880+
"""Result of preparing a tables import. Import can now be finished"""
881+
882+
def __init__(self, client, project_key, candidates):
883+
"""Do not call this directly, use :meth:`DSSProject.init_tables_import` and then prepare"""
884+
self.client = client
885+
self.project_key = project_key
886+
self.candidates = candidates
887+
888+
def execute(self):
889+
"""
890+
Starts executing the import in background and returns a :class:`dataikuapi.dss.future.DSSFuture` to wait on the result
891+
892+
:returns: a future to wait on the result
893+
:rtype: :class:`dataikuapi.dss.future.DSSFuture`
894+
"""
895+
ret = self.client._perform_json("POST", "/projects/%s/datasets/tables-import/actions/execute-from-candidates" % (self.project_key),
896+
body = self.candidates)
897+
return self.client.get_future(ret["jobId"])
898+
823899
class DSSProjectSettings(object):
824900
"""Settings of a DSS project"""
825901

dataikuapi/dss/recipe.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,21 @@ def delete(self):
2828

2929
def get_definition_and_payload(self):
3030
"""
31-
Get the definition of the recipe
31+
Gets the definition of the recipe
3232
33-
Returns:
34-
the definition, as a DSSRecipeDefinitionAndPayload object, containing the recipe definition itself and its payload
33+
:returns: the definition, as a :py:class:`DSSRecipeDefinitionAndPayload` object, containing the recipe definition itself and its payload
34+
:rtype: :py:class:`DSSRecipeDefinitionAndPayload`
3535
"""
3636
data = self.client._perform_json(
3737
"GET", "/projects/%s/recipes/%s" % (self.project_key, self.recipe_name))
3838
return DSSRecipeDefinitionAndPayload(data)
3939

4040
def set_definition_and_payload(self, definition):
4141
"""
42-
Set the definition of the recipe
42+
Sets and saves the definition of the recipe
4343
44-
Args:
45-
definition: the definition, as a DSSRecipeDefinitionAndPayload object. You should only set a definition object
46-
that has been retrieved using the get_definition call.
44+
:param definition object: the definition, as a :py:class:`DSSRecipeDefinitionAndPayload` object. You should only set a definition object
45+
that has been retrieved using the :py:meth:get_definition_and_payload call.
4746
"""
4847
return self.client._perform_json(
4948
"PUT", "/projects/%s/recipes/%s" % (self.project_key, self.recipe_name),

dataikuapi/dssclient.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,17 @@ def get_log(self, name):
596596
return self._perform_json(
597597
"GET", "/admin/logs/%s" % name)
598598

599+
def log_custom_audit(self, custom_type, custom_params={}):
600+
"""
601+
Log a custom entry to the audit trail
602+
603+
:param str custom_type value for customMsgType in audit trail item
604+
:param dict custom_params value for customMsgParams in audit trail item
605+
"""
606+
return self._perform_empty("POST",
607+
"/admin/audit/custom/%s" % custom_type,
608+
body = custom_params)
609+
599610
########################################################
600611
# Variables
601612
########################################################
@@ -774,6 +785,18 @@ def create_personal_api_key(self, label):
774785
return self._perform_json("POST", "/auth/personal-api-keys",
775786
params={"label": label})
776787

788+
########################################################
789+
# Licensing
790+
########################################################
791+
792+
def get_licensing_status(self):
793+
"""
794+
Returns a dictionary with information about licensing status of this DSS instance
795+
796+
:rtype dict
797+
"""
798+
return self._perform_json("GET", "/admin/licensing/status")
799+
777800
########################################################
778801
# Internal Request handling
779802
########################################################

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup
44

5-
VERSION = "5.0.0"
5+
VERSION = "5.1.0"
66

77
long_description = (open('README').read() +
88
'\n\n' + open('HISTORY.txt').read())

0 commit comments

Comments
 (0)