diff --git a/crategen/cli.py b/crategen/cli.py index 9781cc1..20198fb 100644 --- a/crategen/cli.py +++ b/crategen/cli.py @@ -1,24 +1,30 @@ -import json import click +import json from crategen.converter_manager import ConverterManager @click.command() -@click.option('--input', 'input_file', type=click.Path(exists=True), required=True, help='Path to the input file.') -@click.option('--output', 'output_file', type=click.Path(), required=True, help='Path to the output file.') -@click.option('--conversion-type', 'conversion_type', type=click.Choice(['tes_to_wrroc', 'wes_to_wrroc']), required=True, help='Type of conversion.') -def cli(input_file, output_file, conversion_type): - with open(input_file, 'r') as f: - data = json.load(f) - +@click.option('--input', prompt='Input file', help='Path to the input JSON file.') +@click.option('--output', prompt='Output file', help='Path to the output JSON file.') +@click.option('--conversion-type', prompt='Conversion type', type=click.Choice(['tes-to-wrroc', 'wes-to-wrroc']), help='Type of conversion to perform.') +def cli(input, output, conversion_type): + """ + Command Line Interface for converting TES/WES to WRROC. + """ manager = ConverterManager() - if conversion_type == 'tes_to_wrroc': + # Load input data from JSON file + with open(input, 'r') as input_file: + data = json.load(input_file) + + # Perform the conversion based on the specified type + if conversion_type == 'tes-to-wrroc': result = manager.convert_tes_to_wrroc(data) - elif conversion_type == 'wes_to_wrroc': + elif conversion_type == 'wes-to-wrroc': result = manager.convert_wes_to_wrroc(data) - - with open(output_file, 'w') as f: - json.dump(result, f, indent=2) + + # Save the result to the output JSON file + with open(output, 'w') as output_file: + json.dump(result, output_file, indent=4) if __name__ == '__main__': cli() diff --git a/crategen/converter_manager.py b/crategen/converter_manager.py index 8c4f785..3a0ef6b 100644 --- a/crategen/converter_manager.py +++ b/crategen/converter_manager.py @@ -2,7 +2,6 @@ from .converters.wes_converter import WESConverter class ConverterManager: - def __init__(self): self.tes_converter = TESConverter() self.wes_converter = WESConverter() @@ -12,9 +11,3 @@ def convert_tes_to_wrroc(self, tes_data): def convert_wes_to_wrroc(self, wes_data): return self.wes_converter.convert_to_wrroc(wes_data) - - def convert_wrroc_to_tes(self, wrroc_data): - return self.tes_converter.convert_from_wrroc(wrroc_data) - - def convert_wrroc_to_wes(self, wrroc_data): - return self.wes_converter.convert_from_wrroc(wrroc_data) diff --git a/crategen/converters/tes_converter.py b/crategen/converters/tes_converter.py index 88a11ac..c51105d 100644 --- a/crategen/converters/tes_converter.py +++ b/crategen/converters/tes_converter.py @@ -1,41 +1,52 @@ from .abstract_converter import AbstractConverter -import datetime +from ..utils.formatting import convert_to_iso8601 class TESConverter(AbstractConverter): def convert_to_wrroc(self, tes_data): - # Implement the conversion logic from TES to WRROC + # Validate and extract data with defaults + id = tes_data.get("id", "") + name = tes_data.get("name", "") + description = tes_data.get("description", "") + executors = tes_data.get("executors", [{}]) + inputs = tes_data.get("inputs", []) + outputs = tes_data.get("outputs", []) + creation_time = tes_data.get("creation_time", "") + end_time = tes_data.get("end_time", "") + + # Convert to WRROC wrroc_data = { - "@id": tes_data["id"], - "name": tes_data.get("name", ""), - "description": tes_data.get("description", ""), - "instrument": tes_data["executors"][0]["image"] if tes_data.get("executors") else None, - "object": [{"@id": input.get("url"), "name": input.get("path")} for input in tes_data.get("inputs", [])], - "result": [{"@id": output.get("url"), "name": output.get("path")} for output in tes_data.get("outputs", [])], - "startTime": self.convert_to_iso8601(tes_data.get("creation_time")), - "endTime": self.convert_to_iso8601(tes_data.get("end_time")), + "@id": id, + "name": name, + "description": description, + "instrument": executors[0].get("image", None) if executors else None, + "object": [{"@id": input.get("url", ""), "name": input.get("path", "")} for input in inputs], + "result": [{"@id": output.get("url", ""), "name": output.get("path", "")} for output in outputs], + "startTime": convert_to_iso8601(creation_time), + "endTime": convert_to_iso8601(end_time), } return wrroc_data def convert_from_wrroc(self, wrroc_data): - # Implement the conversion logic from WRROC to TES + # Validate and extract data with defaults + id = wrroc_data.get("@id", "") + name = wrroc_data.get("name", "") + description = wrroc_data.get("description", "") + instrument = wrroc_data.get("instrument", "") + object_data = wrroc_data.get("object", []) + result_data = wrroc_data.get("result", []) + start_time = wrroc_data.get("startTime", "") + end_time = wrroc_data.get("endTime", "") + + # Convert from WRROC to TES tes_data = { - "id": wrroc_data["@id"], - "name": wrroc_data.get("name", ""), - "description": wrroc_data.get("description", ""), - "executors": [{"image": wrroc_data.get("instrument")}], - "inputs": [{"url": obj["@id"], "path": obj["name"]} for obj in wrroc_data.get("object", [])], - "outputs": [{"url": res["@id"], "path": res["name"]} for res in wrroc_data.get("result", [])], - "creation_time": wrroc_data.get("startTime"), - "end_time": wrroc_data.get("endTime"), + "id": id, + "name": name, + "description": description, + "executors": [{"image": instrument}], + "inputs": [{"url": obj.get("@id", ""), "path": obj.get("name", "")} for obj in object_data], + "outputs": [{"url": res.get("@id", ""), "path": res.get("name", "")} for res in result_data], + "creation_time": start_time, + "end_time": end_time, } return tes_data - - def convert_to_iso8601(self, timestamp): - if timestamp: - try: - return datetime.datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ").isoformat() + "Z" - except ValueError: - # Handle incorrect format or other issues - return None - return None diff --git a/crategen/converters/wes_converter.py b/crategen/converters/wes_converter.py index d7bc045..9638fa6 100644 --- a/crategen/converters/wes_converter.py +++ b/crategen/converters/wes_converter.py @@ -1,39 +1,46 @@ from .abstract_converter import AbstractConverter -import datetime +from ..utils.formatting import convert_to_iso8601 class WESConverter(AbstractConverter): def convert_to_wrroc(self, wes_data): - # Implement the conversion logic from WES to WRROC + # 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 wrroc_data = { - "@id": wes_data.get("run_id", ""), - "name": wes_data.get("run_log", {}).get("name", ""), - "status": wes_data.get("state", ""), - "startTime": self.convert_to_iso8601(wes_data.get("run_log", {}).get("start_time")), - "endTime": self.convert_to_iso8601(wes_data.get("run_log", {}).get("end_time")), - "result": [{"@id": output.get("location", ""), "name": output.get("name", "")} for output in wes_data.get("outputs", [])], + "@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], } return wrroc_data def convert_from_wrroc(self, wrroc_data): - # Implement the conversion logic from WRROC to WES + # 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 wes_data = { - "run_id": wrroc_data.get("@id", ""), + "run_id": run_id, "run_log": { - "name": wrroc_data.get("name", ""), - "start_time": wrroc_data.get("startTime", ""), - "end_time": wrroc_data.get("endTime", ""), + "name": name, + "start_time": start_time, + "end_time": end_time, }, - "state": wrroc_data.get("status", ""), - "outputs": [{"location": res.get("@id", ""), "name": res.get("name", "")} for res in wrroc_data.get("result", [])], + "state": state, + "outputs": [{"location": res.get("@id", ""), "name": res.get("name", "")} for res in result_data], } return wes_data - - def convert_to_iso8601(self, timestamp): - if timestamp: - try: - return datetime.datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ").isoformat() + "Z" - except ValueError: - # Handle incorrect format or other issues - return None - return None diff --git a/crategen/utils/formatting.py b/crategen/utils/formatting.py new file mode 100644 index 0000000..9c28cb8 --- /dev/null +++ b/crategen/utils/formatting.py @@ -0,0 +1,34 @@ +import datetime + +def convert_to_iso8601(timestamp): + """ + Convert a given timestamp to ISO 8601 format. + Handles multiple formats including RFC 3339, ISO 8601 with and without fractional seconds. + + Args: + timestamp (str): The timestamp to be converted. + + Returns: + str: The converted timestamp in ISO 8601 format, or None if the input format is incorrect. + """ + if timestamp: + # List of supported formats + formats = [ + "%Y-%m-%dT%H:%M:%S.%fZ", # RFC 3339 with fractional seconds + "%Y-%m-%dT%H:%M:%SZ", # RFC 3339 without fractional seconds + "%Y-%m-%dT%H:%M:%S%z", # ISO 8601 with timezone + "%Y-%m-%dT%H:%M:%S.%f%z", # ISO 8601 with fractional seconds and timezone + ] + for fmt in formats: + try: + dt = datetime.datetime.strptime(timestamp, fmt) + iso_format = dt.isoformat() + # Strip fractional seconds if not needed + if '.' in iso_format: + iso_format = iso_format.split('.')[0] + return iso_format + 'Z' + except ValueError: + continue + # Handle incorrect format or other issues + return None + return None diff --git a/poetry.lock b/poetry.lock index be817c9..234a7e1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -296,63 +296,63 @@ files = [ [[package]] name = "coverage" -version = "7.5.4" +version = "7.6.0" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" files = [ - {file = "coverage-7.5.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6cfb5a4f556bb51aba274588200a46e4dd6b505fb1a5f8c5ae408222eb416f99"}, - {file = "coverage-7.5.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2174e7c23e0a454ffe12267a10732c273243b4f2d50d07544a91198f05c48f47"}, - {file = "coverage-7.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2214ee920787d85db1b6a0bd9da5f8503ccc8fcd5814d90796c2f2493a2f4d2e"}, - {file = "coverage-7.5.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1137f46adb28e3813dec8c01fefadcb8c614f33576f672962e323b5128d9a68d"}, - {file = "coverage-7.5.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b385d49609f8e9efc885790a5a0e89f2e3ae042cdf12958b6034cc442de428d3"}, - {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b4a474f799456e0eb46d78ab07303286a84a3140e9700b9e154cfebc8f527016"}, - {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:5cd64adedf3be66f8ccee418473c2916492d53cbafbfcff851cbec5a8454b136"}, - {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e564c2cf45d2f44a9da56f4e3a26b2236504a496eb4cb0ca7221cd4cc7a9aca9"}, - {file = "coverage-7.5.4-cp310-cp310-win32.whl", hash = "sha256:7076b4b3a5f6d2b5d7f1185fde25b1e54eb66e647a1dfef0e2c2bfaf9b4c88c8"}, - {file = "coverage-7.5.4-cp310-cp310-win_amd64.whl", hash = "sha256:018a12985185038a5b2bcafab04ab833a9a0f2c59995b3cec07e10074c78635f"}, - {file = "coverage-7.5.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:db14f552ac38f10758ad14dd7b983dbab424e731588d300c7db25b6f89e335b5"}, - {file = "coverage-7.5.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3257fdd8e574805f27bb5342b77bc65578e98cbc004a92232106344053f319ba"}, - {file = "coverage-7.5.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a6612c99081d8d6134005b1354191e103ec9705d7ba2754e848211ac8cacc6b"}, - {file = "coverage-7.5.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d45d3cbd94159c468b9b8c5a556e3f6b81a8d1af2a92b77320e887c3e7a5d080"}, - {file = "coverage-7.5.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed550e7442f278af76d9d65af48069f1fb84c9f745ae249c1a183c1e9d1b025c"}, - {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7a892be37ca35eb5019ec85402c3371b0f7cda5ab5056023a7f13da0961e60da"}, - {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8192794d120167e2a64721d88dbd688584675e86e15d0569599257566dec9bf0"}, - {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:820bc841faa502e727a48311948e0461132a9c8baa42f6b2b84a29ced24cc078"}, - {file = "coverage-7.5.4-cp311-cp311-win32.whl", hash = "sha256:6aae5cce399a0f065da65c7bb1e8abd5c7a3043da9dceb429ebe1b289bc07806"}, - {file = "coverage-7.5.4-cp311-cp311-win_amd64.whl", hash = "sha256:d2e344d6adc8ef81c5a233d3a57b3c7d5181f40e79e05e1c143da143ccb6377d"}, - {file = "coverage-7.5.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:54317c2b806354cbb2dc7ac27e2b93f97096912cc16b18289c5d4e44fc663233"}, - {file = "coverage-7.5.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:042183de01f8b6d531e10c197f7f0315a61e8d805ab29c5f7b51a01d62782747"}, - {file = "coverage-7.5.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6bb74ed465d5fb204b2ec41d79bcd28afccf817de721e8a807d5141c3426638"}, - {file = "coverage-7.5.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b3d45ff86efb129c599a3b287ae2e44c1e281ae0f9a9bad0edc202179bcc3a2e"}, - {file = "coverage-7.5.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5013ed890dc917cef2c9f765c4c6a8ae9df983cd60dbb635df8ed9f4ebc9f555"}, - {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1014fbf665fef86cdfd6cb5b7371496ce35e4d2a00cda501cf9f5b9e6fced69f"}, - {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3684bc2ff328f935981847082ba4fdc950d58906a40eafa93510d1b54c08a66c"}, - {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:581ea96f92bf71a5ec0974001f900db495488434a6928a2ca7f01eee20c23805"}, - {file = "coverage-7.5.4-cp312-cp312-win32.whl", hash = "sha256:73ca8fbc5bc622e54627314c1a6f1dfdd8db69788f3443e752c215f29fa87a0b"}, - {file = "coverage-7.5.4-cp312-cp312-win_amd64.whl", hash = "sha256:cef4649ec906ea7ea5e9e796e68b987f83fa9a718514fe147f538cfeda76d7a7"}, - {file = "coverage-7.5.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cdd31315fc20868c194130de9ee6bfd99755cc9565edff98ecc12585b90be882"}, - {file = "coverage-7.5.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:02ff6e898197cc1e9fa375581382b72498eb2e6d5fc0b53f03e496cfee3fac6d"}, - {file = "coverage-7.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d05c16cf4b4c2fc880cb12ba4c9b526e9e5d5bb1d81313d4d732a5b9fe2b9d53"}, - {file = "coverage-7.5.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c5986ee7ea0795a4095ac4d113cbb3448601efca7f158ec7f7087a6c705304e4"}, - {file = "coverage-7.5.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5df54843b88901fdc2f598ac06737f03d71168fd1175728054c8f5a2739ac3e4"}, - {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:ab73b35e8d109bffbda9a3e91c64e29fe26e03e49addf5b43d85fc426dde11f9"}, - {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:aea072a941b033813f5e4814541fc265a5c12ed9720daef11ca516aeacd3bd7f"}, - {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:16852febd96acd953b0d55fc842ce2dac1710f26729b31c80b940b9afcd9896f"}, - {file = "coverage-7.5.4-cp38-cp38-win32.whl", hash = "sha256:8f894208794b164e6bd4bba61fc98bf6b06be4d390cf2daacfa6eca0a6d2bb4f"}, - {file = "coverage-7.5.4-cp38-cp38-win_amd64.whl", hash = "sha256:e2afe743289273209c992075a5a4913e8d007d569a406ffed0bd080ea02b0633"}, - {file = "coverage-7.5.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b95c3a8cb0463ba9f77383d0fa8c9194cf91f64445a63fc26fb2327e1e1eb088"}, - {file = "coverage-7.5.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3d7564cc09dd91b5a6001754a5b3c6ecc4aba6323baf33a12bd751036c998be4"}, - {file = "coverage-7.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:44da56a2589b684813f86d07597fdf8a9c6ce77f58976727329272f5a01f99f7"}, - {file = "coverage-7.5.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e16f3d6b491c48c5ae726308e6ab1e18ee830b4cdd6913f2d7f77354b33f91c8"}, - {file = "coverage-7.5.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dbc5958cb471e5a5af41b0ddaea96a37e74ed289535e8deca404811f6cb0bc3d"}, - {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:a04e990a2a41740b02d6182b498ee9796cf60eefe40cf859b016650147908029"}, - {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:ddbd2f9713a79e8e7242d7c51f1929611e991d855f414ca9996c20e44a895f7c"}, - {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:b1ccf5e728ccf83acd313c89f07c22d70d6c375a9c6f339233dcf792094bcbf7"}, - {file = "coverage-7.5.4-cp39-cp39-win32.whl", hash = "sha256:56b4eafa21c6c175b3ede004ca12c653a88b6f922494b023aeb1e836df953ace"}, - {file = "coverage-7.5.4-cp39-cp39-win_amd64.whl", hash = "sha256:65e528e2e921ba8fd67d9055e6b9f9e34b21ebd6768ae1c1723f4ea6ace1234d"}, - {file = "coverage-7.5.4-pp38.pp39.pp310-none-any.whl", hash = "sha256:79b356f3dd5b26f3ad23b35c75dbdaf1f9e2450b6bcefc6d0825ea0aa3f86ca5"}, - {file = "coverage-7.5.4.tar.gz", hash = "sha256:a44963520b069e12789d0faea4e9fdb1e410cdc4aab89d94f7f55cbb7fef0353"}, + {file = "coverage-7.6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dff044f661f59dace805eedb4a7404c573b6ff0cdba4a524141bc63d7be5c7fd"}, + {file = "coverage-7.6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a8659fd33ee9e6ca03950cfdcdf271d645cf681609153f218826dd9805ab585c"}, + {file = "coverage-7.6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7792f0ab20df8071d669d929c75c97fecfa6bcab82c10ee4adb91c7a54055463"}, + {file = "coverage-7.6.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d4b3cd1ca7cd73d229487fa5caca9e4bc1f0bca96526b922d61053ea751fe791"}, + {file = "coverage-7.6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e7e128f85c0b419907d1f38e616c4f1e9f1d1b37a7949f44df9a73d5da5cd53c"}, + {file = "coverage-7.6.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:a94925102c89247530ae1dab7dc02c690942566f22e189cbd53579b0693c0783"}, + {file = "coverage-7.6.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:dcd070b5b585b50e6617e8972f3fbbee786afca71b1936ac06257f7e178f00f6"}, + {file = "coverage-7.6.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:d50a252b23b9b4dfeefc1f663c568a221092cbaded20a05a11665d0dbec9b8fb"}, + {file = "coverage-7.6.0-cp310-cp310-win32.whl", hash = "sha256:0e7b27d04131c46e6894f23a4ae186a6a2207209a05df5b6ad4caee6d54a222c"}, + {file = "coverage-7.6.0-cp310-cp310-win_amd64.whl", hash = "sha256:54dece71673b3187c86226c3ca793c5f891f9fc3d8aa183f2e3653da18566169"}, + {file = "coverage-7.6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c7b525ab52ce18c57ae232ba6f7010297a87ced82a2383b1afd238849c1ff933"}, + {file = "coverage-7.6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4bea27c4269234e06f621f3fac3925f56ff34bc14521484b8f66a580aacc2e7d"}, + {file = "coverage-7.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed8d1d1821ba5fc88d4a4f45387b65de52382fa3ef1f0115a4f7a20cdfab0e94"}, + {file = "coverage-7.6.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:01c322ef2bbe15057bc4bf132b525b7e3f7206f071799eb8aa6ad1940bcf5fb1"}, + {file = "coverage-7.6.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:03cafe82c1b32b770a29fd6de923625ccac3185a54a5e66606da26d105f37dac"}, + {file = "coverage-7.6.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:0d1b923fc4a40c5832be4f35a5dab0e5ff89cddf83bb4174499e02ea089daf57"}, + {file = "coverage-7.6.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:4b03741e70fb811d1a9a1d75355cf391f274ed85847f4b78e35459899f57af4d"}, + {file = "coverage-7.6.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:a73d18625f6a8a1cbb11eadc1d03929f9510f4131879288e3f7922097a429f63"}, + {file = "coverage-7.6.0-cp311-cp311-win32.whl", hash = "sha256:65fa405b837060db569a61ec368b74688f429b32fa47a8929a7a2f9b47183713"}, + {file = "coverage-7.6.0-cp311-cp311-win_amd64.whl", hash = "sha256:6379688fb4cfa921ae349c76eb1a9ab26b65f32b03d46bb0eed841fd4cb6afb1"}, + {file = "coverage-7.6.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f7db0b6ae1f96ae41afe626095149ecd1b212b424626175a6633c2999eaad45b"}, + {file = "coverage-7.6.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bbdf9a72403110a3bdae77948b8011f644571311c2fb35ee15f0f10a8fc082e8"}, + {file = "coverage-7.6.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9cc44bf0315268e253bf563f3560e6c004efe38f76db03a1558274a6e04bf5d5"}, + {file = "coverage-7.6.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:da8549d17489cd52f85a9829d0e1d91059359b3c54a26f28bec2c5d369524807"}, + {file = "coverage-7.6.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0086cd4fc71b7d485ac93ca4239c8f75732c2ae3ba83f6be1c9be59d9e2c6382"}, + {file = "coverage-7.6.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1fad32ee9b27350687035cb5fdf9145bc9cf0a094a9577d43e909948ebcfa27b"}, + {file = "coverage-7.6.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:044a0985a4f25b335882b0966625270a8d9db3d3409ddc49a4eb00b0ef5e8cee"}, + {file = "coverage-7.6.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:76d5f82213aa78098b9b964ea89de4617e70e0d43e97900c2778a50856dac605"}, + {file = "coverage-7.6.0-cp312-cp312-win32.whl", hash = "sha256:3c59105f8d58ce500f348c5b56163a4113a440dad6daa2294b5052a10db866da"}, + {file = "coverage-7.6.0-cp312-cp312-win_amd64.whl", hash = "sha256:ca5d79cfdae420a1d52bf177de4bc2289c321d6c961ae321503b2ca59c17ae67"}, + {file = "coverage-7.6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d39bd10f0ae453554798b125d2f39884290c480f56e8a02ba7a6ed552005243b"}, + {file = "coverage-7.6.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:beb08e8508e53a568811016e59f3234d29c2583f6b6e28572f0954a6b4f7e03d"}, + {file = "coverage-7.6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b2e16f4cd2bc4d88ba30ca2d3bbf2f21f00f382cf4e1ce3b1ddc96c634bc48ca"}, + {file = "coverage-7.6.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6616d1c9bf1e3faea78711ee42a8b972367d82ceae233ec0ac61cc7fec09fa6b"}, + {file = "coverage-7.6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ad4567d6c334c46046d1c4c20024de2a1c3abc626817ae21ae3da600f5779b44"}, + {file = "coverage-7.6.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:d17c6a415d68cfe1091d3296ba5749d3d8696e42c37fca5d4860c5bf7b729f03"}, + {file = "coverage-7.6.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:9146579352d7b5f6412735d0f203bbd8d00113a680b66565e205bc605ef81bc6"}, + {file = "coverage-7.6.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:cdab02a0a941af190df8782aafc591ef3ad08824f97850b015c8c6a8b3877b0b"}, + {file = "coverage-7.6.0-cp38-cp38-win32.whl", hash = "sha256:df423f351b162a702c053d5dddc0fc0ef9a9e27ea3f449781ace5f906b664428"}, + {file = "coverage-7.6.0-cp38-cp38-win_amd64.whl", hash = "sha256:f2501d60d7497fd55e391f423f965bbe9e650e9ffc3c627d5f0ac516026000b8"}, + {file = "coverage-7.6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7221f9ac9dad9492cecab6f676b3eaf9185141539d5c9689d13fd6b0d7de840c"}, + {file = "coverage-7.6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ddaaa91bfc4477d2871442bbf30a125e8fe6b05da8a0015507bfbf4718228ab2"}, + {file = "coverage-7.6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c4cbe651f3904e28f3a55d6f371203049034b4ddbce65a54527a3f189ca3b390"}, + {file = "coverage-7.6.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:831b476d79408ab6ccfadaaf199906c833f02fdb32c9ab907b1d4aa0713cfa3b"}, + {file = "coverage-7.6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46c3d091059ad0b9c59d1034de74a7f36dcfa7f6d3bde782c49deb42438f2450"}, + {file = "coverage-7.6.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:4d5fae0a22dc86259dee66f2cc6c1d3e490c4a1214d7daa2a93d07491c5c04b6"}, + {file = "coverage-7.6.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:07ed352205574aad067482e53dd606926afebcb5590653121063fbf4e2175166"}, + {file = "coverage-7.6.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:49c76cdfa13015c4560702574bad67f0e15ca5a2872c6a125f6327ead2b731dd"}, + {file = "coverage-7.6.0-cp39-cp39-win32.whl", hash = "sha256:482855914928c8175735a2a59c8dc5806cf7d8f032e4820d52e845d1f731dca2"}, + {file = "coverage-7.6.0-cp39-cp39-win_amd64.whl", hash = "sha256:543ef9179bc55edfd895154a51792b01c017c87af0ebaae092720152e19e42ca"}, + {file = "coverage-7.6.0-pp38.pp39.pp310-none-any.whl", hash = "sha256:6fe885135c8a479d3e37a7aae61cbd3a0fb2deccb4dda3c25f92a49189f766d6"}, + {file = "coverage-7.6.0.tar.gz", hash = "sha256:289cc803fa1dc901f84701ac10c9ee873619320f2f9aff38794db4a4a0268d51"}, ] [package.extras] @@ -1510,21 +1510,21 @@ files = [ [[package]] name = "typos" -version = "1.23.1" +version = "1.23.2" description = "Source Code Spelling Correction" optional = false python-versions = ">=3.7" files = [ - {file = "typos-1.23.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:c6ac98510ac54b7ea9ab73806ba22935c960f8d09678e358dd336e2a9dd7018b"}, - {file = "typos-1.23.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:31e1200e28c78a7ac5b4bc7673f9299c85682e838b8e05e413146c8fe6be980a"}, - {file = "typos-1.23.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:89cf023373f3581cd38e41d43bddb5902e55a0ec93b1899699dec3fe95e2f9be"}, - {file = "typos-1.23.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c14bcbe2b585a554cef265620c384918eb2f2436c636d92cad42d66b1b4433a7"}, - {file = "typos-1.23.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7dddb05fc60ccf979761e4a10a3a280fa701fe55b1835b94d435c34dc06cf05d"}, - {file = "typos-1.23.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:86b23fbdfc192851e9dada7db9d7269c15267c2e0b422906e7c36226f5100f4e"}, - {file = "typos-1.23.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:34d2f693111fedffeec7fe5cf096ec8cff9c0b01f2c13e4ddee34bd063aa2c6f"}, - {file = "typos-1.23.1-py3-none-win32.whl", hash = "sha256:822ea2ba610f91a7f1c037d91c9f5d12cf8d92e3f6470747dd76e85711558dc3"}, - {file = "typos-1.23.1-py3-none-win_amd64.whl", hash = "sha256:d7fedee1b0c9aa2a796bffa5d30285cc7a32eb4850336b91c84ef672852ddd7f"}, - {file = "typos-1.23.1.tar.gz", hash = "sha256:390b071b2081d61d3c1718b1c05b92756692ed066907f04caf7297c9a25c7eee"}, + {file = "typos-1.23.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b1549225f26cbcb6640e87999f20496287751428c71a7650e6afe3143e39112f"}, + {file = "typos-1.23.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:290c6628b60f570999dfcdcf0ce5c90f195cceba160a1b16316eebd5c68129f2"}, + {file = "typos-1.23.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0461d8e33c9ba51518203ef59df19b0945293626ce620652650927f3e3b1a9af"}, + {file = "typos-1.23.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2873d83a562725c841e6ee3ee03865ebcee7a1b5add57ca7a88578cb752c7f4a"}, + {file = "typos-1.23.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:16ea2a308f731729711b660e0c68753047e6b9937d8d97bd6e1d1c274303ad36"}, + {file = "typos-1.23.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2dcd035661c1a45688fd0ffb14fd242bf8907996e12a8cbf8166bec0a6b360e5"}, + {file = "typos-1.23.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:38da8651809e86de5cd338a68552688ab10fb45056d86c1f90a36f7911d29bd4"}, + {file = "typos-1.23.2-py3-none-win32.whl", hash = "sha256:de20d68507126f2577c7dca88ec8d52364e8c519218d72791edcfe256622948a"}, + {file = "typos-1.23.2-py3-none-win_amd64.whl", hash = "sha256:85f0877de4c4024fc846a08ece5a8f56dd85ab69d42d23608c29783e1d6899ed"}, + {file = "typos-1.23.2.tar.gz", hash = "sha256:2a7b0c3523140f1c32ed91e46171a925d3748735648381cec4f6b992217d4167"}, ] [[package]] diff --git a/tests/data/input/tes_example.json b/tests/data/input/tes_example.json index 7969b4f..e7cb132 100644 --- a/tests/data/input/tes_example.json +++ b/tests/data/input/tes_example.json @@ -1,65 +1,10 @@ { - "id": "task-12345", - "state": "COMPLETE", - "name": "example-task", - "description": "This is an example task for testing.", - "inputs": [ - { - "name": "input-file", - "description": "An input file for the task.", - "url": "s3://example-bucket/input-file.txt", - "path": "/data/input-file.txt", - "type": "FILE" - } - ], - "outputs": [ - { - "name": "output-file", - "description": "An output file from the task.", - "url": "s3://example-bucket/output-file.txt", - "path": "/data/output-file.txt", - "type": "FILE" - } - ], - "resources": { - "cpu_cores": 4, - "preemptible": false, - "ram_gb": 16, - "disk_gb": 50, - "zones": ["us-central1-a"] - }, - "executors": [ - { - "image": "example/image:latest", - "command": ["python", "script.py"], - "workdir": "/workspace", - "stdin": "/workspace/input-file.txt", - "stdout": "/workspace/output-file.txt", - "stderr": "/workspace/error.log", - "env": { - "EXAMPLE_ENV": "example_value" - } - } - ], - "tags": { - "project": "example-project", - "purpose": "testing" - }, - "volumes": [ - { - "name": "example-volume", - "mount_path": "/workspace", - "read_only": false - } - ], - "logs": [ - { - "start_time": "2023-07-01T12:00:00Z", - "end_time": "2023-07-01T12:30:00Z", - "stdout": "Execution completed successfully.", - "stderr": "", - "exit_code": 0 - } - ], - "creation_time": "2023-07-01T11:00:00Z" + "id": "task-id", + "name": "test-task", + "description": "test-description", + "executors": [{"image": "executor-image"}], + "inputs": [{"url": "input-url", "path": "input-path"}], + "outputs": [{"url": "output-url", "path": "output-path"}], + "creation_time": "2023-07-10T14:30:00Z", + "end_time": "2023-07-10T15:30:00Z" } diff --git a/tests/data/input/wes_example.json b/tests/data/input/wes_example.json index c578e58..1eae08c 100644 --- a/tests/data/input/wes_example.json +++ b/tests/data/input/wes_example.json @@ -1,51 +1,10 @@ { - "run_id": "wes-12345", - "request": { - "workflow_params": { - "input_file": "s3://example-bucket/input-file.txt", - "output_file": "s3://example-bucket/output-file.txt" - }, - "workflow_type": "CWL", - "workflow_type_version": "v1.0", - "workflow_url": "https://example.com/workflow.cwl", - "tags": { - "project": "example-project", - "purpose": "testing" - } - }, - "state": "COMPLETE", + "run_id": "run-id", "run_log": { - "name": "example-workflow", - "start_time": "2023-07-01T12:00:00Z", - "end_time": "2023-07-01T12:30:00Z", - "stdout": "Execution completed successfully.", - "stderr": "", - "exit_code": 0 + "name": "test-run", + "start_time": "2023-07-10T14:30:00Z", + "end_time": "2023-07-10T15:30:00Z" }, - "task_logs": [ - { - "name": "task1", - "cmd": ["python", "script.py"], - "start_time": "2023-07-01T12:00:00Z", - "end_time": "2023-07-01T12:10:00Z", - "stdout": "Task 1 completed.", - "stderr": "", - "exit_code": 0 - }, - { - "name": "task2", - "cmd": ["python", "script2.py"], - "start_time": "2023-07-01T12:10:00Z", - "end_time": "2023-07-01T12:20:00Z", - "stdout": "Task 2 completed.", - "stderr": "", - "exit_code": 0 - } - ], - "outputs": [ - { - "location": "s3://example-bucket/output-file.txt", - "name": "output-file" - } - ] + "state": "COMPLETED", + "outputs": [{"location": "output-location", "name": "output-name"}] } diff --git a/tests/data/output/tes_to_wrroc_output.json b/tests/data/output/tes_to_wrroc_output.json index 8dcfd65..bd4770f 100644 --- a/tests/data/output/tes_to_wrroc_output.json +++ b/tests/data/output/tes_to_wrroc_output.json @@ -1,20 +1,20 @@ { - "@id": "karanjot-task", - "name": "example-task", - "description": "This is an example task for testing.", - "instrument": "example/image:latest", - "object": [ - { - "@id": "s3://example-bucket/input-file.txt", - "name": "/data/input-file.txt" - } - ], - "result": [ - { - "@id": "s3://example-bucket/output-file.txt", - "name": "/data/output-file.txt" - } - ], - "startTime": "2023-07-01T11:00:00Z", - "endTime": null + "@id": "task-id", + "name": "test-task", + "description": "test-description", + "instrument": "executor-image", + "object": [ + { + "@id": "input-url", + "name": "input-path" + } + ], + "result": [ + { + "@id": "output-url", + "name": "output-path" + } + ], + "startTime": "2023-07-10T14:30:00Z", + "endTime": "2023-07-10T15:30:00Z" } \ No newline at end of file diff --git a/tests/data/output/wes_to_wrroc_output.json b/tests/data/output/wes_to_wrroc_output.json index a5aed5a..73783f1 100644 --- a/tests/data/output/wes_to_wrroc_output.json +++ b/tests/data/output/wes_to_wrroc_output.json @@ -1,13 +1,13 @@ { - "@id": "wes-12345", - "name": "example-workflow", - "status": "COMPLETE", - "startTime": "2023-07-01T12:00:00Z", - "endTime": "2023-07-01T12:30:00Z", - "result": [ - { - "@id": "s3://example-bucket/output-file.txt", - "name": "output-file" - } - ] + "@id": "run-id", + "name": "test-run", + "status": "COMPLETED", + "startTime": "2023-07-10T14:30:00Z", + "endTime": "2023-07-10T15:30:00Z", + "result": [ + { + "@id": "output-location", + "name": "output-name" + } + ] } \ No newline at end of file diff --git a/tests/unit/test_tes_converter.py b/tests/unit/test_tes_converter.py index cc1ebdf..9fc8e5d 100644 --- a/tests/unit/test_tes_converter.py +++ b/tests/unit/test_tes_converter.py @@ -8,65 +8,55 @@ def setUp(self): def test_convert_to_wrroc(self): tes_data = { - "id": "tes-12345", - "name": "example-task", - "description": "This is a sample TES task.", - "executors": [ - { - "image": "python:3.8", - "command": ["python", "script.py"], - "workdir": "/workspace", - "stdout": "/workspace/output.log", - "stderr": "/workspace/error.log" - } - ], - "inputs": [ - { - "url": "s3://example-bucket/input-file.txt", - "path": "/workspace/input-file.txt", - "type": "FILE" - } - ], - "outputs": [ - { - "url": "s3://example-bucket/output-file.txt", - "path": "/workspace/output-file.txt", - "type": "FILE" - } - ], - "creation_time": "2023-07-01T12:00:00Z", - "end_time": "2023-07-01T12:30:00Z" + "id": "task-id", + "name": "test-task", + "description": "test-description", + "executors": [{"image": "executor-image"}], + "inputs": [{"url": "input-url", "path": "input-path"}], + "outputs": [{"url": "output-url", "path": "output-path"}], + "creation_time": "2023-07-10T14:30:00Z", + "end_time": "2023-07-10T15:30:00Z" } + + expected_wrroc_data = { + "@id": "task-id", + "name": "test-task", + "description": "test-description", + "instrument": "executor-image", + "object": [{"@id": "input-url", "name": "input-path"}], + "result": [{"@id": "output-url", "name": "output-path"}], + "startTime": "2023-07-10T14:30:00Z", + "endTime": "2023-07-10T15:30:00Z" + } + result = self.converter.convert_to_wrroc(tes_data) - self.assertEqual(result["@id"], "tes-12345") - self.assertEqual(result["name"], "example-task") - self.assertEqual(result["description"], "This is a sample TES task.") + self.assertEqual(result, expected_wrroc_data) def test_convert_from_wrroc(self): wrroc_data = { - "@id": "tes-12345", - "name": "example-task", - "description": "This is a sample TES task.", - "instrument": "python:3.8", - "object": [ - { - "@id": "s3://example-bucket/input-file.txt", - "name": "/workspace/input-file.txt" - } - ], - "result": [ - { - "@id": "s3://example-bucket/output-file.txt", - "name": "/workspace/output-file.txt" - } - ], - "startTime": "2023-07-01T12:00:00Z", - "endTime": "2023-07-01T12:30:00Z" + "@id": "task-id", + "name": "test-task", + "description": "test-description", + "instrument": "executor-image", + "object": [{"@id": "input-url", "name": "input-path"}], + "result": [{"@id": "output-url", "name": "output-path"}], + "startTime": "2023-07-10T14:30:00Z", + "endTime": "2023-07-10T15:30:00Z" + } + + expected_tes_data = { + "id": "task-id", + "name": "test-task", + "description": "test-description", + "executors": [{"image": "executor-image"}], + "inputs": [{"url": "input-url", "path": "input-path"}], + "outputs": [{"url": "output-url", "path": "output-path"}], + "creation_time": "2023-07-10T14:30:00Z", + "end_time": "2023-07-10T15:30:00Z" } + result = self.converter.convert_from_wrroc(wrroc_data) - self.assertEqual(result["id"], "tes-12345") - self.assertEqual(result["name"], "example-task") - self.assertEqual(result["description"], "This is a sample TES task.") + self.assertEqual(result, expected_tes_data) if __name__ == '__main__': unittest.main() diff --git a/tests/unit/test_wes_converter.py b/tests/unit/test_wes_converter.py index 5641d97..cf1a5b0 100644 --- a/tests/unit/test_wes_converter.py +++ b/tests/unit/test_wes_converter.py @@ -7,14 +7,52 @@ def setUp(self): self.converter = WESConverter() def test_convert_to_wrroc(self): - wes_data = {} # Add sample WES data here + wes_data = { + "run_id": "run-id", + "run_log": { + "name": "test-run", + "start_time": "2023-07-10T14:30:00Z", + "end_time": "2023-07-10T15:30:00Z" + }, + "state": "COMPLETED", + "outputs": [{"location": "output-location", "name": "output-name"}] + } + + expected_wrroc_data = { + "@id": "run-id", + "name": "test-run", + "status": "COMPLETED", + "startTime": "2023-07-10T14:30:00Z", + "endTime": "2023-07-10T15:30:00Z", + "result": [{"@id": "output-location", "name": "output-name"}] + } + result = self.converter.convert_to_wrroc(wes_data) - # Add assertions here + self.assertEqual(result, expected_wrroc_data) def test_convert_from_wrroc(self): - wrroc_data = {} # Add sample WRROC data here + wrroc_data = { + "@id": "run-id", + "name": "test-run", + "status": "COMPLETED", + "startTime": "2023-07-10T14:30:00Z", + "endTime": "2023-07-10T15:30:00Z", + "result": [{"@id": "output-location", "name": "output-name"}] + } + + expected_wes_data = { + "run_id": "run-id", + "run_log": { + "name": "test-run", + "start_time": "2023-07-10T14:30:00Z", + "end_time": "2023-07-10T15:30:00Z" + }, + "state": "COMPLETED", + "outputs": [{"location": "output-location", "name": "output-name"}] + } + result = self.converter.convert_from_wrroc(wrroc_data) - # Add assertions here + self.assertEqual(result, expected_wes_data) if __name__ == '__main__': unittest.main()