def get_builder(self, preprocessor, base_image, registry, needs_deps_installation=True, pod_spec_mutators=None): """Creates a builder instance with right config for AWS :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(aws.add_aws_credentials_if_exists) if aws.is_ecr_registry(registry): pod_spec_mutators.append(aws.add_ecr_config) aws.create_ecr_registry(registry, constants.DEFAULT_IMAGE_NAME) return super(AWSBackend, self).get_builder(preprocessor, base_image, registry, needs_deps_installation, pod_spec_mutators)
def get_builder(self, preprocessor, base_image, registry, needs_deps_installation=True, pod_spec_mutators=None, annotations=None): """Creates a builder instance with right config for AWS :param annotations: Adding annotations to the training job useful for kube2iam implementation :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 [] # if the annotations contains some sort of role, we assume that user is using # kube2iam role so injection of credentials should be avoided import re def search(dictionary, searchword): """ :param dictionary: Dictionary in which you need to perform the search :param searchword: word or part of word to search :return: Boolean True/False """ search.a = [] for key, value in dictionary.items(): match = re.search(r'{}'.format(searchword), key) matchval = re.search(r'{}'.format(searchword), value) if match or matchval: return True else: return False if annotations: rolepresent = search(annotations, 'role') if not rolepresent: pod_spec_mutators.append(aws.add_aws_credentials_if_exists) if aws.is_ecr_registry(registry): pod_spec_mutators.append(aws.add_ecr_config) aws.create_ecr_registry(registry, constants.DEFAULT_IMAGE_NAME) return super(AWSBackend, self).get_builder(preprocessor, base_image, registry, needs_deps_installation, pod_spec_mutators, annotations)