diff --git a/script/dh-validate.py b/script/dh-validate.py index c732d04b..33d8d5b3 100644 --- a/script/dh-validate.py +++ b/script/dh-validate.py @@ -52,17 +52,6 @@ from linkml_runtime.dumpers.yaml_dumper import YAMLDumper import subprocess -# ISSUE TRYING TO IMPORT linkml, getting "error: no such option: --schema" when --schema provided to argparse; and "Input LinkML schema file not given" when not given that parameter! -""" -try: - from linkml.validator import validate -except Exception as inst: - print(type(inst)) # the exception type - print(inst.args) # arguments stored in .args - print(inst) # __str__ allows args to be printed directly, - # but may be overridden in exception subclasses -""" - def init_parser(): parser = argparse.ArgumentParser( @@ -530,15 +519,33 @@ def isInteger(x): if len(warnings): print ("\nWARNING: \n", "\n ".join(warnings)); - +""" # SNIPETS: -# -#stderr=None; -#try: +# A challenge trying to get linkml-validate working via python module. + +report = validate(data_handle, args.schema_path, "Person") # , "Person" +if not report.results: + print('The instance is valid!') +else: + for result in report.results: + print(result.message) + +# ISSUE TRYING TO IMPORT linkml, getting "error: no such option: --schema" when --schema provided to argparse; and "Input LinkML schema file not given" when not given that parameter! +try: + from linkml.validator import validate +except Exception as inst: + print(type(inst)) # the exception type + print(inst.args) # arguments stored in .args + print(inst) # __str__ allows args to be printed directly, + # but may be overridden in exception subclasses + + +stderr=None; +try: # e.g. > linkml-convert -s schema.yaml -C CanCOGeNCovid19 --index-slot specimen_collector_sample_id -o validTestData_2-1-2.tmp.tsv.json validTestData_2-1-2.tmp.tsv # ISSUE IS range="ANY_OF" slots may have content but if REQUIRED=True, ARE THROWING ERROR. -#run_state = subprocess.check_output(["linkml-convert", "-s", args.schema_path, "-C", target_class, "--index-slot", slot_key, "-o", temp_file + '.json', temp_file]) #, stderr=subprocess.STDOUT -""" + run_state = subprocess.check_output(["linkml-convert", "-s", args.schema_path, "-C", target_class, "--index-slot", slot_key, "-o", temp_file + '.json', temp_file]) #, stderr=subprocess.STDOUT + except BaseException as inst: print(type(inst)) # the exception type @@ -547,15 +554,6 @@ def isInteger(x): # but may be overridden in exception subclasses finally: -""" +... """ -# A challenge trying to get linkml-validate working via python module. - -report = validate(data_handle, args.schema_path, "Person") # , "Person" -if not report.results: - print('The instance is valid!') -else: - for result in report.results: - print(result.message) -""" \ No newline at end of file