From 75cc41733ee8a848dfffdd1bff9fefaa77d10529 Mon Sep 17 00:00:00 2001 From: Adrian Gonzalez-Martin Date: Fri, 14 Apr 2023 09:19:02 +0200 Subject: [PATCH] Adding symbolic link to openapi schema within package --- MANIFEST.in | 2 +- mlserver/rest/openapi/__init__.py | 3 +++ mlserver/rest/openapi/dataplane.json | 1 + mlserver/rest/openapi/model_repository.json | 1 + mlserver/rest/{openapi.py => openapi/schema.py} | 4 +--- tests/rest/openapi/__init__.py | 0 tests/rest/{test_openapi.py => openapi/test_schema.py} | 2 +- 7 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 mlserver/rest/openapi/__init__.py create mode 120000 mlserver/rest/openapi/dataplane.json create mode 120000 mlserver/rest/openapi/model_repository.json rename mlserver/rest/{openapi.py => openapi/schema.py} (94%) create mode 100644 tests/rest/openapi/__init__.py rename tests/rest/{test_openapi.py => openapi/test_schema.py} (95%) diff --git a/MANIFEST.in b/MANIFEST.in index c8964f1dc..80bcc2ff9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include openapi/*.json +include mlserver/rest/openapi/*.json diff --git a/mlserver/rest/openapi/__init__.py b/mlserver/rest/openapi/__init__.py new file mode 100644 index 000000000..92cb17843 --- /dev/null +++ b/mlserver/rest/openapi/__init__.py @@ -0,0 +1,3 @@ +from .schema import get_openapi_schema, get_model_schema, get_model_schema_uri + +__all__ = ["get_openapi_schema", "get_model_schema", "get_model_schema_uri"] diff --git a/mlserver/rest/openapi/dataplane.json b/mlserver/rest/openapi/dataplane.json new file mode 120000 index 000000000..d0c1b27f6 --- /dev/null +++ b/mlserver/rest/openapi/dataplane.json @@ -0,0 +1 @@ +/home/agm/Seldon/mlserver/openapi/dataplane.json \ No newline at end of file diff --git a/mlserver/rest/openapi/model_repository.json b/mlserver/rest/openapi/model_repository.json new file mode 120000 index 000000000..1e45db458 --- /dev/null +++ b/mlserver/rest/openapi/model_repository.json @@ -0,0 +1 @@ +/home/agm/Seldon/mlserver/openapi/model_repository.json \ No newline at end of file diff --git a/mlserver/rest/openapi.py b/mlserver/rest/openapi/schema.py similarity index 94% rename from mlserver/rest/openapi.py rename to mlserver/rest/openapi/schema.py index ed85b3dec..ec04abbce 100644 --- a/mlserver/rest/openapi.py +++ b/mlserver/rest/openapi/schema.py @@ -4,15 +4,13 @@ from typing import Optional, Tuple from importlib_resources import files -OPENAPI_SCHEMA_RELATIVE_PATH = "../openapi/dataplane.json" MODEL_NAME_PARAMETER = "model_name" MODEL_VERSION_PARAMETER = "model_version" @lru_cache def get_openapi_schema() -> dict: - mlserver_package = __package__.split(".")[0] - openapi_schema_path = files(mlserver_package).joinpath(OPENAPI_SCHEMA_RELATIVE_PATH) + openapi_schema_path = files(__package__).joinpath("dataplane.json") return orjson.loads(openapi_schema_path.read_bytes()) diff --git a/tests/rest/openapi/__init__.py b/tests/rest/openapi/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/rest/test_openapi.py b/tests/rest/openapi/test_schema.py similarity index 95% rename from tests/rest/test_openapi.py rename to tests/rest/openapi/test_schema.py index 8d2d2c960..02a8dbd1a 100644 --- a/tests/rest/test_openapi.py +++ b/tests/rest/openapi/test_schema.py @@ -2,7 +2,7 @@ from typing import Optional -from mlserver.rest.openapi import ( +from mlserver.rest.openapi.schema import ( get_openapi_schema, get_model_schema, MODEL_VERSION_PARAMETER,