示例#1
0
    def _initialize_client(self, uri):
        self.uri = uri
        self.options = parse_uri(uri)["query"]

        self.client = TrackClient(uri)
        self.backend = self.client.protocol
        self.project = None
        self.group = None
        self.objective = self.options.get("objective")
        assert self.objective is not None, "An objective should be defined!"
示例#2
0
    def __init__(self, uri):
        uri = parse_uri(uri)
        self.username = uri.get('username')
        self.password = uri.get('password')
        self.security_layer = uri['query'].get('security_layer')
        self.socket = open_socket(uri.get('address'),
                                  int(uri.get('port')),
                                  backend=self.security_layer)

        self.token = self._authenticate(uri)
        info(f'token: {self.token}')
示例#3
0
    def __init__(self, uri):
        from track.persistence import get_protocol

        uri = parse_uri(uri)
        self.address, self.port = uri.get('address'), int(uri.get('port'))
        self.security_layer = uri['query'].get('security_layer')

        self.backend = get_protocol(uri['query'].get('backend'))
        self.authentication = {}
        self.timeout = 10
        self.client_cache = {}
        self.sckt = None
        self.loop = None
示例#4
0
文件: cometml.py 项目: bouthilx/track
    def __init__(self, uri):
        uri = parse_uri(uri)

        # cometml:workspace/project
        path = uri.get('path')

        if not path:
            # cometml://workspace/project
            path = uri.get('address')

        workspace, project = path.split('/', maxsplit=2)

        self.cml = Experiment(project_name=project, workspace=workspace)
        self.chrono = {}
        self._api = None
示例#5
0
文件: track.py 项目: obilaniu/orion
    def __init__(self, uri):
        if not HAS_TRACK:
            # We ignored the import error above in case we did not need track
            # but now that we do we can rethrow it
            raise ImportError("Track is not installed!")

        self.uri = uri
        self.options = parse_uri(uri)["query"]

        self.client = TrackClient(uri)
        self.backend = self.client.protocol
        self.project = None
        self.group = None
        self.objective = self.options.get("objective")
        self.lies = dict()
        assert self.objective is not None, "An objective should be defined!"
示例#6
0
    def __init__(self, uri, strict=True, eager=True):
        uri = parse_uri(uri)

        # file:test.json
        path = uri.get('path')

        if not path:
            # file://test.json
            path = uri.get('address')

        self.path = path
        self.storage: LocalStorage = load_database(path)
        self.chronos = {}
        self.strict = strict
        self.eager = eager
        self.lock = make_lock(f'{path}.lock', eager)
        self.signal_handler = LockFileRemover(f'{path}.lock')
示例#7
0
def test_uri_parsing():
    hostname = 'localhost'
    port = 8123
    protocol = 'file://test.json'
    password = '******'
    username = '******'

    results = parse_uri(
        f'socket://{username}:{password}@{hostname}:{port}?backend={protocol}&test=2'
    )

    assert results['scheme'] == 'socket'
    assert results['address'] == hostname
    assert results['password'] == password
    assert results['username'] == username
    assert int(results['port']) == port
    assert results['query']['backend'] == protocol
    assert int(results['query']['test']) == 2
示例#8
0
    def __init__(self, uri):
        uri = parse_uri(uri)
        debug('connecting to server')
        self.con = psycopg2.connect(
            database='track',
            user=uri.get('username', 'track_client'),
            password=uri.get('password', 'track_password'),
            # sslmode='require',
            # sslrootcert='certs/ca.crt',
            # sslkey='certs/client.maxroach.key',
            # sslcert='certs/client.maxroach.crt',
            port=uri['port'],
            host=uri['address'])
        self.con.set_session(autocommit=True)

        debug('get connection cursor')
        self.cursor = self.con.cursor()
        self.chrono = {}
示例#9
0
文件: utils.py 项目: Delaunay/track
    def __init__(self, uri):
        """Init method, see attributes of :class:`AbstractDB`."""

        # host = 'localhost', name = None,
        # port = None, username = None, password = None, ** kwargs
        self.resource = uri
        args = parse_uri(uri)

        self.host = args.get('address')
        self.name = args.get('query', {}).pop('name', 'default')
        self.port = args.get('port')
        self.username = args.get('username')
        self.password = args.get('password')
        self.options = args.get('query')

        self._db = None
        self._conn = None
        self.initiate_connection()
示例#10
0
def get_protocol(backend_name):
    """ proto://arg """

    arguments = parse_uri(backend_name)
    log = _protocols.get(arguments['scheme'])

    if log is None:
        warning(f'Logger (backend: {backend_name}) was not found!')
        log = _protocols.get('__default__')

    if log is make_local:
        debug('return local protocol')
        return log(backend_name)
    else:
        debug('return multiplexed protocol')
        return ProtocolMultiplexer(
            # Make a file Protocol to log everything in memory as well as remotely
            make_local('file:', strict=False, eager=False),
            log(backend_name))
示例#11
0
    username = '******'

    results = parse_uri(
        f'socket://{username}:{password}@{hostname}:{port}?backend={protocol}&test=2'
    )

    assert results['scheme'] == 'socket'
    assert results['address'] == hostname
    assert results['password'] == password
    assert results['username'] == username
    assert int(results['port']) == port
    assert results['query']['backend'] == protocol
    assert int(results['query']['test']) == 2


if __name__ == '__main__':
    test_uri_parsing()

    a = parse_uri(
        'protocol://*****:*****@host1:port1/database?options=2')
    print(a)

    a = parse_uri('socket://192.128.0.1:8123/database?options=2')
    print(a)

    a = parse_uri('cometml:workspace/project?options=2')
    print(a)

    a = parse_uri('file:test.json')
    print(a)