-
Notifications
You must be signed in to change notification settings - Fork 95
Description
When running mulled-search -o biocontainers -s minimap2=2.28
the GitHub API error is raised due to lack of the token. Github now requires a valid token to search code which triggers error
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.github.com/search/code?q=minimap2=2.28+in:path+repo:bioconda/bioconda-recipes+path:recipes
To solve this one needs to import GITHUB_TOKEN
global variable from the environment and modify the mulled_search.py
around line 160 def get_json(self, search_string)
to add header with the token to correctly query GitHub API. GitHub classical token needs to generated in your account at https://github.com/settings/tokens/
Update the code as follows:
def get_json(self, search_string):
"""
Takes search_string variable and return results from the bioconda-recipes github repository in JSON format
DEPRECATED: this method is currently unreliable because the API query
sometimes succeeds but returns no items.
"""
github_token = os.getenv("GITHUB_TOKEN")
headers = {
"Accept": "application/vnd.github+json"
}
if github_token:
headers["Authorization"] = f"Bearer {github_token}"
response = requests.get(
f"https://api.github.com/search/code?q={search_string}+in:path+repo:bioconda/bioconda-recipes+path:recipes",
headers=headers,
timeout=MULLED_SOCKET_TIMEOUT,
)
...
After this modification all works great and the following output is obtained
$ mulled-search -o biocontainers -s minimap2=2.28
The query returned the following result(s).
LOCATION NAME VERSION COMMAND
conda minimap2 2.28--h577a1d6_4 conda install -c bioconda minimap2=2.28=h577a1d6_4
conda minimap2 2.28--he4a0461_0 conda install -c bioconda minimap2=2.28=he4a0461_0
conda minimap2 2.28--he4a0461_1 conda install -c bioconda minimap2=2.28=he4a0461_1
conda minimap2 2.28--he4a0461_2 conda install -c bioconda minimap2=2.28=he4a0461_2
conda minimap2 2.28--he4a0461_3 conda install -c bioconda minimap2=2.28=he4a0461_3
The following recipes were found in the bioconda-recipes repository which exactly matched one of the search terms:
QUERY LOCATION
I noticed that this issue is linked to galaxy-tool-util
package which contains all mulled-*
scripts. I was using v24.2.3 of galaxy-tool-util
and galaxy-util