-
Notifications
You must be signed in to change notification settings - Fork 29
Jupyter notebook / last polish (Sourcery refactored) #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import time, warnings, sys, os.path as osp | ||
| from .dataset import DSSDataset, DSSDatasetListItem, DSSManagedDatasetCreationHelper | ||
| from .jupyternotebook import DSSJupyterNotebook | ||
| from .jupyternotebook import DSSJupyterNotebook, DSSJupyterNotebookListItem | ||
| from .notebook import DSSNotebook | ||
| from .streaming_endpoint import DSSStreamingEndpoint, DSSStreamingEndpointListItem, DSSManagedStreamingEndpointCreationHelper | ||
| from .recipe import DSSRecipeListItem, DSSRecipe | ||
|
|
@@ -193,8 +193,9 @@ def duplicate(self, target_project_key, | |
| if target_project_folder is not None: | ||
| obj["targetProjectFolderId"] = target_project_folder.project_folder_id | ||
|
|
||
| ref = self.client._perform_json("POST", "/projects/%s/duplicate/" % self.project_key, body = obj) | ||
| return ref | ||
| return self.client._perform_json( | ||
| "POST", "/projects/%s/duplicate/" % self.project_key, body=obj | ||
| ) | ||
|
|
||
| ######################################################## | ||
| # Project infos | ||
|
|
@@ -263,9 +264,9 @@ def list_datasets(self, as_type="listitems"): | |
| :rtype: list | ||
| """ | ||
| items = self.client._perform_json("GET", "/projects/%s/datasets/" % self.project_key) | ||
| if as_type == "listitems" or as_type == "listitem": | ||
| if as_type in ["listitems", "listitem"]: | ||
| return [DSSDatasetListItem(self.client, item) for item in items] | ||
| elif as_type == "objects" or as_type == "object": | ||
| elif as_type in ["objects", "object"]: | ||
|
Comment on lines
-266
to
+269
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return [DSSDataset(self.client, self.project_key, item["name"]) for item in items] | ||
| else: | ||
| raise ValueError("Unknown as_type") | ||
|
|
@@ -403,9 +404,9 @@ def list_streaming_endpoints(self, as_type="listitems"): | |
| :rtype: list | ||
| """ | ||
| items = self.client._perform_json("GET", "/projects/%s/streamingendpoints/" % self.project_key) | ||
| if as_type == "listitems" or as_type == "listitem": | ||
| if as_type in ["listitems", "listitem"]: | ||
| return [DSSStreamingEndpointListItem(self.client, item) for item in items] | ||
| elif as_type == "objects" or as_type == "object": | ||
| elif as_type in ["objects", "object"]: | ||
|
Comment on lines
-406
to
+409
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return [DSSStreamingEndpoint(self.client, self.project_key, item["id"]) for item in items] | ||
| else: | ||
| raise ValueError("Unknown as_type") | ||
|
|
@@ -715,7 +716,7 @@ def list_model_evaluation_stores(self, as_type=None): | |
| :rtype: list | ||
| """ | ||
| items = self.client._perform_json("GET", "/projects/%s/modelevaluationstores/" % self.project_key) | ||
| if as_type == "objects" or as_type == "object": | ||
| if as_type in ["objects", "object"]: | ||
|
Comment on lines
-718
to
+719
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return [DSSModelEvaluationStore(self.client, self.project_key, item["id"]) for item in items] | ||
| else: | ||
| return items | ||
|
|
@@ -839,11 +840,11 @@ def list_jupyter_notebooks(self, active=False, as_type="object"): | |
| :returns: The list of the notebooks. If "as_type" is "names", each one as a string, if "as_type" is "objects", each one as a :class:`dataikuapi.dss.notebook.DSSJupyterNotebook` | ||
| :rtype: list of :class:`dataikuapi.dss.notebook.DSSJupyterNotebook` or list of String | ||
| """ | ||
| notebook_names = self.client._perform_json("GET", "/projects/%s/jupyter-notebooks/" % self.project_key, params={"active": active}) | ||
| if as_type == "names" or as_type == "name": | ||
| return notebook_names | ||
| elif as_type == "objects" or as_type == "object": | ||
| return [DSSJupyterNotebook(self.client, self.project_key, notebook_name) for notebook_name in notebook_names] | ||
| notebook_items = self.client._perform_json("GET", "/projects/%s/jupyter-notebooks/" % self.project_key, params={"active": active}) | ||
| if as_type in ["listitems", "listitem"]: | ||
| return [DSSJupyterNotebookListItem(self.client, notebook_item) for notebook_item in notebook_items] | ||
| elif as_type in ["objects", "object"]: | ||
| return [DSSJupyterNotebook(self.client, self.project_key, notebook_item["name"]) for notebook_item in notebook_items] | ||
| else: | ||
| raise ValueError("Unknown as_type") | ||
|
|
||
|
|
@@ -922,9 +923,9 @@ def set_variables(self, obj): | |
|
|
||
| @param dict obj: must be a modified version of the object returned by get_variables | ||
| """ | ||
| if not "standard" in obj: | ||
| if "standard" not in obj: | ||
| raise ValueError("Missing 'standard' key in argument") | ||
| if not "local" in obj: | ||
| if "local" not in obj: | ||
|
Comment on lines
-925
to
+928
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| raise ValueError("Missing 'local' key in argument") | ||
|
|
||
| self.client._perform_empty( | ||
|
|
@@ -1141,9 +1142,9 @@ def list_recipes(self, as_type="listitems"): | |
| :rtype: list | ||
| """ | ||
| items = self.client._perform_json("GET", "/projects/%s/recipes/" % self.project_key) | ||
| if as_type == "listitems" or as_type == "listitem": | ||
| if as_type in ["listitems", "listitem"]: | ||
| return [DSSRecipeListItem(self.client, item) for item in items] | ||
| elif as_type == "objects" or as_type == "object": | ||
| elif as_type in ["objects", "object"]: | ||
|
Comment on lines
-1144
to
+1147
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return [DSSRecipe(self.client, self.project_key, item["name"]) for item in items] | ||
| else: | ||
| raise ValueError("Unknown as_type") | ||
|
|
@@ -1229,7 +1230,7 @@ def new_recipe(self, type, name=None): | |
| return recipe.SamplingRecipeCreator(name, self) | ||
| elif type == "split": | ||
| return recipe.SplitRecipeCreator(name, self) | ||
| elif type == "prepare" or type == "shaker": | ||
| elif type in ["prepare", "shaker"]: | ||
|
Comment on lines
-1232
to
+1233
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return recipe.PrepareRecipeCreator(name, self) | ||
| elif type == "prediction_scoring": | ||
| return recipe.PredictionScoringRecipeCreator(name, self) | ||
|
|
@@ -1588,11 +1589,9 @@ def add_exposed_object(self, object_type, object_id, target_project): | |
| found_eo = {"type" : object_type, "localName" : object_id, "rules" : []} | ||
| self.settings["exposedObjects"]["objects"].append(found_eo) | ||
|
|
||
| already_exists = False | ||
| for rule in found_eo["rules"]: | ||
| if rule["targetProject"] == target_project: | ||
| already_exists = True | ||
| break | ||
| already_exists = any( | ||
| rule["targetProject"] == target_project for rule in found_eo["rules"] | ||
| ) | ||
|
Comment on lines
-1591
to
+1594
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| if not already_exists: | ||
| found_eo["rules"].append({"targetProject": target_project}) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
DSSProject.duplicaterefactored with the following changes:inline-immediately-returned-variable)