The Wayback Machine - https://web.archive.org/web/20210206160915/https://github.com/Unity-Technologies/ml-agents/pull/4788
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

setuptools-based plugin for StatsWriters #4788

Merged
merged 15 commits into from Feb 5, 2021
Merged

Conversation

@chriselion
Copy link
Collaborator

@chriselion chriselion commented Dec 21, 2020

Proposed change(s)

Adds a setuptools-based plugin system, and an interface for registering custom StatsWriters. Also refactored some of the output directory settings so that TensorBoardWriter just needs the RunOptions.

For more background, see this video and example code.

Example output:

$ mlagents-learn --force
...
2020-12-21 15:06:51 INFO [learn.py:274] run_seed set to 249
registering default
registering example
Creating a new stats writer! This is so exciting!

...

ExampleStatsWriter category: 3DBall values: {'Policy/Entropy': StatsSummary(mean=1.4183114, std=0.00084836915, num=50172), ...}

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

https://github.com/anthonywritescode/explains/tree/master/sample_code/ep128
https://www.youtube.com/watch?v=fY3Y_xPKWNA

Types of change(s)

  • New feature

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
@@ -0,0 +1,11 @@
from setuptools import setup

This comment has been minimized.

@chriselion

chriselion Dec 21, 2020
Author Collaborator

