| 1 | import tempfile |
| 2 | |
| 3 | from pbcommand.models.legacy import Pipeline |
| 4 | from pbcommand.pb_io.common import load_pipeline_interface_from |
| 5 | |
| 6 | |
| 7 | class TestLegacyModels: |
| 8 | |
| 9 | def test_load_pipeline_from_json(self): |
| 10 | pipeline_json = """ |
| 11 | { |
| 12 | "_comment": "Automatically generated by pbcromwell.wdl2json", |
| 13 | "description": "Cromwell workflow dev_diagnostic_subreads", |
| 14 | "entryPoints": [ |
| 15 | { |
| 16 | "entryId": "eid_subread", |
| 17 | "fileTypeId": "PacBio.DataSet.SubreadSet", |
| 18 | "name": "Entry eid_subread", |
| 19 | "optional": false |
| 20 | }, |
| 21 | { |
| 22 | "entryId": "eid_ref_dataset", |
| 23 | "fileTypeId": "PacBio.DataSet.ReferenceSet", |
| 24 | "name": "Entry eid_ref_dataset", |
| 25 | "optional": true |
| 26 | } |
| 27 | ], |
| 28 | "id": "cromwell.workflows.dev_diagnostic_subreads", |
| 29 | "name": "SubreadSet Diagnostics Workflow", |
| 30 | "options": [], |
| 31 | "schemaVersion": "2.0.0", |
| 32 | "tags": [ |
| 33 | "dev", |
| 34 | "cromwell" |
| 35 | ], |
| 36 | "taskOptions": [ |
| 37 | { |
| 38 | "default": 0, |
| 39 | "description": "Cromwell workflow option exit_code", |
| 40 | "id": "exit_code", |
| 41 | "name": "Exit code", |
| 42 | "optionTypeId": "integer" |
| 43 | }, |
| 44 | { |
| 45 | "default": false, |
| 46 | "description": "Cromwell workflow option emit_warn_alarm", |
| 47 | "id": "emit_warn_alarm", |
| 48 | "name": "Emit warn alarm", |
| 49 | "optionTypeId": "boolean" |
| 50 | }, |
| 51 | { |
| 52 | "default": false, |
| 53 | "description": "Cromwell workflow option emit_error_alarm", |
| 54 | "id": "emit_error_alarm", |
| 55 | "name": "Emit error alarm", |
| 56 | "optionTypeId": "boolean" |
| 57 | } |
| 58 | ], |
| 59 | "version": "0.5.0" |
| 60 | }""" |
| 61 | json_file = tempfile.NamedTemporaryFile(suffix=".json").name |
| 62 | with open(json_file, "w") as json_out: |
| 63 | json_out.write(pipeline_json) |
| 64 | p = load_pipeline_interface_from(json_file) |
| 65 | assert p.pipeline_id == "cromwell.workflows.dev_diagnostic_subreads" |
| 66 | s = p.summary() |