Skip to content
Merged
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
20 changes: 18 additions & 2 deletions tests/test_handler_clearml_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,38 @@

from __future__ import annotations

import tempfile
import unittest
from os import environ

from monai.handlers import ClearMLImageHandler
from monai.utils import optional_import

Task, has_clearml = optional_import("clearml", name="Task")
get_active_config_file, has_get_active_config_file = optional_import(
"clearml.backend_config.defs", name="get_active_config_file"
)
_, has_tb = optional_import("torch.utils.tensorboard", name="SummaryWriter")


@unittest.skipUnless(has_clearml, "Requires 'clearml' installation")
@unittest.skipUnless(has_tb, "Requires SummaryWriter installation")
@unittest.skip("temp mute clearml tests https://github.com/Project-MONAI/MONAI/issues/6148")
@unittest.skipIf(not has_get_active_config_file, "ClearML 'get_active_config_file' not found")
# @unittest.skip("temp mute clearml tests https://github.com/Project-MONAI/MONAI/issues/6148")
class TestHandlerClearMLImageHandler(unittest.TestCase):
def test_task_init(self):
Task.set_offline(offline_mode=True)
handle, path = tempfile.mkstemp()
with open(handle, "w") as new_config:
if get_active_config_file():
with open(get_active_config_file()) as old_config:
new_config.write(old_config.read())
new_config.write(
"\nsdk.development.vcs_repo_detect_async: false\nsdk.development.report_use_subprocess: false\n"
)
environ["CLEARML_CONFIG_FILE"] = path
try:
Task.force_store_standalone_script(True)
Task.set_offline(offline_mode=True)
ClearMLImageHandler(
project_name="MONAI",
task_name="monai_experiment",
Expand Down
20 changes: 18 additions & 2 deletions tests/test_handler_clearml_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,38 @@

from __future__ import annotations

import tempfile
import unittest
from os import environ

from monai.handlers import ClearMLStatsHandler
from monai.utils import optional_import

Task, has_clearml = optional_import("clearml", name="Task")
get_active_config_file, has_get_active_config_file = optional_import(
"clearml.backend_config.defs", name="get_active_config_file"
)
_, has_tb = optional_import("torch.utils.tensorboard", name="SummaryWriter")


@unittest.skipUnless(has_clearml, "Requires 'clearml' installation")
@unittest.skipUnless(has_tb, "Requires SummaryWriter installation")
@unittest.skip("temp mute clearml tests https://github.com/Project-MONAI/MONAI/issues/6148")
@unittest.skipIf(not has_get_active_config_file, "ClearML 'get_active_config_file' not found")
# @unittest.skip("temp mute clearml tests https://github.com/Project-MONAI/MONAI/issues/6148")
class TestHandlerClearMLStatsHandler(unittest.TestCase):
def test_task_init(self):
Task.set_offline(offline_mode=True)
handle, path = tempfile.mkstemp()
with open(handle, "w") as new_config:
if get_active_config_file():
with open(get_active_config_file()) as old_config:
new_config.write(old_config.read())
new_config.write(
"\nsdk.development.vcs_repo_detect_async: false\nsdk.development.report_use_subprocess: false\n"
)
environ["CLEARML_CONFIG_FILE"] = path
try:
Task.force_store_standalone_script(True)
Task.set_offline(offline_mode=True)
ClearMLStatsHandler(
project_name="MONAI",
task_name="monai_experiment",
Expand Down