Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Apr 1, 2021

Pull Request #140 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 task/dss90-add-publish-version-method branch, then run:

git fetch origin sourcery/task/dss90-add-publish-version-method
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai sourcery-ai bot requested a review from AgatheG April 1, 2021 10:59
@sourcery-ai sourcery-ai bot force-pushed the sourcery/task/dss90-add-publish-version-method branch from f9c586b to f0db4d9 Compare April 1, 2021 17:35
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
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 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
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 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
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 on lines -718 to +719
if as_type == "objects" or as_type == "object":
if as_type in ["objects", "object"]:
Copy link
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 on lines -843 to +846
if as_type == "listitems" or as_type == "listitem":
if as_type in ["listitems", "listitem"]:
return [DSSJupyterNotebookListItem(self.client, notebook_item) for notebook_item in notebook_items]
elif as_type == "objects" or as_type == "object":
elif as_type in ["objects", "object"]:
Copy link
Author

Choose a reason for hiding this comment

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

Function DSSProject.list_jupyter_notebooks refactored with the following changes:

Comment on lines -925 to +928
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
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 on lines -1144 to +1147
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
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 on lines -1232 to +1233
elif type == "prepare" or type == "shaker":
elif type in ["prepare", "shaker"]:
Copy link
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 on lines -1591 to +1594
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
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)

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Apr 1, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 2.45 ⭐ 2.17 ⭐ -0.28 👍
Method Length 32.03 ⭐ 31.80 ⭐ -0.23 👍
Working memory 8.54 🙂 8.51 🙂 -0.03 👍
Quality 79.45% 79.91% 0.46% 👍
Other metrics Before After Change
Lines 1425 1424 -1
Changed files Quality Before Quality After Quality Change
dataikuapi/dss/project.py 79.45% ⭐ 79.91% ⭐ 0.46% 👍

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/dss/project.py DSSProject.duplicate 2 ⭐ 70 🙂 18 ⛔ 60.50% 🙂 Extract out complex expressions
dataikuapi/dss/project.py DSSProject.create_prediction_ml_task 2 ⭐ 75 🙂 14 😞 63.99% 🙂 Extract out complex expressions
dataikuapi/dss/project.py DSSProject.list_jupyter_notebooks 3 ⭐ 65 🙂 12 😞 67.50% 🙂 Extract out complex expressions
dataikuapi/dss/project.py DSSProject.list_datasets 3 ⭐ 59 ⭐ 12 😞 68.44% 🙂 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.

@AgatheG AgatheG closed this Apr 8, 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.

2 participants