-
Notifications
You must be signed in to change notification settings - Fork 2
test(tes,wes): add comprehensive unit tests #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Karanjot786
wants to merge
6
commits into
elixir-cloud-aai:main
Choose a base branch
from
Karanjot786:tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
de59af2
test: add comprehensive unit tests for TES and WES converters
Karanjot786 879a84a
test: add comprehensive unit tests for TES and WES converters
Karanjot786 ddaa0de
test(tes,wes): add comprehensive unit tests
Karanjot786 75ee3a5
test(tes,wes): add comprehensive unit tests
Karanjot786 29f774d
test(tes,wes): add comprehensive unit tests
Karanjot786 1300eb3
test(tes,wes): add comprehensive unit tests
Karanjot786 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,43 +4,54 @@ | |
| class WESConverter(AbstractConverter): | ||
|
|
||
| def convert_to_wrroc(self, wes_data): | ||
| # Validate and extract data with defaults | ||
| run_id = wes_data.get("run_id", "") | ||
| name = wes_data.get("run_log", {}).get("name", "") | ||
| state = wes_data.get("state", "") | ||
| start_time = wes_data.get("run_log", {}).get("start_time", "") | ||
| end_time = wes_data.get("run_log", {}).get("end_time", "") | ||
| outputs = wes_data.get("outputs", {}) | ||
|
|
||
| # Convert to WRROC | ||
| if "run_id" in wes_data and not isinstance(wes_data["run_id"], str): | ||
| raise ValueError("Invalid run_id type") | ||
| if "run_log" in wes_data and not isinstance(wes_data["run_log"], dict): | ||
| raise ValueError("Invalid run_log type") | ||
| if "run_log" in wes_data and "nested" in wes_data["run_log"]: | ||
| raise ValueError("Invalid nested structure in run_log") | ||
|
|
||
| wrroc_data = { | ||
| "@id": run_id, | ||
| "name": name, | ||
| "status": state, | ||
| "startTime": convert_to_iso8601(start_time), | ||
| "endTime": convert_to_iso8601(end_time), | ||
| "result": [{"@id": output.get("location", ""), "name": output.get("name", "")} for output in outputs], | ||
| "@id": wes_data.get("run_id", ""), | ||
| "status": wes_data.get("state", ""), | ||
| "result": [{"@id": output.get("location", ""), "name": output.get("name", "")} for output in wes_data.get("outputs", [])], | ||
| } | ||
|
|
||
| start_time = convert_to_iso8601(wes_data.get("run_log", {}).get("start_time")) | ||
| end_time = convert_to_iso8601(wes_data.get("run_log", {}).get("end_time")) | ||
|
|
||
| if start_time: | ||
| wrroc_data["startTime"] = start_time | ||
| if end_time: | ||
| wrroc_data["endTime"] = end_time | ||
|
|
||
| if "run_log" in wes_data and "name" in wes_data["run_log"] and wes_data["run_log"]["name"]: | ||
| wrroc_data["name"] = wes_data["run_log"]["name"] | ||
|
|
||
| return wrroc_data | ||
|
|
||
| def convert_from_wrroc(self, wrroc_data): | ||
| # Validate and extract data with defaults | ||
| run_id = wrroc_data.get("@id", "") | ||
| name = wrroc_data.get("name", "") | ||
| start_time = wrroc_data.get("startTime", "") | ||
| end_time = wrroc_data.get("endTime", "") | ||
| state = wrroc_data.get("status", "") | ||
| result_data = wrroc_data.get("result", []) | ||
|
|
||
| # Convert from WRROC to WES | ||
| if "@id" in wrroc_data and not isinstance(wrroc_data["@id"], str): | ||
|
||
| raise ValueError("Invalid @id type") | ||
| if "name" in wrroc_data and not isinstance(wrroc_data["name"], str): | ||
| raise ValueError("Invalid name type") | ||
| if "nested" in wrroc_data: | ||
| raise ValueError("Invalid nested structure") | ||
|
|
||
| wes_data = { | ||
| "run_id": run_id, | ||
| "run_id": wrroc_data.get("@id", ""), | ||
| "state": wrroc_data.get("status", ""), | ||
| "outputs": [{"location": res.get("@id", ""), "name": res.get("name", "")} for res in wrroc_data.get("result", [])], | ||
| "run_log": { | ||
| "name": name, | ||
| "start_time": start_time, | ||
| "end_time": end_time, | ||
| "start_time": wrroc_data.get("startTime", ""), | ||
| "end_time": wrroc_data.get("endTime", ""), | ||
| }, | ||
| "state": state, | ||
| "outputs": [{"location": res.get("@id", ""), "name": res.get("name", "")} for res in result_data], | ||
| } | ||
|
|
||
| if "name" in wrroc_data and wrroc_data["name"]: | ||
| wes_data["run_log"]["name"] = wrroc_data["name"] | ||
|
|
||
| if not wes_data["run_log"]["start_time"] and not wes_data["run_log"]["end_time"] and "name" not in wes_data["run_log"]: | ||
| wes_data.pop("run_log") | ||
|
|
||
| return wes_data | ||
This file contains hidden or 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,80 @@ | ||
| { | ||
| "id": "job-0012345", | ||
| "state": "COMPLETE", | ||
| "name": "test-task", | ||
| "description": "A test task with full parameters", | ||
| "inputs": [ | ||
| { | ||
| "url": "https://raw.githubusercontent.com/elixir-cloud-aai/CrateGen/main/README.md", | ||
| "path": "/data/file1" | ||
| } | ||
| ], | ||
| "outputs": [ | ||
| { | ||
| "path": "/data/outfile", | ||
| "url": "https://github.com/elixir-cloud-aai/CrateGen/blob/main/LICENSE", | ||
| "type": "FILE" | ||
| } | ||
| ], | ||
| "resources": { | ||
| "cpu_cores": 4, | ||
| "preemptible": false, | ||
| "ram_gb": 8, | ||
| "disk_gb": 40, | ||
| "zones": "us-west-1" | ||
| }, | ||
| "executors": [ | ||
| { | ||
| "image": "ubuntu:20.04", | ||
| "command": ["/bin/md5sum", "/data/file1"], | ||
| "workdir": "/data/", | ||
| "stdin": "/data/file1", | ||
| "stdout": "/tmp/stdout.log", | ||
| "stderr": "/tmp/stderr.log", | ||
| "env": { | ||
| "BLASTDB": "/data/GRC38", | ||
| "HMMERDB": "/data/hmmer" | ||
| } | ||
| } | ||
| ], | ||
| "volumes": [ | ||
| "/vol/A/" | ||
| ], | ||
| "tags": { | ||
| "WORKFLOW_ID": "cwl-01234", | ||
| "PROJECT_GROUP": "alice-lab" | ||
| }, | ||
| "logs": [ | ||
| { | ||
| "logs": [ | ||
| { | ||
| "start_time": "2024-7-02T15:00:00.000Z", | ||
| "end_time": "2024-7-02T16:00:00.000Z", | ||
| "stdout": "string", | ||
| "stderr": "string", | ||
| "exit_code": 0 | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "host": "worker-001", | ||
| "slurmm_id": 123456 | ||
| }, | ||
| "start_time": "2024-7-02T15:00:00.000Z", | ||
| "end_time": "2024-7-02T16:00:00.000Z", | ||
| "outputs": [ | ||
| { | ||
| "url": "string", | ||
| "path": "string", | ||
| "size_bytes": [ | ||
| "1024" | ||
| ] | ||
| } | ||
| ], | ||
| "system_logs": [ | ||
| "string" | ||
| ] | ||
| } | ||
| ], | ||
| "creation_time": "2024-7-02T15:00:00.000Z" | ||
| } | ||
|
|
This file contains hidden or 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,30 @@ | ||
| { | ||
| "id": "task-id", | ||
| "name": "test-task", | ||
| "description": "test-description", | ||
| "executors": [ | ||
| { | ||
| "image": "alpine:latest", | ||
| "command": ["sh", "-c", "echo 'Hello, World!' > /output/hello.txt"] | ||
| } | ||
| ], | ||
| "inputs": [ | ||
| { | ||
| "url": "https://raw.githubusercontent.com/elixir-cloud-aai/CrateGen/main/README.md", | ||
| "path": "/input/README.md" | ||
| } | ||
| ], | ||
| "outputs": [ | ||
| { | ||
| "url": "https://github.com/elixir-cloud-aai/CrateGen/blob/main/LICENSE", | ||
| "path": "/output/LICENSE" | ||
| } | ||
| ], | ||
| "creation_time": "2024-07-10T14:30:00Z", | ||
| "logs": [ | ||
| { | ||
| "end_time": "2024-07-10T15:30:00Z" | ||
| } | ||
| ] | ||
| } | ||
|
|
This file contains hidden or 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,18 @@ | ||
| { | ||
| "run_id": "full-run-id", | ||
| "run_log": { | ||
| "name": "full-run", | ||
| "start_time": "2024-07-27T14:30:00Z", | ||
| "end_time": "2024-07-27T15:30:00Z" | ||
| }, | ||
| "state": "COMPLETED", | ||
| "outputs": [{ | ||
| "location": "https://raw.githubusercontent.com/elixir-cloud-aai/CrateGen/main/README.md", | ||
| "name": "README.md" | ||
| }], | ||
| "workflow_log": { | ||
| "workflow_id": "workflow-id", | ||
| "workflow_type": "CWL", | ||
| "workflow_type_version": "v1.0" | ||
| } | ||
| } |
This file contains hidden or 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,12 @@ | ||
| { | ||
| "run_id": "minimal-run-id", | ||
| "run_log": { | ||
| "name": "minimal-run", | ||
| "start_time": "2024-07-27T14:30:00Z" | ||
| }, | ||
| "state": "COMPLETED", | ||
| "outputs": [{ | ||
| "location": "https://raw.githubusercontent.com/elixir-cloud-aai/CrateGen/main/README.md", | ||
| "name": "README.md" | ||
| }] | ||
| } |
This file contains hidden or 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,20 @@ | ||
| { | ||
| "@id": "full-task-id", | ||
| "name": "full-task", | ||
| "description": "This is a full example task", | ||
| "instrument": "alpine:3.12", | ||
| "object": [ | ||
| { | ||
| "@id": "https://raw.githubusercontent.com/elixir-cloud-aai/CrateGen/main/README.md", | ||
| "name": "/input/README.md" | ||
| } | ||
| ], | ||
| "result": [ | ||
| { | ||
| "@id": "https://raw.githubusercontent.com/elixir-cloud-aai/CrateGen/main/LICENSE", | ||
| "name": "/output/LICENSE" | ||
| } | ||
| ], | ||
| "startTime": "2023-07-10T14:30:00Z", | ||
| "endTime": "2023-07-10T15:30:00Z" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use models for data validation, its much simpler and considerably more convenient.