in python-batch/batch.py [0:0]
def _create_task(self) -> batch_v1.TaskSpec:
"""
_summary_
:return: _description_
:rtype: batch_v1.TaskSpec
"""
self.task = batch_v1.TaskSpec()
self.task.max_retry_count = 2
self.task.max_run_duration = "604800s"
self.task.volumes = []
if "nfs_server" in self.config:
nfs_server = batch_v1.NFS()
nfs_server.server = self.config["nfs_server"]
nfs_server.remote_path = self.config["nfs_remote_path"] if "nfs_remote_path" in self.config else "/nfshare"
nfs_volume = batch_v1.Volume()
nfs_volume.nfs = nfs_server
nfs_volume.mount_path = self.config["nfs_path"] if "nfs_path" in self.config else "/mnt/nfs"
self.task.volumes.append(nfs_volume)
# Use commmand line flags first, then config file, to set
# gcs bucket mounts
if(FLAGS.volumes):
self.volumes_list = []
for volume_pair in FLAGS.volumes:
(bucket_name, gcs_path) = volume_pair.split(":")
self.volumes_list.append({"bucket_name":bucket_name, "gcs_path":gcs_path})
elif "volumes" in self.config:
self.volumes_list = self.config["volumes"]
else:
self.volumes_list = None
if(not self.volumes_list is None):
gcs_volume = batch_v1.Volume()
for volume in self.volumes_list:
gcs_bucket = batch_v1.GCS()
gcs_bucket.remote_path = volume["bucket_name"]
gcs_volume.mount_path = volume["gcs_path"]
gcs_volume.gcs = gcs_bucket
self.task.volumes.append(gcs_volume)
if "container" in self.config:
self.runnable.container.volumes.append(
volume["gcs_path"]+":"+volume["gcs_path"]+":rw")
# We can specify what resources are requoested by each task.
resources = batch_v1.ComputeResource()
resources.cpu_milli = self.config["cpu_milli"] if "cpu_milli" in self.config else 1000
resources.memory_mib = self.config["memory_mib"] if "memory_mib" in self.config else 102400
resources.boot_disk_mib = self.config["boot_disk_mib"] if "boot_disk_mib" in self.config else 102400
self.task.compute_resource = resources
return(self.task)