Skip to content

Commit 9b4dd35

Browse files
committed
chore: add nightly and check default for model list
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
1 parent a0b952b commit 9b4dd35

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/openllm/cloud.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ def _get_deploy_cmd(
117117
return cmd, env
118118

119119

120+
def get_current_context() -> str | None:
121+
cmd = ['bentoml', 'cloud', 'current-context']
122+
try:
123+
result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
124+
return typing.cast(str, json.loads(result)['name'])
125+
except subprocess.CalledProcessError:
126+
return None
127+
128+
120129
def ensure_cloud_context() -> None:
121130
import questionary
122131

@@ -167,6 +176,10 @@ def get_cloud_machine_spec(context: typing.Optional[str] = None) -> list[Deploym
167176
cmd = ['bentoml', 'deployment', 'list-instance-types', '-o', 'json']
168177
if context:
169178
cmd += ['--context', context]
179+
180+
if context is None:
181+
context = get_current_context()
182+
170183
try:
171184
result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
172185
instance_types = json.loads(result)
@@ -185,7 +198,10 @@ def get_cloud_machine_spec(context: typing.Optional[str] = None) -> list[Deploym
185198
for it in instance_types
186199
]
187200
except (subprocess.CalledProcessError, json.JSONDecodeError):
188-
output('Failed to get cloud instance types', style='red')
201+
output(
202+
f'Failed to get cloud instance types{"" if context is None else f" for context {context}"}',
203+
style='red',
204+
)
189205
return []
190206

191207

src/openllm/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def output(
7373

7474
class Config(pydantic.BaseModel):
7575
repos: dict[str, str] = pydantic.Field(
76-
default_factory=lambda: {'default': 'https://github.com/bentoml/openllm-models@main'}
76+
default_factory=lambda: {
77+
'default': 'https://github.com/bentoml/openllm-models@main',
78+
'nightly': 'https://github.com/bentoml/openllm-models@nightly',
79+
}
7780
)
7881
default_repo: str = 'default'
7982

src/openllm/model.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from openllm.accelerator_spec import can_run
77
from openllm.common import DeploymentTarget
88
from openllm.analytic import OpenLLMTyper
9-
from openllm.common import VERBOSE_LEVEL, BentoInfo, output as output_
9+
from openllm.common import VERBOSE_LEVEL, BentoInfo, output as output_, load_config
1010
from openllm.repo import ensure_repo_updated, list_repo
1111

1212
app = OpenLLMTyper(help='manage models')
@@ -31,6 +31,9 @@ def list_model(
3131
if verbose:
3232
VERBOSE_LEVEL.set(20)
3333

34+
if repo is None:
35+
repo = load_config().default_repo
36+
3437
bentos = list_bento(tag=tag, repo_name=repo)
3538
bentos.sort(key=lambda x: x.name)
3639

@@ -79,6 +82,11 @@ def ensure_bento(
7982
target: typing.Optional[DeploymentTarget] = None,
8083
repo_name: typing.Optional[str] = None,
8184
) -> BentoInfo:
85+
if repo_name is None:
86+
from openllm.common import load_config
87+
88+
repo_name = load_config().default_repo
89+
8290
bentos = list_bento(model, repo_name=repo_name)
8391
if len(bentos) == 0:
8492
output_(f'No model found for {model}', style='red')

0 commit comments

Comments
 (0)