Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DEVPKGS=-rdev-requirements.txt -rtest-requirements.txt -rmypy-requirements.txt -
COVBASE=coverage run --append
PYTEST_EXTRA ?=

VERSION=8.8.$(shell date +%Y%m%d%H%M%S --utc --date=`git log --first-parent \
VERSION=8.9.$(shell date +%Y%m%d%H%M%S --utc --date=`git log --first-parent \
--max-count=1 --format=format:%cI`)

## all : default task (install schema-salad in dev mode)
Expand Down
10 changes: 7 additions & 3 deletions schema_salad/ref_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import requests
from cachecontrol.caches import SeparateBodyFileCache
from cachecontrol.wrapper import CacheControl
from mypy_extensions import mypyc_attr
from rdflib.exceptions import ParserError
from rdflib.graph import Graph
from rdflib.namespace import OWL, RDF, RDFS
Expand Down Expand Up @@ -134,6 +135,11 @@ def SubLoader(loader: "Loader") -> "Loader":
)


def _url_norm(url: str) -> str:
return urllib.parse.urlsplit(url).geturl()


@mypyc_attr(allow_interpreted_subclasses=True)
class Loader:
def __init__(
self,
Expand All @@ -150,9 +156,7 @@ def __init__(
doc_cache: Union[str, bool] = True,
salad_version: Optional[str] = None,
) -> None:
self.idx: IdxType = (
NormDict(lambda url: urllib.parse.urlsplit(url).geturl()) if idx is None else idx
)
self.idx: IdxType = NormDict(_url_norm) if idx is None else idx

self.ctx: ContextType = {}
self.graph = schemagraph if schemagraph is not None else Graph()
Expand Down
10 changes: 9 additions & 1 deletion schema_salad/tests/test_pickling.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pickle
from pathlib import Path

from schema_salad import schema
from schema_salad import ref_resolver, schema
from schema_salad.avro.schema import Names, RecordSchema

from .util import get_data_uri
Expand All @@ -21,6 +21,14 @@ def test_recordschema_pickle() -> None:
print(pickle.loads(d))


def test_loader_pickle() -> None:
"""Pickle a Loader."""
loader = ref_resolver.Loader({})
print(loader)
d = pickle.dumps(loader)
print(pickle.loads(d))


def test_extend_and_specialize_enums(tmp_path: Path) -> None:
cwl_file_uri = get_data_uri("tests/test_schema/CommonWorkflowLanguage.yml")
_, avsc_names, _, _ = schema.load_schema(cwl_file_uri)
Expand Down
1 change: 0 additions & 1 deletion schema_salad/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def avro_type_name(url: str) -> str:
Extract either the last part of the URL fragment past the slash, otherwise
the whole fragment.
"""
global primitives

if url in primitives:
return primitives[url]
Expand Down