def test_16_create_entity_with_import(self): entity_type = 'dataset' IMPORT_PATH = 'src' self.assertIn( output_messages['INFO_INITIALIZED_PROJECT'] % self.tmp_dir, check_output(MLGIT_INIT)) import_path = os.path.join(self.tmp_dir, IMPORT_PATH) os.makedirs(import_path) create_zip_file(IMPORT_PATH, 3) self.assertTrue(os.path.exists(os.path.join(import_path, 'file.zip'))) api.create(entity_type, entity_type + '-ex', categories=['computer-vision', 'images'], unzip=True, import_path=import_path, mutability='strict') self.check_created_folders(entity_type, StoreType.S3H.value) folder_data = os.path.join(self.tmp_dir, entity_type, entity_type + '-ex', 'data', 'file') self.assertTrue(os.path.exists(folder_data)) files = [f for f in os.listdir(folder_data)] self.assertIn('file0.txt', files) self.assertIn('file1.txt', files) self.assertIn('file2.txt', files) self.assertEqual(3, len(files))
def test_27_create_with_invalid_entity(self): try: entity_type = 'dataset_invalid' self.assertIn(output_messages['INFO_INITIALIZED_PROJECT_IN'] % self.tmp_dir, check_output(MLGIT_INIT)) api.create('dataset_invalid', DATASET_NAME, categories=['computer-vision', 'images'], mutability=STRICT) self.check_created_folders(entity_type, S3H) self.assertTrue(False) except Exception as e: self.assertIn(output_messages['ERROR_INVALID_ENTITY_TYPE'] % EntityType.to_list(), str(e))
def test_14_create_entity(self): self.assertIn( output_messages['INFO_INITIALIZED_PROJECT_IN'] % self.tmp_dir, check_output(MLGIT_INIT)) api.create(DATASETS, DATASET_NAME, categories=['computer-vision', 'images'], mutability=STRICT) self.check_created_folders(DATASETS, S3H)
def test_14_create_entity(self): entity_type = 'dataset' store_type = StoreType.S3H.value self.assertIn( output_messages['INFO_INITIALIZED_PROJECT'] % self.tmp_dir, check_output(MLGIT_INIT)) api.create('dataset', 'dataset-ex', categories=['computer-vision', 'images'], mutability='strict') self.check_created_folders(entity_type, store_type)
def _push_model_with_metrics(self, entity_name): init_repository(MODELS, self) workspace = os.path.join(self.tmp_dir, MODELS, entity_name) api.create(MODELS, entity_name, categories=['computer-vision', 'images'], mutability=STRICT, bucket_name='mlgit') os.makedirs(os.path.join(workspace, 'data'), exist_ok=True) self.create_file(workspace, 'file1', '0') api.add(MODELS, entity_name, metric={'accuracy': 10.0, 'precision': 10.0}) api.commit(MODELS, entity_name) api.push(MODELS, entity_name)
def test_27_create_with_invalid_entity(self): try: entity_type = 'dataset_invalid' store_type = StoreType.S3H.value self.assertIn( output_messages['INFO_INITIALIZED_PROJECT'] % self.tmp_dir, check_output(MLGIT_INIT)) api.create('dataset_invalid', 'dataset-ex', categories=['computer-vision', 'images'], mutability='strict') self.check_created_folders(entity_type, store_type) self.assertTrue(False) except Exception as e: self.assertIn(output_messages['ERROR_INVALID_ENTITY_TYPE'], str(e))
def test_15_create_entity_with_optional_arguments(self): self.assertIn( output_messages['INFO_INITIALIZED_PROJECT_IN'] % self.tmp_dir, check_output(MLGIT_INIT)) api.create(DATASETS, DATASET_NAME, categories=['computer-vision', 'images'], version=5, storage_type=AZUREBLOBH, bucket_name='test', mutability=STRICT) self.check_created_folders(DATASETS, AZUREBLOBH, version=5, bucket_name='test')
def test_15_create_entity_with_optional_arguments(self): entity_type = 'dataset' store_type = StoreType.AZUREBLOBH.value self.assertIn( output_messages['INFO_INITIALIZED_PROJECT'] % self.tmp_dir, check_output(MLGIT_INIT)) api.create('dataset', 'dataset-ex', categories=['computer-vision', 'images'], version=5, store_type=store_type, bucket_name='test', mutability='strict') self.check_created_folders(entity_type, store_type, version=5, bucket_name='test')