1111from . import recipe
1212
1313class DSSDatasetListItem (DSSTaggableObjectListItem ):
14- """An item in a list of datasets. Do not instantiate this class"""
14+ """An item in a list of datasets. Do not instantiate this class, use :meth:`dataikuapi.dss.project.DSSProject.list_datasets` """
1515 def __init__ (self , client , data ):
1616 super (DSSDatasetListItem , self ).__init__ (data )
1717 self .client = client
@@ -51,7 +51,7 @@ def get_column(self, column):
5151
5252class DSSDataset (object ):
5353 """
54- A dataset on the DSS instance
54+ A dataset on the DSS instance. Do not instantiate this class, use :meth:`dataikuapi.dss.project.DSSProject.get_dataset`
5555 """
5656 def __init__ (self , client , project_key , dataset_name ):
5757 self .client = client
@@ -109,9 +109,9 @@ def get_settings(self):
109109 """
110110 data = self .client ._perform_json ("GET" , "/projects/%s/datasets/%s" % (self .project_key , self .dataset_name ))
111111
112- if data ["type" ] in self .__class__ .FS_TYPES :
112+ if data ["type" ] in self .__class__ ._FS_TYPES :
113113 return FSLikeDatasetSettings (self , data )
114- elif data ["type" ] in self .__class__ .SQL_TYPES :
114+ elif data ["type" ] in self .__class__ ._SQL_TYPES :
115115 return SQLDatasetSettings (self , data )
116116 else :
117117 return DSSDatasetSettings (self , data )
@@ -558,33 +558,41 @@ def get_object_discussions(self):
558558 # Test / Autofill
559559 ########################################################
560560
561- FS_TYPES = ["Filesystem" , "UploadedFiles" , "FilesInFolder" ,
561+ _FS_TYPES = ["Filesystem" , "UploadedFiles" , "FilesInFolder" ,
562562 "HDFS" , "S3" , "Azure" , "GCS" , "FTP" , "SCP" , "SFTP" ]
563563 # HTTP is FSLike but not FS
564564
565- SQL_TYPES = ["JDBC" , "PostgreSQL" , "MySQL" , "Vertica" , "Snowflake" , "Redshift" ,
565+ _SQL_TYPES = ["JDBC" , "PostgreSQL" , "MySQL" , "Vertica" , "Snowflake" , "Redshift" ,
566566 "Greenplum" , "Teradata" , "Oracle" , "SQLServer" , "SAPHANA" , "Netezza" ,
567567 "BigQuery" , "Athena" , "hiveserver2" ]
568568
569569 def test_and_detect (self , infer_storage_types = False ):
570+ """Used internally by autodetect_settings. It is not usually required to call this method"""
570571 settings = self .get_settings ()
571572
572- if settings .type in self .__class__ .FS_TYPES :
573+ if settings .type in self .__class__ ._FS_TYPES :
573574 future_resp = self .client ._perform_json ("POST" ,
574575 "/projects/%s/datasets/%s/actions/testAndDetectSettings/fsLike" % (self .project_key , self .dataset_name ),
575576 body = {"detectPossibleFormats" : True , "inferStorageTypes" : infer_storage_types })
576577
577578 return DSSFuture (self .client , future_resp .get ('jobId' , None ), future_resp )
578- elif settings .type in self .__class__ .SQL_TYPES :
579+ elif settings .type in self .__class__ ._SQL_TYPES :
579580 return self .client ._perform_json ("POST" ,
580581 "/projects/%s/datasets/%s/actions/testAndDetectSettings/externalSQL" % (self .project_key , self .dataset_name ))
581582 else :
582583 raise ValueError ("don't know how to test/detect on dataset type:%s" % settings .type )
583584
584585 def autodetect_settings (self , infer_storage_types = False ):
586+ """
587+ Detects appropriate settings for this dataset using Dataiku detection engine
588+
589+ Returns new suggested settings that you can :meth:`DSSDatasetSettings.save`
590+
591+ :rtype: :class:`DSSDatasetSettings` or a subclass
592+ """
585593 settings = self .get_settings ()
586594
587- if settings .type in self .__class__ .FS_TYPES :
595+ if settings .type in self .__class__ ._FS_TYPES :
588596 future = self .test_and_detect (infer_storage_types )
589597 result = future .wait_for_result ()
590598
@@ -597,7 +605,7 @@ def autodetect_settings(self, infer_storage_types=False):
597605
598606 return settings
599607
600- elif settings .type in self .__class__ .SQL_TYPES :
608+ elif settings .type in self .__class__ ._SQL_TYPES :
601609 result = self .test_and_detect ()
602610
603611 if not "schemaDetection" in result :
@@ -610,6 +618,7 @@ def autodetect_settings(self, infer_storage_types=False):
610618 raise ValueError ("don't know how to test/detect on dataset type:%s" % settings .type )
611619
612620 def get_as_core_dataset (self ):
621+ """Returns the :class:`dataiku.Dataset` object corresponding to this dataset"""
613622 import dataiku
614623 return dataiku .Dataset ("%s.%s" % (self .project_key , self .dataset_name ))
615624
@@ -645,6 +654,13 @@ def new_recipe(self, type, recipe_name=None):
645654 return builder
646655
647656class DSSDatasetSettings (DSSTaggableObjectSettings ):
657+ """
658+ Base settings class for a DSS dataset.
659+ Do not instantiate this class directly, use :meth:`DSSDataset.get_settings`
660+
661+ Use :meth:`save` to save your changes
662+ """
663+
648664 def __init__ (self , dataset , settings ):
649665 super (DSSDatasetSettings , self ).__init__ (settings )
650666 self .dataset = dataset
@@ -662,6 +678,10 @@ def get_raw_params(self):
662678 def type (self ):
663679 return self .settings ["type" ]
664680
681+ @property
682+ def schema_columns (self ):
683+ return self .settings ["schema" ]["columns" ]
684+
665685 def remove_partitioning (self ):
666686 self .settings ["partitioning" ] = {"dimensions" : []}
667687
@@ -680,6 +700,13 @@ def save(self):
680700 body = self .settings )
681701
682702class FSLikeDatasetSettings (DSSDatasetSettings ):
703+ """
704+ Settings for a files-based dataset. This class inherits from :class:`DSSDatasetSettings`.
705+ Do not instantiate this class directly, use :meth:`DSSDataset.get_settings`
706+
707+ Use :meth:`save` to save your changes
708+ """
709+
683710 def __init__ (self , dataset , settings ):
684711 super (FSLikeDatasetSettings , self ).__init__ (dataset , settings )
685712
@@ -711,6 +738,12 @@ def set_partitioning_file_pattern(self, pattern):
711738 self .settings ["partitioning" ]["filePathPattern" ] = pattern
712739
713740class SQLDatasetSettings (DSSDatasetSettings ):
741+ """
742+ Settings for a SQL dataset. This class inherits from :class:`DSSDatasetSettings`.
743+ Do not instantiate this class directly, use :meth:`DSSDataset.get_settings`
744+
745+ Use :meth:`save` to save your changes
746+ """
714747 def __init__ (self , dataset , settings ):
715748 super (SQLDatasetSettings , self ).__init__ (dataset , settings )
716749
0 commit comments