# Path: onecodex/vendored/potion_client/resource.py
# class Reference(collections.Mapping):
#     """
# 
#     This implementation makes the assumption that a {$ref} object always points to an object, never an array or
#     any of the other types.
#     """
#     _client = None
#     __properties = None
# 
#     def __init__(self, uri, client=None):
#         self._status = None
#         self._uri = uri
#         self.__properties = {'$uri': uri}
#         if client is not None:
#             self._client = client
# 
#     @classmethod
#     def _resolve(self, client, uri):
#         return client.fetch(uri, uri_to_instance=False)
# 
#     @property
#     def _properties(self):
#         if self._uri and self._status is None:
#             self.__properties = self._resolve(self._client, self._uri)
#             self._status = 200
#         return self.__properties
# 
#     @_properties.setter
#     def _properties(self, value):
#         self.__properties = value
#         self._status = 200
# 
#     def __contains__(self, item):
#         return item in self._properties
# 
#     def __getitem__(self, item):
#         return self._properties[item]
# 
#     def __iter__(self):
#         return iter(self._properties)
# 
#     def __len__(self):
#         return len(self._properties)
# 
#     def __repr__(self):
#         return '{cls}({uri})'.format(cls=self.__class__.__name__,
#                                      uri=repr(self._uri))


import calendar
import six
                import pandas as pd
from functools import partial
    from simplejson import JSONEncoder, JSONDecoder
    from json import JSONEncoder, JSONDecoder
from datetime import date, datetime
from six.moves.urllib.parse import urljoin
from .resource import Reference
    from datetime import timezone
    from datetime import tzinfo, timedelta
        if isinstance(o, dict):
            if len(o) == 1:
                if "$date" in o:
                    return datetime.fromtimestamp(o["$date"] / 1000.0, timezone.utc)
                if "$ref" in o and isinstance(o["$ref"], six.string_types):
                    reference = o["$ref"]
                    if reference.startswith("#"):
                        reference = urljoin(self.referrer, reference, True)
                    return self.client.instance(reference)
            elif self.uri_to_instance and "$uri" in o and isinstance(o["$uri"], six.string_types):
                # TODO handle or ("$id" in o and "$type" in o)
                if depth == 0:
                    instance = self.client.instance(o['$uri'], default=self.default_instance)
                else:
                    instance = self.client.instance(o['$uri'])

                instance._status = 200
                instance._properties.update({k: self._decode(v, depth + 1) for k, v in o.items()})
                return instance

            return {k: self._decode(v, depth + 1) for k, v in o.items()}
        if isinstance(o, (list, tuple)):
            return [self._decode(v, depth + 1) for v in o]
        return o

    def decode(self, s, *args, **kwargs):
        o = JSONDecoder.decode(self, s, *args, **kwargs)
        return self._decode(o)



# Path: onecodex/vendored/potion_client/resource.py
# class Reference(collections.Mapping):
#     """
# 
#     This implementation makes the assumption that a {$ref} object always points to an object, never an array or
#     any of the other types.
#     """
#     _client = None
#     __properties = None
# 
#     def __init__(self, uri, client=None):
#         self._status = None
#         self._uri = uri
#         self.__properties = {'$uri': uri}
#         if client is not None:
#             self._client = client
# 
#     @classmethod
#     def _resolve(self, client, uri):
#         return client.fetch(uri, uri_to_instance=False)
# 
#     @property
#     def _properties(self):
#         if self._uri and self._status is None:
#             self.__properties = self._resolve(self._client, self._uri)
#             self._status = 200
#         return self.__properties
# 
#     @_properties.setter
#     def _properties(self, value):
#         self.__properties = value
#         self._status = 200
# 
#     def __contains__(self, item):
#         return item in self._properties
# 
#     def __getitem__(self, item):
#         return self._properties[item]
# 
#     def __iter__(self):
#         return iter(self._properties)
# 
#     def __len__(self):
#         return len(self._properties)
# 
#     def __repr__(self):
#         return '{cls}({uri})'.format(cls=self.__class__.__name__,
#                                      uri=repr(self._uri))


# Path: onecodex/vendored/potion_client/converter.py
import calendar
import six
                import pandas as pd
from functools import partial
    from simplejson import JSONEncoder, JSONDecoder
    from json import JSONEncoder, JSONDecoder
from datetime import date, datetime
from six.moves.urllib.parse import urljoin
from .resource import Reference
    from datetime import timezone
    from datetime import tzinfo, timedelta

        if isinstance(o, dict):
            if len(o) == 1:
                if "$date" in o:
                    return datetime.fromtimestamp(o["$date"] / 1000.0, timezone.utc)
                if "$ref" in o and isinstance(o["$ref"], six.string_types):
                    reference = o["$ref"]
                    if reference.startswith("#"):
                        reference = urljoin(self.referrer, reference, True)
                    return self.client.instance(reference)
            elif self.uri_to_instance and "$uri" in o and isinstance(o["$uri"], six.string_types):
                # TODO handle or ("$id" in o and "$type" in o)
                if depth == 0:
                    instance = self.client.instance(o['$uri'], default=self.default_instance)
                else:
                    instance = self.client.instance(o['$uri'])

                instance._status = 200
                instance._properties.update({k: self._decode(v, depth + 1) for k, v in o.items()})
                return instance

            return {k: self._decode(v, depth + 1) for k, v in o.items()}
        if isinstance(o, (list, tuple)):
            return [self._decode(v, depth + 1) for v in o]
        return o

    def decode(self, s, *args, **kwargs):
        o = JSONDecoder.decode(self, s, *args, **kwargs)
        return self._decode(o)



class JSONSchemaReference(Reference):