def test_log_backend(self):
     log.debug("MarquezWriteOnlyClient.setup(): ")
     os.environ['MARQUEZ_BACKEND'] = 'log'
     self.client_wo_log = Clients.new_write_only_client()
     log.info("created marquez_client_wo_log.")
     if not isinstance(self.client_wo_log._backend, LogBackend):
         raise Exception("Not a LogBackend.")
Esempio n. 2
0
def test_new_wo_client_log():
    os.environ['MARQUEZ_BACKEND'] = 'log'

    client = Clients.new_write_only_client()
    assert isinstance(client._backend, LogBackend)

    del os.environ['MARQUEZ_BACKEND']
Esempio n. 3
0
def test_new_wo_client_file():
    os.environ['MARQUEZ_BACKEND'] = 'file'

    client = Clients.new_write_only_client()
    assert isinstance(client._backend, FileBackend)

    del os.environ['MARQUEZ_BACKEND']
Esempio n. 4
0
def test_new_wo_client_http():
    os.environ['MARQUEZ_BACKEND'] = 'http'
    os.environ['MARQUEZ_API_KEY'] = API_KEY

    client = Clients.new_write_only_client()
    assert isinstance(client._backend, HttpBackend)
    assert client._backend._api_base == API_BASE
    assert client._backend._api_key == API_KEY

    del os.environ['MARQUEZ_BACKEND']
    del os.environ['MARQUEZ_API_KEY']
Esempio n. 5
0
    def setUp(self):
        log.debug("MarquezWriteOnlyClient.setup(): ")

        with open('tests/logConfig.yaml', 'rt') as file:
            yamlConfig = yaml.safe_load(file.read())
            logging.config.dictConfig(yamlConfig)
            log.info("loaded logConfig.yaml")

        os.environ['MARQUEZ_BACKEND'] = 'file'
        self.client_wo_file = Clients.new_write_only_client()
        log.info("created marquez_client_wo_file.")
Esempio n. 6
0
def test_new_client():
    os.environ['MARQUEZ_API_KEY'] = API_KEY

    from marquez_client.client import _USER_AGENT, _HEADERS
    headers_with_auth = {'User-Agent': _USER_AGENT}

    # Add API key to headers
    Utils.add_auth_to(headers_with_auth, API_KEY)

    client = Clients.new_client()
    assert client._api_base == API_BASE
    assert _HEADERS == headers_with_auth

    del os.environ['MARQUEZ_API_KEY']
Esempio n. 7
0
 def get_or_create_marquez_client(self):
     if not self._marquez_client:
         self._marquez_client = Clients.new_write_only_client()
     return self._marquez_client
Esempio n. 8
0
    def setUp(self):
        log.debug("MarquezWriteOnlyClient.setup(): ")

        os.environ['MARQUEZ_BACKEND'] = 'file'
        self.client_wo_file = Clients.new_write_only_client()
        log.info("created marquez_client_wo_file.")
Esempio n. 9
0
from marquez_client import Clients
from marquez_client.models import (
    DatasetType,
    DatasetId,
    JobType
)

# Construct a new MarquezClient instance we'll use to collect metadata.
# Marquez listens on 'localhost:8080' for all API calls by default.
# Use the 'MARQUEZ_URL' the environment variable to override the default
# Marquez host and port.
#
# For example:
#     $ export MARQUEZ_URL=http://localhost:5000
marquez_client = Clients.new_client()

# Create a namespace to organize related dataset and job metadata.
namespace = marquez_client.create_namespace(
    namespace_name='my-namespace',
    owner_name='me',
    description='My first namespace!'
)

# Create the source 'my-source' for the database 'mydb'.
marquez_client.create_source(
    source_type='POSTGRESQL',
    source_name='my-source',
    connection_url='jdbc:postgresql://localhost:5431/mydb',
    description='My first source!'
)