def test(build_config_path, profiles, nvidia=False, network=None): build_config = BuildConfig.from_path(path=build_config_path, profiles=profiles, network=network) PESTO_LOG.info('build configuration : {}'.format(build_config)) pesto_path = Path(build_config.algorithm_path) / 'pesto' / 'tests' / 'resources' TestRunner(docker_image_name=build_config.docker_image_name, network=network, nvidia=nvidia).run_all(pesto_path)
def test_docker_image_name(): # given config = BuildConfig(name='my-service', version='1.2.3', profiles=['p1', 'p2']) # when actual = config.docker_image_name # then expected = '{}:{}-{}'.format(config.name, config.version, '-'.join(config.profiles)) assert actual == expected
def build(build_config_path: str, profiles: List[str], proxy: str = None) -> None: config = BuildConfig.from_path(path=build_config_path, profiles=profiles, proxy=proxy) builder = Builder(config) builder.conf_validation() builder.copy_factory_files() builder.copy_requirements() builder.copy_pesto_whl() builder.build_docker_image()
def push(build_config_path, registry_path, profiles: List[str]): PESTO_LOG.info('Push docker image to registry : {}'.format(registry_path)) build_config = BuildConfig.from_path(path=build_config_path, profiles=profiles) PESTO_LOG.info('build configuration : {}'.format(build_config)) algo_name = build_config.name algo_version = build_config.version local_image_name = '{}:{}'.format(algo_name, algo_version) remote_image_name = '{}/{}'.format(registry_path, local_image_name) print(local_image_name) print(remote_image_name) PESTO_LOG.info('tag image {} as {}'.format(local_image_name, remote_image_name)) subprocess.call( shlex.split('docker tag {} {}'.format(local_image_name, remote_image_name))) PESTO_LOG.info('push to gcloud : {}'.format(remote_image_name)) subprocess.call( shlex.split('gcloud docker -- push {}'.format(remote_image_name)))
def test_pythonpath(): # given build_config = BuildConfig(name='my-service', version='1.2.3', profiles=['p1', 'p2'], workspace=".") requirements = { "dockerBaseImage": {}, "requirements": {}, "environments": {} } dockerbuilder = DockerBuilder(requirements, build_config).dockerfile() # when actual = dockerbuilder.split("\n")[17] dockerfile_lines = dockerbuilder.split("\n") for line in dockerfile_lines: if line[:14] == "ENV PYTHONPATH": actual = line # then expected = 'ENV PYTHONPATH=$PYTHONPATH${PYTHONPATH:+:}/opt/my-service' assert actual == expected
def test_network(): config = BuildConfig(name='my-service', version='1.2.3', profiles=['p1', 'p2'], network='test_network') assert config.network == "test_network"