-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from EMBL-EBI-TSI/testing
Merge testing into master for 0.2 release
- Loading branch information
Showing
9 changed files
with
437 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.swp | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
steps: | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: ['build', '-t', 'eu.gcr.io/tes-wes/taskmaster:testing', '-f', 'dockerfiles/taskmaster/Dockerfile', '.'] | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: ['build', '-t', 'eu.gcr.io/tes-wes/filer:testing', '-f', 'dockerfiles/filer/Dockerfile', '.'] | ||
images: ['eu.gcr.io/tes-wes/taskmaster:testing', 'eu.gcr.io/tes-wes/filer:testing'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{ | ||
"outputs": [ | ||
{ | ||
"url": "ftp://ftp-private.ebi.ac.uk/upload/mouselist.txt", | ||
"path": "/tmp/vol1/mouselist.txt", | ||
"type": "FILE" | ||
}, | ||
{ | ||
"url": "ftp://ftp-private.ebi.ac.uk/upload/mouse_out", | ||
"path": "/tmp/vol2/mouse", | ||
"type": "DIRECTORY" | ||
} | ||
], | ||
"inputs": [ | ||
{ | ||
"url": "ftp://ftp-private.ebi.ac.uk/upload/input.txt", | ||
"path": "/tmp/vol1/in.txt", | ||
"type": "FILE" | ||
}, | ||
{ | ||
"url": "ftp://ftp-private.ebi.ac.uk/upload/mouse", | ||
"path": "/tmp/vol2/mouse", | ||
"type": "DIRECTORY" | ||
} | ||
], | ||
"volumes": [ | ||
"/tmp/vol1", | ||
"/tmp/vol2" | ||
], | ||
"executors": [ | ||
{ | ||
"apiVersion": "batch/v1", | ||
"kind": "Job", | ||
"metadata": { | ||
"annotations": { | ||
"tes-task-name": "Hello Input" | ||
}, | ||
"labels": { | ||
"job-type": "executor", | ||
"taskmaster-name": "task-7d5c53f4", | ||
"executor-no": "0" | ||
}, | ||
"name": "task-7d5c53f4-ex-00" | ||
}, | ||
"spec": { | ||
"template": { | ||
"metadata": { | ||
"name": "task-7d5c53f4-ex-00" | ||
}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"command": [ | ||
"cat", | ||
"/tmp/vol1/in.txt" | ||
], | ||
"image": "alpine", | ||
"name": "task-7d5c53f4-ex-00", | ||
"resources": {} | ||
} | ||
], | ||
"restartPolicy": "Never" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"apiVersion": "batch/v1", | ||
"kind": "Job", | ||
"metadata": { | ||
"annotations": { | ||
"tes-task-name": "Hello Input" | ||
}, | ||
"labels": { | ||
"job-type": "executor", | ||
"taskmaster-name": "task-7d5c53f4", | ||
"executor-no": "1" | ||
}, | ||
"name": "task-7d5c53f4-ex-01" | ||
}, | ||
"spec": { | ||
"template": { | ||
"metadata": { | ||
"name": "task-7d5c53f4-ex-01" | ||
}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"command": [ | ||
"sh", "-c", | ||
"find /tmp/vol2 > /tmp/vol1/mouselist.txt" | ||
], | ||
"image": "alpine", | ||
"name": "task-7d5c53f4-ex-01", | ||
"resources": {} | ||
} | ||
], | ||
"restartPolicy": "Never" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"resources": { | ||
"disk_gb": 0.1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import json | ||
|
||
class Filer: | ||
def __init__(self, name, data, filer_version='v0.5', debug=False): | ||
self.name = name | ||
self.spec = { | ||
"kind": "Job", | ||
"apiVersion": "batch/v1", | ||
"metadata": { "name": name }, | ||
"spec": { | ||
"template": { | ||
"metadata": { "name": "tesk-filer" }, | ||
"spec": { | ||
"containers": [ { | ||
"name": "filer", | ||
"image": "eu.gcr.io/tes-wes/filer:"+filer_version, | ||
"args": [], | ||
"env": [], | ||
"volumeMounts": [], | ||
"imagePullPolicy": "IfNotPresent" | ||
} | ||
], | ||
"volumes": [], | ||
"restartPolicy": "Never" | ||
} | ||
} | ||
} | ||
} | ||
|
||
if debug: | ||
self.spec['spec']['template']['spec']['containers'][0]['imagePullPolicy'] = 'Always' | ||
|
||
container = self.spec['spec']['template']['spec']['containers'][0] | ||
container['env'].append({ "name": "JSON_INPUT", "value": json.dumps(data) }) | ||
#container['env'].append({ "name": "JSON_INPUT", "value": 'test' }) | ||
|
||
def set_ftp(self, user, pw): | ||
env = self.spec['spec']['template']['spec']['containers'][0]['env'] | ||
env.append({ "name": "TESK_FTP_USERNAME", "value": user }) | ||
env.append({ "name": "TESK_FTP_PASSWORD", "value": pw }) | ||
|
||
def set_volume_mounts(self, pvc): | ||
tempspec = self.spec['spec']['template']['spec'] | ||
tempspec['containers'][0]['volumeMounts'] = pvc.volume_mounts | ||
tempspec['volumes'] = [ { "name": "task-volume", "persistentVolumeClaim": { "claimName": pvc.name} } ] | ||
|
||
def get_spec(self, mode): | ||
self.spec['spec']['template']['spec']['containers'][0]['args'] = [mode, "$(JSON_INPUT)"] | ||
self.spec['spec']['template']['metadata']['name'] = self.name | ||
return self.spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from kubernetes import client, config | ||
import logging | ||
import time | ||
|
||
class Job: | ||
def __init__(self, body, name='task-job', namespace='default'): | ||
self.name = name | ||
self.namespace = namespace | ||
self.status = 'Initialized' | ||
self.bv1 = client.BatchV1Api() | ||
self.body = body | ||
self.body['metadata']['name'] = self.name | ||
|
||
def run_to_completion(self, poll_interval, check_cancelled): | ||
logging.debug(self.body) | ||
self.bv1.create_namespaced_job(self.namespace, self.body) | ||
status = self.get_status() | ||
while status == 'Running': | ||
if check_cancelled(): | ||
self.delete() | ||
return 'Cancelled' | ||
|
||
time.sleep(poll_interval) | ||
|
||
status = self.get_status() | ||
|
||
return status | ||
|
||
def get_status(self): | ||
job = self.bv1.read_namespaced_job(self.name, self.namespace) | ||
try: | ||
if job.status.conditions[0].type == 'Complete' and job.status.conditions[0].status: | ||
self.status = 'Complete' | ||
elif job.status.conditions[0].type == 'Failed' and job.status.conditions[0].status: | ||
self.status = 'Failed' | ||
else: | ||
self.status = 'Error' | ||
except TypeError: # The condition is not initialized, so it is not complete yet, wait for it | ||
self.status = 'Running' | ||
|
||
return self.status | ||
|
||
def delete(self): | ||
self.bv1.delete_namespaced_job(self.name, self.namespace, client.V1DeleteOptions()) |
Oops, something went wrong.