예제 #1
0
 def test_order_batching(self):
     o = Ordering()
     order_id = o.order(['10400100120FEA00', '101001000DB2FB00'],
                        batch_size=1)
     # assert order_id == '2b3ba38e-4d7e-4ef6-ac9d-2e2e0a8ca1e7'
     assert len(order_id) == 2
     assert len(order_id[0]) == 36
예제 #2
0
 def test_order_batching(self):
     o = Ordering()
     res = o.location(['10400100120FEA00', '101001000DB2FB00'], batch_size=1)
     acq_list = res['acquisitions']
     assert len(acq_list) == 2
     for entry in res['acquisitions']:
         assert entry['location'].startswith('s3')
예제 #3
0
    def get_data_location(self, catalog_id):
        """
        Find and return the S3 data location given a catalog_id.

        Args:
            catalog_id: The catalog ID

        Returns:
            A string containing the s3 location of the data associated with a catalog ID.  Returns
            None if the catalog ID is not found, or if there is no data yet associated with it.
        """

        try:
            record = self.get(catalog_id)
        except:
            return None

        # Handle Landsat8
        if 'Landsat8' in record['type'] and 'LandsatAcquisition' in record['type']:
            bucket = record['properties']['bucketName']
            prefix = record['properties']['bucketPrefix']
            return 's3://' + bucket + '/' + prefix

        # Handle DG Acquisition
        if 'DigitalGlobeAcquisition' in record['type']:
            o = Ordering()
            res = o.location([catalog_id])
            return res['acquisitions'][0]['location']

        return None
예제 #4
0
    def get_data_location(self, catalog_id):
        """
        Find and return the S3 data location given a catalog_id.

        Args:
            catalog_id: The catalog ID

        Returns:
            A string containing the s3 location of the data associated with a catalog ID.  Returns
            None if the catalog ID is not found, or if there is no data yet associated with it.
        """

        try:
            record = self.get(catalog_id)
        except:
            return None

        # Handle Landsat8
        if 'Landsat8' in record['type'] and 'LandsatAcquisition' in record[
                'type']:
            bucket = record['properties']['bucketName']
            prefix = record['properties']['bucketPrefix']
            return 's3://' + bucket + '/' + prefix

        # Handle DG Acquisition
        if 'DigitalGlobeAcquisition' in record['type']:
            o = Ordering()
            res = o.location([catalog_id])
            return res['acquisitions'][0]['location']

        return None
예제 #5
0
 def test_get_order_status(self):
     o = Ordering()
     results = o.status('c5cd8157-3001-4a03-a716-4ef673748c7a')
     print(results)
     for result in results:
         assert 'acquisition_id' in result.keys()
         assert 'state' in result.keys()
         assert 'location' in result.keys()
예제 #6
0
 def test_order_batching(self):
     o = Ordering()
     res = o.location(['10400100120FEA00', '101001000DB2FB00'],
                      batch_size=1)
     acq_list = res['acquisitions']
     assert len(acq_list) == 2
     for entry in res['acquisitions']:
         assert entry['location'].startswith('s3')
예제 #7
0
 def test_get_order_status(self):
     o = Ordering()
     results = o.status('c5cd8157-3001-4a03-a716-4ef673748c7a')
     print(results)
     for result in results:
         assert 'acquisition_id' in result.keys()
         assert 'state' in result.keys()
         assert 'location' in result.keys()
예제 #8
0
    def __init__(self, **kwargs):
        interface = Auth(**kwargs)
        self.gbdx_connection = interface.gbdx_connection
        self.root_url = interface.root_url
        self.logger = interface.logger

        # create and store an instance of the GBDX s3 client
        self.s3 = S3()

        # create and store an instance of the GBDX Ordering Client
        self.ordering = Ordering()

        # create and store an instance of the GBDX Catalog Client
        self.catalog = Catalog()

        # create and store an instance of the GBDX Workflow Client
        self.workflow = Workflow()

        # create and store an instance of the Idaho Client
        self.idaho = Idaho()

        self.vectors = Vectors()

        self.catalog_image = CatalogImage
        self.idaho_image = IdahoImage
        self.landsat_image = LandsatImage
        self.sentinel2 = Sentinel2
        self.tms_image = TmsImage
        self.dem_image = DemImage
        self.wv03_vnir = WV03_VNIR
        self.wv02 = WV02
        self.ge01 = GE01
        self.s3_image = S3Image

        self.task_registry = TaskRegistry()
예제 #9
0
    def __init__(self, **kwargs):
        interface = Auth(**kwargs)
        self.gbdx_connection = interface.gbdx_connection
        self.root_url = interface.root_url
        self.logger = interface.logger

        # create and store an instance of the GBDX s3 client
        self.s3 = S3()

        # create and store an instance of the GBDX Ordering Client
        self.ordering = Ordering()

        # create and store an instance of the GBDX Catalog Client
        self.catalog = Catalog()

        # create and store an instance of the GBDX Workflow Client
        self.workflow = Workflow()

        # create and store an instance of the Idaho Client
        self.idaho = Idaho()

        self.vectors = Vectors()

        self.catalog_image = CatalogImage
        self.idaho_image = IdahoImage

        self.task_registry = TaskRegistry()
예제 #10
0
    def __init__(self, **kwargs):
        host = kwargs.get('host') if kwargs.get('host') else 'geobigdata.io'
        self.root_url = 'https://%s' % host

        if (kwargs.get('username') and kwargs.get('password')
                and kwargs.get('client_id') and kwargs.get('client_secret')):
            self.gbdx_connection = gbdx_auth.session_from_kwargs(**kwargs)
        elif kwargs.get('gbdx_connection'):
            # Pass in a custom gbdx connection object, for testing purposes
            self.gbdx_connection = kwargs.get('gbdx_connection')
        else:
            # This will throw an exception if your .ini file is not set properly
            self.gbdx_connection = gbdx_auth.get_session(
                kwargs.get('config_file'))

        # create a logger
        # for now, just log to the console. We'll replace all the 'print' statements
        # with at least logger.info or logger.debug statements
        # later, we can log to a service, file, or some other aggregator
        self.logger = logging.getLogger('gbdxtools')
        self.logger.setLevel(logging.ERROR)
        console_handler = logging.StreamHandler()
        console_handler.setLevel(logging.ERROR)
        formatter = logging.Formatter(
            '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        console_handler.setFormatter(formatter)
        self.logger.addHandler(console_handler)
        self.logger.info('Logger initialized')

        # create and store an instance of the GBDX s3 client
        self.s3 = S3(self)

        # create and store an instance of the GBDX Ordering Client
        self.ordering = Ordering(self)

        # create and store an instance of the GBDX Catalog Client
        self.catalog = Catalog(self)

        # create and store an instance of the GBDX Workflow Client
        self.workflow = Workflow(self)

        # create and store an instance of the Idaho Client
        self.idaho = Idaho(self)

        self.vectors = Vectors(self)

        self.task_registry = TaskRegistry(self)
예제 #11
0
 def test_order_batching(self):
     o = Ordering()
     order_id = o.order(['10400100120FEA00', '101001000DB2FB00'], batch_size=1)
     # assert order_id == '2b3ba38e-4d7e-4ef6-ac9d-2e2e0a8ca1e7'
     assert len(order_id) == 2
     assert len(order_id[0]) == 36
예제 #12
0
 def test_order_single_catid(self):
     o = Ordering()
     order_id = o.order('10400100120FEA00')
     # assert order_id == 'c5cd8157-3001-4a03-a716-4ef673748c7a'
     assert len(order_id) == 36
예제 #13
0
 def test_init(self):
     o = Ordering()
     assert isinstance(o, Ordering)
예제 #14
0
def test_order_multi_catids():
	o = Ordering(gbdx)
	order_id = o.order(['10400100120FEA00','101001000DB2FB00'])
	# assert order_id == '2b3ba38e-4d7e-4ef6-ac9d-2e2e0a8ca1e7'
	assert len(order_id) == 36
예제 #15
0
def test_get_order_status():
	o = Ordering(gbdx)
	r = o.status('c5cd8157-3001-4a03-a716-4ef673748c7a')
	print r.keys()
	assert 's3://bucketname/prefixname' in r.keys()
예제 #16
0
 def test_heartbeat_failure(self):
     # mock requests.get so that we get a result for which response.json() will throw an exception
     with patch('gbdxtools.ordering.requests.get', return_value = False) as mock_within:
         o = Ordering()
         assert o.heartbeat() == False
예제 #17
0
def test_order_single_catid():
	o = Ordering(gbdx)
	order_id = o.order('10400100120FEA00')
	# assert order_id == 'c5cd8157-3001-4a03-a716-4ef673748c7a'
	assert len(order_id) == 36
예제 #18
0
 def test_heartbeat(self):
     o = Ordering()
     assert o.heartbeat() == True
예제 #19
0
 def test_order_multi_catids(self):
     o = Ordering()
     order_id = o.order(['10400100120FEA00', '101001000DB2FB00'])
     # assert order_id == '2b3ba38e-4d7e-4ef6-ac9d-2e2e0a8ca1e7'
     assert len(order_id) == 36
예제 #20
0
 def test_heartbeat(self):
     o = Ordering()
     assert o.heartbeat() == True
예제 #21
0
def test_init():
    o = Ordering(gbdx)
    assert isinstance(o, Ordering)
예제 #22
0
 def test_heartbeat_failure(self):
     # mock requests.get so that we get a result for which response.json() will throw an exception
     with patch('gbdxtools.ordering.requests.get',
                return_value=False) as mock_within:
         o = Ordering()
         assert o.heartbeat() == False