Skip to content

Commit

Permalink
Adding symbolic link to openapi schema within package
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Gonzalez-Martin committed Apr 14, 2023
1 parent 3cec437 commit aef7901
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include openapi/*.json
include mlserver/rest/openapi/*.json
3 changes: 3 additions & 0 deletions mlserver/rest/openapi/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
1 change: 1 addition & 0 deletions mlserver/rest/openapi/dataplane.json
1 change: 1 addition & 0 deletions mlserver/rest/openapi/model_repository.json
4 changes: 1 addition & 3 deletions mlserver/rest/openapi.py → mlserver/rest/openapi/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())


Expand Down
Empty file added tests/rest/openapi/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit aef7901

Please sign in to comment.