Skip to content

Commit f0c58de

Browse files
committed
more documentation for tables import:
1 parent d53a851 commit f0c58de

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

dataikuapi/dss/project.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,18 @@ def get_object_discussions(self):
825825
########################################################
826826

827827
def init_tables_import(self):
828-
return TablesImportBuffer(self.client, self.project_key)
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)
829835

830-
class TablesImportBuffer(object):
836+
class TablesImportDefinition(object):
837+
"""
838+
Temporary structure holding the list of tables to import
839+
"""
831840

832841
def __init__(self, client, project_key):
833842
"""Do not call this directly, use :meth:`DSSProject.init_tables_import`"""
@@ -836,19 +845,30 @@ def __init__(self, client, project_key):
836845
self.keys = []
837846

838847
def add_hive_table(self, hive_database, hive_table):
848+
"""Add a Hive table to the list of tables to import"""
839849
self.keys.append({
840850
"connectionName" : "@virtual(hive-jdbc):" + hive_database,
841851
"name" : hive_table
842852
})
843853

844854
def add_sql_table(self, connection, schema, table):
855+
"""Add a SQL table to the list of table to import"""
845856
self.keys.append({
846857
"connectionName" : connection,
847858
"schema": schema,
848859
"name" : table
849860
})
850861

851862
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+
"""
852872
ret = self.client._perform_json("POST", "/projects/%s/datasets/tables-import/actions/prepare-from-keys" % (self.project_key),
853873
body = {"keys": self.keys} )
854874

@@ -857,16 +877,19 @@ def prepare(self):
857877
return TablesPreparedImport(self.client, self.project_key, future.get_result())
858878

859879
class TablesPreparedImport(object):
860-
"""Do not call this directly, use :meth:`DSSProject.init_tables_import` and then prepare"""
880+
"""Result of preparing a tables import. Import can now be finished"""
881+
861882
def __init__(self, client, project_key, candidates):
883+
"""Do not call this directly, use :meth:`DSSProject.init_tables_import` and then prepare"""
862884
self.client = client
863885
self.project_key = project_key
864886
self.candidates = candidates
865887

866888
def execute(self):
867889
"""
868-
Executes the import in background
890+
Starts executing the import in background and returns a :class:`dataikuapi.dss.future.DSSFuture` to wait on the result
869891
892+
:returns: a future to wait on the result
870893
:rtype: :class:`dataikuapi.dss.future.DSSFuture`
871894
"""
872895
ret = self.client._perform_json("POST", "/projects/%s/datasets/tables-import/actions/execute-from-candidates" % (self.project_key),

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),

0 commit comments

Comments
 (0)