Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Autoupdate hooks [pre-commit.ci] #907

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-ast # Simply check whether the files parse as valid python
- id: check-yaml # Attempts to load all yaml files to verify syntax
Expand All @@ -26,7 +26,7 @@ repos:
# The structure of this was suggested by the author of pre-commit and maintainer of flake8
# See https://stackoverflow.com/a/66485642/3956024
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.1.1
hooks:
- id: flake8
name: flake8 ./hi-ml/
Expand All @@ -50,7 +50,7 @@ repos:
args: [--config, hi-ml-multimodal/.flake8]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.10.0
hooks:
- id: black
extend-exclude: ^docs/source/amulet/amulet_script.py
Expand Down
8 changes: 5 additions & 3 deletions hi-ml-cpath/src/health_cpath/utils/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,11 @@ def get_best_epoch_metrics(
containing only scalar values.
"""
best_metrics = [
metrics_df.loc[metrics_list, k].apply(lambda values: values[epoch])
if epoch is not None
else metrics_df.loc[metrics_list, k]
(
metrics_df.loc[metrics_list, k].apply(lambda values: values[epoch])
if epoch is not None
else metrics_df.loc[metrics_list, k]
)
for k, epoch in best_epochs.items()
]
best_metrics_df = pd.DataFrame(best_metrics).T
Expand Down
1 change: 1 addition & 0 deletions hi-ml-cpath/testSSL/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
DO NOT RENAME THIS FILE: (https://docs.pytest.org/en/latest/fixture.html#sharing-a-fixture-across-tests-in-a-module
-or-class-session)
"""

import shutil
import uuid
from pathlib import Path
Expand Down
6 changes: 3 additions & 3 deletions hi-ml-multimodal/test_multimodal/image/model/test_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def test_reload_resnet_with_dilation(replace_stride_with_dilation: Sequence[bool

resnet50_kwargs = {
"pretrained": True,
"replace_stride_with_dilation": replace_stride_with_dilation
if replace_stride_with_dilation
else DEFAULT_DILATION_VALUES_FOR_RESNET,
"replace_stride_with_dilation": (
replace_stride_with_dilation if replace_stride_with_dilation else DEFAULT_DILATION_VALUES_FOR_RESNET
),
}
expected_model = resnet50(**resnet50_kwargs)

Expand Down
6 changes: 3 additions & 3 deletions hi-ml/src/health_ml/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ def log_on_epoch(
if name is not None:
metrics[name] = value # type: ignore
metrics_as_tensors = {
key: torch.tensor(value, dtype=torch.float, device=module.device)
if isinstance(value, numbers.Number)
else value
key: (
torch.tensor(value, dtype=torch.float, device=module.device) if isinstance(value, numbers.Number) else value
)
for key, value in metrics.items()
}
module.log_dict(metrics_as_tensors, on_epoch=True, on_step=False, sync_dist=is_sync_dist, reduce_fx=reduce_fx)
Expand Down
Loading