Skip to content

Sourcery refactored master branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Apr 28, 2022

Branch master refactored by Sourcery.

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

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 master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from edson-github April 28, 2022 23:50
Comment on lines -41 to +43
dataDict = {}
for i in range(len(encodedCols)):
dataDict[f"col{1 + i}"] = list(encodedCols[i])
dataDict = {
f"col{1 + i}": list(encodedCols[i]) for i in range(len(encodedCols))
}
Copy link
Author

Choose a reason for hiding this comment

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

Function PCA refactored with the following changes:

Comment on lines -15 to +18
return p_value
# two sample t-test where _arg1 is numeric and _arg2 is a binary factor
elif len(set(_arg2)) == 2:
# each sample in _arg1 needs to have a corresponding classification
# in _arg2
if not (len(_arg1) == len(_arg2)):
if len(_arg1) != len(_arg2):
Copy link
Author

Choose a reason for hiding this comment

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

Function ttest refactored with the following changes:

This removes the following comments ( why? ):

# arg1 is a sample and arg2 is a sample
# two sample t-test where _arg1 is numeric and _arg2 is a binary factor

pkg_path = os.path.dirname(tabpy.__file__)
config_file_path = os.path.join(pkg_path, "tabpy_server", "common", "default.conf")
return config_file_path
return os.path.join(pkg_path, "tabpy_server", "common", "default.conf")
Copy link
Author

Choose a reason for hiding this comment

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

Function get_default_config_file_path refactored with the following changes:

Comment on lines -21 to +20
port = 9004
if "TABPY_PORT" in tabpy_config:
port = tabpy_config["TABPY_PORT"]

port = tabpy_config["TABPY_PORT"] if "TABPY_PORT" in tabpy_config else 9004
Copy link
Author

Choose a reason for hiding this comment

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

Function parse_config refactored with the following changes:

Comment on lines -24 to +28
msg = https_error + f"The certificate provided is not valid until {not_before}."
msg = f"{https_error}The certificate provided is not valid until {not_before}."
logger.critical(msg)
raise RuntimeError(msg)
if now > not_after:
msg = https_error + f"The certificate provided expired on {not_after}."
msg = f"{https_error}The certificate provided expired on {not_after}."
Copy link
Author

Choose a reason for hiding this comment

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

Function validate_cert refactored with the following changes:

sub_path.append(str(version))
full_path = root_path + "/".join(sub_path)
return full_path
return root_path + "/".join(sub_path)
Copy link
Author

Choose a reason for hiding this comment

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

Function get_query_object_path refactored with the following changes:

Comment on lines -132 to +131
endpoint_info["docstring"] = str(
bytes(docstring, "utf-8").decode("unicode_escape")
)
endpoint_info["docstring"] = bytes(docstring, "utf-8").decode("unicode_escape")
Copy link
Author

Choose a reason for hiding this comment

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

Function TabPyState.get_endpoints refactored with the following changes:

Comment on lines -185 to +180
if dependencies or not isinstance(dependencies, list):
raise ValueError("dependencies must be a list.")

return dependencies
raise ValueError("dependencies must be a list.")
Copy link
Author

Choose a reason for hiding this comment

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

Function TabPyState._check_and_set_dependencies refactored with the following changes:

Comment on lines -263 to +255
dstring = str(
bytes(info["docstring"], "utf-8").decode("unicode_escape")
)
dstring = bytes(info["docstring"], "utf-8").decode("unicode_escape")
Copy link
Author

Choose a reason for hiding this comment

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

Function TabPyState._add_update_endpoints_config refactored with the following changes:

Comment on lines -399 to +389
if len(deps) > 0:
if deps:
Copy link
Author

Choose a reason for hiding this comment

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

Function TabPyState.delete_endpoint refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Apr 28, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 4.15 ⭐ 3.93 ⭐ -0.22 👍
Method Length 45.70 ⭐ 45.48 ⭐ -0.22 👍
Working memory 6.96 🙂 6.96 🙂 0.00
Quality 74.73% 🙂 74.97% 🙂 0.24% 👍
Other metrics Before After Change
Lines 4299 4260 -39
Changed files Quality Before Quality After Quality Change
tabpy/models/scripts/PCA.py 51.26% 🙂 52.53% 🙂 1.27% 👍
tabpy/models/scripts/tTest.py 61.66% 🙂 62.77% 🙂 1.11% 👍
tabpy/models/utils/setup_utils.py 77.83% ⭐ 77.31% ⭐ -0.52% 👎
tabpy/tabpy_server/app/util.py 63.33% 🙂 63.33% 🙂 0.00%
tabpy/tabpy_server/common/endpoint_file_mgr.py 75.11% ⭐ 77.33% ⭐ 2.22% 👍
tabpy/tabpy_server/common/util.py 93.21% ⭐ 96.34% ⭐ 3.13% 👍
tabpy/tabpy_server/handlers/base_handler.py 76.90% ⭐ 76.73% ⭐ -0.17% 👎
tabpy/tabpy_server/handlers/endpoint_handler.py 62.51% 🙂 62.81% 🙂 0.30% 👍
tabpy/tabpy_server/handlers/evaluation_plane_handler.py 65.97% 🙂 66.55% 🙂 0.58% 👍
tabpy/tabpy_server/handlers/management_handler.py 43.12% 😞 43.16% 😞 0.04% 👍
tabpy/tabpy_server/handlers/service_info_handler.py 82.19% ⭐ 82.73% ⭐ 0.54% 👍
tabpy/tabpy_server/handlers/status_handler.py 83.95% ⭐ 83.38% ⭐ -0.57% 👎
tabpy/tabpy_server/management/state.py 78.92% ⭐ 79.25% ⭐ 0.33% 👍
tabpy/tabpy_server/psws/callbacks.py 57.65% 🙂 58.02% 🙂 0.37% 👍
tabpy/tabpy_server/psws/python_service.py 68.71% 🙂 69.16% 🙂 0.45% 👍
tabpy/tabpy_tools/client.py 77.98% ⭐ 78.00% ⭐ 0.02% 👍
tabpy/tabpy_tools/query_object.py 89.06% ⭐ 89.58% ⭐ 0.52% 👍
tabpy/tabpy_tools/rest.py 85.38% ⭐ 85.59% ⭐ 0.21% 👍
tabpy/tabpy_tools/rest_client.py 91.62% ⭐ 91.58% ⭐ -0.04% 👎
tabpy/tabpy_tools/schema.py 56.47% 🙂 58.58% 🙂 2.11% 👍
tabpy/utils/tabpy_user.py 82.11% ⭐ 82.52% ⭐ 0.41% 👍
tests/integration/integ_test_base.py 75.21% ⭐ 75.07% ⭐ -0.14% 👎
tests/integration/test_gzip.py 67.57% 🙂 67.84% 🙂 0.27% 👍
tests/unit/server_tests/test_config.py 86.16% ⭐ 86.03% ⭐ -0.13% 👎
tests/unit/server_tests/test_pwd_file.py 87.51% ⭐ 87.18% ⭐ -0.33% 👎
tests/unit/tools_tests/test_rest_object.py 56.74% 🙂 56.96% 🙂 0.22% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
tabpy/tabpy_server/handlers/management_handler.py ManagementHandler._add_or_update_endpoint 16 🙂 305 ⛔ 17 ⛔ 28.19% 😞 Try splitting into smaller methods. Extract out complex expressions
tabpy/tabpy_server/psws/callbacks.py on_state_change 14 🙂 196 😞 12 😞 41.85% 😞 Try splitting into smaller methods. Extract out complex expressions
tabpy/tabpy_server/handlers/evaluation_plane_handler.py EvaluationPlaneHandler._post_impl 12 🙂 212 ⛔ 11 😞 44.14% 😞 Try splitting into smaller methods. Extract out complex expressions
tabpy/tabpy_server/management/state.py TabPyState.update_endpoint 8 ⭐ 178 😞 13 😞 47.16% 😞 Try splitting into smaller methods. Extract out complex expressions
tabpy/models/scripts/PCA.py PCA 10 🙂 193 😞 10 😞 49.24% 😞 Try splitting into smaller methods. 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!

Help us improve this quality report!

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