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

Renamed TlcEnvironment to Console. Also introduced LocalEnvironment #923

Merged
merged 6 commits into from
Sep 17, 2018

Conversation

Zruty0
Copy link
Contributor

@Zruty0 Zruty0 commented Sep 14, 2018

No description provided.

@@ -215,7 +215,7 @@ private void ValidateMetadata(IDataView result)
[Fact]
public void TestCommandLine()
{
using (var env = new TlcEnvironment())
using (var env = new ConsoleEnvironment())
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 15, 2018

Choose a reason for hiding this comment

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

using (var env = new ConsoleEnvironment()) [](start = 12, length = 42)

Why I'm even doing this? #Closed

@@ -97,7 +97,7 @@ public void Pkpd()
{
var dataPath = GetDataPath(IrisDataPath);

using (var env = new TlcEnvironment())
using (var env = new ConsoleEnvironment())
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 15, 2018

Choose a reason for hiding this comment

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

env [](start = 23, length = 3)

you can use Env from base class, but it's unrelated to your PR #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed.


In reply to: 217868501 [](ancestors = 217868501)

Copy link
Member

Choose a reason for hiding this comment

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

I'll fix it.


In reply to: 217869448 [](ancestors = 217869448,217868501)

@@ -25,7 +25,7 @@ public ImageTests(ITestOutputHelper output) : base(output)
[Fact]
public void TestEstimatorChain()
{
using (var env = new TlcEnvironment())
using (var env = new ConsoleEnvironment())
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 15, 2018

Choose a reason for hiding this comment

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

env [](start = 23, length = 3)

Want to replace it to Env from TestDataPipeBase? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not in this PR


In reply to: 217868612 [](ancestors = 217868612)

@Ivanidzo4ka
Copy link
Contributor

Ivanidzo4ka commented Sep 15, 2018

        Console.SetOut(_textWriter);

You probably want to hear my valuable opinion?
No?
I'll spill it anyway.

All our tests use XUnit which completely ignores Console, and you have to do this tricks to capture output.
Which is sad.

I would rather had XUnitEnvironment or TestEnvironment which would send output through ITestOutputHelper.
But this is probably unrelated to scope of your PR. #Closed


Refers to: test/Microsoft.ML.StaticPipelineTesting/StaticPipeTests.cs:31 in 28a17e3. [](commit_id = 28a17e3, deletion_comment = False)

namespace Microsoft.ML.Runtime.Data
{
using Stopwatch = System.Diagnostics.Stopwatch;
public sealed class LocalEnvironment : HostEnvironmentBase<LocalEnvironment>
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 15, 2018

Choose a reason for hiding this comment

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

LocalEnvironment [](start = 24, length = 16)

Maybe SilentEnvironment? Or you somehow can hook up to the messages? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can hook up via AddListener<ChannelMessage>


In reply to: 217869228 [](ancestors = 217869228)

@@ -17,7 +17,7 @@ namespace Microsoft.ML.Runtime.Data
public static class ProgressReporting
{
/// <summary>
/// The progress channel for <see cref="TlcEnvironment"/>.
/// The progress channel for <see cref="ConsoleEnvironment"/>.
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 15, 2018

Choose a reason for hiding this comment

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

ConsoleEnvironment [](start = 48, length = 18)

Is it really only TlcEnvironment specific or can be used in any HostEnvironmentBase descendant? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it could be used elsewhere, but I'm not sure, and I would rather not try now.


In reply to: 217869313 [](ancestors = 217869313)

@Zruty0
Copy link
Contributor Author

Zruty0 commented Sep 15, 2018

        Console.SetOut(_textWriter);

Yea, you are right, not it the scope of this PR.
Having a GH issue would help though


In reply to: 421516389 [](ancestors = 421516389)


Refers to: test/Microsoft.ML.StaticPipelineTesting/StaticPipeTests.cs:31 in 28a17e3. [](commit_id = 28a17e3, deletion_comment = False)

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka left a comment

Choose a reason for hiding this comment

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

:shipit:

@Ivanidzo4ka
Copy link
Contributor

        Console.SetOut(_textWriter);

#925 sure


In reply to: 421517087 [](ancestors = 421517087,421516389)


Refers to: test/Microsoft.ML.StaticPipelineTesting/StaticPipeTests.cs:31 in 28a17e3. [](commit_id = 28a17e3, deletion_comment = False)

Copy link
Member

@sfilipi sfilipi left a comment

Choose a reason for hiding this comment

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

:shipit:

@@ -358,20 +358,36 @@ protected override void DisposeCore()
private volatile ConsoleWriter _consoleWriter;
private readonly MessageSensitivity _sensitivityFlags;

public TlcEnvironment(int? seed = null, bool verbose = false,
/// <summary>
/// Create an ML.NET environment for local execution, with console feedback.
Copy link
Member

@sfilipi sfilipi Sep 15, 2018

Choose a reason for hiding this comment

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

ML.NET environmen [](start = 22, length = 17)

add a #Resolved

@@ -480,7 +480,7 @@ private string DataArg(string dataPath)

protected void TestPipeFromModel(string dataPath, OutputPath model)
{
using (var env = new TlcEnvironment(new SysRandom(42)))
using (var env = new ConsoleEnvironment(42))
Copy link
Member

@eerhardt eerhardt Sep 17, 2018

Choose a reason for hiding this comment

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

This isn't an equivalent change, right? It used to use SysRandom, but now it will use TauswortheHybrid. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is not. I don't think it matter though


In reply to: 218092356 [](ancestors = 218092356)

/// <summary>
/// An ML.NET environment for local execution.
/// </summary>
public sealed class LocalEnvironment : HostEnvironmentBase<LocalEnvironment>
Copy link
Member

@eerhardt eerhardt Sep 17, 2018

Choose a reason for hiding this comment

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

We should have some tests that cover this class. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made API scenario tests use it.


In reply to: 218093190 [](ancestors = 218093190)

@@ -111,7 +111,7 @@ private protected FastTreeTrainerBase(IHostEnvironment env, TArgs args)
ParallelTraining.InitEnvironment();
// REVIEW: CLR 4.6 has a bug that is only exposed in Scope, and if we trigger GC.Collect in scope environment
// with memory consumption more than 5GB, GC get stuck in infinite loop. So for now let's call GC only if we call things from TlcEnvironment.
Copy link
Member

@eerhardt eerhardt Sep 17, 2018

Choose a reason for hiding this comment

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

TlcEnvironment [](start = 138, length = 14)

This comment is now out of date. #Resolved


namespace Microsoft.ML.Runtime.Data
{
using Stopwatch = System.Diagnostics.Stopwatch;
Copy link
Member

@eerhardt eerhardt Sep 17, 2018

Choose a reason for hiding this comment

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

What other kind of Stopwatch is there? Can we just have a using System.Diagnostics; at the top? #ByDesign

Copy link
Contributor

Choose a reason for hiding this comment

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

System.Diagnostics is a pretty big namespace with some names that for whatever reason cleave pretty tightly to common terms in ML (e.g., we have 90% of our code bent around processing instance data, and sure enough we get Process and InstanceData... :P), after several instances of developer confusion, we decided to adopt this practice. My innate tendency would be to keep up our existing practice of, when you want only a stopwatch, just import only that, rather than to relax it just yet. (Or better yet C# could have a less awkward way to import a single class from a namespace.)

Of course we could relax it. That practice dates from the times before we had channels, where literally every component instantiated stopwatches to time themselves, and there were lots of namespace collisions, and so lots of cost. Now that we do have channels, few things produce their own stopwatches -- use of System.Diagnostics is quite limited. So the amount of pain that would be generated now by your suggestion would be much less.


In reply to: 218094176 [](ancestors = 218094176)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes to the above


In reply to: 218118934 [](ancestors = 218118934,218094176)

private void ChannelFinished()
=> Dispatch(this, new ChannelMessage(ChannelMessageKind.Trace, MessageSensitivity.None, "Channel finished. Elapsed { 0:c }.", Watch.Elapsed));

protected override void DisposeCore()
Copy link
Member

@eerhardt eerhardt Sep 17, 2018

Choose a reason for hiding this comment

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

FYI - I logged #930 to implement the Dispose Pattern correctly on these types. #Resolved

@@ -113,7 +113,7 @@ public interface IMessageDispatcher : IHostEnvironment
/// AddListener/RemoveListener methods, and exposes the <see cref="ProgressReporting.ProgressTracker"/> to
/// query progress.
/// </summary>
public abstract class HostEnvironmentBase<TEnv> : ChannelProviderBase, IHostEnvironment, IDisposable, IChannelProvider, IMessageDispatcher
public abstract class HostEnvironmentBase<TEnv> : ChannelProviderBase, IHostEnvironment, IChannelProvider, IMessageDispatcher
Copy link
Member

@eerhardt eerhardt Sep 17, 2018

Choose a reason for hiding this comment

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

I think we should get rid of the Dispose method as well.
It feels like we should fix the whole IDisposable concern in 1 change - i.e. remove the Dispose method, remove the "temp file" capability, etc.

Here, we are hanging in limbo where this type doesn't implement IDisposable, but it has a Dispose method, and it holds onto Disposable objects (the IFileHandle instances). #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, let's separate the change and get rid of temp files later


In reply to: 218099076 [](ancestors = 218099076)

@Zruty0 Zruty0 merged commit 160b0df into dotnet:master Sep 17, 2018
@Zruty0 Zruty0 deleted the feature/host-env branch September 17, 2018 21:15
@ghost ghost locked as resolved and limited conversation to collaborators Mar 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants