Skip to content
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

Sourcery refactored main branch #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Sourcery refactored main branch #16

wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented May 25, 2022

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

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from bvhpatel May 25, 2022 17:53
Comment on lines -38 to +48
error_message = make_response("Invalid data: need a json with key 'datasetIds' and value an array of integers", 400)
return error_message
return make_response(
"Invalid data: need a json with key 'datasetIds' and value an array of integers",
400,
)


print("json:", request.json)

payload = job_api.start_python_osparc_job(dataset_dict)

resp = make_response(json.dumps(payload), payload["status_code"])
return resp
return make_response(json.dumps(payload), payload["status_code"])
Copy link
Author

Choose a reason for hiding this comment

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

Function set_routes.create_job refactored with the following changes:

Comment on lines -64 to +66
resp = make_response(json.dumps(payload), payload["status_code"])
return resp
return make_response(json.dumps(payload), payload["status_code"])
Copy link
Author

Choose a reason for hiding this comment

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

Function set_routes.check_job_status refactored with the following changes:

payload = start_osparc_job("python", input_file_paths)

return payload
return start_osparc_job("python", input_file_paths)
Copy link
Author

Choose a reason for hiding this comment

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

Function start_python_osparc_job refactored with the following changes:

Comment on lines -74 to +72
payload = start_osparc_job("matlab", input_file_paths)

return payload
return start_osparc_job("matlab", input_file_paths)
Copy link
Author

Choose a reason for hiding this comment

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

Function start_matlab_osparc_job refactored with the following changes:

print(f"Now downloading to disk path:")
print("Now downloading to disk path:")
results_file: File = outputs.results[output_result_to_use]
#print(f"file id: {results_file.id}")
download_path: str = files_api.download_file(file_id=results_file.id)

Copy link
Author

Choose a reason for hiding this comment

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

Function check_job_status refactored with the following changes:

Comment on lines -398 to +381
# manifest.json: get dataset title, subtitle, publication date
# subjects.xlsx: species, n subjects, age range, sex
# samples.xlsx: n samples, specimen type, specimen anatomical location
data_table_summary = {}
manifest_json = get_dataset_main_manifest(datasetId)
data_table_summary['Dataset id'] = datasetId
data_table_summary['Title'] = manifest_json['name']
data_table_summary['Subtitle'] = manifest_json['description']
data_table_summary['Publication_date'] = manifest_json['datePublished']
data_table_summary = {
'Dataset id': datasetId,
'Title': manifest_json['name'],
'Subtitle': manifest_json['description'],
'Publication_date': manifest_json['datePublished'],
}
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_summary_table_data refactored with the following changes:

This removes the following comments ( why? ):

# subjects.xlsx: species, n subjects, age range, sex
# samples.xlsx: n samples, specimen type, specimen anatomical location
# manifest.json: get dataset title, subtitle, publication date

Comment on lines -465 to +440
data_text[datasetId] = {}
# text from dataset description
data_text[datasetId]['description'] = get_dataset_description_text(
datasetId)
data_text[datasetId] = {'description': get_dataset_description_text(datasetId)}
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_all_datasets_text refactored with the following changes:

This removes the following comments ( why? ):

# text from dataset description

Comment on lines -523 to +496
abstract = summariser(text_to_summarise, top_n=10)

# abstract = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
return abstract
return summariser(text_to_summarise, top_n=10)
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_abstract refactored with the following changes:

Comment on lines -605 to +575
dataset_mat = get_dataset_mat_files(datasetId)
if dataset_mat:
if dataset_mat := get_dataset_mat_files(datasetId):
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_all_datasets_mat_files refactored with the following changes:

Comment on lines -693 to -698
#list_datasetId = ['60', '64', '65', '16', '61', '89', '97']
#list_datasetId = ['60', '64', '65']

# storage dict to be saved as a json and returned to front-end
dataset_data = {}

Copy link
Author

Choose a reason for hiding this comment

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

Lines 693-710 refactored with the following changes:

This removes the following comments ( why? ):

#list_datasetId = ['60', '64', '65', '16', '61', '89', '97']
# storage dict to be saved as a json and returned to front-end
#list_datasetId = ['60', '64', '65']

@sourcery-ai
Copy link
Author

sourcery-ai bot commented May 25, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.25%.

Quality metrics Before After Change
Complexity 7.66 ⭐ 7.75 ⭐ 0.09 👎
Method Length 84.80 🙂 82.96 🙂 -1.84 👍
Working memory 8.71 🙂 8.82 🙂 0.11 👎
Quality 62.12% 🙂 61.87% 🙂 -0.25% 👎
Other metrics Before After Change
Lines 1164 1125 -39
Changed files Quality Before Quality After Quality Change
app/routes.py 66.89% 🙂 67.83% 🙂 0.94% 👍
app/osparc/job_api.py 65.35% 🙂 64.82% 🙂 -0.53% 👎
assets/INPUT_FOLDER/main.py 60.19% 🙂 59.83% 🙂 -0.36% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
assets/INPUT_FOLDER/main.py get_summary_table_data 13 🙂 273 ⛔ 15 😞 33.96% 😞 Try splitting into smaller methods. Extract out complex expressions
assets/INPUT_FOLDER/main.py get_all_datasets_mat_files 19 😞 220 ⛔ 13 😞 34.63% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
assets/INPUT_FOLDER/main.py get_text_correlation 22 😞 306 ⛔ 7 🙂 40.36% 😞 Refactor to reduce nesting. Try splitting into smaller methods
assets/INPUT_FOLDER/main.py get_protocolsio_text 15 🙂 153 😞 15 😞 40.67% 😞 Try splitting into smaller methods. Extract out complex expressions
app/osparc/job_api.py check_job_status 10 🙂 291 ⛔ 10 😞 43.81% 😞 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!

@lgtm-com
Copy link

lgtm-com bot commented May 25, 2022

This pull request fixes 1 alert when merging 26e3365 into 9ba2afb - view on LGTM.com

fixed alerts:

  • 1 for Unnecessary pass

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