Exemplo n.º 1
0
 def get_init_container(self, init_command, init_args, env_vars,
                        context_mounts, persistence_outputs,
                        persistence_data):
     """Pod init container for setting outputs path."""
     env_vars = to_list(env_vars, check_none=True)
     outputs_path = stores.get_job_outputs_path(
         persistence=persistence_outputs, job_name=self.job_name)
     _, outputs_volume_mount = get_pod_outputs_volume(
         persistence_outputs=persistence_outputs)
     volume_mounts = outputs_volume_mount + to_list(context_mounts,
                                                    check_none=True)
     init_command = init_command or ["/bin/sh", "-c"]
     init_args = init_args or to_list(
         get_output_args(command=InitCommands.CREATE,
                         outputs_path=outputs_path))
     init_args += to_list(
         get_auth_context_args(entity='job', entity_name=self.job_name))
     return client.V1Container(
         name=self.init_container_name,
         image=self.init_docker_image,
         image_pull_policy=self.init_docker_image_pull_policy,
         command=init_command,
         args=[''.join(init_args)],
         env=env_vars,
         resources=get_init_resources(),
         volume_mounts=volume_mounts)
Exemplo n.º 2
0
 def get_init_container(self, init_command, init_args, env_vars,
                        context_mounts, persistence_outputs,
                        persistence_data):
     """Pod init container for setting outputs path."""
     env_vars = to_list(env_vars, check_none=True)
     env_vars += [
         get_env_var(name=constants.CONFIG_MAP_JOB_INFO_KEY_NAME,
                     value=json.dumps(self.labels)),
     ]
     return client.V1Container(
         name=self.init_container_name,
         image=self.init_docker_image,
         image_pull_policy=self.init_docker_image_pull_policy,
         command=init_command,
         env=env_vars,
         args=init_args,
         resources=get_init_resources(),
         volume_mounts=context_mounts)
Exemplo n.º 3
0
 def get_init_container(self, init_command, init_args, env_vars,
                        context_mounts, persistence_outputs,
                        persistence_data):
     """Pod init container for setting outputs path."""
     env_vars = to_list(env_vars, check_none=True)
     volume_mounts = to_list(context_mounts, check_none=True)
     init_command = init_command or ["/bin/sh", "-c"]
     init_args = to_list(
         get_auth_context_args(entity='notebook',
                               entity_name=self.job_name))
     return client.V1Container(
         name=self.init_container_name,
         image=self.init_docker_image,
         image_pull_policy=self.init_docker_image_pull_policy,
         command=init_command,
         args=init_args,
         env=env_vars,
         resources=get_init_resources(),
         volume_mounts=volume_mounts)
Exemplo n.º 4
0
    def get_init_container(self,
                           init_command,
                           init_args,
                           env_vars,
                           context_mounts,
                           persistence_outputs,
                           persistence_data):
        """Pod init container for setting outputs path."""
        env_vars = to_list(env_vars, check_none=True)
        if self.original_name is not None and self.cloning_strategy == CloningStrategy.RESUME:
            return []
        if self.original_name is not None and self.cloning_strategy == CloningStrategy.COPY:
            command = InitCommands.COPY
            original_outputs_path = stores.get_experiment_outputs_path(
                persistence=persistence_outputs,
                experiment_name=self.original_name)
        else:
            command = InitCommands.CREATE
            original_outputs_path = None

        outputs_path = stores.get_experiment_outputs_path(
            persistence=persistence_outputs,
            experiment_name=self.experiment_name)
        _, outputs_volume_mount = get_pod_outputs_volume(persistence_outputs=persistence_outputs)
        volume_mounts = outputs_volume_mount + to_list(context_mounts, check_none=True)
        init_command = init_command or ["/bin/sh", "-c"]
        init_args = init_args or to_list(
            get_output_args(command=command,
                            outputs_path=outputs_path,
                            original_outputs_path=original_outputs_path))
        init_args += to_list(get_auth_context_args(entity='experiment',
                                                   entity_name=self.experiment_name))
        return [
            client.V1Container(
                name=self.init_container_name,
                image=self.init_docker_image,
                image_pull_policy=self.init_docker_image_pull_policy,
                command=init_command,
                args=[''.join(init_args)],
                env=env_vars,
                resources=get_init_resources(),
                volume_mounts=volume_mounts)
        ]