From 23bb7f30fb94a5aa884379bc58bc65a1f49695cf Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 23 Jun 2021 16:58:34 -0400 Subject: [PATCH 1/9] Convert URIs to avro namespaces for types. The key difference is that field names, symbols and type names are unified in the Salad/RDF data model, but are separate in the Avro data model. Types and fields names and enum symbols need to have their names mapped differently. This is now handled. The practical effect is that this fixes a longstanding issue in referencing types from imported schemas, as is done in cwltool extension schema to reference cwl:Expression. refs #326 --- schema_salad/schema.py | 66 +++++++++++++++++++++++++++++++--------- schema_salad/validate.py | 2 +- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/schema_salad/schema.py b/schema_salad/schema.py index d3c5c988..23874d09 100644 --- a/schema_salad/schema.py +++ b/schema_salad/schema.py @@ -410,7 +410,7 @@ def get_anon_name( if rec["type"] in ("enum", saladp + "enum"): for sym in rec["symbols"]: anon_name += sym - return "enum_" + hashlib.sha1(anon_name.encode("UTF-8")).hexdigest() # nosec + return "anon.enum_" + hashlib.sha1(anon_name.encode("UTF-8")).hexdigest() # nosec if rec["type"] in ("record", saladp + "record"): for field in rec["fields"]: if isinstance(field, Mapping): @@ -488,8 +488,20 @@ def replace_type( found.add(items) return items - -def avro_name(url: str) -> str: +primitives = { + "http://www.w3.org/2001/XMLSchema#string": "string", + "http://www.w3.org/2001/XMLSchema#boolean": "boolean", + "http://www.w3.org/2001/XMLSchema#int": "int", + "http://www.w3.org/2001/XMLSchema#long": "long", + "http://www.w3.org/2001/XMLSchema#float": "float", + "http://www.w3.org/2001/XMLSchema#double": "double", + saladp + "null": "null", + saladp + "enum": "enum", + saladp + "array": "array", + saladp + "record": "record" +} + +def avro_type_name(url: str) -> str: """ Turn a URL into an Avro-safe name. @@ -498,14 +510,34 @@ def avro_name(url: str) -> str: Extract either the last part of the URL fragment past the slash, otherwise the whole fragment. """ - frg = urldefrag(url)[1] - if frg != "": - if "/" in frg: - return frg[frg.rindex("/") + 1 :] - return frg + global primitives + + if url in primitives: + return primitives[url] + + if url.startswith("http://"): + url = url[7:] + elif url.startswith("https://"): + url = url[8:] + url = url.replace("/", ".").replace("#", ".") return url +def avro_field_name(url: str) -> str: + """ + Turn a URL into an Avro-safe name. + + If the URL has no fragment, return this plain URL. + + Extract either the last part of the URL fragment past the slash, otherwise + the whole fragment. + """ + d = urlparse(url) + if d.fragment: + return d.fragment.split("/")[-1] + return d.path.split("/")[-1] + + Avro = TypeVar("Avro", MutableMapping[str, Any], MutableSequence[Any], str) @@ -514,6 +546,7 @@ def make_valid_avro( alltypes: Dict[str, Dict[str, Any]], found: Set[str], union: bool = False, + field: bool = False ) -> Union[ Avro, MutableMapping[str, str], str, List[Union[Any, MutableMapping[str, str], str]] ]: @@ -522,7 +555,10 @@ def make_valid_avro( if isinstance(items, MutableMapping): avro = copy.copy(items) if avro.get("name") and avro.get("inVocab", True): - avro["name"] = avro_name(avro["name"]) + if field: + avro["name"] = avro_field_name(avro["name"]) + else: + avro["name"] = avro_type_name(avro["name"]) if "type" in avro and avro["type"] in ( saladp + "record", @@ -537,19 +573,19 @@ def make_valid_avro( found.add(avro["name"]) for field in ("type", "items", "values", "fields"): if field in avro: - avro[field] = make_valid_avro(avro[field], alltypes, found, union=True) + avro[field] = make_valid_avro(avro[field], alltypes, found, union=True, field=(field=="fields")) if "symbols" in avro: - avro["symbols"] = [avro_name(sym) for sym in avro["symbols"]] + avro["symbols"] = [avro_field_name(sym) for sym in avro["symbols"]] return avro if isinstance(items, MutableSequence): ret = [] for i in items: - ret.append(make_valid_avro(i, alltypes, found, union=union)) + ret.append(make_valid_avro(i, alltypes, found, union=union, field=field)) return ret if union and isinstance(items, str): - if items in alltypes and avro_name(items) not in found: + if items in alltypes and avro_type_name(items) not in found: return make_valid_avro(alltypes[items], alltypes, found, union=union) - return avro_name(items) + return avro_type_name(items) else: return items @@ -647,7 +683,7 @@ def extend_and_specialize( for ex in aslist(result["extends"]): if ex_types[ex].get("abstract"): add_dictlist(extended_by, ex, ex_types[result["name"]]) - add_dictlist(extended_by, avro_name(ex), ex_types[ex]) + add_dictlist(extended_by, avro_type_name(ex), ex_types[ex]) for result in results: if result.get("abstract") and result["name"] not in extended_by: diff --git a/schema_salad/validate.py b/schema_salad/validate.py index 11931526..d5cdb57c 100644 --- a/schema_salad/validate.py +++ b/schema_salad/validate.py @@ -127,7 +127,7 @@ def validate_ex( ) return False elif isinstance(expected_schema, avro.schema.EnumSchema): - if expected_schema.name == "Any": + if expected_schema.name == "w3id.org.cwl.salad.Any": if datum is not None: return True if raise_ex: From 3cf538ec022e5527776133531b656d05031cfeaf Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 23 Jun 2021 17:33:46 -0400 Subject: [PATCH 2/9] Fix tests --- mypy_requirements.txt | 1 - schema_salad/codegen_base.py | 2 +- schema_salad/java_codegen.py | 2 +- schema_salad/makedoc.py | 10 +++++----- schema_salad/python_codegen.py | 10 ++++++---- schema_salad/schema.py | 4 ++-- schema_salad/validate.py | 10 ++++++---- setup.py | 2 +- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/mypy_requirements.txt b/mypy_requirements.txt index d8f3601a..1f438395 100644 --- a/mypy_requirements.txt +++ b/mypy_requirements.txt @@ -1,4 +1,3 @@ mypy==0.910 types-pkg_resources types-requests -pytest diff --git a/schema_salad/codegen_base.py b/schema_salad/codegen_base.py index 02a6072b..17d26cf4 100644 --- a/schema_salad/codegen_base.py +++ b/schema_salad/codegen_base.py @@ -66,7 +66,7 @@ def prologue(self) -> None: @staticmethod def safe_name(name: str) -> str: """Generate a safe version of the given name.""" - return schema.avro_name(name) + return schema.avro_field_name(name) def begin_class( self, # pylint: disable=too-many-arguments diff --git a/schema_salad/java_codegen.py b/schema_salad/java_codegen.py index 37ae62b7..9d80d6e8 100644 --- a/schema_salad/java_codegen.py +++ b/schema_salad/java_codegen.py @@ -151,7 +151,7 @@ def prologue(self) -> None: @staticmethod def property_name(name: str) -> str: - avn = schema.avro_name(name) + avn = schema.avro_field_name(name) return avn @staticmethod diff --git a/schema_salad/makedoc.py b/schema_salad/makedoc.py index 29a190ce..f152b00b 100644 --- a/schema_salad/makedoc.py +++ b/schema_salad/makedoc.py @@ -315,7 +315,7 @@ def typefmt( "https://w3id.org/cwl/salad#record", "https://w3id.org/cwl/salad#enum", ): - frg = schema.avro_name(tp["name"]) + frg = schema.avro_type_name(tp["name"]) if tp["name"] in redirects: return """{}""".format(redirects[tp["name"]], frg) if tp["name"] in self.typemap: @@ -325,7 +325,7 @@ def typefmt( and len(tp["symbols"]) == 1 ): return "constant value {}".format( - schema.avro_name(tp["symbols"][0]) + schema.avro_field_name(tp["symbols"][0]) ) return frg if isinstance(tp["type"], MutableMapping): @@ -335,7 +335,7 @@ def typefmt( return """{}""".format(redirects[tp], redirects[tp]) if str(tp) in basicTypes: return """{}""".format( - self.primitiveType, schema.avro_name(str(tp)) + self.primitiveType, schema.avro_type_name(str(tp)) ) frg2 = urldefrag(tp)[1] if frg2 != "": @@ -443,7 +443,7 @@ def extendsfrom(item: Dict[str, Any], ex: List[Dict[str, Any]]) -> None: desc = i["doc"] - rfrg = schema.avro_name(i["name"]) + rfrg = schema.avro_field_name(i["name"]) tr = """
{}
@@ -472,7 +472,7 @@ def extendsfrom(item: Dict[str, Any], ex: List[Dict[str, Any]]) -> None: for e in ex: for i in e.get("symbols", []): doc += "" - efrg = schema.avro_name(i) + efrg = schema.avro_field_name(i) doc += "{}{}".format( efrg, enumDesc.get(efrg, "") ) diff --git a/schema_salad/python_codegen.py b/schema_salad/python_codegen.py index 8fd79ae1..71150ada 100644 --- a/schema_salad/python_codegen.py +++ b/schema_salad/python_codegen.py @@ -14,7 +14,7 @@ from pkg_resources import resource_stream -from . import schema +from . import schema, validate from .codegen_base import CodeGenBase, TypeDef from .exceptions import SchemaException from .schema import shortname @@ -56,7 +56,9 @@ def __init__(self, out: IO[str], copyright: Optional[str]) -> None: @staticmethod def safe_name(name): # type: (str) -> str - avn = schema.avro_name(name) + avn = schema.avro_field_name(name) + if avn.startswith("anon."): + avn = avn[5:] if avn in ("class", "in"): # reserved words avn = avn + "_" @@ -498,8 +500,8 @@ def typedsl_loader(self, inner, ref_scope): # type: (TypeDef, Union[int, None]) -> TypeDef return self.declare_type( TypeDef( - f"typedsl_{inner.name}_{ref_scope}", - f"_TypeDSLLoader({inner.name}, {ref_scope})", + f"typedsl_{self.safe_name(inner.name)}_{ref_scope}", + f"_TypeDSLLoader({self.safe_name(inner.name)}, {ref_scope})", ) ) diff --git a/schema_salad/schema.py b/schema_salad/schema.py index 23874d09..cf5e03ad 100644 --- a/schema_salad/schema.py +++ b/schema_salad/schema.py @@ -376,13 +376,13 @@ def validate_doc( except ClassValidationException as exc1: errors = [ ClassValidationException( - f"tried `{name}` but", sourceline, [exc1] + f"tried `{validate.friendly(name)}` but", sourceline, [exc1] ) ] break except ValidationException as exc2: errors.append( - ValidationException(f"tried `{name}` but", sourceline, [exc2]) + ValidationException(f"tried `{validate.friendly(name)}` but", sourceline, [exc2]) ) objerr = "Invalid" diff --git a/schema_salad/validate.py b/schema_salad/validate.py index d5cdb57c..71c4cb84 100644 --- a/schema_salad/validate.py +++ b/schema_salad/validate.py @@ -41,10 +41,12 @@ def validate( LONG_MIN_VALUE = -(1 << 63) LONG_MAX_VALUE = (1 << 63) - 1 +def avro_shortname(name: str) -> str: + return name.split(".")[-1] def friendly(v): # type: (Any) -> Any if isinstance(v, avro.schema.NamedSchema): - return v.name + return avro_shortname(v.name) if isinstance(v, avro.schema.ArraySchema): return "array of <{}>".format(friendly(v.items)) elif isinstance(v, avro.schema.PrimitiveSchema): @@ -52,7 +54,7 @@ def friendly(v): # type: (Any) -> Any elif isinstance(v, avro.schema.UnionSchema): return " or ".join([friendly(s) for s in v.schemas]) else: - return v + return avro_shortname(v) def vpformat(datum): # type: (Any) -> str @@ -139,7 +141,7 @@ def validate_ex( "value is a {} but expected a string".format(type(datum).__name__) ) return False - if expected_schema.name == "Expression": + if expected_schema.name == "w3id.org.cwl.cwl.Expression": if "$(" in datum or "${" in datum: return True if raise_ex: @@ -279,7 +281,7 @@ def validate_ex( raise ValidationException(f"Missing '{f.name}' field") else: return False - if expected_schema.name != d: + if avro_shortname(expected_schema.name) != d: if raise_ex: raise ValidationException( "Expected class '{}' but this is '{}'".format( diff --git a/setup.py b/setup.py index e9054760..5e38e87f 100644 --- a/setup.py +++ b/setup.py @@ -98,7 +98,7 @@ setup( name="schema-salad", - version="7.1", # update the VERSION prefix in the Makefile as well 🙂 + version="8.0", # update the VERSION prefix in the Makefile as well 🙂 description="Schema Annotations for Linked Avro Data (SALAD)", long_description=open(README).read(), long_description_content_type="text/x-rst", From 353b8b1cf08604cb39ee933210d41e37d5cd4a9e Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 23 Jun 2021 17:51:05 -0400 Subject: [PATCH 3/9] mypy & format fixes --- schema_salad/schema.py | 28 +++++++++++++++++++++------- schema_salad/validate.py | 2 ++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/schema_salad/schema.py b/schema_salad/schema.py index cf5e03ad..55a3323e 100644 --- a/schema_salad/schema.py +++ b/schema_salad/schema.py @@ -382,7 +382,9 @@ def validate_doc( break except ValidationException as exc2: errors.append( - ValidationException(f"tried `{validate.friendly(name)}` but", sourceline, [exc2]) + ValidationException( + f"tried `{validate.friendly(name)}` but", sourceline, [exc2] + ) ) objerr = "Invalid" @@ -410,7 +412,9 @@ def get_anon_name( if rec["type"] in ("enum", saladp + "enum"): for sym in rec["symbols"]: anon_name += sym - return "anon.enum_" + hashlib.sha1(anon_name.encode("UTF-8")).hexdigest() # nosec + return ( + "anon.enum_" + hashlib.sha1(anon_name.encode("UTF-8")).hexdigest() + ) # nosec if rec["type"] in ("record", saladp + "record"): for field in rec["fields"]: if isinstance(field, Mapping): @@ -488,6 +492,7 @@ def replace_type( found.add(items) return items + primitives = { "http://www.w3.org/2001/XMLSchema#string": "string", "http://www.w3.org/2001/XMLSchema#boolean": "boolean", @@ -498,9 +503,10 @@ def replace_type( saladp + "null": "null", saladp + "enum": "enum", saladp + "array": "array", - saladp + "record": "record" + saladp + "record": "record", } + def avro_type_name(url: str) -> str: """ Turn a URL into an Avro-safe name. @@ -546,7 +552,7 @@ def make_valid_avro( alltypes: Dict[str, Dict[str, Any]], found: Set[str], union: bool = False, - field: bool = False + fielddef: bool = False, ) -> Union[ Avro, MutableMapping[str, str], str, List[Union[Any, MutableMapping[str, str], str]] ]: @@ -555,7 +561,7 @@ def make_valid_avro( if isinstance(items, MutableMapping): avro = copy.copy(items) if avro.get("name") and avro.get("inVocab", True): - if field: + if fielddef: avro["name"] = avro_field_name(avro["name"]) else: avro["name"] = avro_type_name(avro["name"]) @@ -573,14 +579,22 @@ def make_valid_avro( found.add(avro["name"]) for field in ("type", "items", "values", "fields"): if field in avro: - avro[field] = make_valid_avro(avro[field], alltypes, found, union=True, field=(field=="fields")) + avro[field] = make_valid_avro( + avro[field], + alltypes, + found, + union=True, + fielddef=(field == "fields"), + ) if "symbols" in avro: avro["symbols"] = [avro_field_name(sym) for sym in avro["symbols"]] return avro if isinstance(items, MutableSequence): ret = [] for i in items: - ret.append(make_valid_avro(i, alltypes, found, union=union, field=field)) + ret.append( + make_valid_avro(i, alltypes, found, union=union, fielddef=fielddef) + ) return ret if union and isinstance(items, str): if items in alltypes and avro_type_name(items) not in found: diff --git a/schema_salad/validate.py b/schema_salad/validate.py index 71c4cb84..dd052ed3 100644 --- a/schema_salad/validate.py +++ b/schema_salad/validate.py @@ -41,9 +41,11 @@ def validate( LONG_MIN_VALUE = -(1 << 63) LONG_MAX_VALUE = (1 << 63) - 1 + def avro_shortname(name: str) -> str: return name.split(".")[-1] + def friendly(v): # type: (Any) -> Any if isinstance(v, avro.schema.NamedSchema): return avro_shortname(v.name) From 5bc914d791e508932ee5dc56f2c733d3056fc3af Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Thu, 24 Jun 2021 10:53:35 +0200 Subject: [PATCH 4/9] misc cleanups --- schema_salad/python_codegen.py | 2 +- schema_salad/schema.py | 6 +++--- schema_salad/validate.py | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/schema_salad/python_codegen.py b/schema_salad/python_codegen.py index 71150ada..2d24d09e 100644 --- a/schema_salad/python_codegen.py +++ b/schema_salad/python_codegen.py @@ -14,7 +14,7 @@ from pkg_resources import resource_stream -from . import schema, validate +from . import schema from .codegen_base import CodeGenBase, TypeDef from .exceptions import SchemaException from .schema import shortname diff --git a/schema_salad/schema.py b/schema_salad/schema.py index 55a3323e..2bffc85e 100644 --- a/schema_salad/schema.py +++ b/schema_salad/schema.py @@ -17,7 +17,7 @@ Union, cast, ) -from urllib.parse import urldefrag, urlparse +from urllib.parse import urlparse from pkg_resources import resource_stream from ruamel.yaml.comments import CommentedMap, CommentedSeq @@ -413,8 +413,8 @@ def get_anon_name( for sym in rec["symbols"]: anon_name += sym return ( - "anon.enum_" + hashlib.sha1(anon_name.encode("UTF-8")).hexdigest() - ) # nosec + "anon.enum_" + hashlib.sha1(anon_name.encode("UTF-8")).hexdigest() # nosec + ) if rec["type"] in ("record", saladp + "record"): for field in rec["fields"]: if isinstance(field, Mapping): diff --git a/schema_salad/validate.py b/schema_salad/validate.py index dd052ed3..a3a737f3 100644 --- a/schema_salad/validate.py +++ b/schema_salad/validate.py @@ -43,6 +43,7 @@ def validate( def avro_shortname(name: str) -> str: + """Produce an avro friendly short name.""" return name.split(".")[-1] From f9967f5136979940f73782eb60be12fc25f3bb24 Mon Sep 17 00:00:00 2001 From: Rupert Nash Date: Wed, 2 Dec 2020 10:44:20 +0000 Subject: [PATCH 5/9] Simple (failing) unit test that for issue #326 --- schema_salad/tests/test_avro_names.py | 11 ++++++++++ .../tests/test_schema/avro_naming.yml | 22 +++++++++++++++++++ .../tests/test_schema/avro_naming_base.yml | 22 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 schema_salad/tests/test_avro_names.py create mode 100644 schema_salad/tests/test_schema/avro_naming.yml create mode 100644 schema_salad/tests/test_schema/avro_naming_base.yml diff --git a/schema_salad/tests/test_avro_names.py b/schema_salad/tests/test_avro_names.py new file mode 100644 index 00000000..ff6a1328 --- /dev/null +++ b/schema_salad/tests/test_avro_names.py @@ -0,0 +1,11 @@ +from schema_salad.avro.schema import Names, SchemaParseException +from schema_salad.ref_resolver import Loader +from schema_salad.schema import load_and_validate, load_schema + +from .util import get_data + +def test_avro_loading(): + path = get_data("tests/test_schema/avro_naming.yml") + assert path + document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(path) + diff --git a/schema_salad/tests/test_schema/avro_naming.yml b/schema_salad/tests/test_schema/avro_naming.yml new file mode 100644 index 00000000..efeb89b5 --- /dev/null +++ b/schema_salad/tests/test_schema/avro_naming.yml @@ -0,0 +1,22 @@ +$base: "https://example.com/derived_schema#" + +$namespaces: + bs: "https://example.com/base_schema#" + +$graph: + +- $import: avro_naming_base.yml + +- name: ExtendedThing + type: record + doc: | + A refinement of the base schema's arbitrary abstract thing, + that allows one of the base schema's types as a field. + inVocab: false + extends: bs:AbstractThing + fields: + field_one: + type: + type: array + items: [string, bs:RealThing] + diff --git a/schema_salad/tests/test_schema/avro_naming_base.yml b/schema_salad/tests/test_schema/avro_naming_base.yml new file mode 100644 index 00000000..faa50eda --- /dev/null +++ b/schema_salad/tests/test_schema/avro_naming_base.yml @@ -0,0 +1,22 @@ +$base: "https://example.com/base_schema#" + +$namespaces: + bs: "https://example.com/base_schema#" + +$graph: + +- $import: "metaschema_base.yml" + +- type: enum + name: RealThing + doc: | + This is an arbitrary thing from a base schema that might be used. + symbols: + - bs:Placeholder + +- type: record + name: AbstractThing + abstract: true + doc: | + This is an arbitrary abstract thing from a base schema that might + be extended. From a33519beeace92927d4cd269411f113c2d2b1980 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Thu, 24 Jun 2021 11:19:51 +0200 Subject: [PATCH 6/9] cleanups --- schema_salad/tests/test_avro_names.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/schema_salad/tests/test_avro_names.py b/schema_salad/tests/test_avro_names.py index ff6a1328..36e67eb4 100644 --- a/schema_salad/tests/test_avro_names.py +++ b/schema_salad/tests/test_avro_names.py @@ -1,11 +1,9 @@ -from schema_salad.avro.schema import Names, SchemaParseException -from schema_salad.ref_resolver import Loader -from schema_salad.schema import load_and_validate, load_schema +from schema_salad.schema import load_schema from .util import get_data -def test_avro_loading(): + +def test_avro_loading() -> None: path = get_data("tests/test_schema/avro_naming.yml") assert path document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(path) - From c88c6ad82217a50572271cd58ad67dac31d0615f Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Thu, 24 Jun 2021 11:22:12 +0200 Subject: [PATCH 7/9] update version in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dba7602f..4188e361 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ COVBASE=coverage run --append # Updating the Major & Minor version below? # Don't forget to update setup.py as well -VERSION=7.1.$(shell date +%Y%m%d%H%M%S --utc --date=`git log --first-parent \ +VERSION=8.0.$(shell date +%Y%m%d%H%M%S --utc --date=`git log --first-parent \ --max-count=1 --format=format:%cI`) ## all : default task From bec3d7fed260a3932fc1122607b5a1567b8fca39 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Thu, 24 Jun 2021 11:30:14 +0200 Subject: [PATCH 8/9] stop CI testing on MS Windows --- README.rst | 4 +--- appveyor.yml | 51 --------------------------------------------------- setup.py | 1 - 3 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 appveyor.yml diff --git a/README.rst b/README.rst index e1a17d89..d4287705 100644 --- a/README.rst +++ b/README.rst @@ -1,9 +1,7 @@ -|Linux Build Status| |Windows Build status| |Code coverage| |CII Best Practices| +|Linux Build Status| |Code coverage| |CII Best Practices| .. |Linux Build Status| image:: https://github.com/common-workflow-language/schema-salad/actions/workflows/ci-tests.yml/badge.svg?branch=main :target: https://github.com/common-workflow-language/schema-salad/actions/workflows/ci-tests.yml -.. |Windows Build status| image:: https://img.shields.io/appveyor/ci/mr-c/schema-salad/main.svg?label=windows%20build - :target: https://ci.appveyor.com/project/mr-c/schema-salad/branch/main .. |Code coverage| image:: https://codecov.io/gh/common-workflow-language/schema_salad/branch/main/graph/badge.svg :target: https://codecov.io/gh/common-workflow-language/schema_salad .. |CII Best Practices| image:: https://bestpractices.coreinfrastructure.org/projects/1867/badge diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 42abbf33..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,51 +0,0 @@ -version: .{build}-{branch} -image: Visual Studio 2019 - -cache: - - '%LOCALAPPDATA%\pip\Cache' - -environment: - - SYSTEMROOT: "C:\\WINDOWS" - - matrix: - - PYTHON: "C:\\Python36-x64" - PYTHON_VERSION: "3.6.x" - PYTHON_ARCH: "64" - - - PYTHON: "C:\\Python37-x64" - PYTHON_VERSION: "3.7.x" - PYTHON_ARCH: "64" - - - PYTHON: "C:\\Python38-x64" - PYTHON_VERSION: "3.8.x" - PYTHON_ARCH: "64" - - - PYTHON: "C:\\Python39-x64" - PYTHON_VERSION: "3.9.x" - PYTHON_ARCH: "64" - -install: - - "set PATH=%PYTHON%\\Scripts;%PATH%" - - "%PYTHON%\\python.exe -m pip install -U pip setuptools^>=20.3 wheel" - - "%PYTHON%\\python.exe -m pip install -U -rtest-requirements.txt codecov" - - "%PYTHON%\\python.exe -m pip install -rrequirements.txt" - -build_script: - - "%PYTHON%\\python.exe -m pip install -e ." - -test_script: - - | - %PYTHON%\\python.exe -m pytest --cov --cov-config=.coveragerc --cov-report= -n auto --strict-markers -p no:cacheprovider -p no:stepwise --junit-xml=tests.xml - - "%PYTHON%\\python.exe -m coverage report" - - "%PYTHON%\\python.exe -m coverage xml" - - "%PYTHON%\\python.exe -m codecov --file coverage.xml" - -on_finish: - - ps: | - $wc = New-Object 'System.Net.WebClient' - $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($Env:APPVEYOR_JOB_ID)", (Resolve-Path .\tests.xml)) - -branches: - only: - - main diff --git a/setup.py b/setup.py index 5e38e87f..7f49fa71 100644 --- a/setup.py +++ b/setup.py @@ -131,7 +131,6 @@ "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX", "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", "Development Status :: 5 - Production/Stable", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", From c1d0e203ad58681fd86714e7059202ff1b001246 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Thu, 24 Jun 2021 11:33:23 +0200 Subject: [PATCH 9/9] add docstrings for new test --- schema_salad/tests/test_avro_names.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/schema_salad/tests/test_avro_names.py b/schema_salad/tests/test_avro_names.py index 36e67eb4..2ce21897 100644 --- a/schema_salad/tests/test_avro_names.py +++ b/schema_salad/tests/test_avro_names.py @@ -1,9 +1,11 @@ +"""Avro related tests.""" from schema_salad.schema import load_schema from .util import get_data def test_avro_loading() -> None: + """Confirm conversion of SALAD style names to avro.""" path = get_data("tests/test_schema/avro_naming.yml") assert path document_loader, avsc_names, schema_metadata, metaschema_loader = load_schema(path)