Commit 04e642eb authored by aknecht2's avatar aknecht2
Browse files

Heavily updated workflow_job parsing & validation. Addeded several tests to...

Heavily updated workflow_job parsing & validation.  Addeded several tests to confirm the validity of new parsing.  additional_inputs no longer exist, and input / output files are defined as dicts instead of lists.  References refer directly to the dict key names instead of a list index.
parent d21332b1
......@@ -142,27 +142,27 @@ argument_types = {
# Defines information about arguments
argument_keys = {
"required": ["type", "changeable", "has_value"],
"optional": ["required", "default", "file_type", "path"]
"required": ["type", "changeable", "has_value", "required"],
"optional": ["default", "path"]
}
# workflow_job keys
job_keys = {
"required": ["inputs", "additional_inputs", "outputs", "command", "arguments"] + resources.keys(),
"required": ["inputs", "outputs", "command", "arguments"] + resources.keys(),
"optional": []
}
job_inout_keys = {
"required": ["type"],
"optional": ["file_type"]
}
# param keys
param_keys = {
"required": [],
"optional": ["arguments"] + resources.keys()
}
file_list_keys = {
"required": ["name", "type"],
"optional": ["file_type"]
}
# workflow order
workflow = ["align", "remove_duplicates", "peak_calling"]
......
download_from_encode:
inputs:
url:
type: string
md5:
type: string
outputs:
downloaded_file:
type: file
file_type: any
command: chip-job-download-encode
arguments:
- "-u":
type: string
changeable: false
not_a_real_key: batman
default: $url
- "-m":
type: string
changeable: false
required: true
has_value: true
default: $md5
- "-p":
type: file
changeable: false
required: true
has_value: true
default: $downloaded_file
walltime: 60
memory: 2000
cores: 1
nodes: 1
download_from_encode:
inputs:
url:
type: string
md5:
type: string
outputs:
downloaded_file:
type: file
file_type: any
command: chip-job-download-encode
arguments:
- "-u":
type: string
changeable: false
required: true
has_value: true
default: $this_arg
- "-m":
type: string
changeable: false
required: true
has_value: true
default: $doesnt_exist
- "-p":
type: file
changeable: false
required: true
has_value: true
default: $not_a_file
walltime: 60
memory: 2000
cores: 1
nodes: 1
download_from_encode:
inputs:
url:
type: string
md5:
type: string
outputs:
downloaded_file:
type: file
file_type: any
command: chip-job-download-encode
arguments:
- "-u":
type: string
changeable: false
required: true
has_value: true
default: $url
- "-m":
type: string
changeable: false
required: true
has_value: true
default: $md5
- "-p":
type: file
changeable: false
required: true
has_value: true
default: $downloaded_file
walltime: "enough"
memory: "all-the-memory"
cores:
- boy
- howdy
nodes: 1
download_from_encode:
inputs:
url:
type: string
md5:
type: string
outputs:
downloaded_file:
type: file
file_type: any
command: chip-job-download-encode
arguments:
- "-u":
type: string
changeable: false
required: true
has_value: true
default: $url
- "-m":
type: string
changeable: false
required: true
has_value: true
default: $md5
- "-p":
type: file
changeable: false
required: true
has_value: true
default: $downloaded_file
walltime: 60
memory: 2000
cores: 1
nodes: 1
download_from_encode:
not_a_real_key:
url:
type: string
md5:
type: string
outputs:
downloaded_file:
type: file
file_type: any
command: chip-job-download-encode
arguments:
- "-u":
type: string
changeable: false
required: true
has_value: true
default: $url
- "-m":
type: string
changeable: false
required: true
has_value: true
default: $md5
- "-p":
type: file
changeable: false
required: true
has_value: true
default: $downloaded_file
walltime: 60
memory: 2000
cores: 1
nodes: 1
download_from_encode:
inputs:
url:
type: string
md5:
type: string
outputs:
downloaded_file:
type: file
file_type: any
command: chip-job-download-encode
arguments:
- "-u":
type: string
changeable: false
required: true
has_value: true
default: $url
- "-m":
type: string
changeable: false
required: true
has_value: true
default: $md5
- "-p":
type: file
changeable: false
required: true
has_value: true
default: $downloaded_file
walltime: 60
nodes: 1
download_from_encode:
inputs:
url:
type: string
md5:
type: string
outputs:
downloaded_file:
type: file
command: chip-job-download-encode
arguments:
- "-u":
type: string
changeable: false
required: true
has_value: true
default: $url
- "-m":
type: string
changeable: false
required: true
has_value: true
default: $md5
- "-p":
type: file
changeable: false
required: true
has_value: true
default: $downloaded_file
walltime: 60
memory: 2000
cores: 1
nodes: 1
import unittest
from chipathlon.workflow_job import WorkflowJob
import yaml
import os
class WorkflowJobTests(unittest.TestCase):
def setUp(self):
self.base_path = os.path.dirname(os.path.abspath(__file__))
return
def test_invalid_base(self):
job = WorkflowJob(
"%s/workflow_job/invalid_base.yaml" % (self.base_path,),
{},
debug=True
)
self.assertFalse(job.is_valid(), msg=job.get_error_string())
return
def test_no_file_type(self):
job = WorkflowJob(
"%s/workflow_job/no_file_type.yaml" % (self.base_path,),
{},
debug=True
)
self.assertFalse(job.is_valid(), msg=job.get_error_string())
return
def test_missing_resources(self):
job = WorkflowJob(
"%s/workflow_job/missing_resources.yaml" % (self.base_path,),
{},
debug=True
)
self.assertFalse(job.is_valid(), msg=job.get_error_string())
return
def test_bad_resources(self):
job = WorkflowJob(
"%s/workflow_job/bad_resources.yaml" % (self.base_path,),
{},
debug=True
)
self.assertFalse(job.is_valid(), msg=job.get_error_string())
return
def test_bad_arguments(self):
job = WorkflowJob(
"%s/workflow_job/bad_arguments.yaml" % (self.base_path,),
{},
debug=True
)
self.assertFalse(job.is_valid(), msg=job.get_error_string())
return
def test_bad_references(self):
job = WorkflowJob(
"%s/workflow_job/bad_references.yaml" % (self.base_path,),
{},
debug=True
)
self.assertFalse(job.is_valid(), msg=job.get_error_string())
return
def test_valid_job(self):
job = WorkflowJob(
"%s/workflow_job/download_from_encode.yaml" % (self.base_path,),
{},
debug=True
)
self.assertTrue(job.is_valid(), msg=job.get_error_string())
return
if __name__ == "__main__":
unittest.TextTestRunner(verbosity=2).run(
unittest.TestLoader().loadTestsFromTestCase(WorkflowJobTests)
)
......@@ -7,13 +7,14 @@ from test.insert_tests import InsertResultsTests
from test.existance_tests import SampleExistanceTests
from test.parser_tests import RunParserTests
from test.genome_tests import GenomeTests
from test.workflow_job_tests import WorkflowJobTests
# Load all test suites
suites = [
#unittest.TestLoader().loadTestsFromTestCase(InsertResultsTests)
unittest.TestLoader().loadTestsFromTestCase(SampleExistanceTests),
unittest.TestLoader().loadTestsFromTestCase(RunParserTests),
unittest.TestLoader().loadTestsFromTestCase(GenomeTests)
unittest.TestLoader().loadTestsFromTestCase(GenomeTests),
unittest.TestLoader().loadTestsFromTestCase(WorkflowJobTests)
]
# Run all tests
......
......@@ -70,7 +70,7 @@ def is_number(s):
try:
float(s)
return True
except ValueError:
except (TypeError, ValueError):
pass
try:
import unicodedata
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment