Exemplo n.º 1
0
 def _initialize_entity(self, entity_type, git=GIT_PATH):
     api.init('repository')
     api.remote_add(entity_type, git)
     api.storage_add(bucket_type=STORAGE_TYPE, bucket_name=BUCKET_NAME, credentials=PROFILE)
     api.init(entity_type)
     metadata_path = os.path.join(self.tmp_dir, ML_GIT_DIR, entity_type, 'metadata')
     self.assertTrue(os.path.exists(metadata_path))
Exemplo n.º 2
0
 def test_21_add_storage(self):
     api.init('repository')
     with open(os.path.join(self.tmp_dir, ML_GIT_DIR, 'config.yaml'), 'r') as c:
         config = yaml_processor.load(c)
         self.assertNotIn(S3H, config[STORAGE_CONFIG_KEY])
     api.storage_add(bucket_name=BUCKET_NAME, credentials=PROFILE)
     with open(os.path.join(self.tmp_dir, ML_GIT_DIR, 'config.yaml'), 'r') as c:
         config = yaml_processor.load(c)
         self.assertEqual(PROFILE, config[STORAGE_CONFIG_KEY][S3H][BUCKET_NAME]['aws-credentials']['profile'])
Exemplo n.º 3
0
 def test_22_add_storage_azure_type(self):
     bucket_name = 'container_azure'
     api.init('repository')
     with open(os.path.join(self.tmp_dir, ML_GIT_DIR, 'config.yaml'), 'r') as c:
         config = yaml_processor.load(c)
         self.assertNotIn(AZUREBLOBH, config[STORAGE_CONFIG_KEY])
     api.storage_add(bucket_name=bucket_name, bucket_type=AZUREBLOBH)
     with open(os.path.join(self.tmp_dir, ML_GIT_DIR, 'config.yaml'), 'r') as c:
         config = yaml_processor.load(c)
         self.assertIn(bucket_name, config[STORAGE_CONFIG_KEY][AZUREBLOBH])
Exemplo n.º 4
0
 def test_23_add_storage_gdrive_type(self):
     bucket_name = 'my-drive'
     profile = 'path-to-credentials'
     api.init('repository')
     with open(os.path.join(self.tmp_dir, ML_GIT_DIR, 'config.yaml'), 'r') as c:
         config = yaml_processor.load(c)
         self.assertNotIn(GDRIVEH, config[STORAGE_CONFIG_KEY])
     api.storage_add(bucket_name=bucket_name, bucket_type=GDRIVEH, credentials=profile)
     with open(os.path.join(self.tmp_dir, ML_GIT_DIR, 'config.yaml'), 'r') as c:
         config = yaml_processor.load(c)
         self.assertEqual(profile, config[STORAGE_CONFIG_KEY][GDRIVEH][bucket_name]['credentials-path'])
Exemplo n.º 5
0
 def test_32_add_storage_with_region(self):
     bucket_region = 'my-bucket-region'
     api.init('repository')
     api.storage_add(bucket_name=BUCKET_NAME,
                     credentials=PROFILE,
                     region=bucket_region)
     with open(os.path.join(self.tmp_dir, ML_GIT_DIR, 'config.yaml'),
               'r') as c:
         config = yaml_processor.load(c)
         self.assertEqual(
             PROFILE, config[STORAGE_CONFIG_KEY][S3H][BUCKET_NAME]
             ['aws-credentials']['profile'])
         self.assertEqual(
             bucket_region,
             config[STORAGE_CONFIG_KEY][S3H][BUCKET_NAME]['region'])