@@ -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
@@ -294,9 +295,9 @@ def list_datasets(self, as_type="listitems"):
294295 :rtype: list
295296 """
296297 items = self .client ._perform_json ("GET" , "/projects/%s/datasets/" % self .project_key )
297- if as_type == "listitems" or as_type == "listitem" :
298+ if as_type in [ "listitems" , "listitem" ] :
298299 return [DSSDatasetListItem (self .client , item ) for item in items ]
299- elif as_type == "objects" or as_type == "object" :
300+ elif as_type in [ "objects" , "object" ] :
300301 return [DSSDataset (self .client , self .project_key , item ["name" ]) for item in items ]
301302 else :
302303 raise ValueError ("Unknown as_type" )
@@ -434,9 +435,9 @@ def list_streaming_endpoints(self, as_type="listitems"):
434435 :rtype: list
435436 """
436437 items = self .client ._perform_json ("GET" , "/projects/%s/streamingendpoints/" % self .project_key )
437- if as_type == "listitems" or as_type == "listitem" :
438+ if as_type in [ "listitems" , "listitem" ] :
438439 return [DSSStreamingEndpointListItem (self .client , item ) for item in items ]
439- elif as_type == "objects" or as_type == "object" :
440+ elif as_type in [ "objects" , "object" ] :
440441 return [DSSStreamingEndpoint (self .client , self .project_key , item ["id" ]) for item in items ]
441442 else :
442443 raise ValueError ("Unknown as_type" )
@@ -746,7 +747,7 @@ def list_model_evaluation_stores(self, as_type=None):
746747 :rtype: list
747748 """
748749 items = self .client ._perform_json ("GET" , "/projects/%s/modelevaluationstores/" % self .project_key )
749- if as_type == "objects" or as_type == "object" :
750+ if as_type in [ "objects" , "object" ] :
750751 return [DSSModelEvaluationStore (self .client , self .project_key , item ["id" ]) for item in items ]
751752 else :
752753 return items
@@ -957,9 +958,9 @@ def set_variables(self, obj):
957958
958959 @param dict obj: must be a modified version of the object returned by get_variables
959960 """
960- if not "standard" in obj :
961+ if "standard" not in obj :
961962 raise ValueError ("Missing 'standard' key in argument" )
962- if not "local" in obj :
963+ if "local" not in obj :
963964 raise ValueError ("Missing 'local' key in argument" )
964965
965966 self .client ._perform_empty (
@@ -1176,9 +1177,9 @@ def list_recipes(self, as_type="listitems"):
11761177 :rtype: list
11771178 """
11781179 items = self .client ._perform_json ("GET" , "/projects/%s/recipes/" % self .project_key )
1179- if as_type == "listitems" or as_type == "listitem" :
1180+ if as_type in [ "listitems" , "listitem" ] :
11801181 return [DSSRecipeListItem (self .client , item ) for item in items ]
1181- elif as_type == "objects" or as_type == "object" :
1182+ elif as_type in [ "objects" , "object" ] :
11821183 return [DSSRecipe (self .client , self .project_key , item ["name" ]) for item in items ]
11831184 else :
11841185 raise ValueError ("Unknown as_type" )
@@ -1264,7 +1265,7 @@ def new_recipe(self, type, name=None):
12641265 return recipe .SamplingRecipeCreator (name , self )
12651266 elif type == "split" :
12661267 return recipe .SplitRecipeCreator (name , self )
1267- elif type == "prepare" or type == "shaker" :
1268+ elif type in [ "prepare" , "shaker" ] :
12681269 return recipe .PrepareRecipeCreator (name , self )
12691270 elif type == "prediction_scoring" :
12701271 return recipe .PredictionScoringRecipeCreator (name , self )
@@ -1622,11 +1623,9 @@ def add_exposed_object(self, object_type, object_id, target_project):
16221623 found_eo = {"type" : object_type , "localName" : object_id , "rules" : []}
16231624 self .settings ["exposedObjects" ]["objects" ].append (found_eo )
16241625
1625- already_exists = False
1626- for rule in found_eo ["rules" ]:
1627- if rule ["targetProject" ] == target_project :
1628- already_exists = True
1629- break
1626+ already_exists = any (
1627+ rule ["targetProject" ] == target_project for rule in found_eo ["rules" ]
1628+ )
16301629
16311630 if not already_exists :
16321631 found_eo ["rules" ].append ({"targetProject" : target_project })
0 commit comments