Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure preparation times printed fully and nicely #1046

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading