Skip to content

Commit 3ee0963

Browse files
author
Ervin T
authored
Merge pull request #2380 from Unity-Technologies/release-0.9.0
Release v0.9.0
2 parents 9b1a399 + 52c004b commit 3ee0963

File tree

312 files changed

+10560
-2657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+10560
-2657
lines changed

.circleci/config.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
pip install --upgrade setuptools
2525
cd ml-agents-envs && pip install -e .
2626
cd ../ml-agents && pip install -e .
27-
pip install black pytest-cov==2.6.1 codacy-coverage==1.3.11
27+
pip install pre-commit pytest-cov==2.6.1
2828
cd ../gym-unity && pip install -e .
2929
3030
- save_cache:
@@ -38,15 +38,12 @@ jobs:
3838
. venv/bin/activate
3939
mkdir test-reports
4040
pytest --cov=mlagents --cov-report xml --junitxml=test-reports/junit.xml -p no:warnings
41-
python-codacy-coverage -r coverage.xml
4241
4342
- run:
44-
name: Check Code Style for ml-agents and gym_unity using black
43+
name: Check Code Style using pre-commit
4544
command: |
4645
. venv/bin/activate
47-
black --check ml-agents
48-
black --check ml-agents-envs
49-
black --check gym-unity
46+
pre-commit run --show-diff-on-failure --all-files
5047
5148
- run:
5249
name: Verify there are no hidden/missing metafiles.

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,19 @@
8686
.DS_Store
8787
.ipynb_checkpoints
8888

89-
# pytest cache
89+
# pytest cache
9090
*.pytest_cache/
9191

9292
# Ignore compiled protobuf files.
93-
ml-agents-protobuf/cs
94-
ml-agents-protobuf/python
95-
ml-agents-protobuf/Grpc*
93+
*Grpc.Tools*
9694

9795
# Ignore PyPi build files.
9896
dist/
9997
build/
10098

10199
# Python virtual environment
102100
venv/
101+
.mypy_cache/
102+
103+
# Code coverage report
104+
.coverage

.pre-commit-config.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
repos:
2+
- repo: https://github.com/python/black
3+
rev: 19.3b0
4+
hooks:
5+
- id: black
6+
- repo: https://github.com/pre-commit/mirrors-mypy
7+
rev: v0.720
8+
hooks:
9+
- id: mypy
10+
name: mypy-ml-agents
11+
files: "ml-agents/.*"
12+
args: [--ignore-missing-imports, --disallow-incomplete-defs]
13+
- id: mypy
14+
name: mypy-ml-agents-envs
15+
files: "ml-agents-envs/.*"
16+
# Exclude protobuf files and don't follow them when imported
17+
exclude: ".*_pb2.py"
18+
# TODO get disallow-incomplete-defs working
19+
args: [--ignore-missing-imports, --follow-imports=silent]
20+
- id: mypy
21+
name: mypy-gym-unity
22+
files: "gym-unity/.*"
23+
args: [--ignore-missing-imports, --disallow-incomplete-defs]
24+
- repo: https://github.com/pre-commit/pre-commit-hooks
25+
rev: v2.2.3
26+
hooks:
27+
- id: mixed-line-ending
28+
exclude: >
29+
(?x)^(
30+
.*cs.meta|
31+
.*.css
32+
)$
33+
args: [--fix=lf]
34+
- id: flake8
35+
exclude: >
36+
(?x)^(
37+
.*_pb2.py|
38+
.*_pb2_grpc.py
39+
)$

CONTRIBUTING.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ the platform, and provide a unique non-trivial challenge to modern
4848
machine learning algorithms. Feel free to submit these environments with a
4949
PR explaining the nature of the environment and task.
5050

51-
## Style Guide
51+
## Continuous Integration (CI)
5252

