Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(v3.5.2) SB3 Logger bug fix with wandb #429

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/train/train_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse

Check failure on line 1 in scripts/train/train_agent.py

View workflow job for this annotation

GitHub Actions / format-check

Imports are incorrectly sorted and/or formatted.
import json
import sys
from datetime import datetime
import traceback

import gymnasium as gym
import numpy as np
Expand Down Expand Up @@ -343,6 +344,7 @@

except (Exception, KeyboardInterrupt) as err:
print("Error or interruption in process detected")
print(traceback.print_exc(), file=sys.stderr)

# Current model state save
model.save(env.get_wrapper_attr('workspace_path') + '/model')
Expand Down
8 changes: 6 additions & 2 deletions scripts/train/train_agent_A2C.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"stats_window_size": 100,
"tensorboard_log": null,
"policy_kwargs": null,
"verbose": 0,
"verbose": 1,
"seed": null,
"device": "auto",
"_init_setup_model": true
Expand All @@ -42,7 +42,11 @@
"LoggerWrapper": {
"storage_class": "sinergym.utils.logger.LoggerStorage"
},
"CSVLogger": {}
"CSVLogger": {},
"WandBLogger": {
"entity": "sail_ugr",
"project_name": "test_project"
}
},
"evaluation": {
"eval_freq": 2,
Expand Down
8 changes: 6 additions & 2 deletions scripts/train/train_agent_DDPG.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"optimize_memory_usage": false,
"tensorboard_log": null,
"policy_kwargs": null,
"verbose": 0,
"verbose": 1,
"seed": null,
"device": "auto",
"_init_setup_model": true
Expand All @@ -39,7 +39,11 @@
"LoggerWrapper": {
"storage_class": "sinergym.utils.logger.LoggerStorage"
},
"CSVLogger": {}
"CSVLogger": {},
"WandBLogger": {
"entity": "sail_ugr",
"project_name": "test_project"
}
},
"evaluation": {
"eval_freq": 2,
Expand Down
6 changes: 5 additions & 1 deletion scripts/train/train_agent_DQN.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
"LoggerWrapper": {
"storage_class": "sinergym.utils.logger.LoggerStorage"
},
"CSVLogger": {}
"CSVLogger": {},
"WandBLogger": {
"entity": "sail_ugr",
"project_name": "test_project"
}
},
"evaluation": {
"eval_freq": 2,
Expand Down
6 changes: 5 additions & 1 deletion scripts/train/train_agent_PPO.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@
"LoggerWrapper": {
"storage_class": "sinergym.utils.logger.LoggerStorage"
},
"CSVLogger": {}
"CSVLogger": {},
"WandBLogger":{
"entity": "sail_ugr",
"project_name": "test_project"
}
},
"evaluation": {
"eval_freq": 2,
Expand Down
8 changes: 6 additions & 2 deletions scripts/train/train_agent_SAC.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"stats_window_size": 100,
"tensorboard_log": null,
"policy_kwargs": null,
"verbose": 0,
"verbose": 1,
"seed": null,
"device": "auto",
"_init_setup_model": true
Expand All @@ -46,7 +46,11 @@
"LoggerWrapper": {
"storage_class": "sinergym.utils.logger.LoggerStorage"
},
"CSVLogger": {}
"CSVLogger": {},
"WandBLogger": {
"entity": "sail_ugr",
"project_name": "test_project"
}
},
"evaluation": {
"eval_freq": 2,
Expand Down
6 changes: 5 additions & 1 deletion scripts/train/train_agent_TD3.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
"LoggerWrapper": {
"storage_class": "sinergym.utils.logger.LoggerStorage"
},
"CSVLogger": {}
"CSVLogger": {},
"WandBLogger": {
"entity": "sail_ugr",
"project_name": "test_project"
}
},
"evaluation": {
"eval_freq": 2,
Expand Down
2 changes: 1 addition & 1 deletion sinergym/utils/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(
self.train_env = train_env
self.n_eval_episodes = n_eval_episodes
self.eval_freq = eval_freq_episodes * \
train_env.get_wrapper_attr('timestep_per_episode') - 3
train_env.get_wrapper_attr('timestep_per_episode') - 30
self.save_path = self.train_env.get_wrapper_attr(
'workspace_path') + '/evaluation'
# Make dir if not exists
Expand Down
2 changes: 1 addition & 1 deletion sinergym/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ def write(

if isinstance(value, np.ScalarType):
if not isinstance(value, str):
wandb.log({key: value}, step=step)
wandb.log({key: value}, commit=False)
2 changes: 1 addition & 1 deletion sinergym/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.1
3.5.2
Loading