Skip to content

Commit 6fa35ac

Browse files
committed
minor
1 parent d96b6ae commit 6fa35ac

File tree

6 files changed

+82
-36
lines changed

6 files changed

+82
-36
lines changed

deployment/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ custom:
126126
# Taskmaster image name
127127
imageName: docker.io/elixircloud/tesk-core-taskmaster
128128
# Taskmaster image version
129-
imageVersion: fix-null-volumes3
129+
imageVersion: fix-null-volumes5
130130
# Filer image name
131131
filerImageName: docker.io/elixircloud/tesk-core-filer
132132
# Filer image version

json_dump_tm.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"api_version": "batch/v1", "kind": "Job", "metadata": {"annotations": {"json-input": "{\n \"id\": null,\n \"state\": \"UNKNOWN\",\n \"name\": \"string\",\n \"description\": \"string\",\n \"inputs\": [\n {\n \"name\": null,\n \"description\": null,\n \"url\": \"s3://my-object-store/file1\",\n \"path\": \"/data/file1\",\n \"type\": \"FILE\",\n \"content\": null,\n \"streamable\": null\n }\n ],\n \"outputs\": [\n {\n \"name\": null,\n \"description\": null,\n \"url\": \"s3://my-object-store/outfile-1\",\n \"path\": \"/data/outfile\",\n \"path_prefix\": null,\n \"type\": \"FILE\"\n }\n ],\n \"resources\": {\n \"cpu_cores\": 4,\n \"preemptible\": false,\n \"ram_gb\": 8.0,\n \"disk_gb\": 40.0,\n \"zones\": [\n \"us-west-1\"\n ],\n \"backend_parameters\": {\n \"VmSize\": \"Standard_D64_v3\"\n },\n \"backend_parameters_strict\": false\n },\n \"executors\": [\n {\n \"image\": \"ubuntu:20.04\",\n \"command\": [\n \"/bin/md5\",\n \"/data/file1\"\n ],\n \"workdir\": \"/data/\",\n \"stdin\": \"/data/file1\",\n \"stdout\": \"/tmp/stdout.log\",\n \"stderr\": \"/tmp/stderr.log\",\n \"env\": {\n \"BLASTDB\": \"/data/GRC38\",\n \"HMMERDB\": \"/data/hmmer\"\n },\n \"ignore_error\": true\n }\n ],\n \"volumes\": [\n \"/vol/A/\"\n ],\n \"tags\": {\n \"PROJECT_GROUP\": \"alice-lab\",\n \"WORKFLOW_ID\": \"cwl-01234\"\n },\n \"logs\": null,\n \"creation_time\": null\n}", "tes-task-name": "string"}, "creation_timestamp": null, "deletion_grace_period_seconds": null, "deletion_timestamp": null, "finalizers": null, "generate_name": null, "generation": null, "labels": {"app": "taskmaster", "job-type": "taskmaster"}, "managed_fields": null, "name": "task-aa423895-42c2-417e-b080-2287f667f856", "namespace": null, "owner_references": null, "resource_version": null, "self_link": null, "uid": null}, "spec": {"active_deadline_seconds": null, "backoff_limit": null, "backoff_limit_per_index": null, "completion_mode": null, "completions": null, "manual_selector": null, "max_failed_indexes": null, "parallelism": null, "pod_failure_policy": null, "pod_replacement_policy": null, "selector": null, "suspend": null, "template": {"metadata": {"annotations": null, "creation_timestamp": null, "deletion_grace_period_seconds": null, "deletion_timestamp": null, "finalizers": null, "generate_name": null, "generation": null, "labels": null, "managed_fields": null, "name": "taskmaster", "namespace": null, "owner_references": null, "resource_version": null, "self_link": null, "uid": null}, "spec": {"active_deadline_seconds": null, "affinity": null, "automount_service_account_token": null, "containers": [{"args": ["-f", "/jsoninput/JSON_INPUT.gz", "-n", "tesk", "-fn", "docker.io/elixircloud/tesk-core-filer", "-fv", "v0.10.2"], "command": null, "env": [{"name": "TESK_FTP_USERNAME", "value": null, "value_from": {"config_map_key_ref": null, "field_ref": null, "resource_field_ref": null, "secret_key_ref": {"key": "username", "name": "account-secret", "optional": true}}}, {"name": "TESK_FTP_PASSWORD", "value": null, "value_from": {"config_map_key_ref": null, "field_ref": null, "resource_field_ref": null, "secret_key_ref": {"key": "password", "name": "account-secret", "optional": true}}}, {"name": "KEY", "value": "value", "value_from": null}, {"name": "FILER_BACKOFF_LIMIT", "value": "2", "value_from": null}, {"name": "EXECUTOR_BACKOFF_LIMIT", "value": "2", "value_from": null}], "env_from": null, "image": "docker.io/elixircloud/tesk-core-taskmaster:fix-null-volumes5", "image_pull_policy": null, "lifecycle": null, "liveness_probe": null, "name": "task-aa423895-42c2-417e-b080-2287f667f856", "ports": null, "readiness_probe": null, "resize_policy": null, "resources": null, "restart_policy": null, "security_context": null, "startup_probe": null, "stdin": null, "stdin_once": null, "termination_message_path": null, "termination_message_policy": null, "tty": null, "volume_devices": null, "volume_mounts": [{"mount_path": "/podinfo", "mount_propagation": null, "name": "podinfo", "read_only": true, "sub_path": null, "sub_path_expr": null}, {"mount_path": "/jsoninput", "mount_propagation": null, "name": "jsoninput", "read_only": true, "sub_path": null, "sub_path_expr": null}], "working_dir": null}], "dns_config": null, "dns_policy": null, "enable_service_links": null, "ephemeral_containers": null, "host_aliases": null, "host_ipc": null, "host_network": null, "host_pid": null, "host_users": null, "hostname": null, "image_pull_secrets": null, "init_containers": null, "node_name": null, "node_selector": null, "os": null, "overhead": null, "preemption_policy": null, "priority": null, "priority_class_name": null, "readiness_gates": null, "resource_claims": null, "restart_policy": "Never", "runtime_class_name": null, "scheduler_name": null, "scheduling_gates": null, "security_context": null, "service_account": null, "service_account_name": "taskmaster", "set_hostname_as_fqdn": null, "share_process_namespace": null, "subdomain": null, "termination_grace_period_seconds": null, "tolerations": null, "topology_spread_constraints": null, "volumes": [{"aws_elastic_block_store": null, "azure_disk": null, "azure_file": null, "cephfs": null, "cinder": null, "config_map": null, "csi": null, "downward_api": {"default_mode": null, "items": [{"field_ref": {"api_version": null, "field_path": "metadata.labels"}, "mode": null, "path": "labels", "resource_field_ref": null}]}, "empty_dir": null, "ephemeral": null, "fc": null, "flex_volume": null, "flocker": null, "gce_persistent_disk": null, "git_repo": null, "glusterfs": null, "host_path": null, "iscsi": null, "name": "podinfo", "nfs": null, "persistent_volume_claim": null, "photon_persistent_disk": null, "portworx_volume": null, "projected": null, "quobyte": null, "rbd": null, "scale_io": null, "secret": null, "storageos": null, "vsphere_volume": null}, {"aws_elastic_block_store": null, "azure_disk": null, "azure_file": null, "cephfs": null, "cinder": null, "config_map": {"default_mode": null, "items": null, "name": "task-aa423895-42c2-417e-b080-2287f667f856", "optional": null}, "csi": null, "downward_api": null, "empty_dir": null, "ephemeral": null, "fc": null, "flex_volume": null, "flocker": null, "gce_persistent_disk": null, "git_repo": null, "glusterfs": null, "host_path": null, "iscsi": null, "name": "jsoninput", "nfs": null, "persistent_volume_claim": null, "photon_persistent_disk": null, "portworx_volume": null, "projected": null, "quobyte": null, "rbd": null, "scale_io": null, "secret": null, "storageos": null, "vsphere_volume": null}]}}, "ttl_seconds_after_finished": null}, "status": null}

