Skip to content

Commit

Permalink
Add ClearML as optional dependency (#6827)
Browse files Browse the repository at this point in the history
### 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]>
  • Loading branch information
pollfly authored Aug 7, 2023
1 parent 65cf5fe commit 0eb26fc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions monai/config/deviceconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def get_optional_config_values():
output["transformers"] = get_package_version("transformers")
output["mlflow"] = get_package_version("mlflow")
output["pynrrd"] = get_package_version("nrrd")
output["clearml"] = get_package_version("clearml")

return output

Expand Down
6 changes: 3 additions & 3 deletions monai/handlers/clearml_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
project_name: ClearML project name, default to 'MONAI'.
task_name: ClearML task name, default to 'monai_experiment'.
output_uri: The default location for output models and other artifacts, default to 'True'.
tags: A list of tags (str) to the created Task, default to 'None'.
tags: Add a list of tags (str) to the created Task, default to 'None'.
reuse_last_task_id: Force a new Task (experiment) with a previously used Task ID, default to 'True'.
continue_last_task: Continue the execution of a previously executed Task (experiment), default to 'False'.
auto_connect_frameworks: Automatically connect frameworks, default to 'True'.
Expand Down Expand Up @@ -104,7 +104,7 @@ def __init__(
project_name: ClearML project name, default to 'MONAI'.
task_name: ClearML task name, default to 'monai_experiment'.
output_uri: The default location for output models and other artifacts, default to 'True'.
tags: A list of tags (str) to the created Task, default to 'None'.
tags: Add a list of tags (str) to the created Task, default to 'None'.
reuse_last_task_id: Force a new Task (experiment) with a previously used Task ID, default to 'True'.
continue_last_task: Continue the execution of a previously executed Task (experiment), default to 'False'.
auto_connect_frameworks: Automatically connect frameworks, default to 'True'.
Expand Down Expand Up @@ -155,7 +155,7 @@ def __init__(
project_name: ClearML project name, default to 'MONAI'.
task_name: ClearML task name, default to 'monai_experiment'.
output_uri: The default location for output models and other artifacts, default to 'True'.
tags: A list of tags (str) to the created Task, default to 'None'.
tags: Add a list of tags (str) to the created Task, default to 'None'.
reuse_last_task_id: Force a new Task (experiment) with a previously used Task ID, default to 'True'.
continue_last_task: Continue the execution of a previously executed Task (experiment), default to 'False'.
auto_connect_frameworks: Automatically connect frameworks, default to 'True'.
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ mlflow =
mlflow
matplotlib =
matplotlib
clearml =
clearml
tensorboardX =
tensorboardX
pyyaml =
Expand Down
8 changes: 5 additions & 3 deletions tests/test_perceptual_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.losses import PerceptualLoss
from monai.utils import optional_import
from tests.utils import SkipIfBeforePyTorchVersion
from tests.utils import SkipIfBeforePyTorchVersion, skip_if_downloading_fails

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

@parameterized.expand(TEST_CASES)
def test_identical_input(self, input_param, input_shape, target_shape):
loss = PerceptualLoss(**input_param)
with skip_if_downloading_fails():
loss = PerceptualLoss(**input_param)
tensor = torch.randn(input_shape)
result = loss(tensor, tensor)
self.assertEqual(result, torch.Tensor([0.0]))

def test_different_shape(self):
loss = PerceptualLoss(spatial_dims=2, network_type="squeeze")
with skip_if_downloading_fails():
loss = PerceptualLoss(spatial_dims=2, network_type="squeeze")
tensor = torch.randn(2, 1, 64, 64)
target = torch.randn(2, 1, 32, 32)
with self.assertRaises(ValueError):
Expand Down

0 comments on commit 0eb26fc

Please sign in to comment.