public RSessionEvaluation(IReadOnlyList<IRContext> contexts, IRExpressionEvaluator evaluator, CancellationToken ct) { Contexts = contexts; _evaluator = evaluator; _tcs = new TaskCompletionSource<object>(); _ct = ct; ct.Register(() => _tcs.TrySetCanceled()); }
public static Task SetLocalLibsAsync(IRExpressionEvaluator eval, params string[] libPaths) { foreach (var libPath in libPaths.Where(libPath => !Directory.Exists(libPath))) { Directory.CreateDirectory(libPath); } var paths = string.Join(",", libPaths.Select(p => p.ToRPath().ToRStringLiteral())); var code = $".libPaths(c({paths}))"; return eval.ExecuteAsync(code); }
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, new MaxLoggingPermissions(), null, null, null, 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 static Task SetCranRepoAsync(IRExpressionEvaluator eval) { var code = @"options(repos=list(CRAN='http://cran.r-project.org'))"; return eval.ExecuteAsync(code); }
public static Task SetLocalRepoAsync(IRExpressionEvaluator eval, string localRepoPath) { var code = $"options(repos=list(LOCAL=\"file:///{localRepoPath.ToRPath()}\"))"; return eval.ExecuteAsync(code); }
public static Task SetLocalRepoAsync(IRExpressionEvaluator eval, TestFilesFixture testFiles) => SetLocalRepoAsync(eval, GetRepoPath(testFiles));
private async Task InstallPackageAsync(IRExpressionEvaluator eval, string packageName, string libPath) { var code = $"install.packages(\"{packageName}\", verbose=FALSE, quiet=TRUE)"; var evalResult = await eval.EvaluateAsync(code, REvaluationKind.Normal); WaitForPackageInstalled(libPath, packageName); }
public Task BeginEvaluationAsync(IReadOnlyList<IRContext> contexts, IRExpressionEvaluator evaluator, CancellationToken ct) { var evaluation = new RSessionEvaluation(contexts, evaluator, ct); return _tcs.TrySetResult(evaluation) ? evaluation.Task : System.Threading.Tasks.Task.CompletedTask; }
public static Task OptionsSetWidthAsync(this IRExpressionEvaluator evaluation, int width) { return(evaluation.ExecuteAsync(Invariant($"options(width=as.integer({width}))\n"))); }
public static Task QuitAsync(this IRExpressionEvaluator eval) => eval.ExecuteAsync("q()", REvaluationKind.Normal);
public static async Task <Guid> GetActivePlotDeviceAsync(this IRExpressionEvaluator evaluation) { var id = await evaluation.EvaluateAsync <string>("rtvs:::graphics.ide.getactivedeviceid()", REvaluationKind.Normal); return(id != null?Guid.Parse(id) : Guid.Empty); }
public static async Task NewPlotDeviceAsync(this IRExpressionEvaluator evaluation) { await evaluation.ExecuteAsync("ide()"); }
public static Task <int?> GetPlotDeviceNumAsync(this IRExpressionEvaluator evaluation, Guid deviceId) { Debug.Assert(deviceId != Guid.Empty); return(evaluation.EvaluateAsync <int?>(Invariant($"rtvs:::graphics.ide.getdevicenum({deviceId.ToString().ToRStringLiteral()})"), REvaluationKind.Normal)); }
public static async Task ActivatePlotDeviceAsync(this IRExpressionEvaluator evaluation, Guid deviceId) { Debug.Assert(deviceId != Guid.Empty); await evaluation.ExecuteAsync(Invariant($"rtvs:::graphics.ide.setactivedeviceid({deviceId.ToString().ToRStringLiteral()})")); }
public static Task SetLocalLibraryAsync(IRExpressionEvaluator eval, MethodInfo testMethod, TestFilesFixture testFiles) { return SetLocalLibsAsync(eval, Path.Combine(testFiles.LibraryDestinationPath, testMethod.Name)); }
static void Main(string[] args) { Console.CancelKeyPress += Console_CancelKeyPress; var host = new RHost("Program", new Program()); host.CreateAndRun(args[0]).GetAwaiter().GetResult(); _evaluator = host; }
private static Task SuppressUI(IRExpressionEvaluator eval) { // # Suppress Windows UI // http://astrostatistics.psu.edu/datasets/R/html/utils/html/winMenus.html return(eval.ExecuteAsync(@"rtvs:::suppress_ui()")); }