tesk/api/ga4gh/tes/task/create_task.py

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def create_task(self) -> TesCreateTaskResponse:
3636
try:
3737
attempts_no += 1
3838
resources = self.task.resources
39-
39+
limits = self.kubernetes_client_wrapper.list_limits()
40+
print("limits", limits)
4041
minimum_ram_gb = self.kubernetes_client_wrapper.minimum_ram_gb()
4142

4243
if not self.task.resources:
@@ -49,22 +50,65 @@ def create_task(self) -> TesCreateTaskResponse:
4950
# self.user
5051
)
5152

52-
print(taskmaster_job)
5353
taskmaster_config_map = (
5454
self.tes_kubernetes_converter.from_tes_task_to_k8s_config_map(
5555
self.task,
5656
taskmaster_job,
5757
# self.user
5858
)
5959
)
60-
print(taskmaster_config_map)
61-
62-
# Create ConfigMap and Job
63-
_ = self.kubernetes_client_wrapper.create_config_map(
64-
taskmaster_config_map
65-
)
66-
created_job = self.kubernetes_client_wrapper.create_job(taskmaster_job)
67-
60+
# print("*********************************")
61+
# print(
62+
# f"Manifest consumed to create taskmaster job as {type(taskmaster_job)}"
63+
# )
64+
# print(taskmaster_config_map)
65+
# print("*********************************")
66+
67+
# print("*********************************")
68+
# print(
69+
# f"Manifest consumed to create config map as {type(taskmaster_config_map)}"
70+
# )
71+
# print(taskmaster_config_map)
72+
# print("*********************************")
73+
74+
# # Create ConfigMap and Job
75+
# configmap = self.kubernetes_client_wrapper.create_config_map(
76+
# taskmaster_config_map
77+
# )
78+
# print("********************")
79+
# print(f"Created ConfigMap as {type(configmap)}")
80+
# print(configmap)
81+
# print("********************")
82+
# created_job = self.kubernetes_client_wrapper.create_job(taskmaster_job)
83+
84+
# print("********************")
85+
# print(f"Created taskmaster job as {type(created_job)}")
86+
# print(created_job)
87+
# print("********************")
88+
# Open a file to write the output
89+
with open("output.log", "w") as f:
90+
f.write("*********************************\n")
91+
f.write(f"Manifest consumed to create taskmaster job as {type(taskmaster_job)}\n")
92+
f.write(str(taskmaster_job) + "\n")
93+
f.write("*********************************\n")
94+
95+
f.write("*********************************\n")
96+
f.write(f"Manifest consumed to create config map as {type(taskmaster_config_map)}\n")
97+
f.write(str(taskmaster_config_map) + "\n")
98+
f.write("*********************************\n")
99+
100+
# Create ConfigMap and Job
101+
configmap = self.kubernetes_client_wrapper.create_config_map(taskmaster_config_map)
102+
f.write("********************\n")
103+
f.write(f"Created ConfigMap as {type(configmap)}\n")
104+
f.write(str(configmap) + "\n")
105+
f.write("********************\n")
106+
107+
created_job = self.kubernetes_client_wrapper.create_job(taskmaster_job)
108+
f.write("********************\n")
109+
f.write(f"Created taskmaster job as {type(created_job)}\n")
110+
f.write(str(created_job) + "\n")
111+
f.write("********************\n")
68112
assert created_job.metadata is not None
69113
assert created_job.metadata.name is not None
70114

