def get_builder(self, preprocessor, base_image, registry, needs_deps_installation=True, pod_spec_mutators=None): """Creates a builder instance with right config for GKE :param preprocessor: Preprocessor to use to modify inputs :param base_image: Base image to use for this job :param registry: Registry to push image to. Example: gcr.io/kubeflow-images :param needs_deps_installation: need depends on installation(Default value = True) :param pod_spec_mutators: list of functions that is used to mutate the podsspec. e.g. fairing.cloud.gcp.add_gcp_credentials_if_exists This can used to set things like volumes and security context. (Default value =None) """ pod_spec_mutators = pod_spec_mutators or [] pod_spec_mutators.append(gcp.add_gcp_credentials_if_exists) if not needs_deps_installation: return AppendBuilder(preprocessor=preprocessor, base_image=base_image, registry=registry) elif (utils.is_running_in_k8s() or not ml_tasks_utils.is_docker_daemon_exists()): return ClusterBuilder(preprocessor=preprocessor, base_image=base_image, registry=registry, pod_spec_mutators=pod_spec_mutators, namespace=self._namespace, context_source=self._build_context_source) elif ml_tasks_utils.is_docker_daemon_exists(): return DockerBuilder(preprocessor=preprocessor, base_image=base_image, registry=registry) else: msg = ["Not able to guess the right builder for this job!"] if not utils.is_running_in_k8s(): msg.append( " Also If you are using 'sudo' to access docker in your system you can" " solve this problem by adding your username to the docker group. " "Reference: https://docs.docker.com/install/linux/linux-postinstall/" "#manage-docker-as-a-non-root-user You need to logout and login to " "get change activated.") message = " ".join(msg) raise RuntimeError(message)
def get_builder(self, preprocessor, base_image, registry, needs_deps_installation=True, # pylint:disable=arguments-differ pod_spec_mutators=None): """Creates a builder instance with right config for the given Kubernetes :param preprocessor: Preprocessor to use to modify inputs :param base_image: Base image to use for this job :param registry: Registry to push image to. Example: gcr.io/kubeflow-images :param needs_deps_installation: need depends on installation(Default value = True) :param pod_spec_mutators: list of functions that is used to mutate the podsspec. e.g. fairing.cloud.gcp.add_gcp_credentials_if_exists This can used to set things like volumes and security context. (Default value =None) """ if not needs_deps_installation: return AppendBuilder(preprocessor=preprocessor, base_image=base_image, registry=registry) elif utils.is_running_in_k8s(): return ClusterBuilder(preprocessor=preprocessor, base_image=base_image, registry=registry, pod_spec_mutators=pod_spec_mutators, namespace=self._namespace, context_source=self._build_context_source) elif ml_tasks_utils.is_docker_daemon_exists(): return DockerBuilder(preprocessor=preprocessor, base_image=base_image, registry=registry) else: # TODO (karthikv2k): Add more info on how to reolve this issue raise RuntimeError( "Not able to guess the right builder for this job!")