Skip to content

Commit

Permalink
clearml offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Moshe Raboh [email protected] committed Aug 26, 2024
1 parent 594252e commit d1e0254
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fuse/data/ops/ops_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __init__(
:param key_index: name of value in sample_dict which will be used as the key/index
:param key_column: name of the column which use as key/index. In case of None, the original dataframe index will be used to extract the values for a single sample.
"""
super().__init__()
# store input
self._data_filename = data_filename
self._columns_to_extract = columns_to_extract
Expand All @@ -146,7 +147,7 @@ def __init__(
self._h5 = h5py.File(self._data_filename, "r")

if self._columns_to_extract is None:
self._columns_to_extract = self._h5.keys()
self._columns_to_extract = list(self._h5.keys())

self._num_samples = len(self._h5[self._columns_to_extract[0]])

Expand Down
5 changes: 5 additions & 0 deletions fuse/dl/lightning/pl_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def start_clearml_logger(
auto_resource_monitoring: bool = True,
auto_connect_streams: Union[bool, Mapping[str, bool]] = True,
deferred_init: bool = False,
offline_mode: bool = False,
) -> TaskInstance:
"""
Just a fuse function to quickly start the clearml logger. It sets up patches to pytorch lightning logging hooks so it doesn't need to be passed to any lightning logger.
Expand Down Expand Up @@ -86,6 +87,10 @@ def start_clearml_logger(
bool_start_logger = True

if bool_start_logger:
if offline_mode: # Use the set_offline class method before initializing a Task
Task.set_offline(offline_mode=True)
os.environ["CLEARML_OFFLINE_MODE"] = "1"

task = Task.init(
project_name=project_name,
task_name=task_name,
Expand Down
3 changes: 3 additions & 0 deletions fuse/dl/lightning/pl_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ def __init__(

## forward
def forward(self, batch_dict: NDict) -> NDict:
# workaround for fsdp
if not isinstance(batch_dict, NDict):
batch_dict = NDict(batch_dict)
return self._model(batch_dict)

## Step
Expand Down

0 comments on commit d1e0254

Please sign in to comment.