From 73a494cbe067f2f9491d37dcacf1a7c48b91bd92 Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Wed, 16 Apr 2025 09:50:58 +0000 Subject: [PATCH 1/4] Add function to update W&B run name with sequence number --- amp_rsl_rl/runners/amp_on_policy_runner.py | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/amp_rsl_rl/runners/amp_on_policy_runner.py b/amp_rsl_rl/runners/amp_on_policy_runner.py index e090dd6..8ffd134 100644 --- a/amp_rsl_rl/runners/amp_on_policy_runner.py +++ b/amp_rsl_rl/runners/amp_on_policy_runner.py @@ -234,12 +234,46 @@ def learn(self, num_learning_iterations: int, init_at_random_ep_len: bool = Fals ) elif self.logger_type == "wandb": from rsl_rl.utils.wandb_utils import WandbSummaryWriter + import wandb + + # Update the run name with a sequence number. This function is usefull to + # replicate the same behaviour of rsl-rl-lib before v2.3.0 + def update_run_name_with_sequence(prefix: str) -> None: + # Retrieve the current wandb run details (project and entity) + project = wandb.run.project + entity = wandb.run.entity + + # Use wandb's API to list all runs in your project + api = wandb.Api() + runs = api.runs(f"{entity}/{project}") + + max_num = 0 + # Iterate through runs to extract the numeric suffix after the prefix. + for run in runs: + if run.name.startswith(prefix): + # Extract the numeric part from the run name. + numeric_suffix = run.name[ + len(prefix) : + ] # e.g., from "prefix564", get "542" + try: + run_num = int(numeric_suffix) + if run_num > max_num: + max_num = run_num + except ValueError: + continue + + # Increment to get the new run number + new_num = max_num + 1 + new_run_name = f"{prefix}{new_num}" + + # Update the wandb run's name + wandb.run.name = new_run_name + print("Updated run name to:", wandb.run.name) self.writer = WandbSummaryWriter( log_dir=self.log_dir, flush_secs=10, cfg=self.cfg ) - - import wandb + update_run_name_with_sequence(prefix=self.cfg["wandb_project"]) wandb.gym.monitor() self.writer.log_config( From 11a680ba038d0927107ae6e7a4744e0e8b109fda Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Wed, 16 Apr 2025 09:51:28 +0000 Subject: [PATCH 2/4] Format the file with black --- amp_rsl_rl/utils/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/amp_rsl_rl/utils/__init__.py b/amp_rsl_rl/utils/__init__.py index 404527b..0ede374 100644 --- a/amp_rsl_rl/utils/__init__.py +++ b/amp_rsl_rl/utils/__init__.py @@ -10,4 +10,10 @@ from .motion_loader import AMPLoader, download_amp_dataset_from_hf from .exporter import export_policy_as_onnx -__all__ = ["Normalizer", "RunningMeanStd", "AMPLoader", "download_amp_dataset_from_hf", "export_policy_as_onnx"] +__all__ = [ + "Normalizer", + "RunningMeanStd", + "AMPLoader", + "download_amp_dataset_from_hf", + "export_policy_as_onnx", +] From a2ea037cbf61d058e41e3c7a2fc419ba98eb16ac Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Wed, 16 Apr 2025 11:57:12 +0200 Subject: [PATCH 3/4] Update amp_rsl_rl/runners/amp_on_policy_runner.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- amp_rsl_rl/runners/amp_on_policy_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp_rsl_rl/runners/amp_on_policy_runner.py b/amp_rsl_rl/runners/amp_on_policy_runner.py index 8ffd134..977ebaa 100644 --- a/amp_rsl_rl/runners/amp_on_policy_runner.py +++ b/amp_rsl_rl/runners/amp_on_policy_runner.py @@ -236,7 +236,7 @@ def learn(self, num_learning_iterations: int, init_at_random_ep_len: bool = Fals from rsl_rl.utils.wandb_utils import WandbSummaryWriter import wandb - # Update the run name with a sequence number. This function is usefull to + # Update the run name with a sequence number. This function is useful to # replicate the same behaviour of rsl-rl-lib before v2.3.0 def update_run_name_with_sequence(prefix: str) -> None: # Retrieve the current wandb run details (project and entity) From 6056d4443558f33ce3277426a670e3e6238f96b7 Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Wed, 16 Apr 2025 11:58:03 +0200 Subject: [PATCH 4/4] Update amp_on_policy_runner.py --- amp_rsl_rl/runners/amp_on_policy_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp_rsl_rl/runners/amp_on_policy_runner.py b/amp_rsl_rl/runners/amp_on_policy_runner.py index 977ebaa..5e074e5 100644 --- a/amp_rsl_rl/runners/amp_on_policy_runner.py +++ b/amp_rsl_rl/runners/amp_on_policy_runner.py @@ -254,7 +254,7 @@ def update_run_name_with_sequence(prefix: str) -> None: # Extract the numeric part from the run name. numeric_suffix = run.name[ len(prefix) : - ] # e.g., from "prefix564", get "542" + ] # e.g., from "prefix564", get "564" try: run_num = int(numeric_suffix) if run_num > max_num: