Exemple #1
0
 def create(env=None):
     nonlocal proc, log_fp
     root = mkdtemp(prefix='mlrun-test-')
     print(f'root={root!r}')
     db_path = f'{root}/mlrun.sqlite3?check_same_thread=false'
     log_fp = open(f'{root}/httpd.log', 'w+')
     proc, url = start_server(db_path, log_fp, env)
     conn = HTTPRunDB(url)
     conn.connect()
     return Server(url, conn)
Exemple #2
0
 def create(env=None):
     nonlocal proc, log_fp
     root = mkdtemp(prefix='mlrun-test')
     print(f'root={root!r}')
     dirpath = f'{root}/db'
     log_fp = open(f'{root}/httpd.log', 'w+')
     proc, url, log_file = start_server(dirpath, log_fp, env)
     conn = HTTPRunDB(url)
     conn.connect()
     return Server(proc, url, log_file, conn)
Exemple #3
0
    def create(env_config=None):
        nonlocal container_id, workdir

        env_config = {} if env_config is None else env_config
        cmd = [
            "docker",
            "build",
            "-f",
            "dockerfiles/mlrun-api/Dockerfile",
            "--tag",
            docker_tag,
            ".",
        ]
        run(cmd, check=True, stdout=PIPE, cwd=project_dir_path)
        workdir = create_workdir(root_dir="/tmp")

        cmd = [
            "docker",
            "run",
            "--detach",
            "--publish",
            "8080",
            # For debugging
            "--volume",
            f"{workdir}:/tmp",
        ]

        env_config.setdefault("MLRUN_httpdb__logs_path", "/tmp")
        for key, value in env_config.items():
            cmd.extend(["--env", f"{key}={value}"])
        cmd.append(docker_tag)
        out = run(cmd, stdout=PIPE, check=True)
        container_id = out.stdout.decode("utf-8").strip()

        # retrieve container bind port + host
        out = run(["docker", "port", container_id, "8080"],
                  stdout=PIPE,
                  check=True)
        host = out.stdout.decode("utf-8").strip()

        url = f"http://{host}"
        print(f"api url: {url}")
        check_server_up(url)
        conn = HTTPRunDB(url)
        conn.connect()
        return Server(url, conn, workdir)
Exemple #4
0
    def create(env_config=None):
        nonlocal cid

        env_config = {} if env_config is None else env_config
        cmd = [
            'docker',
            'build',
            '-f',
            'dockerfiles/mlrun-api/Dockerfile',
            '--tag',
            docker_tag,
            '.',
        ]
        out = run(cmd)
        assert out.returncode == 0, 'cannot build docker'

        run(['docker', 'network', 'create', 'mlrun'])
        port = free_port()
        cmd = [
            'docker',
            'run',
            '--detach',
            '--publish',
            f'{port}:8080',
            '--network',
            'mlrun',
            '--volume',
            '/tmp:/tmp',  # For debugging
        ]
        for key, value in env_config.items():
            cmd.extend(['--env', f'{key}={value}'])
        cmd.append(docker_tag)
        out = run(cmd, stdout=PIPE)
        assert out.returncode == 0, 'cannot run docker'
        cid = out.stdout.decode('utf-8').strip()
        if in_docker:
            host = cid[:12]
            url = f'http://{host}:8080'
        else:
            url = f'http://localhost:{port}'
        print(f'httpd url: {url}')
        check_server_up(url)
        conn = HTTPRunDB(url)
        conn.connect()
        return Server(url, conn)
Exemple #5
0
 def create(env=None):
     url = 'http://localhost:8080'
     conn = HTTPRunDB(url)
     conn.connect()
     return Server(url, conn)