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
1 change: 1 addition & 0 deletions inference_schema/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

INPUT_SCHEMA_ATTR = "input_schema"
OUTPUT_SCHEMA_ATTR = "output_schema"
ALL_SUPPORTED_VERSIONS = ['2.0', '3.0', '3.1']
16 changes: 13 additions & 3 deletions inference_schema/schema_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import copy

from inference_schema._constants import INPUT_SCHEMA_ATTR, OUTPUT_SCHEMA_ATTR
from inference_schema._constants import INPUT_SCHEMA_ATTR, OUTPUT_SCHEMA_ATTR, ALL_SUPPORTED_VERSIONS

__functions_schema__ = {}
__versions__ = {}
Expand Down Expand Up @@ -38,7 +38,10 @@ def get_output_schema(func):

def get_supported_versions(func):
"""
Extract supported swagger versions from the decorated function.
Extract supported swagger versions from the decorated function. This will return the min set of supported
versions between any decorators provided to the specified function. This could result in an empty list
(if there is no overlap in versions between decorators), and it is ultimately up to the caller to decide
how that case should be handled when creating the swagger document.

:param func:
:type func: function | FunctionWrapper
Expand All @@ -50,7 +53,14 @@ def get_supported_versions(func):

input_versions = __versions__.get(func_base_name, {}).get(INPUT_SCHEMA_ATTR, {}).get('versions', [])
output_versions = __versions__.get(func_base_name, {}).get(OUTPUT_SCHEMA_ATTR, {}).get('versions', [])
set_intersection = set(input_versions) & set(output_versions)
if input_versions and output_versions:
set_intersection = set(input_versions) & set(output_versions)
elif input_versions:
set_intersection = set(input_versions)
elif output_versions:
set_intersection = set(output_versions)
else:
set_intersection = ALL_SUPPORTED_VERSIONS
return sorted(list(set_intersection))


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
EXTRAS = {
'numpy-support': ['numpy>=1.13.0'],
'pandas-support': ['pandas>=0.20.2'],
'pyspark-support': ['pyspark==2.3.2']
'pyspark-support': ['pyspark>=2.3.2']
}

CLASSIFIERS = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pytz>=2017.2
wrapt>=1.11.1,<=1.12.1
numpy>=1.13.0
pandas>=0.20.2
pyspark==2.3.2
pyspark>=2.3.2
pytest