Skip to content
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
1 change: 1 addition & 0 deletions com.unity.ml-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to
2. env_params.restarts_rate_limit_n (--restarts-rate-limit-n) [default=1]
3. env_params.restarts_rate_limit_period_s (--restarts-rate-limit-period-s) [default=60]
### Bug Fixes
- Fixed the bug where curriculum learning would crash because of the incorrect run_options parsing. (#5586)

#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)

Expand Down
4 changes: 3 additions & 1 deletion ml-agents/mlagents/trainers/subprocess_env_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
EnvironmentStats,
StatsSideChannel,
)
from mlagents.training_analytics_side_channel import TrainingAnalyticsSideChannel
from mlagents.trainers.training_analytics_side_channel import (
TrainingAnalyticsSideChannel,
)
from mlagents_envs.side_channel.side_channel import SideChannel


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import yaml
from mlagents.trainers.settings import RunOptions
from mlagents.trainers.training_analytics_side_channel import (
TrainingAnalyticsSideChannel,
)

test_curriculum_config_yaml = """
environment_parameters:
param_1:
curriculum:
- name: Lesson1
completion_criteria:
measure: reward
behavior: fake_behavior
threshold: 30
min_lesson_length: 100
require_reset: true
value: 1
- name: Lesson2
completion_criteria:
measure: reward
behavior: fake_behavior
threshold: 60
min_lesson_length: 100
require_reset: false
value: 2
- name: Lesson3
value:
sampler_type: uniform
sampler_parameters:
min_value: 1
max_value: 3
"""


def test_sanitize_run_options():
run_options = RunOptions.from_dict(yaml.safe_load(test_curriculum_config_yaml))
sanitized = TrainingAnalyticsSideChannel._sanitize_run_options(run_options)
assert "param_1" not in sanitized["environment_parameters"]
assert "fake_behavior" not in sanitized["environment_parameters"]
assert (
TrainingAnalyticsSideChannel._hash("param_1")
in sanitized["environment_parameters"]
)
level1 = TrainingAnalyticsSideChannel._hash("param_1")
assert sanitized["environment_parameters"][level1]["curriculum"][0][
"completion_criteria"
]["behavior"] == TrainingAnalyticsSideChannel._hash("fake_behavior")
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ def _sanitize_run_options(cls, config: RunOptions) -> Dict[str, Any]:
updated_lessons = []
for lesson in curriculum["curriculum"]:
new_lesson = copy.deepcopy(lesson)
if lesson.has_keys("name"):
if "name" in lesson:
new_lesson["name"] = cls._hash(lesson["name"])
if lesson.has_keys("completion_criteria"):
if (
"completion_criteria" in lesson
and lesson["completion_criteria"] is not None
):
new_lesson["completion_criteria"]["behavior"] = cls._hash(
new_lesson["completion_criteria"]["behavior"]
)
Expand Down