@@ -193,8 +193,9 @@ def duplicate(self, target_project_key,
193193 if target_project_folder is not None :
194194 obj ["targetProjectFolderId" ] = target_project_folder .project_folder_id
195195
196- ref = self .client ._perform_json ("POST" , "/projects/%s/duplicate/" % self .project_key , body = obj )
197- return ref
196+ return self .client ._perform_json (
197+ "POST" , "/projects/%s/duplicate/" % self .project_key , body = obj
198+ )
198199
199200 ########################################################
200201 # Project infos
@@ -263,9 +264,9 @@ def list_datasets(self, as_type="listitems"):
263264 :rtype: list
264265 """
265266 items = self .client ._perform_json ("GET" , "/projects/%s/datasets/" % self .project_key )
266- if as_type == "listitems" or as_type == "listitem" :
267+ if as_type in [ "listitems" , "listitem" ] :
267268 return [DSSDatasetListItem (self .client , item ) for item in items ]
268- elif as_type == "objects" or as_type == "object" :
269+ elif as_type in [ "objects" , "object" ] :
269270 return [DSSDataset (self .client , self .project_key , item ["name" ]) for item in items ]
270271 else :
271272 raise ValueError ("Unknown as_type" )
@@ -403,9 +404,9 @@ def list_streaming_endpoints(self, as_type="listitems"):
403404 :rtype: list
404405 """
405406 items = self .client ._perform_json ("GET" , "/projects/%s/streamingendpoints/" % self .project_key )
406- if as_type == "listitems" or as_type == "listitem" :
407+ if as_type in [ "listitems" , "listitem" ] :
407408 return [DSSStreamingEndpointListItem (self .client , item ) for item in items ]
408- elif as_type == "objects" or as_type == "object" :
409+ elif as_type in [ "objects" , "object" ] :
409410 return [DSSStreamingEndpoint (self .client , self .project_key , item ["id" ]) for item in items ]
410411 else :
411412 raise ValueError ("Unknown as_type" )
@@ -715,7 +716,7 @@ def list_model_evaluation_stores(self, as_type=None):
715716 :rtype: list
716717 """
717718 items = self .client ._perform_json ("GET" , "/projects/%s/modelevaluationstores/" % self .project_key )
718- if as_type == "objects" or as_type == "object" :
719+ if as_type in [ "objects" , "object" ] :
719720 return [DSSModelEvaluationStore (self .client , self .project_key , item ["id" ]) for item in items ]
720721 else :
721722 return items
@@ -840,9 +841,9 @@ def list_jupyter_notebooks(self, active=False, as_type="object"):
840841 :rtype: list of :class:`dataikuapi.dss.notebook.DSSJupyterNotebook` or list of String
841842 """
842843 notebook_items = self .client ._perform_json ("GET" , "/projects/%s/jupyter-notebooks/" % self .project_key , params = {"active" : active })
843- if as_type == "listitems" or as_type == "listitem" :
844+ if as_type in [ "listitems" , "listitem" ] :
844845 return [DSSJupyterNotebookListItem (self .client , notebook_item ) for notebook_item in notebook_items ]
845- elif as_type == "objects" or as_type == "object" :
846+ elif as_type in [ "objects" , "object" ] :
846847 return [DSSJupyterNotebook (self .client , self .project_key , notebook_item ["name" ]) for notebook_item in notebook_items ]
847848 else :
848849 raise ValueError ("Unknown as_type" )
@@ -922,9 +923,9 @@ def set_variables(self, obj):
922923
923924 @param dict obj: must be a modified version of the object returned by get_variables
924925 """
925- if not "standard" in obj :
926+ if "standard" not in obj :
926927 raise ValueError ("Missing 'standard' key in argument" )
927- if not "local" in obj :
928+ if "local" not in obj :
928929 raise ValueError ("Missing 'local' key in argument" )
929930
930931 self .client ._perform_empty (
@@ -1141,9 +1142,9 @@ def list_recipes(self, as_type="listitems"):
11411142 :rtype: list
11421143 """
11431144 items = self .client ._perform_json ("GET" , "/projects/%s/recipes/" % self .project_key )
1144- if as_type == "listitems" or as_type == "listitem" :
1145+ if as_type in [ "listitems" , "listitem" ] :
11451146 return [DSSRecipeListItem (self .client , item ) for item in items ]
1146- elif as_type == "objects" or as_type == "object" :
1147+ elif as_type in [ "objects" , "object" ] :
11471148 return [DSSRecipe (self .client , self .project_key , item ["name" ]) for item in items ]
11481149 else :
11491150 raise ValueError ("Unknown as_type" )
@@ -1229,7 +1230,7 @@ def new_recipe(self, type, name=None):
12291230 return recipe .SamplingRecipeCreator (name , self )
12301231 elif type == "split" :
12311232 return recipe .SplitRecipeCreator (name , self )
1232- elif type == "prepare" or type == "shaker" :
1233+ elif type in [ "prepare" , "shaker" ] :
12331234 return recipe .PrepareRecipeCreator (name , self )
12341235 elif type == "prediction_scoring" :
12351236 return recipe .PredictionScoringRecipeCreator (name , self )
@@ -1588,11 +1589,9 @@ def add_exposed_object(self, object_type, object_id, target_project):
15881589 found_eo = {"type" : object_type , "localName" : object_id , "rules" : []}
15891590 self .settings ["exposedObjects" ]["objects" ].append (found_eo )
15901591
1591- already_exists = False
1592- for rule in found_eo ["rules" ]:
1593- if rule ["targetProject" ] == target_project :
1594- already_exists = True
1595- break
1592+ already_exists = any (
1593+ rule ["targetProject" ] == target_project for rule in found_eo ["rules" ]
1594+ )
15961595
15971596 if not already_exists :
15981597 found_eo ["rules" ].append ({"targetProject" : target_project })
0 commit comments