Skip to content

Commit

Permalink
Merge pull request #2380 from Unity-Technologies/release-0.9.0
Browse files Browse the repository at this point in the history
Release v0.9.0
  • Loading branch information
Ervin T committed Aug 1, 2019
2 parents 9b1a399 + 52c004b commit 3ee0963
Show file tree
Hide file tree
Showing 312 changed files with 10,560 additions and 2,657 deletions.
9 changes: 3 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
pip install --upgrade setuptools
cd ml-agents-envs && pip install -e .
cd ../ml-agents && pip install -e .
pip install black pytest-cov==2.6.1 codacy-coverage==1.3.11
pip install pre-commit pytest-cov==2.6.1
cd ../gym-unity && pip install -e .
- save_cache:
Expand All @@ -38,15 +38,12 @@ jobs:
. venv/bin/activate
mkdir test-reports
pytest --cov=mlagents --cov-report xml --junitxml=test-reports/junit.xml -p no:warnings
python-codacy-coverage -r coverage.xml
- run:
name: Check Code Style for ml-agents and gym_unity using black
name: Check Code Style using pre-commit
command: |
. venv/bin/activate
black --check ml-agents
black --check ml-agents-envs
black --check gym-unity
pre-commit run --show-diff-on-failure --all-files
- run:
name: Verify there are no hidden/missing metafiles.
Expand Down
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@
.DS_Store
.ipynb_checkpoints

# pytest cache
# pytest cache
*.pytest_cache/

# Ignore compiled protobuf files.
ml-agents-protobuf/cs
ml-agents-protobuf/python
ml-agents-protobuf/Grpc*
*Grpc.Tools*

# Ignore PyPi build files.
dist/
build/

# Python virtual environment
venv/
.mypy_cache/

# Code coverage report
.coverage
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
repos:
- repo: https://github.com/python/black
rev: 19.3b0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.720
hooks:
- id: mypy
name: mypy-ml-agents
files: "ml-agents/.*"
args: [--ignore-missing-imports, --disallow-incomplete-defs]
- id: mypy
name: mypy-ml-agents-envs
files: "ml-agents-envs/.*"
# Exclude protobuf files and don't follow them when imported
exclude: ".*_pb2.py"
# TODO get disallow-incomplete-defs working
args: [--ignore-missing-imports, --follow-imports=silent]
- id: mypy
name: mypy-gym-unity
files: "gym-unity/.*"
args: [--ignore-missing-imports, --disallow-incomplete-defs]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: mixed-line-ending
exclude: >
(?x)^(
.*cs.meta|
.*.css
)$
args: [--fix=lf]
- id: flake8
exclude: >
(?x)^(
.*_pb2.py|
.*_pb2_grpc.py
)$
20 changes: 18 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ the platform, and provide a unique non-trivial challenge to modern
machine learning algorithms. Feel free to submit these environments with a
PR explaining the nature of the environment and task.

## Style Guide
## Continuous Integration (CI)

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.
We run CircleCI on all PRs; all tests must be passing before the PR is merged.

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.

### Code style
All python code should be formatted with [`black`](https://github.com/ambv/black). Style and formatting for C# may be enforced later.

### Python type annotations
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
1. Add type annotations to the new or refactored code.
2. Make sure that code calling or called by the modified code also has type annotations.

The [type hint cheat sheet](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html) provides a good introduction to adding type hints.

## Contributor License Agreements

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 ml-agents@unity3d.com.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ developer communities.
* 10+ sample Unity environments
* Support for multiple environment configurations and training scenarios
* Train memory-enhanced agents using deep reinforcement learning
* Easily definable Curriculum Learning scenarios
* Easily definable Curriculum Learning and Generalization scenarios
* Broadcasting of agent behavior for supervised learning
* Built-in support for Imitation Learning
* Flexible agent control with On Demand Decision Making
Expand Down Expand Up @@ -77,11 +77,11 @@ If you run into any problems using the ML-Agents toolkit,
[submit an issue](https://github.com/Unity-Technologies/ml-agents/issues) and
make sure to include as much detail as possible.

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).
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).


For any other questions or feedback, connect directly with the ML-Agents
team at ml-agents@unity3d.com.
team at ml-agents@unity3d.com.

## Translations

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

* [Chinese](docs/localized/zh-CN/)
* [Korean](docs/localized/KR/)

## License

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NUnit.Framework;
using UnityEngine;
using System.Reflection;
using Barracuda;
using MLAgents.InferenceBrain;

namespace MLAgents.Tests
Expand Down Expand Up @@ -35,17 +36,20 @@ public AgentAction GetAction()
public void Contruction()
{
var bp = new BrainParameters();
var tensorGenerator = new TensorApplier(bp, 0);
var alloc = new TensorCachingAllocator();
var tensorGenerator = new TensorApplier(bp, 0, alloc);
Assert.IsNotNull(tensorGenerator);
alloc.Dispose();
}

[Test]
public void ApplyContinuousActionOutput()
{
var inputTensor = new Tensor()
var inputTensor = new TensorProxy()
{
Shape = new long[] {2, 3},
Data = new float[,] {{1, 2, 3}, {4, 5, 6}}
Data = new Tensor (2, 3, new float[] {1, 2, 3,
4, 5, 6})
};
var agentInfos = GetFakeAgentInfos();

Expand All @@ -67,15 +71,15 @@ public void ApplyContinuousActionOutput()
[Test]
public void ApplyDiscreteActionOutput()
{
var inputTensor = new Tensor()
var inputTensor = new TensorProxy()
{
Shape = new long[] {2, 5},
Data = new float[,] {{0.5f, 22.5f, 0.1f, 5f, 1f},
{4f, 5f, 6f, 7f, 8f}}
Data = new Tensor (2, 5, new[] {0.5f, 22.5f, 0.1f, 5f, 1f,
4f, 5f, 6f, 7f, 8f})
};
var agentInfos = GetFakeAgentInfos();

var applier = new DiscreteActionOutputApplier(new int[]{2, 3}, 0);
var alloc = new TensorCachingAllocator();
var applier = new DiscreteActionOutputApplier(new int[]{2, 3}, 0, alloc);
applier.Apply(inputTensor, agentInfos);
var agents = agentInfos.Keys.ToList();
var agent = agents[0] as TestAgent;
Expand All @@ -86,16 +90,17 @@ public void ApplyDiscreteActionOutput()
action = agent.GetAction();
Assert.AreEqual(action.vectorActions[0], 1);
Assert.AreEqual(action.vectorActions[1], 2);
alloc.Dispose();
}

[Test]
public void ApplyMemoryOutput()
{
var inputTensor = new Tensor()
var inputTensor = new TensorProxy()
{
Shape = new long[] {2, 5},
Data = new float[,] {{0.5f, 22.5f, 0.1f, 5f, 1f},
{4f, 5f, 6f, 7f, 8f}}
Data = new Tensor (2, 5, new[] {0.5f, 22.5f, 0.1f, 5f, 1f,
4f, 5f, 6f, 7f, 8f})
};
var agentInfos = GetFakeAgentInfos();

Expand All @@ -115,10 +120,10 @@ public void ApplyMemoryOutput()
[Test]
public void ApplyValueEstimate()
{
var inputTensor = new Tensor()
var inputTensor = new TensorProxy()
{
Shape = new long[] {2, 1},
Data = new float[,] {{0.5f}, {8f}}
Data = new Tensor (2, 1, new[]{0.5f, 8f})
};
var agentInfos = GetFakeAgentInfos();

Expand Down
Loading

0 comments on commit 3ee0963

Please sign in to comment.