Skip to content

Sourcery refactored main branch#6

Open
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main
Open

Sourcery refactored main branch#6
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main

Conversation

@sourcery-ai

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

Copy link
Copy Markdown

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

def plot_most_freq_search_term(n=10):
title='<b> Top '+str(n)+' Most Frequent Search Terms </b>'
title = f'<b> Top {str(n)} Most Frequent Search Terms </b>'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function plot_most_freq_search_term refactored with the following changes:

Comment on lines -97 to +105
else:
df_search=pd.DataFrame.from_dict(rsp['hits']['hits'])
df_search=pd.concat([df_search['_source'].apply(pd.Series)['pennsieve'].apply(pd.Series)[['identifier']],
df_search[['_id']],#df_search[['_id','_score']],
df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)[['name','description']],
df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)['published'].apply(pd.Series)['status'],
], axis=1)
df_search['link']= 'https://sparc.science/datasets/'+df_search['identifier']
df_search=df_search[['_id','name','description','status','link']]
return df_search
df_search=pd.DataFrame.from_dict(rsp['hits']['hits'])
df_search=pd.concat([df_search['_source'].apply(pd.Series)['pennsieve'].apply(pd.Series)[['identifier']],
df_search[['_id']],#df_search[['_id','_score']],
df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)[['name','description']],
df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)['published'].apply(pd.Series)['status'],
], axis=1)
df_search['link']= 'https://sparc.science/datasets/'+df_search['identifier']
df_search=df_search[['_id','name','description','status','link']]
return df_search

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function retrieve_search_to_df refactored with the following changes:

Comment on lines -21 to +24
f = open(fileName, "r")
htmlText = f.read()
f.close()
with open(fileName, "r") as f:
htmlText = f.read()
except:
return html("We are sorry,there was an error ..., %s is not found" % fileName)
return html(f"We are sorry,there was an error ..., {fileName} is not found")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function loadMain refactored with the following changes:

summary = {}
url = 'https://scicrunch.org/api/1/elastic/SPARC_PortalDatasets_pr/_search?api_key='+api_key
url = f'https://scicrunch.org/api/1/elastic/SPARC_PortalDatasets_pr/_search?api_key={api_key}'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function getSearch refactored with the following changes:

Comment on lines -202 to +208
url = 'https://scicrunch.org/api/1/scigraph/vocabulary/suggestions/'+query
url = f'https://scicrunch.org/api/1/scigraph/vocabulary/suggestions/{query}'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function __getSuggestions refactored with the following changes:

Comment on lines -226 to +232
url = 'https://scicrunch.org/api/1/scigraph/vocabulary/autocomplete/'+query
url = f'https://scicrunch.org/api/1/scigraph/vocabulary/autocomplete/{query}'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function __getAutoComplete_sc refactored with the following changes:

Comment on lines -92 to +101
else:
df_search=pd.DataFrame.from_dict(rsp['hits']['hits'])
df_search=pd.concat([
df_search['_source'].apply(pd.Series)['pennsieve'].apply(pd.Series)[['identifier']],
df_search[['_id','_score']],
df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)[['name','description']],
df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)['published'].apply(pd.Series)['status'],
], axis=1)
df_search['link']= 'https://sparc.science/datasets/'+df_search['identifier']

return df_search
df_search=pd.DataFrame.from_dict(rsp['hits']['hits'])
df_search=pd.concat([
df_search['_source'].apply(pd.Series)['pennsieve'].apply(pd.Series)[['identifier']],
df_search[['_id','_score']],
df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)[['name','description']],
df_search['_source'].apply(pd.Series)['item'].apply(pd.Series)['published'].apply(pd.Series)['status'],
], axis=1)
df_search['link']= 'https://sparc.science/datasets/'+df_search['identifier']

return df_search

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function retrieve_search_to_df refactored with the following changes:

@sourcery-ai

sourcery-ai Bot commented May 25, 2022

Copy link
Copy Markdown
Author

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 6.43 ⭐ 6.40 ⭐ -0.03 👍
Method Length 77.10 🙂 77.19 🙂 0.09 👎
Working memory 8.27 🙂 8.12 🙂 -0.15 👍
Quality 67.53% 🙂 67.84% 🙂 0.31% 👍
Other metrics Before After Change
Lines 721 725 4
Changed files Quality Before Quality After Quality Change
NotifyMe/NM_analytics_utils.py 63.56% 🙂 63.56% 🙂 0.00%
NotifyMe/Notifyme_utils.py 73.97% 🙂 74.57% 🙂 0.60% 👍
aqua_docker/app/utils/helper.py 55.47% 🙂 55.21% 🙂 -0.26% 👎
aqua_docker/app/utils/notifyme_utils.py 74.70% 🙂 75.30% ⭐ 0.60% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
aqua_docker/app/utils/helper.py getSearch 32 😞 602 ⛔ 14 😞 18.49% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
NotifyMe/Notifyme_utils.py send_mail_capture_error 17 🙂 87 🙂 11 😞 53.27% 🙂 Extract out complex expressions
aqua_docker/app/utils/notifyme_utils.py send_mail_capture_error 17 🙂 87 🙂 11 😞 53.27% 🙂 Extract out complex expressions
NotifyMe/Notifyme_utils.py scan_waiting_list 3 ⭐ 147 😞 8 🙂 64.52% 🙂 Try splitting into smaller methods
aqua_docker/app/utils/notifyme_utils.py scan_waiting_list 3 ⭐ 140 😞 8 🙂 65.29% 🙂 Try splitting into smaller methods

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