-
Notifications
You must be signed in to change notification settings - Fork 635
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
DYN-6232: Add No-network mode #14526
Merged
Merged
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
64b4706
remove coreclr-ncalc references
aparajit-pratap 4a82ae7
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap dbc3e12
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 81ace20
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap a7cafdc
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 55c654d
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 7ede2a4
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap c43a02d
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 1951d1a
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap cd100b1
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap c04c193
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 35edbdb
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 5c6a4a3
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 1641149
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap eff8d9b
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 8415e17
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 8b498a1
rename, refactor
aparajit-pratap 084e698
keep disableAnalytics flag while adding nonetwork flag
aparajit-pratap ed06f39
cleanup
aparajit-pratap e2f7333
fixes
aparajit-pratap bee08a1
modify comment
aparajit-pratap b92c951
Merge branch 'master' into noNetwork
aparajit-pratap df86d74
make nonetworkmode setter inaccessible
aparajit-pratap 53f4c1b
Merge branch 'noNetwork' of github.com:aparajit-pratap/Dynamo into no…
aparajit-pratap 601dcbc
cleanup
aparajit-pratap a654877
use default property in IStartConfiguration
aparajit-pratap e79a0af
review comments
aparajit-pratap f0b05ed
remove obsolete properties
aparajit-pratap 325e013
restore deleted test
aparajit-pratap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
using Dynamo.Configuration; | ||
using Dynamo.Core; | ||
using Dynamo.Interfaces; | ||
using Dynamo.Logging; | ||
using Dynamo.Models; | ||
using Dynamo.Scheduler; | ||
using Dynamo.Updates; | ||
|
@@ -52,8 +53,10 @@ internal class CMDLineOptions | |
public string CommonDataFolder { get; set; } = String.Empty; | ||
[Option("HostName", Required = false, HelpText = "Identify Dynamo variation associated with host.")] | ||
public string HostName { get; set; } = String.Empty; | ||
[Option("DisableAnalytics", Required = false, HelpText = "Disables analytics in Dynamo for the process liftime.")] | ||
[Option("DisableAnalytics", Required = false, HelpText = "Disables analytics in Dynamo for the process lifetime.")] | ||
public bool DisableAnalytics { get; set; } | ||
[Option("NoNetworkMode", Required = false, HelpText = "Disables network traffic in Dynamo at startup. Disables some features such as Notifications, Sign In, and ML Node Autocomplete for process lifetime.")] | ||
public bool NoNetworkMode { get; set; } | ||
[Option('p', "ParentId", Required = false, HelpText = "Identify Dynamo host analytics parent id.")] | ||
public string ParentId { get; set; } = String.Empty; | ||
[Option('s', "SessionId", Required = false, HelpText = "Identify Dynamo host analytics session id.")] | ||
|
@@ -64,7 +67,7 @@ internal class CMDLineOptions | |
public bool ServiceMode { get; set; } | ||
} | ||
|
||
public class StartupUtils | ||
public static class StartupUtils | ||
{ | ||
//TODO internal? | ||
/// <summary> | ||
|
@@ -142,13 +145,22 @@ public static CommandLineArguments Parse(string[] args) | |
UserDataFolder = cmdArgs.UserDataFolder, | ||
CommonDataFolder = cmdArgs.CommonDataFolder, | ||
DisableAnalytics = cmdArgs.DisableAnalytics, | ||
NoNetworkMode = cmdArgs.NoNetworkMode, | ||
AnalyticsInfo = new HostAnalyticsInfo() { HostName = cmdArgs.HostName, ParentId = cmdArgs.ParentId, SessionId = cmdArgs.SessionId }, | ||
CERLocation = cmdArgs.CERLocation, | ||
ServiceMode = cmdArgs.ServiceMode | ||
}; | ||
}, errs => new CommandLineArguments()); | ||
} | ||
|
||
internal void SetDisableAnalytics() | ||
{ | ||
if (DisableAnalytics || NoNetworkMode) | ||
{ | ||
Analytics.DisableAnalytics = true; | ||
} | ||
} | ||
|
||
public string Locale { get; set; } | ||
public string CommandFilePath { get; set; } | ||
public string OpenFilePath { get; set; } | ||
|
@@ -164,6 +176,7 @@ public static CommandLineArguments Parse(string[] args) | |
[Obsolete("This property will be removed in Dynamo 3.0 - please use AnalyticsInfo")] | ||
public string HostName { get; set; } | ||
public bool DisableAnalytics { get; set; } | ||
public bool NoNetworkMode { get; set; } | ||
public HostAnalyticsInfo AnalyticsInfo { get; set; } | ||
public string CERLocation { get; set; } | ||
|
||
|
@@ -227,22 +240,19 @@ private static IUpdateManager InitializeUpdateManager() | |
// Preload ASM and display corresponding message on splash screen | ||
DynamoModel.OnRequestUpdateLoadBarStatus(new SplashScreenLoadEventArgs(Resources.SplashScreenPreLoadingAsm, 10)); | ||
var isASMloaded = PreloadASM(asmPath, out string geometryFactoryPath, out string preloaderLocation); | ||
var model = StartDynamoWithDefaultConfig(true, userDataFolder, commonDataFolder, geometryFactoryPath, preloaderLocation, info); | ||
var model = StartDynamoWithDefaultConfig(true, userDataFolder, commonDataFolder, geometryFactoryPath, preloaderLocation, false, info); | ||
model.IsASMLoaded = isASMloaded; | ||
return model; | ||
} | ||
|
||
/// <summary> | ||
/// Use this overload to construct a DynamoModel in CLI context when the location of ASM to use is known, host analytics info is known and you want to set data paths. | ||
/// </summary> | ||
/// <param name="asmPath">Path to directory containing geometry library binaries</param> | ||
/// <param name="userDataFolder">Path to be used by PathResolver for UserDataFolder</param> | ||
/// <param name="commonDataFolder">Path to be used by PathResolver for CommonDataFolder</param> | ||
/// <param name="info">Host analytics info specifying Dynamo launching host related information.</param> | ||
/// <param name="isServiceMode">Boolean indication of launching Dynamo in service mode, this mode is optimized for minimal launch time.</param> | ||
/// <param name="cmdLineArgs"></param> | ||
/// <returns></returns> | ||
public static DynamoModel MakeCLIModel(string asmPath, string userDataFolder, string commonDataFolder, HostAnalyticsInfo info = new HostAnalyticsInfo(), bool isServiceMode = false) | ||
public static DynamoModel MakeCLIModel(CommandLineArguments cmdLineArgs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are ok with breaking changes right ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
{ | ||
var asmPath = String.IsNullOrEmpty(cmdLineArgs.ASMPath) ? string.Empty : cmdLineArgs.ASMPath; | ||
IPathResolver pathResolver = CreatePathResolver(false, string.Empty, string.Empty, string.Empty); | ||
PathManager.Instance.AssignHostPathAndIPathResolver(string.Empty, pathResolver); | ||
DynamoModel.SetUICulture(PreferenceSettings.Instance.Locale); | ||
|
@@ -251,7 +261,8 @@ private static IUpdateManager InitializeUpdateManager() | |
// Preload ASM and display corresponding message on splash screen | ||
DynamoModel.OnRequestUpdateLoadBarStatus(new SplashScreenLoadEventArgs(Resources.SplashScreenPreLoadingAsm, 10)); | ||
var isASMloaded = PreloadASM(asmPath, out string geometryFactoryPath, out string preloaderLocation); | ||
var model = StartDynamoWithDefaultConfig(true, userDataFolder, commonDataFolder, geometryFactoryPath, preloaderLocation, info, isServiceMode); | ||
var model = StartDynamoWithDefaultConfig(true, cmdLineArgs.UserDataFolder, cmdLineArgs.CommonDataFolder, | ||
geometryFactoryPath, preloaderLocation, cmdLineArgs.NoNetworkMode, cmdLineArgs.AnalyticsInfo, cmdLineArgs.ServiceMode); | ||
model.IsASMLoaded = isASMloaded; | ||
return model; | ||
} | ||
|
@@ -266,7 +277,8 @@ private static IUpdateManager InitializeUpdateManager() | |
public static DynamoModel MakeModel(bool CLImode, string asmPath = "", string hostName ="") | ||
{ | ||
var isASMloaded = PreloadASM(asmPath, out string geometryFactoryPath, out string preloaderLocation); | ||
var model = StartDynamoWithDefaultConfig(CLImode, string.Empty, string.Empty, geometryFactoryPath, preloaderLocation, new HostAnalyticsInfo() { HostName = hostName }); | ||
var model = StartDynamoWithDefaultConfig(CLImode, string.Empty, string.Empty, | ||
geometryFactoryPath, preloaderLocation, false, new HostAnalyticsInfo() { HostName = hostName }); | ||
model.IsASMLoaded = isASMloaded; | ||
return model; | ||
} | ||
|
@@ -275,10 +287,11 @@ public static DynamoModel MakeModel(bool CLImode, string asmPath = "", string ho | |
/// Use this overload to construct a DynamoModel when the location of ASM to use is known and host analytics info is known. | ||
/// </summary> | ||
/// <param name="CLImode">CLI mode starts the model in test mode and uses a separate path resolver.</param> | ||
/// <param name="noNetworkMode">Option to initialize Dynamo in no-network mode</param> | ||
/// <param name="asmPath">Path to directory containing geometry library binaries</param> | ||
/// <param name="info">Host analytics info specifying Dynamo launching host related information.</param> | ||
/// <returns></returns> | ||
public static DynamoModel MakeModel(bool CLImode, string asmPath = "", HostAnalyticsInfo info = new HostAnalyticsInfo()) | ||
public static DynamoModel MakeModel(bool CLImode, bool noNetworkMode, string asmPath = "", HostAnalyticsInfo info = new HostAnalyticsInfo()) | ||
{ | ||
IPathResolver pathResolver = CreatePathResolver(false, string.Empty, string.Empty, string.Empty); | ||
PathManager.Instance.AssignHostPathAndIPathResolver(string.Empty, pathResolver); | ||
|
@@ -288,7 +301,8 @@ public static DynamoModel MakeModel(bool CLImode, string asmPath = "", string ho | |
// Preload ASM and display corresponding message on splash screen | ||
DynamoModel.OnRequestUpdateLoadBarStatus(new SplashScreenLoadEventArgs(Resources.SplashScreenPreLoadingAsm, 10)); | ||
var isASMloaded = PreloadASM(asmPath, out string geometryFactoryPath, out string preloaderLocation); | ||
var model = StartDynamoWithDefaultConfig(CLImode, string.Empty, string.Empty, geometryFactoryPath, preloaderLocation, info); | ||
var model = StartDynamoWithDefaultConfig(CLImode, string.Empty, string.Empty, geometryFactoryPath, | ||
preloaderLocation, noNetworkMode, info); | ||
model.IsASMLoaded = isASMloaded; | ||
return model; | ||
} | ||
|
@@ -306,33 +320,7 @@ private static IPathResolver CreatePathResolver(bool CLImode, string preloaderLo | |
IPathResolver pathResolver = CLImode ? new CLIPathResolver(preloaderLocation, userDataFolder, commonDataFolder) as IPathResolver : new SandboxPathResolver(preloaderLocation) as IPathResolver; | ||
return pathResolver; | ||
} | ||
|
||
/// <summary> | ||
/// TODO (DYN-2118) remove this method in 3.0 and unify this method with the overload above. | ||
/// Use this overload to construct a DynamoModel when the location of ASM to use is known. | ||
/// </summary> | ||
/// <param name="CLImode">CLI mode starts the model in test mode and uses a seperate path resolver.</param> | ||
/// <param name="asmPath">Path to directory containing geometry library binaries</param> | ||
/// <returns></returns> | ||
[Obsolete("This method will be removed in Dynamo 3.0 - please use the version with more parameters")] | ||
public static DynamoModel MakeModel(bool CLImode, string asmPath) | ||
{ | ||
var isASMloaded = PreloadASM(asmPath, out string geometryFactoryPath, out string preloaderLocation); | ||
var model = StartDynamoWithDefaultConfig(CLImode, string.Empty, string.Empty, geometryFactoryPath, preloaderLocation); | ||
model.IsASMLoaded = isASMloaded; | ||
return model; | ||
} | ||
|
||
//TODO (DYN-2118) remove this method in 3.0 and unify this method with the overload above. | ||
[Obsolete("This method will be removed in Dynamo 3.0 - please use the version with more parameters")] | ||
public static DynamoModel MakeModel(bool CLImode) | ||
{ | ||
var isASMloaded = PreloadASM(string.Empty, out string geometryFactoryPath, out string preloaderLocation); | ||
var model = StartDynamoWithDefaultConfig(CLImode, string.Empty, string.Empty, geometryFactoryPath, preloaderLocation); | ||
model.IsASMLoaded = isASMloaded; | ||
return model; | ||
} | ||
|
||
|
||
private static bool PreloadASM(string asmPath, out string geometryFactoryPath, out string preloaderLocation ) | ||
{ | ||
if (string.IsNullOrEmpty(asmPath) && OSHelper.IsWindows()) | ||
|
@@ -391,6 +379,7 @@ private static DynamoModel StartDynamoWithDefaultConfig(bool CLImode, | |
string commonDataFolder, | ||
string geometryFactoryPath, | ||
string preloaderLocation, | ||
bool noNetworkMode, | ||
HostAnalyticsInfo info = new HostAnalyticsInfo(), | ||
bool isServiceMode = false) | ||
{ | ||
|
@@ -401,13 +390,13 @@ private static DynamoModel StartDynamoWithDefaultConfig(bool CLImode, | |
ProcessMode = CLImode ? TaskProcessMode.Synchronous : TaskProcessMode.Asynchronous, | ||
HostAnalyticsInfo = info, | ||
CLIMode = CLImode, | ||
//TODO we currently use this like a no network comms flags - work on introducing a new flag or renaming this flag. | ||
AuthProvider = CLImode || Dynamo.Logging.Analytics.DisableAnalytics ? null : new Core.IDSDKManager(), | ||
AuthProvider = CLImode || noNetworkMode ? null : new Core.IDSDKManager(), | ||
UpdateManager = CLImode ? null : OSHelper.IsWindows() ? InitializeUpdateManager() : null, | ||
StartInTestMode = CLImode, | ||
PathResolver = CreatePathResolver(CLImode, preloaderLocation, userDataFolder, commonDataFolder), | ||
IsServiceMode = isServiceMode, | ||
Preferences = PreferenceSettings.Instance | ||
Preferences = PreferenceSettings.Instance, | ||
NoNetworkMode = noNetworkMode | ||
}; | ||
var model = DynamoModel.Start(config); | ||
return model; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be too much of a breaking change to make this internal ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you suggesting we make this internal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to reduce the number public footprint. Do you think it is valuable as public facing API or risky to make internal?