Skip to content

Commit

Permalink
remove pydantic namespace warnings using model_config (#470)
Browse files Browse the repository at this point in the history
# What does this PR do?

remove another model_ pydantic namespace warning and convert old-style
'class Config' to new-style 'model_config' workaround.

also a whitespace change to get past -


flake8...................................................................Failed
llama_stack/cli/download.py:296:85: E226 missing whitespace around
arithmetic operator
llama_stack/cli/download.py:297:54: E226 missing whitespace around
arithmetic operator


## Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the
other checks if that's the case).
- [x] Ran pre-commit to handle lint / formatting issues.
- [x] Read the [contributor
guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md),
      Pull Request section?
- [ ] Updated relevant documentation.
- [x] Wrote necessary unit or integration tests.
  • Loading branch information
mattf authored Nov 19, 2024
1 parent 2108a77 commit fcc2132
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions llama_stack/apis/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def model_id(self) -> str:
def provider_model_id(self) -> str:
return self.provider_resource_id

model_config = ConfigDict(protected_namespaces=())


class ModelInput(CommonModelFields):
model_id: str
Expand Down
9 changes: 4 additions & 5 deletions llama_stack/cli/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from llama_models.datatypes import Model
from llama_models.sku_list import LlamaDownloadInfo
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict

from rich.console import Console
from rich.progress import (
Expand Down Expand Up @@ -293,8 +293,8 @@ def has_disk_space(self, tasks: List[DownloadTask]) -> bool:

if free_space < required_space:
self.console.print(
f"[red]Not enough disk space. Required: {required_space // (1024*1024)} MB, "
f"Available: {free_space // (1024*1024)} MB[/red]"
f"[red]Not enough disk space. Required: {required_space // (1024 * 1024)} MB, "
f"Available: {free_space // (1024 * 1024)} MB[/red]"
)
return False
return True
Expand Down Expand Up @@ -413,8 +413,7 @@ class ModelEntry(BaseModel):
model_id: str
files: Dict[str, str]

class Config:
protected_namespaces = ()
model_config = ConfigDict(protected_namespaces=())


class Manifest(BaseModel):
Expand Down

0 comments on commit fcc2132

Please sign in to comment.