Skip to content

Commit

Permalink
Merge pull request #600 from spacetelescope/v2.1.x
Browse files Browse the repository at this point in the history
Release candidate for v2.1.2
  • Loading branch information
drdavella authored Nov 14, 2018
2 parents ac3fef1 + 8000459 commit e46a912
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.1.2 (2018-11-13)
------------------

- Make sure that all types corresponding to core tags are added to the type
index before any others. This fixes a bug that was related to the way that
subclass tags were overwritten by external extensions. [#598]

2.1.1 (2018-11-01)
------------------

Expand Down
12 changes: 9 additions & 3 deletions asdf/asdftypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def __init__(self, version, index):
self._extensions_used = set()

try:
version_map = get_version_map(self._version)['tags']
version_map = get_version_map(self._version)
core_version_map = version_map['core']
standard_version_map = version_map['standard']
except ValueError:
raise ValueError(
"Don't know how to write out ASDF version {0}".format(
Expand Down Expand Up @@ -152,8 +154,12 @@ def add_by_tag(name, version):
self._type_by_name[name] = asdftype
add_all_types(asdftype)

# Process all types defined in the ASDF version map
for name, _version in version_map.items():
# Process all types defined in the ASDF version map. It is important to
# make sure that tags that are associated with the core part of the
# standard are processed first in order to handle subclasses properly.
for name, _version in core_version_map.items():
add_by_tag(name, AsdfVersion(_version))
for name, _version in standard_version_map.items():
add_by_tag(name, AsdfVersion(_version))

# Now add any extension types that aren't known to the ASDF standard.
Expand Down
19 changes: 16 additions & 3 deletions asdf/tests/schema_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,22 @@ def pytest_addoption(parser):
"asdf_schema_root", "Root path indicating where schemas are stored")
parser.addini(
"asdf_schema_skip_names", "Base names of files to skip in schema tests")
parser.addini(
"asdf_schema_skip_examples",
"Base names of schemas whose examples should not be tested")


class AsdfSchemaFile(pytest.File):

def __init__(self, *args, skip_examples=False, **kwargs):
super().__init__(*args, **kwargs)
self.skip_examples = skip_examples

def collect(self):
yield AsdfSchemaItem(str(self.fspath), self)
for example in self.find_examples_in_schema():
yield AsdfSchemaExampleItem(str(self.fspath), self, example)
if not self.skip_examples:
for example in self.find_examples_in_schema():
yield AsdfSchemaExampleItem(str(self.fspath), self, example)

def find_examples_in_schema(self):
"""Returns generator for all examples in schema at given path"""
Expand Down Expand Up @@ -186,6 +195,7 @@ def pytest_collect_file(path, parent):
return

skip_names = parent.config.getini('asdf_schema_skip_names')
skip_examples = parent.config.getini('asdf_schema_skip_examples')

schema_roots = [os.path.join(str(parent.config.rootdir), root)
for root in schema_roots]
Expand All @@ -195,6 +205,9 @@ def pytest_collect_file(path, parent):

for root in schema_roots:
if str(path).startswith(root) and path.purebasename not in skip_names:
return AsdfSchemaFile(path, parent)
skip = path.purebasename in skip_examples
return AsdfSchemaFile(
path, parent,
skip_examples=(path.purebasename in skip_examples))

return None
9 changes: 8 additions & 1 deletion asdf/tests/test_asdftypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io
import os
import sys

import pytest

import asdf
Expand Down Expand Up @@ -219,7 +220,13 @@ def test_versioned_writing(monkeypatch):
'tags': {
'tag:stsci.edu:asdf/core/complex': '42.0.0',
'tag:stscu.edu:asdf/core/asdf': '1.0.0'
}
},
# We need to insert these explicitly since we're monkeypatching
'core': {
'tag:stsci.edu:asdf/core/complex': '42.0.0',
'tag:stscu.edu:asdf/core/asdf': '1.0.0'
},
'standard': {}
})

# Add bogus version to supported versions
Expand Down
12 changes: 11 additions & 1 deletion asdf/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
This module deals with things that change between different versions
of the ASDF spec.
"""
from functools import total_ordering

import yaml
from functools import total_ordering

if getattr(yaml, '__with_libyaml__', None): # pragma: no cover
_yaml_base_loader = yaml.CSafeLoader
Expand Down Expand Up @@ -39,6 +39,16 @@ def get_version_map(version):
except Exception:
raise ValueError(
"Could not load version map for version {0}".format(version))

# Separate the core tags from the rest of the standard for convenience
version_map['core'] = {}
version_map['standard'] = {}
for name, version in version_map['tags'].items():
if name.startswith('tag:stsci.edu:asdf/core'):
version_map['core'][name] = version
else:
version_map['standard'][name] = version

_version_map[version] = version_map

return version_map
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ open_files_ignore = test.fits asdf.fits
# Account for both the astropy test runner case and the native pytest case
asdf_schema_root = asdf-standard/schemas asdf/schemas
asdf_schema_skip_names = asdf-schema-1.0.0 draft-01
asdf_schema_skip_examples = domain-1.0.0
#addopts = --doctest-rst

[ah_bootstrap]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
builtins._PACKAGE_NAME_ = PACKAGE_NAME

# VERSION should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
VERSION = '2.1.1'
VERSION = '2.1.2'

# Indicates if this version is a release version
RELEASE = 'dev' not in VERSION
Expand Down

0 comments on commit e46a912

Please sign in to comment.