Skip to content

Commit

Permalink
fix: Drop calling prefix async
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundmiller committed Nov 21, 2024
1 parent 95549a3 commit 94a9eb6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
6 changes: 3 additions & 3 deletions nf_core/components/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ def create(self) -> bool:
log.info("Created following files:\n " + "\n ".join(new_files))
return True

async def _get_bioconda_tool(self):
def _get_bioconda_tool(self):
"""
Try to find a bioconda package for 'tool'
"""
while True:
try:
if self.tool_conda_name:
anaconda_response = await nf_core.utils.anaconda_package(self.tool_conda_name, ["bioconda"])
anaconda_response = nf_core.utils.anaconda_package(self.tool_conda_name, ["bioconda"])
else:
anaconda_response = await nf_core.utils.anaconda_package(self.component, ["bioconda"])
anaconda_response = nf_core.utils.anaconda_package(self.component, ["bioconda"])

if not self.tool_conda_version:
version = anaconda_response.get("latest_version")
Expand Down
24 changes: 12 additions & 12 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def request_retry(self, url, post_data=None):
gh_api = GitHubAPISession()


async def anaconda_package(dep, dep_channels=None):
def anaconda_package(dep, dep_channels=None):
"""Query conda package information.
Sends a HTTP GET request to the Prefix.dev remote GraphQL API.
Expand Down Expand Up @@ -684,19 +684,19 @@ async def anaconda_package(dep, dep_channels=None):
}

try:
async with aiohttp.ClientSession() as session:
async with session.post(
with requests.Session() as session:
response = session.post(
"https://prefix.dev/api/graphql", json={"query": query, "variables": variables}, headers=headers
) as response:
if response.status == 200:
data = await response.json()
if "errors" in data:
log.debug(f"GraphQL error for {depname}: {data['errors']}")
return None
return data["data"]["package"]
else:
log.debug(f"HTTP {response.status} error for {depname}")
)
if response.status_code == 200:
data = response.json()
if "errors" in data:
log.debug(f"GraphQL error for {depname}: {data['errors']}")
return None
return data["data"]["package"]
else:
log.debug(f"HTTP {response.status_code} error for {depname}")
return None
except Exception as e:
log.debug(f"Error checking package {depname}: {str(e)}")
return None
Expand Down
15 changes: 0 additions & 15 deletions tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ def create_modules_repo_dummy(tmp_dir):
yaml.dump(nf_core_yml.model_dump(), fh)
# mock biocontainers and anaconda response and biotools response
with responses.RequestsMock() as rsps:
# Mock the POST request
rsps.add(
responses.POST,
"https://prefix.dev/api/graphql",
json={}, # or the expected response data
status=200,
)

# Mock the GET request
rsps.add(
responses.GET,
"https://api.biocontainers.pro/ga4gh/trs/v2/tools/bpipe/versions/bpipe-0.9.13",
json={}, # or the expected response data
status=200,
)
mock_prefix_api_calls(rsps, "bpipe", "0.9.13--hdfd78af_0")
mock_biocontainers_api_calls(rsps, "bpipe", "0.9.13--hdfd78af_0")
mock_biotools_api_calls(rsps, "bpipe")
Expand Down

0 comments on commit 94a9eb6

Please sign in to comment.