Skip to content

Commit

Permalink
Check if remote model exists on server
Browse files Browse the repository at this point in the history
  • Loading branch information
gmertes committed Apr 4, 2024
1 parent 4f4a720 commit c9c487f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ai_models/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _main(argv):
parser.add_argument(
"model",
metavar="MODEL",
choices=available_models(),
choices=available_models() if "--remote" not in argv else None,
help="The model to run",
)

Expand Down
11 changes: 11 additions & 0 deletions ai_models/remote/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
import sys
import tempfile
from functools import cached_property

Expand All @@ -7,6 +9,8 @@
from ..model import Model
from .api import RemoteAPI

LOG = logging.getLogger(__name__)


class RemoteModel(Model):
def __init__(self, **kwargs):
Expand All @@ -18,6 +22,13 @@ def __init__(self, **kwargs):
self._param = {}
self.api = RemoteAPI()

if self.model not in self.api.models():
LOG.error(f"Model '{self.model}' not available on remote server.")
LOG.error(
"Rerun the command with --models --remote to list available remote models."
)
sys.exit(1)

self.load_parameters()

super().__init__(**self.cfg)
Expand Down

0 comments on commit c9c487f

Please sign in to comment.