Skip to content

Commit

Permalink
fix: remove .mindnlp in teardown (mindspore-lab#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
PurRigiN authored Jun 1, 2023
1 parent 6c93d38 commit 96cc1c9
Show file tree
Hide file tree
Showing 22 changed files with 140 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/ut/models/bert/test_modeling_bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test Bert"""
import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -69,3 +70,8 @@ def test_from_pretrained_from_pt(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/bloom/test_bloom_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Test Bloom Config"""

import gc
import os
import unittest
import pytest

Expand All @@ -36,3 +37,8 @@ def test_bloom_config(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/bloom/test_modeling_bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Test Bloom"""

import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -57,3 +58,8 @@ def test_from_pretrained_from_pt(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
10 changes: 10 additions & 0 deletions tests/ut/models/clip/test_modeling_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
# ============================================================================
"""Test CLIP"""
import gc
import os
import unittest
import numpy as np
import mindspore
Expand Down Expand Up @@ -234,3 +236,11 @@ def test_clip_vision_model_with_projection(self):

assert outputs[0].shape == (1, self.text_config.hidden_size)
assert outputs[1].shape == (1, 50, self.vision_config.hidden_size)

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/codegen/test_modeling_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test CodeGen"""
import gc
import os
import unittest

import mindspore
Expand Down Expand Up @@ -97,3 +98,8 @@ def test_codegen_forcausallm(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/cpm/test_modeling_cpm_ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test CPM Ant"""
import gc
import os
import unittest
import numpy as np

Expand Down Expand Up @@ -60,3 +61,8 @@ def test_cpm_ant_for_causal_lm(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/ernie/test_ernie.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test Ernie"""
import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -170,3 +171,8 @@ def test_from_pretrained(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
10 changes: 10 additions & 0 deletions tests/ut/models/glm/test_modeling_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
# ============================================================================
"""Test GLM"""
import gc
import os
import unittest
import numpy as np

Expand Down Expand Up @@ -137,3 +139,11 @@ def test_glm_model(self):
output_tuple = model(input_ids_input, position_ids_input, attention_mask_input, mems)
output = output_tuple[0]
assert output.shape == (batch_size, max_sequence_length, hidden_size)

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/gpt/test_modeling_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# ============================================================================
"""Test GPT"""
import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -159,3 +160,8 @@ def test_from_pretrained_from_pt(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/gpt2/test_modeling_gpt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test GPT2"""
import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -152,3 +153,8 @@ def test_from_pretrained_from_pt(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/gpt_neo/test_gpt_neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
"""Test GPTNeo"""
import gc
import os
import unittest
import numpy as np
import mindspore
Expand Down Expand Up @@ -146,3 +147,8 @@ def test_gptneo_for_sequence_classification(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/llama/test_modeling_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test Llama"""
import gc
import os
import unittest
import numpy as np
import mindspore
Expand Down Expand Up @@ -109,3 +110,8 @@ def test_llama_transformer(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/llama/test_modeling_llama_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test Llama"""
import gc
import os
import unittest
import numpy as np
import mindspore
Expand Down Expand Up @@ -142,3 +143,8 @@ def test_llama_for_sequence_classification(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/longformer/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# ============================================================================
"""Test Longformer"""
import gc
import os
import unittest
import numpy as np
import mindspore
Expand Down Expand Up @@ -360,3 +361,8 @@ def test_modeling_longformer_multiple_choice(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/luke/test_modeling_luke.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# pylint:disable=R0904
"""Test LUKE"""
import gc
import os
import unittest

import mindspore
Expand Down Expand Up @@ -265,3 +266,8 @@ def test_luke_for_multiple_choice(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/mobilebert/test_mobilebert.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Test MobileBert
"""
import gc
import os
import unittest

import mindspore
Expand Down Expand Up @@ -340,3 +341,8 @@ def test_mobilebert_fortokenclassification(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/nezha/test_modeling_nezha.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Test Nezha
"""
import gc
import os
import unittest
import random
import numpy as np
Expand Down Expand Up @@ -278,3 +279,8 @@ def test_for_question_answering(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/roberta/test_modeling_roberta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test Roberta"""
import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -72,3 +73,8 @@ def test_from_pretrained(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/rwkv/test_modeling_rwkv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ============================================================================
"""Test RWKV"""
import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -53,3 +54,8 @@ def forward(input_ids):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/t5/test_modeling_t5.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# pylint:disable=W0212
"""Test T5"""
import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -224,3 +225,8 @@ def test_from_pretrained_from_pt(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/tinybert/test_tinybert.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Test TinyBert
"""
import gc
import os
import unittest

import numpy as np
Expand Down Expand Up @@ -365,3 +366,8 @@ def test_tiny_bert_for_sequence_classification(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")
6 changes: 6 additions & 0 deletions tests/ut/models/xlm/test_xlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Test XLM
"""
import gc
import os
import unittest
import pytest
import numpy as np
Expand Down Expand Up @@ -181,3 +182,8 @@ def test_from_pretrained_from_pt(self):

def tearDown(self) -> None:
gc.collect()

@classmethod
def tearDownClass(cls):
if os.path.exists("~/.mindnlp"):
os.removedirs("~/.mindnlp")

0 comments on commit 96cc1c9

Please sign in to comment.