No plans to publish this package, but we could use it to set up tests, e.g. for bad imports.

],
python_requires=">=3.6.1",
entry_points={
"console_scripts": [
"mlagents-learn=mlagents.trainers.learn:main",
"mlagents-run-experiment=mlagents.trainers.run_experiment:main",
]
],
"mlagents.stats_writer": [

This comment has been minimized.

@chriselion

chriselion Dec 21, 2020
Author Collaborator

We would need to add a new key for each type of plugin interface we want, e.g. mlagents.demonstration_provider: [...]

version="0.0.1",
entry_points={
"mlagents.stats_writer": [
"example=mlagents_plugin_examples.example_stats_writer:get_example_stats_writer"

This comment has been minimized.

@chriselion

chriselion Dec 21, 2020
Author Collaborator

The form of this is {entry point name}={plugin module}:{plugin_function}

@chriselion chriselion mentioned this pull request Jan 22, 2021
2 of 10 tasks complete
chriselion added 6 commits Jan 29, 2021
@chriselion chriselion changed the title [WIP] proof-of-concept - setuptools-based plugin for StatsWriters setuptools-based plugin for StatsWriters Feb 1, 2021
@chriselion chriselion marked this pull request as ready for review Feb 1, 2021
@chriselion chriselion requested review from ervteng and vincentpierre Feb 1, 2021
"example=mlagents_plugin_examples.example_stats_writer:get_example_stats_writer"
]
```
* `mlagents.stats_writer` is the name of the plugin interface. This must be one of the provided interfaces (see below).

This comment has been minimized.

@vincentpierre

vincentpierre Feb 3, 2021
Collaborator

Make the see below a link to line 41

This comment has been minimized.

@chriselion

chriselion Feb 5, 2021
Author Collaborator

Done

docs/Training-Plugins.md Show resolved Hide resolved
ml-agents/mlagents/plugins/stats_writer.py Outdated Show resolved Hide resolved
argparser.add_argument(
"--results-dir", default="results", help="Results base directory"
)
Comment on lines +192 to +194

This comment has been minimized.

@vincentpierre

vincentpierre Feb 3, 2021
Collaborator

Is this relevant to this PR? Why are we adding this flag ?

This comment has been minimized.

@chriselion

chriselion Feb 5, 2021
Author Collaborator

This was previously hardcoded in learn.py
https://github.com/Unity-Technologies/ml-agents/pull/4788/files#diff-4e0d7b8aef419254e6fc3c63f5baa53f222afda7c908705e857a22f7d4792c47L68

and is now used in CheckpointSettings.maybe_init_path()
https://github.com/Unity-Technologies/ml-agents/pull/4788/files#diff-546e90789e914f8707fd97391f78c4bba39ae69a965858bbb69c2d324db1ec51R719

I can keep it hardcoded if you prefer, but I do think moving all the path logic to part of RunOptions is a win (and basically a pre-req to make TensorBoardWriter act like a plugin)

This comment has been minimized.

@ervteng

ervteng Feb 5, 2021
Collaborator

If a user changes this from the default results will it mess with how they're saved/synced in cloud? cc: @hvpeteet

This comment has been minimized.

@hvpeteet

hvpeteet Feb 5, 2021
Contributor

If a user can set it in the run_options then yes this could mess with cloud since we don't already take it into account. I don't think it is a reason not to make the change though. We can add logic to overwrite this field since we already modify run_options.

Just a couple of questions to confirm my understanding:

  1. Would this be set under checkpoint_settings --> write_path?
  2. Could we (cloud) blindly set this for every experiment and it would be ignored by older mlagents versions?

This comment has been minimized.

@chriselion

chriselion Feb 5, 2021
Author Collaborator
  1. It would be checkpoint_settings -> results_dir (at the top level)
  2. This would trigger an error here
    def check_and_structure(key: str, value: Any, class_type: type) -> Any:

This comment has been minimized.

@hvpeteet

hvpeteet Feb 5, 2021
Contributor

Thanks, we can check for it and only overwrite it if already set then. When you check this in can you file a ticket against me to make sure we get this added at some point?

This comment has been minimized.

@chriselion

chriselion Feb 5, 2021
Author Collaborator

Will do

@chriselion chriselion merged commit ef03bf6 into master Feb 5, 2021
36 checks passed
36 checks passed
pre-commit
Details
pytest (3.6.x)
Details
pytest (3.7.x)
Details
pytest (3.8.x)
Details
markdown-link-check
Details
validate-meta-files
Details
[Yamato] Pack Succeeded
Details
[Yamato] Test Compressed Sensor Observation 2018.4 Succeeded
Details
[Yamato] Test Compressed Sensor Observation 2019.4 Succeeded
Details
[Yamato] Test Compressed Sensor Observation 2020.1 Succeeded
Details
[Yamato] Test Compressed Sensor Observation 2020.2 Succeeded
Details
[Yamato] Test Linux Fast Training 2018.4 Succeeded
Details
[Yamato] Test Linux Fast Training 2019.4 Succeeded
Details
[Yamato] Test Linux Fast Training 2020.1 Succeeded
Details
[Yamato] Test Linux Fast Training 2020.2 Succeeded
Details
[Yamato] Test Linux Gym Interface 2018.4 Succeeded
Details
[Yamato] Test Linux Gym Interface 2019.4 Succeeded
Details
[Yamato] Test Linux Gym Interface 2020.1 Succeeded
Details
[Yamato] Test Linux Gym Interface 2020.2 Succeeded
Details
[Yamato] Test Linux LL-API 2018.4 Succeeded
Details
[Yamato] Test Linux LL-API 2019.4 Succeeded
Details
[Yamato] Test Linux LL-API 2020.1 Succeeded
Details
[Yamato] Test Linux LL-API 2020.2 Succeeded
Details
[Yamato] Test Linux Standalone 2018.4 Succeeded
Details
[Yamato] Test Linux Standalone 2019.4 Succeeded
Details
[Yamato] Test Linux Standalone 2020.1 Succeeded
Details
[Yamato] Test Linux Standalone 2020.2 Succeeded
Details
[Yamato] com.unity.ml-agents test 2018.4 on linux Succeeded
Details
[Yamato] com.unity.ml-agents test 2019.4 on linux Succeeded
Details
[Yamato] com.unity.ml-agents test 2020.1 on linux Succeeded
Details
[Yamato] com.unity.ml-agents test 2020.2 on linux Succeeded
Details
[Yamato] com.unity.ml-agents.extensions test 2018.4 on linux Succeeded
Details
[Yamato] com.unity.ml-agents.extensions test 2019.4 on linux Succeeded
Details
[Yamato] com.unity.ml-agents.extensions test 2020.1 on linux Succeeded
Details
[Yamato] com.unity.ml-agents.extensions test 2020.2 on linux Succeeded
Details
license/cla Contributor License Agreement is signed.
Details
@delete-merged-branch delete-merged-branch bot deleted the plugin-setuptools-statswriter branch Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants