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

Making some fields and properties internal #3342

Merged
merged 7 commits into from
Feb 4, 2020
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
20 changes: 10 additions & 10 deletions com.unity.ml-agents/Runtime/Academy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace MLAgents
/// <summary>
/// Helper class to step the Academy during FixedUpdate phase.
/// </summary>
public class AcademyFixedUpdateStepper : MonoBehaviour
internal class AcademyFixedUpdateStepper : MonoBehaviour
{
void FixedUpdate()
{
Expand Down Expand Up @@ -92,7 +92,7 @@ public bool IsCommunicatorOn
int m_TotalStepCount;

/// Pointer to the communicator currently in use by the Academy.
public ICommunicator Communicator;
internal ICommunicator Communicator;

bool m_Initialized;
List<ModelRunner> m_ModelRunners = new List<ModelRunner>();
Expand All @@ -108,27 +108,27 @@ public bool IsCommunicatorOn

// Signals to all the Agents at each environment step so they can use
// their Policy to decide on their next action.
public event System.Action DecideAction;
internal event System.Action DecideAction;

// Signals to all the listeners that the academy is being destroyed
public event System.Action DestroyAction;
internal event System.Action DestroyAction;

// Signals to all the agents at each environment step along with the
// Academy's maxStepReached, done and stepCount values. The agents rely
// on this event to update their own values of max step reached and done
// in addition to aligning on the step count of the global episode.
public event System.Action<int> AgentSetStatus;
internal event System.Action<int> AgentSetStatus;

// Signals to all the agents at each environment step so they can send
// their state to their Policy if they have requested a decision.
public event System.Action AgentSendState;
internal event System.Action AgentSendState;

// Signals to all the agents at each environment step so they can act if
// they have requested a decision.
public event System.Action AgentAct;
internal event System.Action AgentAct;

// Signals to all the agents each time the Academy force resets.
public event System.Action AgentForceReset;
internal event System.Action AgentForceReset;

// Signals that the Academy has been reset by the training process
public event System.Action OnEnvironmentReset;
Expand All @@ -154,7 +154,7 @@ public bool IsCommunicatorOn
/// Initialize the Academy if it hasn't already been initialized.
/// This method is always safe to call; it will have no effect if the Academy is already initialized.
/// </summary>
public void LazyInitialization()
internal void LazyInitialization()
{
if (!m_Initialized)
{
Expand Down Expand Up @@ -426,7 +426,7 @@ void EnvironmentReset()
/// <param name="inferenceDevice"> The inference device (CPU or GPU)
/// the ModelRunner will use </param>
/// <returns> The ModelRunner compatible with the input settings</returns>
public ModelRunner GetOrCreateModelRunner(
internal ModelRunner GetOrCreateModelRunner(
NNModel model, BrainParameters brainParameters, InferenceDevice inferenceDevice)
{
var modelRunner = m_ModelRunners.Find(x => x.HasModel(model, inferenceDevice));
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/ActionMasker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace MLAgents
{
public class ActionMasker
internal class ActionMasker
{
/// When using discrete control, is the starting indices of the actions
/// when all the branches are concatenated with each other.
Expand Down
19 changes: 5 additions & 14 deletions com.unity.ml-agents/Runtime/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct AgentInfo
/// Struct that contains the action information sent from the Brain to the
/// Agent.
/// </summary>
public struct AgentAction
internal struct AgentAction
{
public float[] vectorActions;
}
Expand Down Expand Up @@ -174,12 +174,12 @@ public abstract class Agent : MonoBehaviour
/// Currently generated from attached SensorComponents, and a legacy VectorSensor
/// </summary>
[FormerlySerializedAs("m_Sensors")]
public List<ISensor> sensors;
internal List<ISensor> sensors;

/// <summary>
/// VectorSensor which is written to by AddVectorObs
/// </summary>
public VectorSensor collectObservationsSensor;
internal VectorSensor collectObservationsSensor;

/// MonoBehaviour function that is called when the attached GameObject
/// becomes enabled or active.
Expand Down Expand Up @@ -420,7 +420,7 @@ public virtual float[] Heuristic()
/// Set up the list of ISensors on the Agent. By default, this will select any
/// SensorBase's attached to the Agent.
/// </summary>
public void InitializeSensors()
internal void InitializeSensors()
{
// Get all attached sensor components
SensorComponent[] attachedSensorComponents;
Expand Down Expand Up @@ -710,20 +710,11 @@ void _AgentReset()
AgentReset();
}

public void UpdateAgentAction(AgentAction action)
internal void UpdateAgentAction(AgentAction action)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just remove this and UpdateVectorAction? I don't think they're used anywhere currently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it

{
m_Action = action;
}

/// <summary>
/// Updates the vector action.
/// </summary>
/// <param name="vectorActions">Vector actions.</param>
public void UpdateVectorAction(float[] vectorActions)
{
m_Action.vectorActions = vectorActions;
}

/// <summary>
/// Scales continuous action from [-1, 1] to arbitrary range.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions com.unity.ml-agents/Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Unity.ML-Agents.Editor.Tests")]
[assembly: InternalsVisibleTo("Unity.ML-Agents.Editor")]
11 changes: 11 additions & 0 deletions com.unity.ml-agents/Runtime/AssemblyInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace MLAgents
/// <summary>
/// Grouping for use in AddComponentMenu (instead of nesting the menus).
/// </summary>
public enum MenuGroup
internal enum MenuGroup
{
Default = 0,
Sensors = 50
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/EpisodeIdCounter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace MLAgents
{
public static class EpisodeIdCounter
internal static class EpisodeIdCounter
{
private static int Counter;
public static int GetEpisodeId()
Expand Down
24 changes: 12 additions & 12 deletions com.unity.ml-agents/Runtime/Grpc/GrpcExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

namespace MLAgents
{
public static class GrpcExtensions
internal static class GrpcExtensions
{
/// <summary>
/// Converts a AgentInfo to a protobuf generated AgentInfoActionPairProto
/// </summary>
/// <returns>The protobuf version of the AgentInfoActionPairProto.</returns>
internal static AgentInfoActionPairProto ToInfoActionPairProto(this AgentInfo ai)
public static AgentInfoActionPairProto ToInfoActionPairProto(this AgentInfo ai)
{
var agentInfoProto = ai.ToAgentInfoProto();

Expand All @@ -39,7 +39,7 @@ internal static AgentInfoActionPairProto ToInfoActionPairProto(this AgentInfo ai
/// Converts a AgentInfo to a protobuf generated AgentInfoProto
/// </summary>
/// <returns>The protobuf version of the AgentInfo.</returns>
internal static AgentInfoProto ToAgentInfoProto(this AgentInfo ai)
public static AgentInfoProto ToAgentInfoProto(this AgentInfo ai)
{
var agentInfoProto = new AgentInfoProto
{
Expand All @@ -64,7 +64,7 @@ internal static AgentInfoProto ToAgentInfoProto(this AgentInfo ai)
/// <param name="bp">The instance of BrainParameter to extend.</param>
/// <param name="name">The name of the brain.</param>
/// <param name="isTraining">Whether or not the Brain is training.</param>
internal static BrainParametersProto ToProto(this BrainParameters bp, string name, bool isTraining)
public static BrainParametersProto ToProto(this BrainParameters bp, string name, bool isTraining)
{
var brainParametersProto = new BrainParametersProto
{
Expand All @@ -81,7 +81,7 @@ internal static BrainParametersProto ToProto(this BrainParameters bp, string nam
/// <summary>
/// Convert metadata object to proto object.
/// </summary>
internal static DemonstrationMetaProto ToProto(this DemonstrationMetaData dm)
public static DemonstrationMetaProto ToProto(this DemonstrationMetaData dm)
{
var demoProto = new DemonstrationMetaProto
{
Expand All @@ -97,7 +97,7 @@ internal static DemonstrationMetaProto ToProto(this DemonstrationMetaData dm)
/// <summary>
/// Initialize metadata values based on proto object.
/// </summary>
internal static DemonstrationMetaData ToDemonstrationMetaData(this DemonstrationMetaProto demoProto)
public static DemonstrationMetaData ToDemonstrationMetaData(this DemonstrationMetaProto demoProto)
{
var dm = new DemonstrationMetaData
{
Expand All @@ -118,7 +118,7 @@ internal static DemonstrationMetaData ToDemonstrationMetaData(this Demonstration
/// </summary>
/// <param name="bpp">An instance of a brain parameters protobuf object.</param>
/// <returns>A BrainParameters struct.</returns>
internal static BrainParameters ToBrainParameters(this BrainParametersProto bpp)
public static BrainParameters ToBrainParameters(this BrainParametersProto bpp)
{
var bp = new BrainParameters
{
Expand All @@ -129,23 +129,23 @@ internal static BrainParameters ToBrainParameters(this BrainParametersProto bpp)
return bp;
}

internal static UnityRLInitParameters ToUnityRLInitParameters(this UnityRLInitializationInputProto inputProto)
public static UnityRLInitParameters ToUnityRLInitParameters(this UnityRLInitializationInputProto inputProto)
{
return new UnityRLInitParameters
{
seed = inputProto.Seed
};
}

internal static AgentAction ToAgentAction(this AgentActionProto aap)
public static AgentAction ToAgentAction(this AgentActionProto aap)
{
return new AgentAction
{
vectorActions = aap.VectorActions.ToArray()
};
}

internal static List<AgentAction> ToAgentActionList(this UnityRLInputProto.Types.ListAgentActionProto proto)
public static List<AgentAction> ToAgentActionList(this UnityRLInputProto.Types.ListAgentActionProto proto)
{
var agentActions = new List<AgentAction>(proto.Value.Count);
foreach (var ap in proto.Value)
Expand All @@ -155,7 +155,7 @@ internal static List<AgentAction> ToAgentActionList(this UnityRLInputProto.Types
return agentActions;
}

internal static ObservationProto ToProto(this Observation obs)
public static ObservationProto ToProto(this Observation obs)
{
ObservationProto obsProto = null;

Expand Down Expand Up @@ -199,7 +199,7 @@ internal static ObservationProto ToProto(this Observation obs)
/// <param name="sensor"></param>
/// <param name="writeAdapter"></param>
/// <returns></returns>
internal static ObservationProto GetObservationProto(this ISensor sensor, WriteAdapter writeAdapter)
public static ObservationProto GetObservationProto(this ISensor sensor, WriteAdapter writeAdapter)
{
var shape = sensor.GetObservationShape();
ObservationProto observationProto = null;
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Grpc/RpcCommunicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace MLAgents
{
/// Responsible for communication with External using gRPC.
public class RpcCommunicator : ICommunicator
internal class RpcCommunicator : ICommunicator
{
public event QuitCommandHandler QuitCommandReceived;
public event ResetCommandHandler ResetCommandReceived;
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/ICommunicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Since the messages are sent back and forth with exchange and simultaneously when
UnityOutput and UnityInput can be extended to provide functionalities beyond RL
UnityRLOutput and UnityRLInput can be extended to provide new RL functionalities
*/
public interface ICommunicator : IDisposable
internal interface ICommunicator : IDisposable
{
/// <summary>
/// Quit was received by the communicator.
Expand Down
8 changes: 4 additions & 4 deletions com.unity.ml-agents/Runtime/InferenceBrain/ApplierImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace MLAgents.InferenceBrain
/// The Applier for the Continuous Action output tensor. Tensor is assumed to contain the
/// continuous action data of the agents in the batch.
/// </summary>
public class ContinuousActionOutputApplier : TensorApplier.IApplier
internal class ContinuousActionOutputApplier : TensorApplier.IApplier
{
public void Apply(TensorProxy tensorProxy, IEnumerable<int> actionIds, Dictionary<int, float[]> lastActions)
{
Expand Down Expand Up @@ -42,7 +42,7 @@ public void Apply(TensorProxy tensorProxy, IEnumerable<int> actionIds, Dictionar
/// The Applier for the Discrete Action output tensor. Uses multinomial to sample discrete
/// actions from the logits contained in the tensor.
/// </summary>
public class DiscreteActionOutputApplier : TensorApplier.IApplier
internal class DiscreteActionOutputApplier : TensorApplier.IApplier
{
readonly int[] m_ActionSize;
readonly Multinomial m_Multinomial;
Expand Down Expand Up @@ -189,7 +189,7 @@ public static void Eval(TensorProxy src, TensorProxy dst, Multinomial multinomia
/// The Applier for the Memory output tensor. Tensor is assumed to contain the new
/// memory data of the agents in the batch.
/// </summary>
public class MemoryOutputApplier : TensorApplier.IApplier
internal class MemoryOutputApplier : TensorApplier.IApplier
{
Dictionary<int, List<float>> m_Memories;

Expand Down Expand Up @@ -219,7 +219,7 @@ public void Apply(TensorProxy tensorProxy, IEnumerable<int> actionIds, Dictionar
}
}

public class BarracudaMemoryOutputApplier : TensorApplier.IApplier
internal class BarracudaMemoryOutputApplier : TensorApplier.IApplier
{
readonly int m_MemoriesCount;
readonly int m_MemoryIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace MLAgents.InferenceBrain
/// Prepares the Tensors for the Learning Brain and exposes a list of failed checks if Model
/// and BrainParameters are incompatible.
/// </summary>
public class BarracudaModelParamLoader
internal class BarracudaModelParamLoader
{
enum ModelActionType
{
Expand Down
Loading