Skip to content

Commit 93b8ab6

Browse files
[pre-commit.ci] pre-commit suggestions (#86)
* [pre-commit.ci] pre-commit suggestions updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.5.0...v5.0.0) - [github.com/codespell-project/codespell: v2.2.6 → v2.4.1](codespell-project/codespell@v2.2.6...v2.4.1) - [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.8](pre-commit/mirrors-prettier@v3.1.0...v4.0.0-alpha.8) - [github.com/executablebooks/mdformat: 0.7.17 → 0.7.22](hukkin/mdformat@0.7.17...0.7.22) - https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit - [github.com/astral-sh/ruff-pre-commit: v0.3.3 → v0.11.4](astral-sh/ruff-pre-commit@v0.3.3...v0.11.4) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply suggestions from code review --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Jirka B <[email protected]>
1 parent d03f737 commit 93b8ab6

12 files changed

+31
-23
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ci:
99

1010
repos:
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v4.5.0
12+
rev: v5.0.0
1313
hooks:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
@@ -28,7 +28,7 @@ repos:
2828
- id: python-use-type-annotations
2929

3030
- repo: https://github.com/codespell-project/codespell
31-
rev: v2.2.6
31+
rev: v2.4.1
3232
hooks:
3333
- id: codespell
3434
additional_dependencies: [tomli]
@@ -43,7 +43,7 @@ repos:
4343
args: ["--print-width=120"]
4444

4545
- repo: https://github.com/executablebooks/mdformat
46-
rev: 0.7.17
46+
rev: 0.7.22
4747
hooks:
4848
- id: mdformat
4949
args: ["--number"]
@@ -53,8 +53,8 @@ repos:
5353
- mdformat_frontmatter
5454
exclude: CHANGELOG.md
5555

56-
- repo: https://github.com/charliermarsh/ruff-pre-commit
57-
rev: v0.3.3
56+
- repo: https://github.com/astral-sh/ruff-pre-commit
57+
rev: v0.11.4
5858
hooks:
5959
- id: ruff
6060
args: ["--fix"]

examples/demo-upload-download.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import litmodels
21
import torch
32
from lightning.pytorch.demos.boring_classes import BoringModel
43

4+
import litmodels
5+
56
if __name__ == "__main__":
67
# Define your model
78
model = BoringModel()

examples/resume-lightning-training.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from lightning import Trainer
88
from lightning.pytorch.demos.boring_classes import BoringModel
9+
910
from litmodels import download_model
1011

1112
# Define the model name - this should be unique to your model

examples/train-model-and-simple-save.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from lightning import Trainer
66
from lightning.pytorch.demos.boring_classes import BoringModel
7+
78
from litmodels import upload_model
89

910
# Define the model name - this should be unique to your model

examples/train-model-with-lightning-callback.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from lightning import Trainer
66
from lightning.pytorch.demos.boring_classes import BoringModel
7+
78
from litmodels.integrations import LightningModelCheckpoint
89

910
# Define the model name - this should be unique to your model

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ ignore = [
115115
"E731", # Do not assign a lambda expression, use a def
116116
"D100", # Missing docstring in public module
117117
]
118-
# Exclude a variety of commonly ignored directories.
119-
ignore-init-module-imports = true
120118

121119
[tool.ruff.lint.per-file-ignores]
122120
"setup.py" = ["D100", "SIM115"]

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Pytest configuration for integration tests."""
22

33
import pytest
4+
45
from litmodels.integrations.checkpoints import get_model_manager
56

67

tests/integrations/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
23
from litmodels.integrations.imports import (
34
_LIGHTNING_AVAILABLE,
45
_LIGHTNING_GREATER_EQUAL_2_5_1,

tests/integrations/test_checkpoints.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import re
33
from unittest import mock
44

5-
import litmodels
65
import pytest
76

7+
import litmodels
88
from tests.integrations import _SKIP_IF_LIGHTNING_MISSING, _SKIP_IF_PYTORCHLIGHTNING_MISSING
99

1010

@@ -25,13 +25,15 @@ def test_lightning_checkpoint_callback(mock_auth, mock_upload_model, monkeypatch
2525
from lightning import Trainer
2626
from lightning.pytorch.callbacks import ModelCheckpoint
2727
from lightning.pytorch.demos.boring_classes import BoringModel
28+
2829
from litmodels.integrations.checkpoints import LightningModelCheckpoint as LitModelCheckpoint
2930
elif importing == "pytorch_lightning":
30-
from litmodels.integrations.checkpoints import PytorchLightningModelCheckpoint as LitModelCheckpoint
3131
from pytorch_lightning import Trainer
3232
from pytorch_lightning.callbacks import ModelCheckpoint
3333
from pytorch_lightning.demos.boring_classes import BoringModel
3434

35+
from litmodels.integrations.checkpoints import PytorchLightningModelCheckpoint as LitModelCheckpoint
36+
3537
# Validate inheritance
3638
assert issubclass(LitModelCheckpoint, ModelCheckpoint)
3739

tests/integrations/test_cloud.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
from lightning_sdk import Teamspace
1010
from lightning_sdk.lightning_cloud.rest_client import GridRestClient
1111
from lightning_sdk.utils.resolve import _resolve_teamspace
12+
1213
from litmodels import download_model, upload_model
1314
from litmodels.integrations.duplicate import duplicate_hf_model
1415
from litmodels.integrations.mixins import PickleRegistryMixin, PyTorchRegistryMixin
1516
from litmodels.io.cloud import _list_available_teamspaces
16-
1717
from tests.integrations import (
1818
_SKIP_IF_LIGHTNING_BELLOW_2_5_1,
1919
_SKIP_IF_PYTORCHLIGHTNING_BELLOW_2_5_1,
@@ -44,7 +44,7 @@ def _cleanup_model(teamspace: Teamspace, model_name: str, expected_num_versions:
4444
client.models_store_delete_model(project_id=model.project_id, model_id=model.id)
4545

4646

47-
@pytest.mark.cloud()
47+
@pytest.mark.cloud
4848
@pytest.mark.parametrize(
4949
"in_studio",
5050
[False, pytest.param(True, marks=pytest.mark.skipif(platform.system() != "Linux", reason="Studio is just Linux"))],
@@ -100,7 +100,7 @@ def test_upload_download_model(in_studio, monkeypatch, tmp_path):
100100
pytest.param(True, marks=pytest.mark.skipif(platform.system() == "Windows", reason="studio is not Windows")),
101101
],
102102
)
103-
@pytest.mark.cloud()
103+
@pytest.mark.cloud
104104
def test_lightning_default_checkpointing(importing, in_studio, monkeypatch, tmp_path):
105105
if in_studio:
106106
# mock env variables as it would run in studio
@@ -140,7 +140,7 @@ def test_lightning_default_checkpointing(importing, in_studio, monkeypatch, tmp_
140140
pytest.param("pytorch_lightning", marks=_SKIP_IF_PYTORCHLIGHTNING_BELLOW_2_5_1),
141141
],
142142
)
143-
@pytest.mark.cloud()
143+
@pytest.mark.cloud
144144
# todo: mock env variables as it would run in studio
145145
def test_lightning_plain_resume(trainer_method, registry, importing, tmp_path):
146146
if importing == "lightning":
@@ -194,7 +194,7 @@ def test_lightning_plain_resume(trainer_method, registry, importing, tmp_path):
194194
pytest.param("pytorch_lightning", marks=_SKIP_IF_PYTORCHLIGHTNING_BELLOW_2_5_1),
195195
],
196196
)
197-
@pytest.mark.cloud()
197+
@pytest.mark.cloud
198198
def test_lightning_checkpoint_ddp(importing, tmp_path):
199199
if importing == "lightning":
200200
from lightning import Trainer
@@ -229,7 +229,7 @@ def __init__(self, value):
229229
self.value = value
230230

231231

232-
@pytest.mark.cloud()
232+
@pytest.mark.cloud
233233
def test_pickle_mixin_push_and_pull():
234234
# model name with random hash
235235
teamspace, org_team, model_name = _prepare_variables("pickle_mixin")
@@ -263,7 +263,7 @@ def forward(self, x):
263263
return self.fc(x)
264264

265265

266-
@pytest.mark.cloud()
266+
@pytest.mark.cloud
267267
def test_pytorch_mixin_push_and_pull():
268268
# model name with random hash
269269
teamspace, org_team, model_name = _prepare_variables("torch_mixin")
@@ -289,7 +289,7 @@ def test_pytorch_mixin_push_and_pull():
289289
_cleanup_model(teamspace, model_name, expected_num_versions=1)
290290

291291

292-
@pytest.mark.cloud()
292+
@pytest.mark.cloud
293293
def test_duplicate_real_hf_model(tmp_path):
294294
"""Verify that the HF model can be duplicated to the teamspace"""
295295

@@ -309,7 +309,7 @@ def test_duplicate_real_hf_model(tmp_path):
309309
client.models_store_delete_model(project_id=teamspace.id, model_id=model.id)
310310

311311

312-
@pytest.mark.cloud()
312+
@pytest.mark.cloud
313313
def test_list_available_teamspaces():
314314
teams = _list_available_teamspaces()
315315
assert len(teams) > 0

0 commit comments

Comments
 (0)