Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
bachvudinh committed Jul 18, 2024
1 parent 8d2b13f commit b6f0055
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
install_requires=[
'boto3',
# tokenizers >=0.13.3
'torch=2.1.0'
'tokenizers==0.13.3',
'transformers',
'datasets==2.20.0', # Add the datasets library
Expand Down
26 changes: 3 additions & 23 deletions tests/test_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,7 @@ class TestS3Helper(unittest.TestCase):
def setUpClass(cls):
cls.model_name = "jan-hq-test/tokenizer-tinyllama"
cls.dataset_name = "jan-hq-test/test-dataset"

@test_name("S3Helper Singleton Test")
def test_s3helper_singleton(self):
instance1 = S3Helper()
instance2 = S3Helper()
self.assertIs(instance1, instance2, "S3Helper should return the same instance")

@test_name("S3Helper Initialization Test")
def test_s3helper_initialization(self):
try:
S3Helper()
except Exception as e:
self.fail(f"S3Helper initialization raised an exception: {e}")
S3Helper()

@test_name("Tokenizer Loading Test")
@patch('s3helper.S3HelperAutoTokenizer.from_pretrained')
Expand Down Expand Up @@ -126,7 +114,7 @@ def test_config_loading(self, mock_from_pretrained):
mock_config = MagicMock()
mock_from_pretrained.return_value = mock_config

config = S3HelperAutoConfig.from_pretrained(self.model_name)
config = S3HelperAutoConfig.from_pretrained(self.model_name, device='cpu')

mock_from_pretrained.assert_called_once_with(self.model_name)
self.assertIsNotNone(config)
Expand All @@ -138,19 +126,11 @@ def test_model_loading(self, mock_from_pretrained):
mock_model = MagicMock()
mock_from_pretrained.return_value = mock_model

model = S3HelperAutoModelForCausalLM.from_pretrained(self.model_name)
model = S3HelperAutoModelForCausalLM.from_pretrained(self.model_name, device='cpu')

mock_from_pretrained.assert_called_once_with(self.model_name)
self.assertIsNotNone(model)
self.assertEqual(model, mock_model)

@test_name("S3Helper AWS Credentials Test")
@patch.object(S3Helper, '_S3Helper__instance', None) # Reset singleton for this test
@patch('boto3.client')
def test_s3helper_aws_credentials(self, mock_boto3_client):
S3Helper()
mock_boto3_client.assert_called_once_with('s3')

if __name__ == '__main__':
runner = CustomTestRunner()
test_suite = unittest.TestLoader().loadTestsFromTestCase(TestS3Helper)
Expand Down

0 comments on commit b6f0055

Please sign in to comment.