Skip to content

Commit

Permalink
Merge pull request #28 from Helsinki-NLP/fix/pytest-unittests
Browse files Browse the repository at this point in the history
pytest unittests
  • Loading branch information
Waino authored Oct 2, 2023
2 parents ec14333 + d24f915 commit 9a25940
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ jobs:
pip install -e .
pip install -r requirements.opt.txt
pip install flake8==4.0.1
pip install pytest==7.0.1 pytest-flake8==1.1.1
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 --max-line-length 120 .
- name: Unit tests
run: |
python -m unittest discover
python -m pytest
# ## Broken in FoTraNMT
# - name: Test vocabulary build
# run: |
Expand Down Expand Up @@ -410,4 +411,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/build/html
CLEAN: true
CLEAN: true
8 changes: 4 additions & 4 deletions mammoth/tests/test_task_distribution_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def test_weights_all_zero():
opts = Namespace(data={
opts = Namespace(tasks={
'a': {
'weight': 0,
'introduce_at_training_step': 0,
Expand All @@ -25,7 +25,7 @@ def test_weights_all_zero():


def test_weights_all_postponed():
opts = Namespace(data={
opts = Namespace(tasks={
'a': {
'weight': 1,
'introduce_at_training_step': 1,
Expand All @@ -45,7 +45,7 @@ def test_weights_all_postponed():


def test_invalid_curriculum():
opts = Namespace(data={
opts = Namespace(tasks={
# 'a' disabled by weight
'a': {
'weight': 0,
Expand All @@ -67,7 +67,7 @@ def test_invalid_curriculum():


def test_sampling_task_distribution_strategy():
opts = Namespace(data={
opts = Namespace(tasks={
# 'a' disabled by weight
'a': {
'weight': 0,
Expand Down
8 changes: 4 additions & 4 deletions mammoth/tests/test_task_queue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_init_minimal():
'gpu_ranks': [0, 1],
'enc_layers': [1],
'dec_layers': [1],
'data': {
'tasks': {
'train_a-b': {'path_src': 'dummy', 'path_tgt': 'dummy', 'src_tgt': 'a-b'},
'train_c-d': {'path_src': 'dummy', 'path_tgt': 'dummy', 'src_tgt': 'c-d'},
}
Expand Down Expand Up @@ -52,7 +52,7 @@ def create_basic_task_queue_manager():
# enc_sharing_group x is twice, on two devices 0:0 and 0:1
# dec_sharing_group y is twice, on two devices 0:0 and 1:0
# dec_sharing_group yy is twice, but only on a single device 0:1
'data': {
'tasks': {
'train_0_a-b': {
'path_src': 'dummy',
'path_tgt': 'dummy',
Expand Down Expand Up @@ -183,7 +183,7 @@ def test_cpu_distributed_groups():
'n_nodes': 1,
'enc_layers': [1],
'dec_layers': [1],
'data': {
'tasks': {
'train_a-b': {
'path_src': 'dummy',
'path_tgt': 'dummy',
Expand Down Expand Up @@ -221,7 +221,7 @@ def test_distributed_groups_no_encoder_group():
'dec_layers': [1],
'gpu_ranks': [0, 1],
# every language pair on its own gpu: no overlap
'data': {
'tasks': {
'train_a-b': {
'path_src': 'dummy',
'path_tgt': 'dummy',
Expand Down

0 comments on commit 9a25940

Please sign in to comment.