53-
When performing changes to the codebase, please ensure that all python code is reformatted using the [black](https://github.com/ambv/black) formatter. For C#, we will soon be requirements for style and formatting.
53+
We run CircleCI on all PRs; all tests must be passing before the PR is merged.
54+
55+
Several static checks are run on the codebase using the [pre-commit framework](https://pre-commit.com/) during CI. To execute the same checks locally, install `pre-commit` and run `pre-commit run --all-files`. Some hooks (for example, `black`) will output the corrected version of the code; others (like `mypy`) may require more effort to fix.
56+
57+
### Code style
58+
All python code should be formatted with [`black`](https://github.com/ambv/black). Style and formatting for C# may be enforced later.
59+
60+
### Python type annotations
61+
We use [`mypy`](http://mypy-lang.org/) to perform static type checking on python code. Currently not all code is annotated but we will increase coverage over time. If you are adding or refactoring code, please
62+
1. Add type annotations to the new or refactored code.
63+
2. Make sure that code calling or called by the modified code also has type annotations.
64+
65+
The [type hint cheat sheet](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html) provides a good introduction to adding type hints.
66+
67+
## Contributor License Agreements
68+
69+
When you open a pull request, you will be asked to acknolwedge our Contributor License Agreement. We allow both individual contributions and contributions made on behalf of companies. We use an open source tool called CLA assistant. If you have any questions on our CLA, please [submit an issue](https://github.com/Unity-Technologies/ml-agents/issues) or email us at [email protected].

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ developer communities.
2727
* 10+ sample Unity environments
2828
* Support for multiple environment configurations and training scenarios
2929
* Train memory-enhanced agents using deep reinforcement learning
30-
* Easily definable Curriculum Learning scenarios
30+
* Easily definable Curriculum Learning and Generalization scenarios
3131
* Broadcasting of agent behavior for supervised learning
3232
* Built-in support for Imitation Learning
3333
* Flexible agent control with On Demand Decision Making
@@ -77,11 +77,11 @@ If you run into any problems using the ML-Agents toolkit,
7777
[submit an issue](https://github.com/Unity-Technologies/ml-agents/issues) and
7878
make sure to include as much detail as possible.
7979

80-
Your opinion matters a great deal to us. Only by hearing your thoughts on the Unity ML-Agents Toolkit can we continue to improve and grow. Please take a few minutes to [let us know about it](https://github.com/Unity-Technologies/ml-agents/issues/1454).
80+
Your opinion matters a great deal to us. Only by hearing your thoughts on the Unity ML-Agents Toolkit can we continue to improve and grow. Please take a few minutes to [let us know about it](https://github.com/Unity-Technologies/ml-agents/issues/1454).
8181

8282

8383
For any other questions or feedback, connect directly with the ML-Agents
84-
84+
8585

8686
## Translations
8787

@@ -93,6 +93,7 @@ translating more pages and to other languages. Consequently,
9393
we welcome any enhancements and improvements from the community.
9494

9595
* [Chinese](docs/localized/zh-CN/)
96+
* [Korean](docs/localized/KR/)
9697

9798
## License
9899

UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorApplier.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using NUnit.Framework;
44
using UnityEngine;
55
using System.Reflection;
6+
using Barracuda;
67
using MLAgents.InferenceBrain;
78

89
namespace MLAgents.Tests
@@ -35,17 +36,20 @@ private Dictionary<Agent, AgentInfo> GetFakeAgentInfos()
3536
public void Contruction()
3637
{
3738
var bp = new BrainParameters();
38-
var tensorGenerator = new TensorApplier(bp, 0);
39+
var alloc = new TensorCachingAllocator();
40+
var tensorGenerator = new TensorApplier(bp, 0, alloc);
3941
Assert.IsNotNull(tensorGenerator);
42+
alloc.Dispose();
4043
}
4144

4245
[Test]
4346
public void ApplyContinuousActionOutput()
4447
{
45-
var inputTensor = new Tensor()
48+
var inputTensor = new TensorProxy()
4649
{
4750
Shape = new long[] {2, 3},
48-
Data = new float[,] {{1, 2, 3}, {4, 5, 6}}
51+
Data = new Tensor (2, 3, new float[] {1, 2, 3,
52+
4, 5, 6})
4953
};
5054
var agentInfos = GetFakeAgentInfos();
5155

@@ -67,15 +71,15 @@ public void ApplyContinuousActionOutput()
6771
[Test]
6872
public void ApplyDiscreteActionOutput()
6973
{
70-
var inputTensor = new Tensor()
74+
var inputTensor = new TensorProxy()
7175
{
7276
Shape = new long[] {2, 5},
73-
Data = new float[,] {{0.5f, 22.5f, 0.1f, 5f, 1f},
74-
{4f, 5f, 6f, 7f, 8f}}
77+
Data = new Tensor (2, 5, new[] {0.5f, 22.5f, 0.1f, 5f, 1f,
78+
4f, 5f, 6f, 7f, 8f})
7579
};
7680
var agentInfos = GetFakeAgentInfos();
77-
78-
var applier = new DiscreteActionOutputApplier(new int[]{2, 3}, 0);
81+
var alloc = new TensorCachingAllocator();
82+
var applier = new DiscreteActionOutputApplier(new int[]{2, 3}, 0, alloc);
7983
applier.Apply(inputTensor, agentInfos);
8084
var agents = agentInfos.Keys.ToList();
8185
var agent = agents[0] as TestAgent;
@@ -86,16 +90,17 @@ public void ApplyDiscreteActionOutput()
8690
action = agent.GetAction();
8791
Assert.AreEqual(action.vectorActions[0], 1);
8892
Assert.AreEqual(action.vectorActions[1], 2);
93+
alloc.Dispose();
8994
}
9095

9196
[Test]
9297
public void ApplyMemoryOutput()
9398
{
94-
var inputTensor = new Tensor()
99+
var inputTensor = new TensorProxy()
95100
{
96101
Shape = new long[] {2, 5},
97-
Data = new float[,] {{0.5f, 22.5f, 0.1f, 5f, 1f},
98-
{4f, 5f, 6f, 7f, 8f}}
102+
Data = new Tensor (2, 5, new[] {0.5f, 22.5f, 0.1f, 5f, 1f,
103+
4f, 5f, 6f, 7f, 8f})
99104
};
100105
var agentInfos = GetFakeAgentInfos();
101106

@@ -115,10 +120,10 @@ public void ApplyMemoryOutput()
115120
[Test]
116121
public void ApplyValueEstimate()
117122
{
118-
var inputTensor = new Tensor()
123+
var inputTensor = new TensorProxy()
119124
{
120125
Shape = new long[] {2, 1},
121-
Data = new float[,] {{0.5f}, {8f}}
126+
Data = new Tensor (2, 1, new[]{0.5f, 8f})
122127
};
123128
var agentInfos = GetFakeAgentInfos();
124129

0 commit comments

Comments
 (0)