Skip to content

Commit

Permalink
Fix lint null issues
Browse files Browse the repository at this point in the history
  • Loading branch information
8W9aG authored and nevillelyh committed Jan 6, 2025
1 parent a0748a8 commit 2d37e35
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/monobase/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def build_generation(args: argparse.Namespace, mg: MonoGen) -> None:
for (k, v), m in itertools.product(
desc_version_key(mg.cudnn), desc_version(cuda_majors)
):
if m is None:
raise ValueError('cuda cannot be null.')
src = install_cudnn(args, v, m)
dst = f'{gdir}/cudnn{k}-cuda{m}'
reldst = os.path.relpath(src, gdir)
Expand All @@ -158,6 +160,8 @@ def build_generation(args: argparse.Namespace, mg: MonoGen) -> None:
desc_version(mg.torch),
desc_version(mg.cuda.keys()),
):
if c is None:
raise ValueError('cuda cannot be null.')
install_venv(args, rdir, gdir, p, pf, t, c)

optimize_ld_cache(args, gdir, mg)
Expand Down Expand Up @@ -207,7 +211,7 @@ def pick(
raise
return {}

torch = []
torch: list[str | None] = []
if 'R8_TORCH_VERSION' in os.environ:
torch.append(os.environ['R8_TORCH_VERSION'])
else:
Expand Down
2 changes: 1 addition & 1 deletion src/monobase/monogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MonoGen:
cuda: dict[str, str]
cudnn: dict[str, str]
python: dict[str, str]
torch: list[str]
torch: list[str | None]
pip_pkgs: list[str]

@property
Expand Down
2 changes: 2 additions & 0 deletions src/monobase/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def update_generation(
desc_version(mg.torch),
desc_version(mg.cuda.keys()),
):
if c is None:
raise ValueError('cuda version cannot be null.')
update_venv(rdir, tmp.name, p, pf, t, c, mg.pip_pkgs)


Expand Down
6 changes: 4 additions & 2 deletions src/monobase/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class Version:
repr: str

@classmethod
def parse(cls, s: str) -> 'Version':
def parse(cls, s: str | None) -> 'Version':
if s is None:
return cls(0, 0, 0, '', '')
m = VERSION_REGEX.search(s)
if m is None:
raise ValueError(f'Invalid version string: {s}')
Expand Down Expand Up @@ -156,7 +158,7 @@ def mark_done(d: str, *, kind: str, **attributes) -> None:
f.write('\n')


def desc_version(it: Iterable[str]) -> list[str]:
def desc_version(it: Iterable[str | None]) -> list[str | None]:
return sorted(it, key=Version.parse, reverse=True)


Expand Down
8 changes: 4 additions & 4 deletions src/monobase/uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ def update_venv(
tmp: str,
python_version: str,
python_full_version: str,
torch_version: str,
torch_version: str | None,
cuda_version: str,
pip_pkgs: list[str],
) -> None:
trace.get_current_span().set_attributes(
{
'requirements_dir': rdir,
'python_full_version': python_full_version,
'torch_version': torch_version,
'torch_version': torch_version if torch_version is not None else '',
'cuda_version': cuda_version,
'pip_pkgs': str(pip_pkgs),
}
Expand Down Expand Up @@ -154,14 +154,14 @@ def install_venv(
gdir: str,
python_version: str,
python_full_version: str,
torch_version: str,
torch_version: str | None,
cuda_version: str,
) -> None:
trace.get_current_span().set_attributes(
{
'requirements_dir': rdir,
'python_full_version': python_full_version,
'torch_version': torch_version,
'torch_version': torch_version if torch_version is not None else '',
'cuda_version': cuda_version,
}
)
Expand Down

0 comments on commit 2d37e35

Please sign in to comment.