Skip to content

Commit 303cd3d

Browse files
committed
added progress bar to sib fetcher
1 parent ccf5e5b commit 303cd3d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

snapquery/query_set_cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def _handle_sib_examples(self, args: Namespace) -> None:
253253
sib_fetcher = SibSparqlExamples(nqm, debug=debug)
254254
if debug:
255255
print(f"Fetching SIB examples (limit={limit})...")
256-
loaded_queries = sib_fetcher.extract_queries(limit=limit, debug_print=debug or show_progress)
256+
loaded_queries = sib_fetcher.extract_queries(limit=limit, debug_print=debug, show_progress=show_progress)
257257
self._output_dataset(sib_fetcher.named_query_set, args)
258258

259259

snapquery/sib_sparql_examples.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from typing import Optional, List, Dict, Any, Set
1414

1515
import rdflib
16+
from tqdm import tqdm
1617

1718
from snapquery.github_access import GitHub
1819
from snapquery.snapquery_core import NamedQuery, NamedQueryManager, NamedQuerySet
@@ -138,7 +139,7 @@ def parse_ttl_to_namedqueries(self, ttl_content: str, ttl_path: str) -> List[Nam
138139
print(f"Error parsing {ttl_path}: {e}")
139140
return parsed_queries
140141

141-
def extract_queries(self, limit: Optional[int] = None, debug_print: bool = False) -> List[NamedQuery]:
142+
def extract_queries(self, limit: Optional[int] = None, debug_print: bool = False, show_progress: bool = False) -> List[NamedQuery]:
142143
"""
143144
Main: Fetch/parse/store all TTL → NamedQuery/DB/Set.
144145
"""
@@ -147,7 +148,11 @@ def extract_queries(self, limit: Optional[int] = None, debug_print: bool = False
147148
if limit:
148149
ttl_items = ttl_items[:limit]
149150

150-
for item in ttl_items:
151+
iterator = ttl_items
152+
if show_progress:
153+
iterator = tqdm(ttl_items)
154+
155+
for item in iterator:
151156
if debug_print:
152157
print(f"Processing {item['path']}...")
153158
content = self.get_ttl_content(item["download_url"])

0 commit comments

Comments
 (0)