Skip to content

Commit

Permalink
2.4.2 (bugfix: don't ignore name for batch queries) (#39)
Browse files Browse the repository at this point in the history
This PR corrects a bug where the name specified when running multiple queries at once was ignored.
  • Loading branch information
Theodlz authored Jun 25, 2024
1 parent bd58f4f commit 3157924
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions penquins/penquins.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from requests.packages.urllib3.util.retry import Retry
from tqdm.auto import tqdm

__version__ = "2.4.1"
__version__ = "2.4.2"

Num = Union[int, float]

Expand Down Expand Up @@ -577,8 +577,15 @@ def prepare_query(self, query, name=None, instances_load=None) -> dict:

def prepare_queries(self, queries, name=None) -> dict:
"""Based on the catalogs or catalog specified in the queries, split the queries into multiple queries for each instance"""
queries_per_instance = {name: [] for name in self.instances.keys()}
instances_load = {name: 0 for name in self.instances.keys()}
instances_names = list(self.instances.keys())
if name is not None:
if name not in instances_names:
raise ValueError(
f"Instance {name} not found in the list of instances: {instances_names}"
)
instances_names = [name]
queries_per_instance = {instance_name: [] for instance_name in instances_names}
instances_load = {instance_name: 0 for instance_name in instances_names}
for query in queries:
query_per_instance, instances_load = self.prepare_query(
query, name=name, instances_load=instances_load
Expand Down Expand Up @@ -708,7 +715,7 @@ def query(
return results

if queries is not None:
queries_split_in_queries = self.prepare_queries(queries)
queries_split_in_queries = self.prepare_queries(queries, name=name)
if len(queries_split_in_queries) == 0:
raise ValueError(
f"No valid queries found in {str(queries)}\n which yielded {str(queries_split_in_queries)}"
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ for a detailed guide.

```shell script
pip install bumpversion
export PENQUINS_VERSION=2.4.1
export PENQUINS_VERSION=2.4.2

bumpversion --current-version $PENQUINS_VERSION minor setup.py penquins/penquins.py
python setup.py sdist bdist_wheel
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def run_git(cmd):
URL = "https://github.com/dmitryduev/penquins"

# VERSION should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
VERSION = "2.4.1"
VERSION = "2.4.2"

# Indicates if this version is a release version
RELEASE = "dev" not in VERSION
Expand Down

0 comments on commit 3157924

Please sign in to comment.