Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(configuration): override options with envvar #3018

Merged
merged 8 commits into from Sep 27, 2022

Conversation

bojiang
Copy link
Member

@bojiang bojiang commented Sep 20, 2022

Some use cases:

1. override one value

assign a gpu for a runner

BENTOML_CONFIG_OPTIONS='runners.pytorch_mnist.resources."nvidia.com/gpu"=1' bentoml serve pytorch_mnist_demo --production

equal to

runners:
    pytorch_mnist:
        resources:
            nvidia.com/gpu: 1

2. override multiple values (divide with space or new line)

assign two specified gpus to a runner

BENTOML_CONFIG_OPTIONS='runners.pytorch_mnist.resources."nvidia.com/gpu"=[0,2]' bentoml serve pytorch_mnist_demo --production

or

BENTOML_CONFIG_OPTIONS='runners.pytorch_mnist.resources."nvidia.com/gpu"[0]=0 runners.pytorch_mnist.resources."nvidia.com/gpu"[1]=2' bentoml serve pytorch_mnist_demo --production

equal to

runners:
    pytorch_mnist:
        resources:
            nvidia.com/gpu:
                - 0
                - 2

or

runners:
    pytorch_mnist:
        resources:
            nvidia.com/gpu: [0, 2]

@bojiang bojiang marked this pull request as ready for review September 20, 2022 01:34
@bojiang bojiang requested a review from a team as a code owner September 20, 2022 01:34
@bojiang bojiang requested review from aarnphm and removed request for a team September 20, 2022 01:34
@codecov
Copy link

codecov bot commented Sep 20, 2022

Codecov Report

Merging #3018 (1ba4603) into main (a69764e) will decrease coverage by 1.91%.
The diff coverage is 26.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3018      +/-   ##
==========================================
- Coverage   62.89%   60.98%   -1.92%     
==========================================
  Files         145      132      -13     
  Lines       11828    11538     -290     
  Branches        0     1913    +1913     
==========================================
- Hits         7439     7036     -403     
+ Misses       4389     4133     -256     
- Partials        0      369     +369     
Impacted Files Coverage Δ
bentoml/_internal/utils/__init__.py 65.84% <11.11%> (-6.21%) ⬇️
bentoml/_internal/utils/unflatten.py 21.84% <21.84%> (ø)
bentoml/_internal/configuration/containers.py 69.87% <53.84%> (-7.27%) ⬇️
bentoml/_internal/configuration/__init__.py 70.88% <60.00%> (-6.04%) ⬇️
bentoml/_internal/utils/buildx.py 24.48% <0.00%> (-23.84%) ⬇️
bentoml/_internal/service/inference_api.py 56.25% <0.00%> (-13.75%) ⬇️
bentoml/_internal/utils/uri.py 78.94% <0.00%> (-10.53%) ⬇️
bentoml/_internal/server/http/access.py 85.50% <0.00%> (-10.27%) ⬇️
bentoml/_internal/utils/pkg.py 81.81% <0.00%> (-10.19%) ⬇️
bentoml/_internal/utils/cattr.py 71.42% <0.00%> (-9.53%) ⬇️
... and 90 more

@aarnphm
Copy link
Member

aarnphm commented Sep 20, 2022

I'm thinking to pass it as a config-options

bentoml serve --production --config-options 'runners.pytorch_mnist.resources."nvidia.com/gpu"=[0,2]' --config-options "api_server.http.metrics.enabled=false"

aarnphm
aarnphm previously approved these changes Sep 27, 2022
Copy link
Member

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will write some tests for this is the test PR I have 😄

update some types annotations

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm
aarnphm previously approved these changes Sep 27, 2022
Copy link
Member

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did some manual QA for this feature. Works like a charm 😄

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
@aarnphm aarnphm changed the title feat(server): pass any config options by env var feat(configuration): override options with envvar Sep 27, 2022
@aarnphm aarnphm merged commit a666072 into bentoml:main Sep 27, 2022
@bojiang bojiang deleted the general-config-env branch September 28, 2022 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants