Skip to content

Commit

Permalink
Merge pull request #18003 from mvdbeek/add_galaxy_to_user_agent
Browse files Browse the repository at this point in the history
Add galaxy to user agent
  • Loading branch information
jmchilton authored May 20, 2024
2 parents 4296472 + e8a3b8c commit 2f43c32
Show file tree
Hide file tree
Showing 65 changed files with 168 additions and 92 deletions.
3 changes: 2 additions & 1 deletion cron/build_chrom_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from urllib.parse import urlencode

import parse_builds # noqa: I100,I202
import requests

from galaxy.util import requests


def getchrominfo(url, db):
Expand Down
2 changes: 1 addition & 1 deletion cron/parse_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sys
import xml.etree.ElementTree as ElementTree

import requests
from galaxy.util import requests


def getbuilds(url):
Expand Down
2 changes: 1 addition & 1 deletion cron/parse_builds_3_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import xml.etree.ElementTree as ElementTree

import requests
from galaxy.util import requests

sites = [
"http://genome.ucsc.edu/cgi-bin/",
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
build_tours_registry,
ToursRegistry,
)
from galaxy.util import user_agent # noqa: F401
from galaxy.util import (
ExecutionTimer,
heartbeat,
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/authnz/custos_authnz.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from urllib.parse import quote

import jwt
import requests
from oauthlib.common import generate_nonce
from requests_oauthlib import OAuth2Session

Expand All @@ -30,6 +29,7 @@
)
from galaxy.model.base import transaction
from galaxy.model.orm.util import add_object_to_object_session
from galaxy.util import requests
from . import IdentityProvider

try:
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/authnz/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import random
import string

import requests
from cloudauthz import CloudAuthz
from cloudauthz.exceptions import CloudAuthzBaseException

Expand All @@ -19,6 +18,7 @@
etree,
listify,
parse_xml,
requests,
string_as_bool,
unicodify,
)
Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/authnz/psa_authnz.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import time

import jwt
import requests
from msal import ConfidentialClientApplication
from social_core.actions import (
do_auth,
Expand All @@ -27,7 +26,10 @@
UserAuthnzToken,
)
from galaxy.model.base import transaction
from galaxy.util import DEFAULT_SOCKET_TIMEOUT
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
requests,
)
from . import IdentityProvider

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/files/sources/invenio.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
)
from urllib.parse import quote

import requests
from typing_extensions import (
Literal,
TypedDict,
Expand All @@ -37,6 +36,7 @@
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
get_charset_from_http_headers,
requests,
stream_to_open_named_file,
)

Expand Down
7 changes: 4 additions & 3 deletions lib/galaxy/files/sources/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
Union,
)

import requests

from galaxy import exceptions
from galaxy.files import (
ConfiguredFileSources,
Expand All @@ -17,7 +15,10 @@
from galaxy.files.sources import FilesSourceOptions
from galaxy.files.sources.http import HTTPFilesSourceProperties
from galaxy.files.uris import stream_url_to_file
from galaxy.util import DEFAULT_SOCKET_TIMEOUT
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
requests,
)
from galaxy.util.config_parsers import IpAllowedListEntryT

TargetPathT = Union[str, PathLike]
Expand Down
7 changes: 4 additions & 3 deletions lib/galaxy/job_execution/container_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
from functools import partial
from typing import Callable

import requests

from galaxy.tool_util.deps import docker_util
from galaxy.util import DEFAULT_SOCKET_TIMEOUT
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
requests,
)
from galaxy.util.sockets import get_ip

GetIpCallable = Callable[[], str]
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/jobs/runners/godocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import time
from datetime import datetime

import requests

from galaxy import model
from galaxy.jobs.runners import (
AsynchronousJobRunner,
AsynchronousJobState,
)
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
requests,
unicodify,
)

Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/managers/citations.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import functools
import logging

import requests
from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options

from galaxy.structured_app import BasicSharedApp
from galaxy.util import DEFAULT_SOCKET_TIMEOUT
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
requests,
)

log = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/model/store/load_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
Dict,
)

import requests
import yaml

from galaxy.util import requests

