This commit is contained in:
ziguana 2024-01-30 22:20:40 -07:00
commit 0e4e4b0979
19 changed files with 3185 additions and 0 deletions

21
pkgs/smi/default.nix Normal file
View file

@ -0,0 +1,21 @@
{ pkgs, pyluwen, tools-common }:
with pkgs.python3Packages;
buildPythonPackage rec {
pname = "tt-smi";
version = "main-01-31-24";
src = pkgs.fetchFromGitHub {
owner = "tenstorrent";
repo = "tt-smi";
rev = "2071978";
hash = "sha256-sqwGWeeMBxOyHiVI2GcQ5CyZ8Zaty7FjhkS0C7H7QkM=";
};
format = "pyproject";
patches = [ ./pyproject.patch ./log.patch ];
propagatedBuildInputs = [ setuptools requests textual black distro elasticsearch jsons pydantic psutil pyyaml pyluwen importlib-resources pkgs.pre-commit tools-common ];
}

52
pkgs/smi/log.patch Normal file
View file

@ -0,0 +1,52 @@
diff --git a/tt_smi/log.py b/tt_smi/log.py
index e7ae8fd..083bdb7 100644
--- a/tt_smi/log.py
+++ b/tt_smi/log.py
@@ -10,8 +10,8 @@ import base64
import inspect
import datetime
from pathlib import Path
-from typing import Any, Union, List, TypeVar, Generic
-from pydantic import BaseModel
+from typing import Any, Union, List, TypeVar, Generic, Optional
+from pydantic import BaseModel, create_model
from pydantic.fields import Field
@@ -38,26 +38,24 @@ class Date(datetime.datetime):
def optional(*fields):
- """Decorator function used to modify a pydantic model's fields to all be optional.
- Alternatively, you can also pass the field names that should be made optional as arguments
- to the decorator.
- Taken from https://github.com/samuelcolvin/pydantic/issues/1223#issuecomment-775363074
- """
-
- def dec(_cls):
+ def dec(cls):
+ fields_dict = {}
for field in fields:
- _cls.__fields__[field].required = False
- _cls.__fields__[field].default = None
- return _cls
+ field_info = cls.__annotations__.get(field)
+ if field_info is not None:
+ fields_dict[field] = (Optional[field_info], None)
+ OptionalModel = create_model(cls.__name__, **fields_dict)
+ OptionalModel.__module__ = cls.__module__
+
+ return OptionalModel
if fields and inspect.isclass(fields[0]) and issubclass(fields[0], BaseModel):
cls = fields[0]
- fields = cls.__fields__
+ fields = cls.__annotations__
return dec(cls)
return dec
-
def type_to_mapping(type: Any):
if issubclass(type, float):
return {"type": "float"}

22
pkgs/smi/pyproject.patch Normal file
View file

@ -0,0 +1,22 @@
diff --git a/pyproject.toml b/pyproject.toml
index a6e73a4..5085274 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -29,14 +29,14 @@ dependencies = [
'elasticsearch==8.11.0',
'jsons==1.6.3',
'linkify-it-py==2.0.2',
- 'pydantic==1.*',
+ 'pydantic>=1.0.0',
'psutil==5.9.6',
'pyyaml==6.0.1',
'tt_tools_common @ git+https://github.com/tenstorrent/tt-tools-common.git',
'pyluwen @ git+https://github.com/tenstorrent/luwen.git@v0.1.0#subdirectory=crates/pyluwen',
'rich==13.7.0',
- 'textual==0.42.0',
- 'pre-commit==3.5.0',
+ 'textual>=0.42.0',
+ 'pre-commit>=3.5.0',
'importlib_resources==6.1.1',
'requests==2.31.0',
]