Skip to content

Commit 0eb26fc

Browse files
authored
Add ClearML as optional dependency (#6827)
### Description Add option to install `clearml` as optional dependency with `pip install monai[clearml]`. All of the docstrings were updated and unit tests added in [PR #6013](#6013). ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. --------- Signed-off-by: revital <[email protected]>
1 parent 65cf5fe commit 0eb26fc

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

monai/config/deviceconfig.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def get_optional_config_values():
8484
output["transformers"] = get_package_version("transformers")
8585
output["mlflow"] = get_package_version("mlflow")
8686
output["pynrrd"] = get_package_version("nrrd")
87+
output["clearml"] = get_package_version("clearml")
8788

8889
return output
8990

monai/handlers/clearml_handlers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(
4545
project_name: ClearML project name, default to 'MONAI'.
4646
task_name: ClearML task name, default to 'monai_experiment'.
4747
output_uri: The default location for output models and other artifacts, default to 'True'.
48-
tags: A list of tags (str) to the created Task, default to 'None'.
48+
tags: Add a list of tags (str) to the created Task, default to 'None'.
4949
reuse_last_task_id: Force a new Task (experiment) with a previously used Task ID, default to 'True'.
5050
continue_last_task: Continue the execution of a previously executed Task (experiment), default to 'False'.
5151
auto_connect_frameworks: Automatically connect frameworks, default to 'True'.
@@ -104,7 +104,7 @@ def __init__(
104104
project_name: ClearML project name, default to 'MONAI'.
105105
task_name: ClearML task name, default to 'monai_experiment'.
106106
output_uri: The default location for output models and other artifacts, default to 'True'.
107-
tags: A list of tags (str) to the created Task, default to 'None'.
107+
tags: Add a list of tags (str) to the created Task, default to 'None'.
108108
reuse_last_task_id: Force a new Task (experiment) with a previously used Task ID, default to 'True'.
109109
continue_last_task: Continue the execution of a previously executed Task (experiment), default to 'False'.
110110
auto_connect_frameworks: Automatically connect frameworks, default to 'True'.
@@ -155,7 +155,7 @@ def __init__(
155155
project_name: ClearML project name, default to 'MONAI'.
156156
task_name: ClearML task name, default to 'monai_experiment'.
157157
output_uri: The default location for output models and other artifacts, default to 'True'.
158-
tags: A list of tags (str) to the created Task, default to 'None'.
158+
tags: Add a list of tags (str) to the created Task, default to 'None'.
159159
reuse_last_task_id: Force a new Task (experiment) with a previously used Task ID, default to 'True'.
160160
continue_last_task: Continue the execution of a previously executed Task (experiment), default to 'False'.
161161
auto_connect_frameworks: Automatically connect frameworks, default to 'True'.

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ mlflow =
126126
mlflow
127127
matplotlib =
128128
matplotlib
129+
clearml =
130+
clearml
129131
tensorboardX =
130132
tensorboardX
131133
pyyaml =

tests/test_perceptual_loss.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from monai.losses import PerceptualLoss
2020
from monai.utils import optional_import
21-
from tests.utils import SkipIfBeforePyTorchVersion
21+
from tests.utils import SkipIfBeforePyTorchVersion, skip_if_downloading_fails
2222

2323
_, has_torchvision = optional_import("torchvision")
2424
TEST_CASES = [
@@ -59,13 +59,15 @@ def test_shape(self, input_param, input_shape, target_shape):
5959

6060
@parameterized.expand(TEST_CASES)
6161
def test_identical_input(self, input_param, input_shape, target_shape):
62-
loss = PerceptualLoss(**input_param)
62+
with skip_if_downloading_fails():
63+
loss = PerceptualLoss(**input_param)
6364
tensor = torch.randn(input_shape)
6465
result = loss(tensor, tensor)
6566
self.assertEqual(result, torch.Tensor([0.0]))
6667

6768
def test_different_shape(self):
68-
loss = PerceptualLoss(spatial_dims=2, network_type="squeeze")
69+
with skip_if_downloading_fails():
70+
loss = PerceptualLoss(spatial_dims=2, network_type="squeeze")
6971
tensor = torch.randn(2, 1, 64, 64)
7072
target = torch.randn(2, 1, 32, 32)
7173
with self.assertRaises(ValueError):

0 commit comments

Comments
 (0)