Exemple #1
0
def test_port_normalization():
    cwl = pack("remote-cwl/wf1.cwl")
    step_s1 = _find(cwl.get("steps"), "id", "s1")
    step_in1 = _find(step_s1.get("in"), "id", "in1")
    assert step_in1["source"] == "in1"

    cwl = pack("wf2.cwl")
    step_s1 = _find(cwl.get("steps"), "id", "s1")
    step_in1 = _find(step_s1.get("in"), "id", "in1")
    assert step_in1["source"] == "in1"

    out1 = _find(cwl.get("outputs"), "id", "out1")
    assert out1.get("outputSource") == "s2/out1"
Exemple #2
0
def test_already_packed_graph():
    """Workflow already packed in a $graph."""
    cwl = pack("workflows/scatter-wf4.cwl")
    assert "inputs" not in cwl
    assert "outputs" not in cwl
    assert "$graph" in cwl
    assert "requirements" not in cwl
Exemple #3
0
def test_step_packing():
    cwl = pack("remote-cwl/wf1.cwl")
    s1 = _find(cwl.get("steps"), "id", "s1")
    tool2 = s1.get("run")
    _type = _find(tool2.get("inputs"), "id", "in1").get("type")
    assert isinstance(_type, dict)
    assert _type.get("type") == "array"
Exemple #4
0
def test_remote_packing():
    cwl = pack("https://raw.githubusercontent.com/kaushik-work/sbpack/master/tests/wf2.cwl")
    s1 = _find(cwl.get("steps"), "id", "s1")
    wf1 = s1.get("run")
    assert wf1.get("class") == "Workflow"

    tool2 = _find(wf1.get("steps"), "id", "s1").get("run")
    _type = _find(tool2.get("inputs"), "id", "in1").get("type")
    assert isinstance(_type, dict)
    assert _type.get("type") == "array"
Exemple #5
0
def test_include():
    cwl = pack("remote-cwl/tool1.cwl")
    assert "arguments" in cwl
    assert isinstance(cwl.get("arguments"), list)

    inline_js_req = _find(cwl.get("requirements"), "class", "InlineJavascriptRequirement")
    include_js = inline_js_req.get("expressionLib")

    assert isinstance(include_js, list)
    assert "engineers walk into a" in include_js[0]
def test_local_packing_with_validation(f):
    url = urllib.parse.urlparse(f)
    packed_name = pathlib.Path(url.path).stem + "-packed.cwl"

    cwl = pack(f)
    fpacked = pathlib.Path(packed_name)
    with fpacked.open("w") as fout:
        fast_yaml.dump(cwl, fout)
    assert cwl_is_valid(fpacked)
    fpacked.unlink()
Exemple #7
0
def py_pack_sb(cwl_path, profile, appid):

    logging.basicConfig()
    logger.setLevel(logging.INFO)

    if not validate_id(appid):
        print("Illegal characters in app id")
        return

    cwl = pack(cwl_path)

    api = get_profile(profile)

    cwl["sbg:revisionNotes"] = f"Uploaded using sbpack-r \nSource: {cwl_path}"
    try:
        app = api.apps.get(appid)
        logger.debug("Creating revised app: {}".format(appid))
        return api.apps.create_revision(id=appid,
                                        raw=cwl,
                                        revision=app.revision + 1)
    except sbgerr.NotFound:
        logger.debug("Creating new app: {}".format(appid))
        return api.apps.install_app(id=appid, raw=cwl)
Exemple #8
0
def test_remote_packing_github_soft_links():
    cwl = pack("https://raw.githubusercontent.com/rabix/sbpack/master/tests/workflows/wf5.cwl")
    s1 = _find(cwl.get("steps"), "id", "s1")
    tool1 = s1.get("run")
    assert tool1.get("class") == "CommandLineTool"
Exemple #9
0
def test_step_process_id():
    """Workflow step with external "run" reference gets an "id" added."""
    cwl = pack("workflows/wf2.cwl", add_ids=True)
    assert cwl["id"] == "wf2.cwl"
    s1 = _find(cwl.get("steps"), "id", "s1")
    assert s1["run"]["id"] == "wf2.cwl@[email protected]"
Exemple #10
0
def test_embedded_packing():
    cwl = pack("workflows/count-lines16-wf.cwl")
Exemple #11
0
def test_schema_def2():
    cwl = pack("wf2.cwl")
    _type = _find(cwl.get("inputs"), "id", "in2").get("type")
    assert isinstance(_type, dict)
    assert _type.get("type") == "enum"
Exemple #12
0
def test_schema_def1():
    cwl = pack("remote-cwl/tool2.cwl")
    _type = _find(cwl.get("inputs"), "id", "in1").get("type")
    assert isinstance(_type, dict)
    assert _type.get("type") == "array"
Exemple #13
0
def test_recursive_type_resolution():
    cwl = pack("tools/clt1.cwl")
    simple_record = _find(cwl.get("inputs"), "id", "in2").get("type")
    assert simple_record.get("type") == "record"
Exemple #14
0
def test_parent_type_resolution():
    cwl = pack("workflows/wf6.cwl")
    _type = cwl.get("steps")[0].get("run").get("inputs")[0].get("type")
    assert _type.get("type") == "record"
Exemple #15
0
def py_pack_file(input, output):
    fast_yaml.dump(pack(input), Path(output))