Exemplo n.º 1
0
    def __init__(self, __task_type, **kwargs):
        '''
        Construct an instance of GBDX Task

        Args:
            __task_type: name of the task
            **kwargs: key=value pairs for inputs to set on the task

        Returns:
            An instance of Task.

        '''
        self.name = __task_type + '_' + str(uuid.uuid4())[:8]
        self.name = self.name.replace(':','_')  # keep colon out of task name

        self.type = __task_type
        task_registry = TaskRegistry()
        self.definition = task_registry.get_definition(__task_type)
        self.domain = self.definition.get('containerDescriptors', [{'properties': {}}])[0]['properties'].get('domain', 'default')
        self._timeout = self.definition['properties'].get('timeout')

        self.inputs = Inputs(self.input_ports, task=self)
        self.outputs = Outputs(self.output_ports, self.name)
        self.batch_values = None
        self._impersonation_allowed = None

        # all the other kwargs are input port values or sources
        self.set(**kwargs)
def test_delete_task():
    tr = TaskRegistry(gbdx)
    tasks = tr.list()
    if not 'gbdxtools-test-task' in tasks:
        test_list_tasks()
    rv = tr.delete('gbdxtools-test-task')
    assert 'successfully deleted' in rv.lower()
Exemplo n.º 3
0
def test_delete_task():
    tr = TaskRegistry()
    tasks = tr.list()
    if not 'gbdxtools-test-task' in tasks:
        test_list_tasks()
    rv = tr.delete('gbdxtools-test-task')
    assert 'successfully deleted' in rv.lower()
def test_describe_tasks():
    tr = TaskRegistry(gbdx)
    task_list = tr.list()
    assert len(task_list) > 0
    desc = tr.get_definition(task_list[0])
    assert isinstance(desc, dict)
    assert len(desc['description']) > 0   
def _test_register_task(task_json=None, filename=None):
    tr = TaskRegistry(gbdx)

    if task_json:
        rv = tr.register(task_json)
    else:
        rv = tr.register(filename)

    assert 'successfully registered' in rv.lower()
Exemplo n.º 6
0
def _test_register_task(task_json=None, filename=None):
    tr = TaskRegistry(gbdx)

    if task_json:
        rv = tr.register(task_json)
    else:
        rv = tr.register(filename)

    assert 'successfully registered' in rv.lower()
def test_register_fails_when_both_json_and_file_none():
    tr = TaskRegistry(gbdx)

    try:
        tr.register(task_json=None, json_filename=None)
    except Exception as e:
        if "Both task json and filename can't be none." in str(e):
            pass
        else:
            raise
def test_register_fails_when_both_json_and_file():
    tr = TaskRegistry(gbdx)

    try:
        tr.register(task_json={'any': 'thing'}, json_filename="any")
    except Exception as e:
        if "Both task json and filename can't be provided." in str(e):
            pass
        else:
            raise
Exemplo n.º 9
0
def test_register_fails_when_both_json_and_file():
    tr = TaskRegistry(gbdx)

    try:
        tr.register(task_json={'any': 'thing'}, json_filename="any")
    except Exception as e:
        if "Both task json and filename can't be provided." in str(e):
            pass
        else:
            raise
Exemplo n.º 10
0
def test_register_fails_when_both_json_and_file_none():
    tr = TaskRegistry(gbdx)

    try:
        tr.register(task_json=None, json_filename=None)
    except Exception as e:
        if "Both task json and filename can't be none." in str(e):
            pass
        else:
            raise
Exemplo n.º 11
0
def test_update_task_definition():
    # Note that this test requires the task to be registered all ready.
    # If updating the VCR yaml cassette, manually register the gbdxtools-test-task above,
    # Deleting it once the VCR cassette has been created.
    tr = TaskRegistry(gbdx)

    updated_task = _task_json()
    output_ports = updated_task['outputPortDescriptors']
    updated_task['outputPortDescriptors'] = output_ports + [{"name": "output%s" % len(output_ports), "type": "string"}]

    task_name = '%s:%s' % (updated_task['name'], updated_task['version'])

    r = tr.update(task_name, updated_task)

    assert r['outputPortDescriptors'] == updated_task['outputPortDescriptors']
Exemplo n.º 12
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()
Exemplo n.º 13
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()
Exemplo n.º 14
0
def test_update_task_definition():
    # Note that this test requires the task to be registered all ready.
    # If updating the VCR yaml cassette, manually register the gbdxtools-test-task above,
    # Deleting it once the VCR cassette has been created.
    tr = TaskRegistry()

    updated_task = _task_json()
    output_ports = updated_task['outputPortDescriptors']
    updated_task['outputPortDescriptors'] = output_ports + [{
        "name":
        "output%s" % len(output_ports),
        "type":
        "string"
    }]

    task_name = '%s:%s' % (updated_task['name'], updated_task['version'])

    r = tr.update(task_name, updated_task)

    assert r['outputPortDescriptors'] == updated_task['outputPortDescriptors']
Exemplo n.º 15
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)
Exemplo n.º 16
0
def test_list_tasks():
    tr = TaskRegistry(gbdx)
    task_list = tr.list()
    assert task_list is not None
    assert 'HelloGBDX' in task_list
Exemplo n.º 17
0
def test_list_tasks():
    tr = TaskRegistry(gbdx)
    task_list = tr.list()
    assert task_list is not None
    assert 'HelloGBDX' in task_list
Exemplo n.º 18
0
def test_init():
    tr = TaskRegistry(gbdx)
    assert isinstance(tr, TaskRegistry)