diff --git a/nf_core/components/create.py b/nf_core/components/create.py index de344857bf..c781905618 100644 --- a/nf_core/components/create.py +++ b/nf_core/components/create.py @@ -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") diff --git a/nf_core/utils.py b/nf_core/utils.py index 7d1fe08e57..56e21e6b2c 100644 --- a/nf_core/utils.py +++ b/nf_core/utils.py @@ -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. @@ -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 diff --git a/tests/test_modules.py b/tests/test_modules.py index badf3470e6..037a718886 100644 --- a/tests/test_modules.py +++ b/tests/test_modules.py @@ -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")