From 55a08be58b4c998f854902245634f9fedbea19ee Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Fri, 27 Dec 2024 16:09:01 +0000 Subject: [PATCH] fix pre commit issues --- examples/search_values_for_key.py | 23 +++++++++++++------ examples/use_data_sources.py | 38 +++++++++++++++++++------------ 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/examples/search_values_for_key.py b/examples/search_values_for_key.py index 858415c..5068b1e 100644 --- a/examples/search_values_for_key.py +++ b/examples/search_values_for_key.py @@ -43,27 +43,36 @@ ress = json.loads(resp.text) # a list contains the available attributes for res in ress: - data_source=res.get("data_source") + data_source = res.get("data_source") if not data_source: continue - print ("Checking data source: %s "%data_source) + print("Checking data source: %s " % data_source) attributes = res.get("image") - logging.info("Number of available attributes for images: %s" % len(attributes)) # noqa + logging.info( + "Number of available attributes for images: %s" % len(attributes) + ) # noqa """ The user can get the available values for the "Organism" attribute and the number of images for each value """ key = "Organism" - values_attr_url = "{base_url}{image_key_values}?key={key}&data_source={data_source}".format( - base_url=base_url, image_key_values=image_key_values, key=key, data_source=data_source + values_attr_url = ( + "{base_url}{image_key_values}?key={key}&data_source={data_source}".format( + base_url=base_url, + image_key_values=image_key_values, + key=key, + data_source=data_source, + ) ) - print (values_attr_url) + print(values_attr_url) resp = requests.get(url=values_attr_url) res = json.loads(resp.text) # a list contains dicts of the available values with the number of images buckets = res.get("data") - logging.info("Number of available buckets for attribute %s is %s" % (key, len(buckets))) + logging.info( + "Number of available buckets for attribute %s is %s" % (key, len(buckets)) + ) # The first bucket for bucket in buckets: logging.info("Bucket details: %s " % bucket) diff --git a/examples/use_data_sources.py b/examples/use_data_sources.py index a78b231..1857165 100644 --- a/examples/use_data_sources.py +++ b/examples/use_data_sources.py @@ -4,28 +4,36 @@ from utils import base_url -''' -Call the search engine to determine the available data sources''' +""" +Call the search engine to determine the available data sources""" -data_source_url = "{base_url}resources/data_sources/".format( - base_url=base_url) +data_source_url = "{base_url}resources/data_sources/".format(base_url=base_url) logging.info(" getting the available data sources") resp = requests.get(url=data_source_url) data_sources = json.loads(resp.text) -logging.info("There are %s data sources available, i.e. %s "%(len(data_sources), ', '.join(data_sources))) -''' -"The data source can be linked to queries to return search results from the specified data source. -For example, the user can limit the search results to "bia" data source when querying the searchengine for "Organism" and "homo sapiens" - ''' +logging.info( + "There are %s data sources available, i.e. %s " + % (len(data_sources), ", ".join(data_sources)) +) +""" +"The data source can be linked to queries to return search results + from the specified data source. +For example, the user can limit the search results to "bia" data source + when querying the searchengine for "Organism" and "homo sapiens" + """ -key="Organism" -value="homo sapiens" -data_source="bia" -search_url= "{base_url}resources/image/search/?key={key}&value={value}&data_source={data_source}".format( - base_url=base_url, key=key, value=value, data_source=data_source) +key = "Organism" +value = "homo sapiens" +data_source = "bia" +search_url = ( + "{base_url}resources/image/search/?key={key}&value=" + "{value}&data_source={data_source}" +).format(base_url=base_url, key=key, value=value, data_source=data_source) resp = requests.get(url=search_url) results = json.loads(resp.text) -logging.info("The size of the returned results is %s" %results.get("results").get("size")) +logging.info( + "The size of the returned results is %s" % results.get("results").get("size") +)