Skip to content

Commit

Permalink
Make sure preparation times printed fully and nicely (#1046)
Browse files Browse the repository at this point in the history
Signed-off-by: elronbandel <elron.bandel@ibm.com>
Signed-off-by: Benjamin Sznajder <benjams@il.ibm.com>
  • Loading branch information
elronbandel authored and BenjSz committed Jul 29, 2024
1 parent 9af8e18 commit 5521e70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions tests/catalog/test_preparation.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import glob
import os
import time
from datetime import timedelta

from huggingface_hub.utils import GatedRepoError
from unitxt.loaders import MissingKaggleCredentialsError
from unitxt.logging_utils import get_logger
from unitxt.settings_utils import get_constants
from unitxt.settings_utils import get_constants, get_settings
from unitxt.text_utils import print_dict
from unitxt.utils import import_module_from_file

from tests.utils import UnitxtCatalogPreparationTestCase

logger = get_logger()
constants = get_constants()
setting = get_settings()

project_dir = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand Down Expand Up @@ -55,18 +55,21 @@ def test_preparations(self):
self.assertTrue(True)

elapsed_time = time.time() - start_time
formatted_time = str(timedelta(seconds=elapsed_time))
minutes = int(elapsed_time // 60)
seconds = int(elapsed_time % 60)
formatted_time = f"{minutes:02}:{seconds:02}"
logger.info(
"\n_____________________________________________\n"
f" Finished testing preparation file:\n {file}."
f" Preparation Time: {formatted_time}"
"\n_____________________________________________\n"
)

times[file] = formatted_time
times[file.split("prepare")[-1]] = formatted_time
except Exception as e:
logger.critical(f"Testing preparation file '{file}' failed:")
raise e

logger.critical("Preparation times table:")
times = dict(sorted(times.items(), key=lambda item: item[1], reverse=True))
print_dict(times, log_level="critical")
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def setUpClass(cls):
unitxt.settings.allow_unverified_code = True
unitxt.settings.use_only_local_catalogs = True
# unitxt.settings.global_loader_limit = 300
unitxt.settings.max_log_message_size = 1000
unitxt.settings.max_log_message_size = 1000000000000
if settings.default_verbosity in ["error", "critical"]:
if not sys.warnoptions:
warnings.simplefilter("ignore")
Expand Down

0 comments on commit 5521e70

Please sign in to comment.