diff --git a/src/store.js b/src/store.js index 6c0765ed..fe570c2c 100644 --- a/src/store.js +++ b/src/store.js @@ -70,9 +70,14 @@ export function genCode() { continue } store.code[file] = ejs - .render(currentFiles[file], store.config) - .replace(/\s{4}\n/gi, '\n') - .replace(/(\n{3,})/gi, '\n\n') + .render( + // replace `\s(s) or \n(s)#:::\s` + // with `#::: ` + currentFiles[file].replace(/([\s\n]+#:::\s)/gi, '#::: '), + store.config + ) + // trim ` #` + .replace(/\s{4}#$/gim, '') } if (isDev) { store.code[__DEV_CONFIG_FILE__] = JSON.stringify(store.config, null, 2) diff --git a/src/templates/template-common/utils.py b/src/templates/template-common/utils.py index 6bfdc7db..09b37fc1 100644 --- a/src/templates/template-common/utils.py +++ b/src/templates/template-common/utils.py @@ -132,6 +132,8 @@ def setup_logging(config: Any) -> Logger: #::: if (it.save_training || it.save_evaluation || it.patience || it.terminate_on_nan || it.limit_sec) { :::# + + def setup_handlers( trainer: Engine, evaluator: Engine, diff --git a/src/templates/template-text-classification/main.py b/src/templates/template-text-classification/main.py index 799e925e..a290924d 100644 --- a/src/templates/template-text-classification/main.py +++ b/src/templates/template-text-classification/main.py @@ -159,7 +159,7 @@ def _(): if rank == 0: exp_logger.close() #::: } :::# - + # #::: if (it.save_training || it.save_evaluation) { :::# # show last checkpoint names logger.info( diff --git a/src/templates/template-text-classification/trainers.py b/src/templates/template-text-classification/trainers.py index 7cd8cf86..e95557e0 100644 --- a/src/templates/template-text-classification/trainers.py +++ b/src/templates/template-text-classification/trainers.py @@ -52,6 +52,7 @@ def train_function(engine: Union[Engine, DeterministicEngine], batch: Any): engine.state.metrics = metric return metric + # #::: if(it.deterministic) { :::# trainer = DeterministicEngine(train_function) #::: } else { :::# diff --git a/src/templates/template-text-classification/utils.py b/src/templates/template-text-classification/utils.py index eef5d85e..11a0ef3c 100644 --- a/src/templates/template-text-classification/utils.py +++ b/src/templates/template-text-classification/utils.py @@ -132,6 +132,8 @@ def setup_logging(config: Any) -> Logger: #::: if (it.save_training || it.save_evaluation || it.patience || it.terminate_on_nan || it.limit_sec) { :::# + + def setup_handlers( trainer: Engine, evaluator: Engine, diff --git a/src/templates/template-vision-classification/main.py b/src/templates/template-vision-classification/main.py index b2d92870..2610e18c 100644 --- a/src/templates/template-vision-classification/main.py +++ b/src/templates/template-vision-classification/main.py @@ -115,7 +115,7 @@ def _(): if rank == 0: exp_logger.close() #::: } :::# - + # #::: if (it.save_training || it.save_evaluation) { :::# # show last checkpoint names logger.info( diff --git a/src/templates/template-vision-classification/trainers.py b/src/templates/template-vision-classification/trainers.py index b25905dc..54ab28ef 100644 --- a/src/templates/template-vision-classification/trainers.py +++ b/src/templates/template-vision-classification/trainers.py @@ -38,6 +38,7 @@ def train_function(engine: Union[Engine, DeterministicEngine], batch: Any): } return {"train_loss": train_loss} + # #::: if(it.deterministic) { :::# trainer = DeterministicEngine(train_function) #::: } else { :::# diff --git a/src/templates/template-vision-classification/utils.py b/src/templates/template-vision-classification/utils.py index ba10476a..3dd5cc5b 100644 --- a/src/templates/template-vision-classification/utils.py +++ b/src/templates/template-vision-classification/utils.py @@ -132,6 +132,8 @@ def setup_logging(config: Any) -> Logger: #::: if (it.save_training || it.save_evaluation || it.patience || it.terminate_on_nan || it.limit_sec) { :::# + + def setup_handlers( trainer: Engine, evaluator: Engine, diff --git a/src/templates/template-vision-dcgan/main.py b/src/templates/template-vision-dcgan/main.py index e8e58db3..94965b0c 100644 --- a/src/templates/template-vision-dcgan/main.py +++ b/src/templates/template-vision-dcgan/main.py @@ -170,7 +170,7 @@ def _(): if rank == 0: exp_logger.close() #::: } :::# - + # #::: if (it.save_training || it.save_evaluation) { :::# # show last checkpoint names logger.info( diff --git a/src/templates/template-vision-dcgan/trainers.py b/src/templates/template-vision-dcgan/trainers.py index 4d1f90df..20f71ea5 100644 --- a/src/templates/template-vision-dcgan/trainers.py +++ b/src/templates/template-vision-dcgan/trainers.py @@ -88,6 +88,7 @@ def train_function(engine: Union[Engine, DeterministicEngine], batch: Any): return metrics + # #::: if(it.deterministic) { :::# trainer = DeterministicEngine(train_function) #::: } else { :::# diff --git a/src/templates/template-vision-dcgan/utils.py b/src/templates/template-vision-dcgan/utils.py index 43941f5a..1e4de292 100644 --- a/src/templates/template-vision-dcgan/utils.py +++ b/src/templates/template-vision-dcgan/utils.py @@ -132,6 +132,8 @@ def setup_logging(config: Any) -> Logger: #::: if (it.save_training || it.save_evaluation || it.patience || it.terminate_on_nan || it.limit_sec) { :::# + + def setup_handlers( trainer: Engine, evaluator: Engine, diff --git a/src/templates/template-vision-segmentation/main.py b/src/templates/template-vision-segmentation/main.py index e1369882..48bcafe9 100644 --- a/src/templates/template-vision-segmentation/main.py +++ b/src/templates/template-vision-segmentation/main.py @@ -178,7 +178,7 @@ def _(): if rank == 0: exp_logger.close() #::: } :::# - + # #::: if (it.save_training || it.save_evaluation) { :::# # show last checkpoint names logger.info( diff --git a/src/templates/template-vision-segmentation/trainers.py b/src/templates/template-vision-segmentation/trainers.py index e262c864..247c02a1 100644 --- a/src/templates/template-vision-segmentation/trainers.py +++ b/src/templates/template-vision-segmentation/trainers.py @@ -43,6 +43,7 @@ def train_function(engine: Engine, batch: Any): engine.state.metrics = metric return metric + # #::: if(it.deterministic) { :::# trainer = DeterministicEngine(train_function) #::: } else { :::# diff --git a/src/templates/template-vision-segmentation/utils.py b/src/templates/template-vision-segmentation/utils.py index 7e74a0c2..7b5335e5 100644 --- a/src/templates/template-vision-segmentation/utils.py +++ b/src/templates/template-vision-segmentation/utils.py @@ -132,6 +132,8 @@ def setup_logging(config: Any) -> Logger: #::: if (it.save_training || it.save_evaluation || it.patience || it.terminate_on_nan || it.limit_sec) { :::# + + def setup_handlers( trainer: Engine, evaluator: Engine,