Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Mar 29, 2021

Pull Request #132 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 feature/dss-90-API_Modification branch, then run:

git fetch origin sourcery/feature/dss-90-API_Modification
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai sourcery-ai bot requested a review from FlorentDev64 March 29, 2021 13:32
@sourcery-ai sourcery-ai bot force-pushed the sourcery/feature/dss-90-API_Modification branch from 94cbb30 to 08aacdd Compare March 31, 2021 12:36
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 -297 to +300
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 -437 to +440
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 -749 to +750
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 -960 to +963
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 -1179 to +1182
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 -1267 to +1268
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 -1625 to +1628
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 Mar 31, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 2.39 ⭐ 2.13 ⭐ -0.26 👍
Method Length 31.79 ⭐ 31.59 ⭐ -0.20 👍
Working memory 8.47 🙂 8.45 🙂 -0.02 👍
Quality 79.70% 80.13% 0.43% 👍
Other metrics Before After Change
Lines 1458 1457 -1
Changed files Quality Before Quality After Quality Change
dataikuapi/dss/project.py 79.70% ⭐ 80.13% ⭐ 0.43% 👍

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_datasets 3 ⭐ 59 ⭐ 12 😞 68.44% 🙂 Extract out complex expressions
dataikuapi/dss/project.py DSSProject.list_streaming_endpoints 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.

Base automatically changed from feature/dss-90-API_Modification to release/9.0 April 12, 2021 08:41
@cstenac cstenac closed this May 3, 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