diff --git a/examples/entrypoint/task.py b/examples/entrypoint/task.py index c9f8a45..ca6c13b 100644 --- a/examples/entrypoint/task.py +++ b/examples/entrypoint/task.py @@ -41,7 +41,6 @@ def my_optimizer( ) -@run.cli.entrypoint def train_model( model: Model = my_model(), optimizer: Optimizer = my_optimizer(), diff --git a/src/nemo_run/cli/api.py b/src/nemo_run/cli/api.py index 5e3e8ae..e203535 100644 --- a/src/nemo_run/cli/api.py +++ b/src/nemo_run/cli/api.py @@ -192,13 +192,10 @@ def main(fn: F): Execute the main CLI entrypoint for the given function. This function is used to run the CLI entrypoint associated with a decorated function. - It checks if the function is properly decorated as an entrypoint and then executes its main CLI logic. + If the function is not decorated as an entrypoint, it will be wrapped with the default entrypoint. Args: - fn (F): The function decorated with the @entrypoint decorator. - - Raises: - ValueError: If the provided function is not decorated as an entrypoint. + fn (F): The function to be executed as a CLI entrypoint. Example: @entrypoint @@ -210,7 +207,8 @@ def my_cli_function(): main(my_cli_function) """ if not isinstance(fn, EntrypointProtocol): - raise ValueError("The function is not an entrypoint.") + # Wrap the function with the default entrypoint + fn = entrypoint()(fn) fn.cli_entrypoint.main() @@ -745,11 +743,20 @@ def command( def launch(self, experiment: Experiment, sequential: bool = False): """ - Launch the given experiment. + Launch the given experiment, respecting the RunContext settings. + + This method launches the experiment, taking into account the various options + set in the RunContext, such as dryrun, detach, direct execution, and log tailing. Args: experiment (Experiment): The experiment to launch. sequential (bool): If True, run the experiment sequentially. + + Note: + - If self.dryrun is True, it will only perform a dry run of the experiment. + - The method respects self.detach for detached execution. + - It uses direct execution if self.direct is True or if no executor is set. + - Log tailing behavior is controlled by self.tail_logs. """ if self.dryrun: experiment.dryrun()