Skip to content

Commit

Permalink
updates for TES v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstruck committed Nov 17, 2017
1 parent bbdd4aa commit b52f319
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ install:
- python setup.py install

before_script:
- wget https://github.com/ohsu-comp-bio/funnel/releases/download/0.3.0/funnel-linux-amd64-0.3.0.tar.gz -O /opt/funnel.tar.gz
- wget -O /opt/funnel.tar.gz https://github.com/ohsu-comp-bio/funnel/releases/download/0.4.1/funnel-linux-amd64-0.4.1.tar.gz
- tar -zxvf /opt/funnel.tar.gz -C /opt
- export PATH=$PATH:/opt
- docker pull python:2.7
Expand Down
3 changes: 2 additions & 1 deletion tesseract/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def running(self):

def done(self):
r = self.__client.get_task(self.__id, "MINIMAL")
return r.state in ["COMPLETE", "ERROR", "SYSTEM_ERROR", "CANCELED"]
return r.state in ["COMPLETE", "EXECUTOR_ERROR", "SYSTEM_ERROR",
"CANCELED"]

def cancel(self):
self.__result.cancel()
Expand Down
22 changes: 11 additions & 11 deletions tesseract/tesseract.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class Tesseract(object):
)
timeout = attrib(default=30, validator=instance_of(int))
input_files = attrib(
default=Factory(list), validator=tes.models.list_of(tes.TaskParameter)
default=Factory(list), validator=tes.models.list_of(tes.Input)
)
output_files = attrib(
default=Factory(list), validator=tes.models.list_of(tes.TaskParameter)
default=Factory(list), validator=tes.models.list_of(tes.Output)
)
cpu_cores = attrib(default=None, validator=optional(instance_of(int)))
ram_gb = attrib(
Expand Down Expand Up @@ -155,7 +155,7 @@ def with_input(self, url, path):
)

self.input_files.append(
tes.TaskParameter(
tes.Input(
path=os.path.join("/tmp/tesseract", re.sub("^./", "", path)),
url=url,
type="FILE"
Expand All @@ -178,7 +178,7 @@ def with_output(self, path):

run_id = self.__get_id()
self.output_files.append(
tes.TaskParameter(
tes.Output(
path=os.path.join("/tmp/tesseract", re.sub("^./", "", path)),
url=self.file_store.generate_url(
os.path.join(run_id, re.sub("^./|^/", "", path))
Expand Down Expand Up @@ -249,21 +249,21 @@ def _create_task_msg(self, input_cp_url, output_cp_url):
task = tes.Task(
name="tesseract remote execution",
inputs=self.input_files + [
tes.TaskParameter(
tes.Input(
name="pickled function",
url=input_cp_url,
path="/tmp/tesseract/func.pickle",
type="FILE"
),
tes.TaskParameter(
tes.Input(
name="tesseract runner script",
path="/tmp/tesseract/tesseract.py",
type="FILE",
contents=str(runner)
content=str(runner)
)
],
outputs=self.output_files + [
tes.TaskParameter(
tes.Output(
name="pickled result",
url=output_cp_url,
path="/tmp/tesseract/result.pickle",
Expand All @@ -273,12 +273,12 @@ def _create_task_msg(self, input_cp_url, output_cp_url):
resources=tes.Resources(
cpu_cores=self.cpu_cores,
ram_gb=self.ram_gb,
size_gb=self.disk_gb
disk_gb=self.disk_gb
),
executors=[
tes.Executor(
image_name=self.docker,
cmd=["sh", "-c", cmd],
image=self.docker,
command=["sh", "-c", cmd],
stdout="/tmp/tesseract/stdout",
stderr="/tmp/tesseract/stderr",
workdir="/tmp/tesseract"
Expand Down
14 changes: 8 additions & 6 deletions tests/test_tesseract.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ def test_with_input(self):
r.with_input("file:///tmp/input", "/mnt/input")
r.with_input("file:///tmp/input2", "./input2")
expected = [
tes.TaskParameter(
tes.Input(
url="file:///tmp/input",
path="/mnt/input"
path="/mnt/input",
type="FILE"
),
tes.TaskParameter(
tes.Input(
url="file:///tmp/input2",
path="/tmp/tesseract/input2"
path="/tmp/tesseract/input2",
type="FILE"
)
]
print("ACTUAL", r.input_files)
Expand All @@ -93,12 +95,12 @@ def test_with_output(self):
r.with_output("./output.txt")
r.with_output("/mnt/output.txt")
expected = [
tes.TaskParameter(
tes.Output(
path="/tmp/tesseract/output.txt",
url=r.file_store.generate_url("testid/output.txt"),
type="FILE"
),
tes.TaskParameter(
tes.Output(
path="/mnt/output.txt",
url=r.file_store.generate_url("testid/mnt/output.txt"),
type="FILE"
Expand Down

0 comments on commit b52f319

Please sign in to comment.