Skip to content

Jupyter notebook API typo (Sourcery refactored)#129

Closed
sourcery-ai[bot] wants to merge 1 commit into
fix/dss90-jupyter-typofrom
sourcery/fix/dss90-jupyter-typo
Closed

Jupyter notebook API typo (Sourcery refactored)#129
sourcery-ai[bot] wants to merge 1 commit into
fix/dss90-jupyter-typofrom
sourcery/fix/dss90-jupyter-typo

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Mar 24, 2021

Copy link
Copy Markdown

Pull Request #128 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the fix/dss90-jupyter-typo branch, then run:

git fetch origin sourcery/fix/dss90-jupyter-typo
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai sourcery-ai Bot requested a review from pbailly March 24, 2021 14:21
Comment thread dataikuapi/dssclient.py
Comment on lines -594 to +599
definition = {}
definition['name'] = cluster_name
definition['type'] = cluster_type
definition['params'] = params if params is not None else {}
definition = {
'name': cluster_name,
'type': cluster_type,
'params': params if params is not None else {},
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSClient.create_cluster refactored with the following changes:

Comment thread dataikuapi/dssclient.py
Comment on lines -708 to +710
if isinstance(v, str) or isinstance(v, unicode):
if isinstance(v, (str, unicode)):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSClient.make_entry refactored with the following changes:

Comment thread dataikuapi/dss/ml.py Outdated
Comment on lines +141 to +144
if not feature_name in self.mltask_settings["preprocessing"]["per_feature"]:
if (
feature_name
not in self.mltask_settings["preprocessing"]["per_feature"]
):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PredictionSplitParamsHandler.set_time_ordering refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment thread dataikuapi/dss/ml.py Outdated
Comment on lines +309 to +312
if len(diagnostic) == 0:
if not diagnostic:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSMLTaskSettings.set_diagnostic_type_enabled refactored with the following changes:

Comment thread dataikuapi/dss/ml.py Outdated
Comment on lines +713 to +716
pretty_hyperparam = dict()
pretty_hyperparam = {}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NumericalHyperparameterSettings._pretty_repr refactored with the following changes:

Comment thread dataikuapi/dss/ml.py Outdated
Comment on lines +2778 to +2786
if self.gt is not None:
repr_gt = "%s<" % self.gt
elif self.gte is not None:
repr_gt = "%s<=" % self.gte
else:
if self.gt is not None:
repr_gt = "%s<" % self.gt
elif self.gte is not None:
repr_gt = "%s<=" % self.gte
else:
repr_gt = ""
repr_gt = ""

if self.lte is not None:
repr_lt = "<=%s" % self.lte
else:
repr_lt = ""

return "DSSSubpopulationNumericModalityDefinition(%s%s%s)" % (repr_gt, self.feature_name, repr_lt)
repr_lt = "<=%s" % self.lte if self.lte is not None else ""
return "DSSSubpopulationNumericModalityDefinition(%s%s%s)" % (repr_gt, self.feature_name, repr_lt)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSSubpopulationNumericModalityDefinition.__repr__ refactored with the following changes:

Comment thread dataikuapi/dss/ml.py Outdated
Comment on lines +2867 to +2873
if len(modality_candidates) == 0:
if not modality_candidates:
raise ValueError("Modality with index '%s' not found" % definition.index)
return modality_candidates[0]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSSubpopulationAnalysis.get_modality_data refactored with the following changes:

Comment thread dataikuapi/dss/ml.py Outdated
Comment on lines +3120 to +3125
else:
if project_key is None:
project_key = match.group(1)
return DSSMLTask(client, project_key, match.group(2), match.group(3))
if project_key is None:
project_key = match.group(1)
return DSSMLTask(client, project_key, match.group(2), match.group(3))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSMLTask.from_full_model_id refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -196 to +198
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
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.duplicate refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -266 to +269
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"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.list_datasets refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -406 to +409
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"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.list_streaming_endpoints refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -718 to +719
if as_type == "objects" or as_type == "object":
if as_type in ["objects", "object"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.list_model_evaluation_stores refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -930 to +933
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:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.set_variables refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment thread dataikuapi/dss/project.py
Comment on lines -1149 to +1152
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"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.list_recipes refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -1237 to +1238
elif type == "prepare" or type == "shaker":
elif type in ["prepare", "shaker"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.new_recipe refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -1596 to +1599
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"]
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProjectSettings.add_exposed_object refactored with the following changes:

  • Use any() instead of for loop (use-any)

Comment thread dataikuapi/dss/projectdeployer.py Outdated
params = None
else:
params = {
params = None if project_key is None else {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProjectDeployer.upload_bundle refactored with the following changes:

@sourcery-ai sourcery-ai Bot force-pushed the sourcery/fix/dss90-jupyter-typo branch from defb145 to 08b4ab3 Compare March 24, 2021 14:21
@sourcery-ai

sourcery-ai Bot commented Mar 24, 2021

Copy link
Copy Markdown
Author

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.39%.

Quality metrics Before After Change
Complexity 2.16 ⭐ 1.97 ⭐ -0.19 👍
Method Length 29.77 ⭐ 29.56 ⭐ -0.21 👍
Working memory 8.30 🙂 8.27 🙂 -0.03 👍
Quality 80.23% 80.62% 0.39% 👍
Other metrics Before After Change
Lines 2380 2381 1
Changed files Quality Before Quality After Quality Change
dataikuapi/dssclient.py 81.22% ⭐ 81.53% ⭐ 0.31% 👍
dataikuapi/dss/project.py 79.64% ⭐ 80.08% ⭐ 0.44% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
dataikuapi/dss/project.py DSSProject.new_recipe 16 🙂 178 😞 28 ⛔ 30.13% 😞 Try splitting into smaller methods. Extract out complex expressions
dataikuapi/dssclient.py DSSClient.create_meaning 5 ⭐ 116 🙂 14 😞 55.31% 🙂 Extract out complex expressions
dataikuapi/dss/project.py DSSProject.duplicate 2 ⭐ 70 🙂 18 ⛔ 60.50% 🙂 Extract out complex expressions
dataikuapi/dssclient.py DSSClient.sql_query 1 ⭐ 60 ⭐ 20 ⛔ 61.62% 🙂 Extract out complex expressions
dataikuapi/dssclient.py DSSClient._perform_http 5 ⭐ 94 🙂 11 😞 62.98% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@sourcery-ai sourcery-ai Bot closed this Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants