Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
  • Loading branch information
aarnphm committed Nov 21, 2022
1 parent 388340e commit ca27fc5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -236,6 +236,7 @@ exclude = '''
| src/bentoml/grpc/v1
| tests/proto
| grpc-client/thirdparty
| grpc-client/bentoml
)/
| src/bentoml/_version.py
)
Expand Down
8 changes: 1 addition & 7 deletions src/bentoml/_internal/configuration/__init__.py
Expand Up @@ -13,18 +13,12 @@
from ..._version import __version__
from ..._version import __version_tuple__
except ImportError:
<<<<<<< HEAD
# Since we aren't VCS _version.py, which is generated by setuptools_scm
# BentoML uses setuptools_scm 'post-release' for version scheme
from setuptools_scm import get_version

__version__ = get_version(version_scheme="post-release")
__version_tuple__ = (0, 0, 0, "dirty")
=======
# broken installation.
__version__ = "unknown"
__version_tuple__ = (0, 0, 0, "unknown")
>>>>>>> efb2b979 (revert: unrelated change)


# Note this file is loaded prior to logging being configured, thus logger is only
Expand Down Expand Up @@ -164,7 +158,7 @@ def load_config(bentoml_config_file: str | None = None):
)


def save_global_config(config_file_handle: t.IO[t.Any]):
def save_config(config_file_handle: t.IO[t.Any]):
import yaml

from ..configuration.containers import BentoMLContainer
Expand Down
21 changes: 14 additions & 7 deletions src/bentoml/_internal/configuration/containers.py
Expand Up @@ -228,13 +228,20 @@ def serve_info() -> ServeInfo:
@providers.SingletonFactory
@staticmethod
def access_control_options(
allow_origin: str | None = Provide[cors.allow_origin],
allow_origin_regex: str | None = Provide[cors.allow_origin_regex],
allow_credentials: bool | None = Provide[cors.allow_credentials],
allow_methods: list[str] | str | None = Provide[cors.allow_methods],
allow_headers: list[str] | str | None = Provide[cors.allow_headers],
max_age: int | None = Provide[cors.max_age],
expose_headers: list[str] | str | None = Provide[cors.expose_headers],
allow_origin: str | None = Provide[cors.access_control_allow_origin],
allow_origin_regex: str
| None = Provide[cors.access_control_allow_origin_regex],
allow_credentials: bool | None = Provide[cors.access_control_allow_credentials],
allow_methods: list[str]
| str
| None = Provide[cors.access_control_allow_methods],
allow_headers: list[str]
| str
| None = Provide[cors.access_control_allow_headers],
max_age: int | None = Provide[cors.access_control_max_age],
expose_headers: list[str]
| str
| None = Provide[cors.access_control_expose_headers],
) -> dict[str, list[str] | str | int]:
return {
k: v
Expand Down
23 changes: 10 additions & 13 deletions src/bentoml/_internal/configuration/v1/__init__.py
Expand Up @@ -96,13 +96,15 @@
"port": s.And(int, ensure_larger_than_zero),
"cors": {
"enabled": bool,
"allow_origin": s.Or(str, None),
"allow_origin_regex": s.Or(s.And(str, s.Use(re.compile)), None),
"allow_credentials": s.Or(bool, None),
"allow_headers": s.Or([str], str, None),
"allow_methods": s.Or([str], str, None),
"max_age": s.Or(int, None),
"expose_headers": s.Or([str], str, None),
"access_control_allow_origin": s.Or(str, None),
"access_control_allow_origin_regex": s.Or(
s.And(str, s.Use(re.compile)), None
),
"access_control_allow_credentials": s.Or(bool, None),
"access_control_allow_headers": s.Or([str], str, None),
"access_control_allow_methods": s.Or([str], str, None),
"access_control_max_age": s.Or(int, None),
"access_control_expose_headers": s.Or([str], str, None),
},
},
"grpc": {
Expand Down Expand Up @@ -216,12 +218,7 @@ def migration(*, override_config: dict[str, t.Any]):
rename_fields(
override_config,
current=f"api_server.cors.access_control_{f}",
replace_with=f"api_server.http.cors.{f}",
)
rename_fields(
override_config,
current=f"api_server.http.cors.access_control_{f}",
replace_with=f"api_server.http.cors.{f}",
replace_with=f"api_server.http.cors.access_control_{f}",
)

# 4. if ssl is present, in version 2 we introduce a api_server.ssl.enabled field to determine
Expand Down
Expand Up @@ -52,13 +52,13 @@ api_server:
port: 3000
cors:
enabled: false
allow_origin: ~
allow_credentials: ~
allow_methods: ~
allow_headers: ~
allow_origin_regex: ~
max_age: ~
expose_headers: ~
access_control_allow_origin: ~
access_control_allow_credentials: ~
access_control_allow_methods: ~
access_control_allow_headers: ~
access_control_allow_origin_regex: ~
access_control_max_age: ~
access_control_expose_headers: ~
grpc:
host: 0.0.0.0
port: 3000
Expand Down

0 comments on commit ca27fc5

Please sign in to comment.