Skip to content

Commit

Permalink
mypy does not like dicts
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm committed Jul 10, 2022
1 parent 455c9c9 commit c31aae7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
12 changes: 6 additions & 6 deletions deepsearch/cps/data_indices/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def process_url_input(
count_urls = len(urls)
with tqdm(
total=count_urls,
desc=f"{'Submitting input:': <{progressbar['padding']}}",
desc=f"{'Submitting input:': <{progressbar.padding}}",
disable=not (progress_bar),
colour=progressbar["colour"],
bar_format=progressbar["bar_format"],
colour=progressbar.colour,
bar_format=progressbar.bar_format,
) as progress:
for url in urls:
payload = {"file_url": url}
Expand Down Expand Up @@ -138,10 +138,10 @@ def process_local_file(
# start loop
with tqdm(
total=count_total_files,
desc=f"{'Submitting input:': <{progressbar['padding']}}",
desc=f"{'Submitting input:': <{progressbar.padding}}",
disable=not (progress_bar),
colour=progressbar["colour"],
bar_format=progressbar["bar_format"],
colour=progressbar.colour,
bar_format=progressbar.bar_format,
) as progress:
# loop over all files
for single_zip in files_zip:
Expand Down
17 changes: 12 additions & 5 deletions deepsearch/documents/core/common_routines.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from dataclasses import dataclass

dashes = f"{'-'*86}"
WELCOME = f"{dashes}\n{'':>26}Welcome to the Deep Search Toolkit\n{dashes}"
ERROR_MSG = f"{dashes}\nSuggestion:\n(1) Check your input.\n(2) Contact Deep Search developers if problem persists.\n{dashes}"
# setup for progress bars
progressbar_length = 30
progressbar = {
"padding": 22,
"colour": "#0f62fe",
"bar_format": "{l_bar}{bar:%d}{r_bar}{bar:-10b}" % (progressbar_length),
}


@dataclass
class ProgressBarParameters:
padding = 22
colour = "#0f62fe"
bar_format = "{l_bar}{bar:%d}{r_bar}{bar:-10b}" % (progressbar_length)


progressbar = ProgressBarParameters()
success_message = "Whoa... it is done. Until next time, Ciao!"
24 changes: 12 additions & 12 deletions deepsearch/documents/core/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ def send_files_for_conversion(
# start loop
with tqdm(
total=count_total_files,
desc=f"{'Submitting input:': <{progressbar['padding']}}",
desc=f"{'Submitting input:': <{progressbar.padding}}",
disable=not (progress_bar),
colour=progressbar["colour"],
bar_format=progressbar["bar_format"],
colour=progressbar.colour,
bar_format=progressbar.bar_format,
) as progress:
# loop over all files
for single_zip in files_zip:
Expand Down Expand Up @@ -168,10 +168,10 @@ def check_status_running_tasks(

with tqdm(
total=count_total,
desc=f"{'Converting input:': <{progressbar['padding']}}",
desc=f"{'Converting input:': <{progressbar.padding}}",
disable=not (progress_bar),
colour=progressbar["colour"],
bar_format=progressbar["bar_format"],
colour=progressbar.colour,
bar_format=progressbar.bar_format,
) as progress:
for task_id in task_ids:
request_status = check_single_task_status(
Expand Down Expand Up @@ -232,10 +232,10 @@ def download_converted_documents(

with tqdm(
total=len(download_urls),
desc=f"{'Downloading result:': <{progressbar['padding']}}",
desc=f"{'Downloading result:': <{progressbar.padding}}",
disable=not (progress_bar),
colour=progressbar["colour"],
bar_format=progressbar["bar_format"],
colour=progressbar.colour,
bar_format=progressbar.bar_format,
) as progress:
count = 1
for url in download_urls:
Expand Down Expand Up @@ -280,10 +280,10 @@ def send_urls_for_conversion(
task_ids = []
with tqdm(
total=count_urls,
desc=f"{'Submitting input:': <{progressbar['padding']}}",
desc=f"{'Submitting input:': <{progressbar.padding}}",
disable=not (progress_bar),
colour=progressbar["colour"],
bar_format=progressbar["bar_format"],
colour=progressbar.colour,
bar_format=progressbar.bar_format,
) as progress:
for url in urls:
task_id = submit_url_for_conversion(
Expand Down
6 changes: 3 additions & 3 deletions deepsearch/documents/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def batch_single_files(
if len(files_pdf) != 0:
with tqdm(
total=len(files_pdf),
desc=f"{'Processing input:': <{progressbar['padding']}}",
desc=f"{'Processing input:': <{progressbar.padding}}",
disable=not (progress_bar),
colour=progressbar["colour"],
bar_format=progressbar["bar_format"],
colour=progressbar.colour,
bar_format=progressbar.bar_format,
) as progress:
# loop over pdfs
for single_doc in files_pdf:
Expand Down

0 comments on commit c31aae7

Please sign in to comment.