Skip to content

Commit

Permalink
remove logger in data scripts and callback
Browse files Browse the repository at this point in the history
  • Loading branch information
jjanezhang committed Jun 24, 2024
1 parent 6c73ace commit a0c8309
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
5 changes: 4 additions & 1 deletion llmfoundry/callbacks/run_timeout_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

def _timeout(timeout: int, mosaicml_logger: Optional[MosaicMLLogger] = None):
log.error(f'Timeout after {timeout} seconds of inactivity after fit_end.',)
if mosaicml_logger is not None:
if mosaicml_logger is not None and os.environ.get(
'OVERRIDE_EXCEPTHOOK',
'false',
).lower() != 'true':
mosaicml_logger.log_exception(RunTimeoutError(timeout=timeout))
os.kill(os.getpid(), signal.SIGINT)

Expand Down
10 changes: 7 additions & 3 deletions scripts/data_prep/convert_delta_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
from packaging import version
from pyspark.sql import SparkSession
from pyspark.sql.connect.client.core import SparkConnectClient
from pyspark.sql.connect.client.reattach import \
ExecutePlanResponseReattachableIterator
from pyspark.sql.connect.client.reattach import (
ExecutePlanResponseReattachableIterator,
)
from pyspark.sql.connect.dataframe import DataFrame
from pyspark.sql.dataframe import DataFrame as SparkDataFrame
from pyspark.sql.types import Row
Expand Down Expand Up @@ -644,6 +645,9 @@ def fetch_DT(args: Namespace) -> None:
log.info(f'Elapsed time {time.time() - tik}')

except Exception as e:
if mosaicml_logger is not None:
if mosaicml_logger is not None and os.environ.get(
'OVERRIDE_EXCEPTHOOK',
'false',
).lower() != 'true':
mosaicml_logger.log_exception(e)
raise e
5 changes: 4 additions & 1 deletion scripts/data_prep/convert_text_to_mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ def _configure_logging(logging_level: str):
args_str=_args_str(args),
)
except Exception as e:
if mosaicml_logger is not None:
if mosaicml_logger is not None and os.environ.get(
'OVERRIDE_EXCEPTHOOK',
'false',
).lower() != 'true':
mosaicml_logger.log_exception(e)
raise e
28 changes: 17 additions & 11 deletions scripts/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,12 @@ def main(cfg: DictConfig) -> Trainer:
train_cfg.device_train_batch_size,
)
except BaseContextualError as e:
if mosaicml_logger is not None:
e.location = TrainDataLoaderLocation
if os.environ.get('OVERRIDE_EXCEPTHOOK', 'false').lower() != 'true':
mosaicml_logger.log_exception(e)
e.location = TrainDataLoaderLocation
if mosaicml_logger is not None and os.environ.get(
'OVERRIDE_EXCEPTHOOK',
'false',
).lower() != 'true':
mosaicml_logger.log_exception(e)
raise e

if mosaicml_logger is not None:
Expand Down Expand Up @@ -428,11 +430,12 @@ def main(cfg: DictConfig) -> Trainer:
if eval_gauntlet_callback is not None:
callbacks.append(eval_gauntlet_callback)
except BaseContextualError as e:
if mosaicml_logger is not None:
e.location = EvalDataLoaderLocation
if os.environ.get('OVERRIDE_EXCEPTHOOK',
'false').lower() != 'true':
mosaicml_logger.log_exception(e)
e.location = EvalDataLoaderLocation
if mosaicml_logger is not None and os.environ.get(
'OVERRIDE_EXCEPTHOOK',
'false',
).lower() != 'true':
mosaicml_logger.log_exception(e)
raise e

if mosaicml_logger is not None:
Expand Down Expand Up @@ -480,8 +483,11 @@ def main(cfg: DictConfig) -> Trainer:
non_icl_metrics,
)
except BaseContextualError as e:
if mosaicml_logger is not None:
e.location = EvalDataLoaderLocation
e.location = EvalDataLoaderLocation
if mosaicml_logger is not None and os.environ.get(
'OVERRIDE_EXCEPTHOOK',
'false',
).lower() != 'true':
mosaicml_logger.log_exception(e)
raise e

Expand Down

0 comments on commit a0c8309

Please sign in to comment.