示例#1
0
    def _configure_main_task(config, job_exe, job_type, interface):
        """Configures the main task for the given execution with items specific to the main task

        :param config: The execution configuration
        :type config: :class:`job.configuration.json.execution.exe_config.ExecutionConfiguration`
        :param job_exe: The job execution model being scheduled
        :type job_exe: :class:`job.models.JobExecution`
        :param job_type: The job type model
        :type job_type: :class:`job.models.JobType`
        :param interface: The job interface
        :type interface: :class:`job.configuration.interface.job_interface.JobInterface`
        """

        # Set shared memory if required by this job type
        shared_mem = job_type.shared_mem_required
        if shared_mem > 0:
            shared_mem = int(math.ceil(shared_mem))
            env_vars = {'ALLOCATED_SHARED_MEM': '%.1f' % float(shared_mem)}
            config.add_to_task('main', docker_params=[DockerParameter('shm-size', '%dm' % shared_mem)],
                               env_vars=env_vars)

        job_config = job_type.get_job_configuration()
        mount_volumes = {}
        # TODO: use better interface method once we switch to Seed
        for mount in interface.get_dict()['mounts']:
            name = mount['name']
            mode = mount['mode']
            path = mount['path']
            volume_name = get_mount_volume_name(job_exe, name)
            volume = job_config.get_mount_volume(name, volume_name, path, mode)
            if volume:
                mount_volumes[name] = volume
            else:
                mount_volumes[name] = None
        config.add_to_task('main', mount_volumes=mount_volumes)
示例#2
0
    def populate_mounts(self, job_exe):
        """Adds the mounts defined in the job type's interface and configuration to the execution configuration

        :param job_exe: The job execution model with related job and job_type fields
        :type job_exe: :class:`job.models.JobExecution`
        """

        interface = job_exe.get_job_interface()
        job_config = job_exe.get_job_configuration()
        for mount in interface.get_dict()['mounts']:
            name = mount['name']
            mode = mount['mode']
            path = mount['path']
            volume_name = get_mount_volume_name(job_exe, name)
            volume = job_config.get_mount_volume(name, volume_name, path, mode)
            if volume:
                self.add_job_task_docker_params([volume.to_docker_param()])