Skip to content

Commit

Permalink
flag & stage to test one model per lib before testing all
Browse files Browse the repository at this point in the history
  • Loading branch information
C-K-Loan committed Apr 8, 2024
1 parent 4e70743 commit 335483a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/nlu_test_flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
if:
run: |
python -c 'from johnsnowlabs import nlp;nlp.install(browser_login = False, force_browser=False,visual=True)'
- name: Run one test per lib
if: always()
run: |
python tests/run_tests.py --test_type one_per_lib
- name: Run all tests
if: always()
run: |
Expand Down
20 changes: 18 additions & 2 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import json
import os
import subprocess
Expand All @@ -6,10 +7,12 @@

import colorama


sys.path.append(os.getcwd())
sys.path.append(os.getcwd() + '/tests')
sys.path.append(os.getcwd() + '/tests/utils')
from utils import all_tests
from tests.utils import one_per_lib
_TEST_TIMEOUT = 60*60*20

def run_cmd_and_check_succ(
Expand Down Expand Up @@ -61,9 +64,21 @@ def log_process(result: subprocess.CompletedProcess):
# because we cannot de-allocate models from JVM from within a test
# So to prevent JVM-OOM we need to run each test in a separate process

parser = argparse.ArgumentParser(description='Testing CLI')
parser.add_argument('test_type', choices=['all', 'one_per_lib'], default='all', help='Type of test to run')
args = parser.parse_args()
logs = {}
total_tests = len(all_tests)
for i, test_params in enumerate(all_tests):
tests_to_execute = all_tests

if args.test_type == 'all':
tests_to_execute = all_tests
elif args.test_type == 'one_per_lib':
tests_to_execute = one_per_lib
total_tests = len(tests_to_execute)


print(f'Running Tests: {tests_to_execute}')
for i, test_params in enumerate(tests_to_execute):
if i % 10 == 0:
# Delete models so we dont run out of diskspace
os.system('rm -r ~/cache_pretrained')
Expand All @@ -84,3 +99,4 @@ def log_process(result: subprocess.CompletedProcess):
failed += 1
print(logs[test_idx])
print(f"{'#' * 10} {failed} of {total_tests} failed {'#' * 10}")

0 comments on commit 335483a

Please sign in to comment.