diff --git a/README.md b/README.md index bd96596..0c62d18 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ - [Generation of Galaxy ToolConfig files](galaxy/README.md) - [Generation of CWL task files](cwl/README.md) + +## Fail Policy while processing several Files +`CTDConverter` can parse several CTDs and convert them. However, the process will be interrupted and an error code will be returned at the first encountered error (e.g., a CTD is not valid, there are missing support files, etc.). ## Converting a single CTD In its simplest form, the converter takes an input CTD file and generates an output file. The following usage of `CTDConverter`: diff --git a/common/utils.py b/common/utils.py index d1d4093..95c22af 100644 --- a/common/utils.py +++ b/common/utils.py @@ -105,20 +105,18 @@ error("Could not load validation schema %s. Reason: %s" % (xsd_location, str(e)), 0) else: warning("Validation against a schema has not been enabled.", 0) + for input_ctd in input_ctds: - try: - if schema is not None: - validate_against_schema(input_ctd, schema) - output_file = output_destination - # if multiple inputs are being converted, we need to generate a different output_file for each input - if is_converting_multiple_ctds: - output_file = os.path.join(output_file, - get_filename_without_suffix(input_ctd) + "." + output_file_extension) - info("Parsing %s" % input_ctd) - parsed_ctds.append(ParsedCTD(CTDModel(from_file=input_ctd), input_ctd, output_file)) - except Exception, e: - error(str(e), 1) - continue + if schema is not None: + validate_against_schema(input_ctd, schema) + + output_file = output_destination + # if multiple inputs are being converted, we need to generate a different output_file for each input + if is_converting_multiple_ctds: + output_file = os.path.join(output_file, get_filename_without_suffix(input_ctd) + "." + output_file_extension) + info("Parsing %s" % input_ctd) + parsed_ctds.append(ParsedCTD(CTDModel(from_file=input_ctd), input_ctd, output_file)) + return parsed_ctds diff --git a/convert.py b/convert.py index 8b577b5..3d0bbd0 100644 --- a/convert.py +++ b/convert.py @@ -215,7 +215,8 @@ converter.get_preferred_file_extension()) # let the converter do its own thing - return converter.convert_models(args, parsed_ctds) + converter.convert_models(args, parsed_ctds) + return 0 except KeyboardInterrupt: print("Interrupted...") diff --git a/cwl/converter.py b/cwl/converter.py index ec3a1a6..8188558 100755 --- a/cwl/converter.py +++ b/cwl/converter.py @@ -77,8 +77,6 @@ stream.write("# Visit https://github.com/WorkflowConversion/CTDConverter for more information.\n\n") yaml.dump(cwl_tool, stream, default_flow_style=False) stream.close() - - return 0 # returns a dictionary diff --git a/galaxy/converter.py b/galaxy/converter.py index f05fee9..7f3e542 100755 --- a/galaxy/converter.py +++ b/galaxy/converter.py @@ -102,8 +102,6 @@ # generate datatypes_conf.xml if args.data_types_destination is not None: generate_data_type_conf(supported_file_formats, args.data_types_destination) - - return 0 def parse_tools_list_file(tools_list_file):