tesk/api/kubernetes/convert/converter.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,8 @@ def from_tes_task_to_k8s_config_map(
146146
taskmaster_config_map.metadata is not None
147147
), "Taskmaster metadata is should have already been set!"
148148

149-
if taskmaster_config_map.metadata.labels is None:
150-
taskmaster_config_map.metadata.labels = {}
151149

152-
if taskmaster_config_map.metadata.annotations is None:
153-
taskmaster_config_map.metadata.annotations = {}
154-
155-
# FIXME: Figure out what to do if task.name is none.
156-
task_name = task.name or "String"
150+
task_name = task.name
157151

158152
taskmaster_config_map.metadata.annotations[
159153
self.constants.ann_testask_name_key
@@ -185,11 +179,6 @@ def from_tes_task_to_k8s_config_map(
185179
for idx, executor in enumerate(task.executors)
186180
]
187181

188-
print("nice")
189-
print(task)
190-
print(task.volumes)
191-
print("nice")
192-
193182
taskmaster_input: dict[str, Any] = {
194183
"inputs": pydantic_model_list_dict(task.inputs) if task.inputs else [],
195184
"outputs": pydantic_model_list_dict(task.outputs) if task.outputs else [],
@@ -200,16 +189,13 @@ def from_tes_task_to_k8s_config_map(
200189
else 10.0
201190
},
202191
}
203-
print(taskmaster_input)
204192
taskmaster_input[self.constants.taskmaster_input_exec_key] = [
205193
exec_job.to_dict() for exec_job in executors_as_jobs
206194
]
207195

208-
print(taskmaster_input)
209196
taskmaster_input_as_json = json.loads(
210197
json.dumps(taskmaster_input, default=decimal_to_float)
211198
)
212-
print(taskmaster_input_as_json)
213199

214200
try:
215201
with BytesIO() as obj:
@@ -246,9 +232,13 @@ def from_tes_executor_to_k8s_job( # noqa: PLR0913
246232
executor_job: V1Job = (
247233
self.template_supplier.get_executor_template_with_value_from_config()
248234
)
235+
print("Before processing")
236+
print(executor_job)
249237

250238
# Set executors name based on taskmaster's job name
251-
Job(executor_job).change_job_name(Task(taskmaster_name=generated_task_id).get_executor_name(executor_index))
239+
Job(executor_job).change_job_name(
240+
Task(taskmaster_name=generated_task_id).get_executor_name(executor_index)
241+
)
252242

253243
if executor_job.metadata is None:
254244
executor_job.metadata = V1ObjectMeta()
@@ -304,6 +294,9 @@ def from_tes_executor_to_k8s_job( # noqa: PLR0913
304294

305295
assert container.resources.requests is not None
306296

297+
# container.restart_policy = "Never"
298+
print(container)
299+
307300
if resources.cpu_cores:
308301
container.resources.requests["cpu"] = parse_quantity(
309302
str(resources.cpu_cores)
@@ -314,14 +307,20 @@ def from_tes_executor_to_k8s_job( # noqa: PLR0913
314307
f"{resources.ram_gb:.6f}Gi"
315308
)
316309

317-
# # Workaround
318-
# # Check if volumes is None and set it to an empty list if it is
319-
# if (
320-
# executor_job.spec
321-
# and executor_job.spec.spec
322-
# and executor_job.spec.spec.volumes is None
323-
# ):
324-
# executor_job.spec.spec.volumes = []
310+
executor_job.spec.template.spec.containers[
311+
0
312+
].resources.limits = executor_job.spec.template.spec.containers[
313+
0
314+
].resources.requests
315+
316+
# # Workaround
317+
# # Check if volumes is None and set it to an empty list if it is
318+
# if (
319+
# executor_job.spec
320+
# and executor_job.spec.spec
321+
# and executor_job.spec.spec.volumes is None
322+
# ):
323+
# executor_job.spec.spec.volumes = []
325324

326325
return executor_job
327326

tesk/api/kubernetes/convert/executor_command_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ def get_commands_with_stream_redirects(self) -> List[str]:
5151

5252
result.append(" ".join(command_parts))
5353

54-
return result
54+
return result

tesk/api/kubernetes/convert/template.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,6 @@ def get_executor_template_with_value_from_config(self) -> V1Job:
197197
)
198198
]
199199

200+
job.spec.template.spec.containers[0].restart_policy = "Never"
201+
200202
return job

0 commit comments

Comments
 (0)