Skip to content

Commit 9a2ed84

Browse files
author
Chris Elion
authored
add pre-commit hook for dotnet-format (#4362)
1 parent 9df821d commit 9a2ed84

File tree

88 files changed

+377
-311
lines changed

Some content is hidden

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

88 files changed

+377
-311
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ jobs:
113113
# Need ruby for search-and-replace
114114
sudo apt-get update
115115
sudo apt-get install ruby-full
116+
117+
# install dotnet and the formatter - see https://docs.microsoft.com/en-us/dotnet/core/install/linux-debian#debian-9-
118+
pushd ~
119+
wget -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
120+
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
121+
wget https://packages.microsoft.com/config/debian/9/prod.list
122+
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
123+
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
124+
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
125+
popd
126+
127+
sudo apt-get install -y apt-transport-https && \
128+
sudo apt-get update && \
129+
sudo apt-get install -y dotnet-sdk-3.1 && \
130+
dotnet tool install -g dotnet-format --version 4.1.131201
131+
132+
echo "Setting up venv"
116133
python3 -m venv venv
117134
. venv/bin/activate
118135
pip install --upgrade pip
@@ -131,6 +148,7 @@ jobs:
131148
name: Check Code Style using pre-commit
132149
command: |
133150
. venv/bin/activate
151+
export PATH="$PATH:~/.dotnet/tools"
134152
pre-commit run --show-diff-on-failure --all-files
135153
136154
markdown_link_check:
File renamed without changes.

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,9 @@ repos:
132132
name: validate release links
133133
language: script
134134
entry: utils/validate_release_links.py
135-
135+
- id: dotnet-format
136+
name: dotnet-format
137+
language: script
138+
entry: utils/run_dotnet_format.py
139+
types: [c#]
136140

DevProject/Assets/ML-Agents/Scripts/Tests/Performance/SensorPerformanceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void TestCollectObservationsAgentMarkers()
161161
{
162162
using (Measure.ProfilerMarkers(s_Markers))
163163
{
164-
for(var i=0; i<k_MarkerTestSteps; i++)
164+
for (var i = 0; i < k_MarkerTestSteps; i++)
165165
{
166166
RunAgent<CollectObservationsAgent>(k_NumAgentSteps, 7, ObservableAttributeOptions.Ignore);
167167
}

Project/Assets/ML-Agents/Editor/DisableBurstFromMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if UNITY_CLOUD_BUILD
1+
#if UNITY_CLOUD_BUILD
22
using UnityEditor;
33

44
public class DisableBurstFromMenu

Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public class CrawlerAgent : Agent
1313
Vector3 m_WalkDir; //Direction to the target
1414
Quaternion m_WalkDirLookRot; //Will hold the rotation to our target
1515

16-
[Header("Target To Walk Towards")] [Space(10)]
16+
[Header("Target To Walk Towards")]
17+
[Space(10)]
1718
public TargetController target; //Target the agent will walk towards.
1819

1920
[Header("Body Parts")] [Space(10)] public Transform body;
@@ -27,20 +28,23 @@ public class CrawlerAgent : Agent
2728
public Transform leg3Lower;
2829

2930

30-
[Header("Orientation")] [Space(10)]
31+
[Header("Orientation")]
32+
[Space(10)]
3133
//This will be used as a stabilized model space reference point for observations
3234
//Because ragdolls can move erratically during training, using a stabilized reference transform improves learning
3335
public OrientationCubeController orientationCube;
3436

3537
JointDriveController m_JdController;
3638

37-
[Header("Reward Functions To Use")] [Space(10)]
39+
[Header("Reward Functions To Use")]
40+
[Space(10)]
3841
public bool rewardMovingTowardsTarget; // Agent should move towards target
3942

4043
public bool rewardFacingTarget; // Agent should face the target
4144
public bool rewardUseTimePenalty; // Hurry up
4245

43-
[Header("Foot Grounded Visualization")] [Space(10)]
46+
[Header("Foot Grounded Visualization")]
47+
[Space(10)]
4448
public bool useFootGroundedVisualization;
4549

4650
public MeshRenderer foot0;
@@ -208,8 +212,8 @@ void RewardFunctionMovingTowards()
208212
{
209213
throw new ArgumentException(
210214
"NaN in movingTowardsDot.\n" +
211-
$" orientationCube.transform.forward: {orientationCube.transform.forward}\n"+
212-
$" body.velocity: {m_JdController.bodyPartsDict[body].rb.velocity}\n"+
215+
$" orientationCube.transform.forward: {orientationCube.transform.forward}\n" +
216+
$" body.velocity: {m_JdController.bodyPartsDict[body].rb.velocity}\n" +
213217
$" maximumWalkingSpeed: {maximumWalkingSpeed}"
214218
);
215219
}
@@ -226,7 +230,7 @@ void RewardFunctionFacingTarget()
226230
{
227231
throw new ArgumentException(
228232
"NaN in movingTowardsDot.\n" +
229-
$" orientationCube.transform.forward: {orientationCube.transform.forward}\n"+
233+
$" orientationCube.transform.forward: {orientationCube.transform.forward}\n" +
230234
$" body.forward: {body.forward}"
231235
);
232236
}

Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void Update()
5050
// Send stats via SideChannel so that they'll appear in TensorBoard.
5151
// These values get averaged every summary_frequency steps, so we don't
5252
// need to send every Update() call.
53-
if ((Time.frameCount % 100)== 0)
53+
if ((Time.frameCount % 100) == 0)
5454
{
5555
m_Recorder.Add("TotalScore", totalScore);
5656
}

Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,29 @@ public override void WriteDiscreteActionMask(IDiscreteActionMask actionMask)
4040
// Mask the necessary actions if selected by the user.
4141
if (maskActions)
4242
{
43-
// Prevents the agent from picking an action that would make it collide with a wall
43+
// Prevents the agent from picking an action that would make it collide with a wall
4444
var positionX = (int)transform.position.x;
4545
var positionZ = (int)transform.position.z;
4646
var maxPosition = (int)m_ResetParams.GetWithDefault("gridSize", 5f) - 1;
4747

4848
if (positionX == 0)
4949
{
50-
actionMask.WriteMask(0, new []{ k_Left});
50+
actionMask.WriteMask(0, new[] { k_Left });
5151
}
5252

5353
if (positionX == maxPosition)
5454
{
55-
actionMask.WriteMask(0, new []{k_Right});
55+
actionMask.WriteMask(0, new[] { k_Right });
5656
}
5757

5858
if (positionZ == 0)
5959
{
60-
actionMask.WriteMask(0, new []{k_Down});
60+
actionMask.WriteMask(0, new[] { k_Down });
6161
}
6262

6363
if (positionZ == maxPosition)
6464
{
65-
actionMask.WriteMask(0, new []{k_Up});
65+
actionMask.WriteMask(0, new[] { k_Up });
6666
}
6767
}
6868
}

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
using UnityEngine;
44

5-
namespace MLAgentsExamples
5+
namespace MLAgentsExamples
66
{
77
public class AdjustTrainingTimescale : MonoBehaviour
88
{

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/DirectionIndicator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using UnityEngine;
1+
using UnityEngine;
22

33
namespace Unity.MLAgentsExamples
44
{
55
public class DirectionIndicator : MonoBehaviour
66
{
7-
7+
88
public bool updatedByAgent; //should this be updated by the agent? If not, it will use local settings
99
public Transform transformToFollow; //ex: hips or body
1010
public Transform targetToLookAt; //target in the scene the indicator will point to

0 commit comments

Comments
 (0)