DESCRIPTION = """Load a Galaxy model store into a running Galaxy instance.
See the corresponding galaxy-build-objects script for one possible way to
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/selenium/has_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Union,
)

import requests
from axe_selenium_python import Axe
from selenium.common.exceptions import (
NoSuchElementException,
Expand All @@ -29,6 +28,7 @@
from selenium.webdriver.support.wait import WebDriverWait

from galaxy.navigation.components import Target
from galaxy.util import requests
from .axe_results import (
AxeResults,
NullAxeResults,
Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/selenium/navigates_galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
Union,
)

import requests
import yaml
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
Expand All @@ -36,7 +35,10 @@
HasText,
)
from galaxy.navigation.data import load_root_component
from galaxy.util import DEFAULT_SOCKET_TIMEOUT
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
requests,
)
from . import sizzle
from .has_driver import (
exception_indicates_click_intercepted,
Expand Down
7 changes: 4 additions & 3 deletions lib/galaxy/tool_util/biotools/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
Optional,
)

import requests

from galaxy.util import DEFAULT_SOCKET_TIMEOUT
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
requests,
)
from .interface import BiotoolsEntry


Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/cwl/cwltool_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

warnings.filterwarnings("ignore", message=r"[\n.]DEPRECATION: Python 2", module="cwltool")

import requests
from galaxy.util import requests

try:
from cwltool import (
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
Union,
)

import requests
from typing_extensions import (
Protocol,
TypedDict,
Expand All @@ -44,6 +43,7 @@
from galaxy.exceptions import MessageException
from galaxy.util import (
Element,
requests,
RW_R__R__,
)
from galaxy.util.compression_utils import decompress_path_to_directory
Expand Down
16 changes: 12 additions & 4 deletions lib/galaxy/tool_util/deps/mulled/get_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
Optional,
)

import requests
import yaml

from galaxy.util import requests

try:
from jinja2 import Template
from jinja2.exceptions import UndefinedError
Expand Down Expand Up @@ -130,7 +131,10 @@ def find_anaconda_versions(name, anaconda_channel="bioconda"):
"""
Find a list of available anaconda versions for a given container name
"""
r = requests.get(f"https://anaconda.org/{anaconda_channel}/{name}/files", timeout=MULLED_SOCKET_TIMEOUT)
r = requests.get(
f"https://anaconda.org/{anaconda_channel}/{name}/files",
timeout=MULLED_SOCKET_TIMEOUT,
)
r.raise_for_status()
urls = []
for line in r.text.splitlines():
Expand All @@ -147,7 +151,8 @@ def open_recipe_file(file, recipes_path=None, github_repo="bioconda/bioconda-rec
return open(f"{recipes_path}/{file}").read()
else: # if no clone of the repo is available locally, download from GitHub
r = requests.get(
f"https://raw.githubusercontent.com/{github_repo}/master/{file}", timeout=MULLED_SOCKET_TIMEOUT
f"https://raw.githubusercontent.com/{github_repo}/master/{file}",
timeout=MULLED_SOCKET_TIMEOUT,
)
if r.status_code == 404:
raise OSError
Expand All @@ -163,7 +168,10 @@ def get_alternative_versions(filepath, filename, recipes_path=None, github_repo=
return [n.replace(f"{recipes_path}/", "") for n in glob(f"{recipes_path}/{filepath}/*/{filename}")]
# else use the GitHub API:
versions = []
r = requests.get(f"https://api.github.com/repos/{github_repo}/contents/{filepath}", timeout=MULLED_SOCKET_TIMEOUT)
r = requests.get(
f"https://api.github.com/repos/{github_repo}/contents/{filepath}",
timeout=MULLED_SOCKET_TIMEOUT,
)
check_github_api_response_rate_limit(r)
r.raise_for_status()
for subfile in json.loads(r.text):
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/tool_util/deps/mulled/mulled_build_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import sys
import time

import requests

from galaxy.util import requests
from ._cli import arg_parser
from .mulled_build import (
add_build_arguments,
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/tool_util/deps/mulled/mulled_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from glob import glob
from html.parser import HTMLParser

import requests

from galaxy.util import requests
from .util import MULLED_SOCKET_TIMEOUT

QUAY_API_ENDPOINT = "https://quay.io/api/v1/repository"
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/tool_util/deps/mulled/mulled_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import sys
import tempfile

import requests

from galaxy.tool_util.deps.conda_util import CondaContext
from galaxy.util import (
check_github_api_response_rate_limit,
requests,
which,
)
from .mulled_list import get_singularity_containers
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/deps/mulled/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Union,
)

import requests
from conda_package_streaming.package_streaming import stream_conda_info
from conda_package_streaming.url import stream_conda_info as stream_conda_info_from_url
from packaging.version import Version
Expand All @@ -29,6 +28,7 @@
LegacyVersion,
parse_version,
)
from galaxy.util import requests

if TYPE_CHECKING:
from galaxy.tool_util.deps.container_resolvers import ResolutionCache
Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/tool_util/locations/dockstore.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from urllib.parse import quote

import requests
import yaml

from galaxy.util import DEFAULT_SOCKET_TIMEOUT
from galaxy.util import (
DEFAULT_SOCKET_TIMEOUT,
requests,
)
from . import ToolLocationResolver


Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/verify/interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
Union,
)

import requests
from packaging.version import Version
from requests import Response
from requests.cookies import RequestsCookieJar
Expand All @@ -41,6 +40,7 @@
TestCollectionDef,
TestCollectionOutputDef,
)
from galaxy.util import requests
from galaxy.util.bunch import Bunch
from galaxy.util.hash_util import (
memory_bound_hexdigest,
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/tools/data_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
stream_to_file,
stream_url_to_file,
)
from galaxy.util import user_agent # noqa: F401
from galaxy.util import (
in_directory,
safe_makedirs,
Expand Down
Loading

0 comments on commit 2f43c32

Please sign in to comment.