MCPcopy Create free account
hub / github.com/modelscope/modelscope / setUp

Method setUp

tests/utils/test_hf_util.py:23–52  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

21class HFUtilTest(unittest.TestCase):
22
23 def setUp(self):
24 logger.info('SetUp')
25 self.api = HubApi()
26 response, _ = self.api.login(TEST_ACCESS_TOKEN1)
27 self.user = TEST_MODEL_ORG
28 print(self.user)
29 self.create_model_name = '%s/%s_%s' % (self.user, 'test_model_upload',
30 uuid.uuid4().hex)
31 logger.info('create %s' % self.create_model_name)
32 temporary_dir = tempfile.mkdtemp()
33 self.work_dir = temporary_dir
34 self.model_dir = os.path.join(temporary_dir, self.create_model_name)
35 self.repo_path = os.path.join(self.work_dir, 'repo_path')
36 self.test_folder = os.path.join(temporary_dir, 'test_folder')
37 self.test_file1 = os.path.join(
38 os.path.join(temporary_dir, 'test_folder', '1.json'))
39 self.test_file2 = os.path.join(os.path.join(temporary_dir, '2.json'))
40 os.makedirs(self.test_folder, exist_ok=True)
41 with open(self.test_file1, 'w') as f:
42 f.write('{}')
43 with open(self.test_file2, 'w') as f:
44 f.write('{}')
45
46 self.pipeline_qa_context = r"""
47 Extractive Question Answering is the task of extracting an answer from a text given a question. An example
48 of a question answering dataset is the SQuAD dataset, which is entirely based on that task. If you would
49 like to fine-tune a model on a SQuAD task, you may leverage the
50 examples/pytorch/question-answering/run_squad.py script.
51 """
52 self.pipeline_qa_question = 'What is a good example of a question answering dataset?'
53
54 def tearDown(self):
55 logger.info('TearDown')

Callers

nothing calls this directly

Calls 4

HubApiClass · 0.90
printFunction · 0.85
infoMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected