From 1cf2dff1d4eb55932a9eefb415e2112c9c86b391 Mon Sep 17 00:00:00 2001 From: sven1977 Date: Mon, 29 Jul 2024 19:55:47 +0200 Subject: [PATCH 1/4] wip Signed-off-by: sven1977 --- python/ray/air/integrations/wandb.py | 6 ++++-- .../checkpoints/continue_training_from_checkpoint.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/ray/air/integrations/wandb.py b/python/ray/air/integrations/wandb.py index 0511b4385f34..5b308881060d 100644 --- a/python/ray/air/integrations/wandb.py +++ b/python/ray/air/integrations/wandb.py @@ -15,6 +15,7 @@ from ray._private.storage import _load_class from ray.air import session from ray.air._internal import usage as air_usage +from ray.air.constants import TRAINING_ITERATION from ray.air.util.node import _force_on_current_node from ray.train._internal.syncer import DEFAULT_SYNC_TIMEOUT from ray.tune.experiment import Trial @@ -166,7 +167,7 @@ def _setup_wandb( project = _get_wandb_project(kwargs.pop("project", None)) group = kwargs.pop("group", os.environ.get(WANDB_GROUP_ENV_VAR)) - # remove unpickleable items + # Remove unpickleable items. _config = _clean_log(_config) wandb_init_kwargs = dict( @@ -415,7 +416,8 @@ def run(self): log, config_update = self._handle_result(item_content) try: self._wandb.config.update(config_update, allow_val_change=True) - self._wandb.log(log) + step = log.get(TRAINING_ITERATION) + self._wandb.log(log, step=step) except urllib.error.HTTPError as e: # Ignore HTTPError. Missing a few data points is not a # big issue, as long as things eventually recover. diff --git a/rllib/examples/checkpoints/continue_training_from_checkpoint.py b/rllib/examples/checkpoints/continue_training_from_checkpoint.py index 6eff1133e772..a9a526edaccb 100644 --- a/rllib/examples/checkpoints/continue_training_from_checkpoint.py +++ b/rllib/examples/checkpoints/continue_training_from_checkpoint.py @@ -239,9 +239,9 @@ def on_train_result(self, *, algorithm, metrics_logger, result, **kwargs): # Train one iteration to make sure, the performance does not collapse (e.g. due # to the optimizer weights not having been restored properly). test_results = test_algo.train() - assert ( - test_results[ENV_RUNNER_RESULTS][EPISODE_RETURN_MEAN] >= args.stop_reward_crash - ) + #assert ( + # test_results[ENV_RUNNER_RESULTS][EPISODE_RETURN_MEAN] >= args.stop_reward_crash + #), test_results[ENV_RUNNER_RESULTS][EPISODE_RETURN_MEAN] # Stop the test algorithm again. test_algo.stop() From b73da5c5d39f825954957fb8f4603bac9dc6a980 Mon Sep 17 00:00:00 2001 From: sven1977 Date: Wed, 31 Jul 2024 10:02:41 +0200 Subject: [PATCH 2/4] wip Signed-off-by: sven1977 --- .../checkpoints/continue_training_from_checkpoint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rllib/examples/checkpoints/continue_training_from_checkpoint.py b/rllib/examples/checkpoints/continue_training_from_checkpoint.py index a9a526edaccb..6fff3d432878 100644 --- a/rllib/examples/checkpoints/continue_training_from_checkpoint.py +++ b/rllib/examples/checkpoints/continue_training_from_checkpoint.py @@ -239,9 +239,9 @@ def on_train_result(self, *, algorithm, metrics_logger, result, **kwargs): # Train one iteration to make sure, the performance does not collapse (e.g. due # to the optimizer weights not having been restored properly). test_results = test_algo.train() - #assert ( - # test_results[ENV_RUNNER_RESULTS][EPISODE_RETURN_MEAN] >= args.stop_reward_crash - #), test_results[ENV_RUNNER_RESULTS][EPISODE_RETURN_MEAN] + assert ( + test_results[ENV_RUNNER_RESULTS][EPISODE_RETURN_MEAN] >= args.stop_reward_crash + ), test_results[ENV_RUNNER_RESULTS][EPISODE_RETURN_MEAN] # Stop the test algorithm again. test_algo.stop() From 1ef67effefee4d371dad0d32dc1a5ca3adfc0c79 Mon Sep 17 00:00:00 2001 From: sven1977 Date: Wed, 31 Jul 2024 15:40:16 +0200 Subject: [PATCH 3/4] wip Signed-off-by: sven1977 --- python/ray/air/integrations/wandb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/ray/air/integrations/wandb.py b/python/ray/air/integrations/wandb.py index 5b308881060d..fcd683ec0e7f 100644 --- a/python/ray/air/integrations/wandb.py +++ b/python/ray/air/integrations/wandb.py @@ -416,8 +416,7 @@ def run(self): log, config_update = self._handle_result(item_content) try: self._wandb.config.update(config_update, allow_val_change=True) - step = log.get(TRAINING_ITERATION) - self._wandb.log(log, step=step) + self._wandb.log(log, step=log.get(TRAINING_ITERATION)) except urllib.error.HTTPError as e: # Ignore HTTPError. Missing a few data points is not a # big issue, as long as things eventually recover. From e6bdc7a9400e7c454e34a1aa93279bae63a285a3 Mon Sep 17 00:00:00 2001 From: sven1977 Date: Wed, 31 Jul 2024 15:53:54 +0200 Subject: [PATCH 4/4] wip Signed-off-by: sven1977 --- python/ray/air/tests/mocked_wandb_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ray/air/tests/mocked_wandb_integration.py b/python/ray/air/tests/mocked_wandb_integration.py index 323ee25153d4..6ed098345033 100644 --- a/python/ray/air/tests/mocked_wandb_integration.py +++ b/python/ray/air/tests/mocked_wandb_integration.py @@ -65,7 +65,7 @@ def init(self, *args, **kwargs): return mock - def log(self, data): + def log(self, data, step=None): try: json_dumps_safer(data) except Exception: