public void StartRHostMissing() { var brokerClient = new LocalBrokerClient(nameof(RSessionTest), BrokerConnectionInfo.Create(null, "C", @"C:\"), _services, new NullConsole(), Environment.SystemDirectory); var session = new RSession(0, _testMethod.FileSystemSafeName, brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo(), null, 10000); start.ShouldThrow <ComponentBinaryMissingException>(); }
public void StartRHostMissing() { var brokerClient = new LocalBrokerClient(nameof(RSessionTest), @"C:\", TestCoreServices.CreateReal(), new NullConsole(), Environment.SystemDirectory); var session = new RSession(0, brokerClient, () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 10000); start.ShouldThrow <RHostBrokerBinaryMissingException>(); }
static void Main(string[] args) { Console.CancelKeyPress += Console_CancelKeyPress; using (var logger = new Logger("Program", new MaxLoggingPermissions(), FileLogWriter.InTempFolder("Microsoft.R.Host.Client.Program"))) { var services = new CoreServices(new AppConstants(), null, null, null, null); var localConnector = new LocalBrokerClient("Program", args[0], services, new NullConsole()); var host = localConnector.ConnectAsync(new BrokerConnectionInfo("Program", new Program())).GetAwaiter().GetResult(); _evaluator = host; host.Run().GetAwaiter().GetResult(); } }
public async Task StopBeforeInitialized_RHostMissing() { var brokerClient = new LocalBrokerClient(nameof(RSessionTest), BrokerConnectionInfo.Create(null, "C", @"C:\"), _services, new NullConsole(), Environment.SystemDirectory); var session = new RSession(0, _testMethod.FileSystemSafeName, brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo(), null, 10000); var startTask = Task.Run(start).SilenceException <RHostBinaryMissingException>(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); await startTask; }
static void Main(string[] args) { Console.CancelKeyPress += Console_CancelKeyPress; var programName = "Microsoft.R.Host.Client.Program"; using (var shell = new CoreShell(programName)) { var localConnector = new LocalBrokerClient(programName, BrokerConnectionInfo.Create(null, "local", args[0], null, false), shell.Services, new NullConsole()); var host = localConnector.ConnectAsync(new HostConnectionInfo(programName, new Program())).GetAwaiter().GetResult(); _evaluator = host; host.Run().GetAwaiter().GetResult(); } }
static void Main(string[] args) { Console.CancelKeyPress += Console_CancelKeyPress; var programName = "Microsoft.R.Host.Client.Program"; using (var logger = new Logger(programName, Path.GetTempPath(), new MaxLoggingPermissions())) { var services = new CoreServices(null, new MaxLoggingPermissions(), null, null, null, logger, null, null); var localConnector = new LocalBrokerClient(programName, BrokerConnectionInfo.Create(null, "local", args[0]), services, new NullConsole()); var host = localConnector.ConnectAsync(new HostConnectionInfo(programName, new Program())).GetAwaiter().GetResult(); _evaluator = host; host.Run().GetAwaiter().GetResult(); } }
/// <summary> /// Creates R session /// </summary> /// <param name="name">Session name</param> /// <param name="url">Path to local R interpreter (folder with R.dll) or URL to the remote machine</param> /// <returns>R session</returns> public static IRHostSession Create(string name) { var e = new WindowsRInstallation().GetCompatibleEngines().FirstOrDefault(); if (e == null) { throw new InvalidOperationException("No R engines installed"); } var ci = BrokerConnectionInfo.Create(e.Name, e.InstallPath, e.Architecture, string.Empty); var bc = new LocalBrokerClient(name, ci, CoreShell.Create()); return(new RHostSession(new RSession(0, name, bc, new NullLock(), () => { }))); }
public async Task StopBeforeInitialized_RHostMissing() { var brokerClient = new LocalBrokerClient(nameof(RSessionTest), @"C:\", TestCoreServices.CreateReal(), new NullConsole(), Environment.SystemDirectory); var session = new RSession(0, brokerClient, () => { }); Func <Task> start = () => session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name }, null, 10000); var startTask = Task.Run(start).SilenceException <RHostBrokerBinaryMissingException>(); await session.StopHostAsync(); session.IsHostRunning.Should().BeFalse(); await startTask; }
/// <summary> /// Creates R session /// </summary> /// <param name="name">Session name</param> /// <param name="url">Path to local R interpreter (folder with R.dll) or URL to the remote machine</param> /// <returns>R session</returns> public static IRHostSession Create(string name, string url = null) { if (string.IsNullOrEmpty(url)) { var engine = new WindowsRInstallation().GetCompatibleEngines().FirstOrDefault(); if (engine == null) { throw new InvalidOperationException("No R engines installed"); } url = engine.InstallPath; } var ci = BrokerConnectionInfo.Create(name, url, null); var bc = new LocalBrokerClient(name, ci, new ServiceContainer(), new NullConsole(), null); return(new RHostSession(new RSession(0, name, bc, new NullLock(), () => { }))); }