-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Conversation
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"]) |
There was a problem hiding this comment.
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:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
resp = make_response(json.dumps(payload), payload["status_code"]) | ||
return resp | ||
return make_response(json.dumps(payload), payload["status_code"]) |
There was a problem hiding this comment.
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:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
payload = start_osparc_job("python", input_file_paths) | ||
|
||
return payload | ||
return start_osparc_job("python", input_file_paths) |
There was a problem hiding this comment.
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:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
payload = start_osparc_job("matlab", input_file_paths) | ||
|
||
return payload | ||
return start_osparc_job("matlab", input_file_paths) |
There was a problem hiding this comment.
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:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
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) | ||
|
There was a problem hiding this comment.
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:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
# 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'], | ||
} |
There was a problem hiding this comment.
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:
- Merge dictionary assignment with declaration (
merge-dict-assign
) - Move assignment closer to its usage within a block (
move-assign-in-block
)
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
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)} |
There was a problem hiding this comment.
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:
- Merge dictionary assignment with declaration (
merge-dict-assign
)
This removes the following comments ( why? ):
# text from dataset description
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) |
There was a problem hiding this comment.
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:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
dataset_mat = get_dataset_mat_files(datasetId) | ||
if dataset_mat: | ||
if dataset_mat := get_dataset_mat_files(datasetId): |
There was a problem hiding this comment.
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:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Simplify sequence length comparison (
simplify-len-comparison
)
#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 = {} | ||
|
There was a problem hiding this comment.
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:
- Merge dictionary assignment with declaration (
merge-dict-assign
) - Move assignment closer to its usage within a block (
move-assign-in-block
) - Convert for loop into dictionary comprehension (
dict-comprehension
)
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 Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.25%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
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! |
This pull request fixes 1 alert when merging 26e3365 into 9ba2afb - view on LGTM.com fixed alerts:
|
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:Help us improve this pull request!