Skip to content

Commit

Permalink
Add startup argument and flowr config file entry for changing the R s…
Browse files Browse the repository at this point in the history
…hell's R executable (#718)
  • Loading branch information
EagleoutIce authored Mar 11, 2024
2 parents b24ba32 + 9c890d0 commit 84f42a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ export interface FlowrConfigOptions extends MergeableRecord {
* Whether source calls should be ignored, causing {@link processSourceCall}'s behavior to be skipped
*/
ignoreSourceCalls: boolean
/**
* The path to the R executable to use. If this is undefined, {@link DEFAULT_R_PATH} will be used.
*/
rPath: string | undefined
}

export const defaultConfigOptions: FlowrConfigOptions = {
ignoreSourceCalls: false
ignoreSourceCalls: false,
rPath: undefined
}
export const defaultConfigFile = 'flowr.json'

Expand Down
5 changes: 4 additions & 1 deletion src/flowr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const optionDefinitions: OptionDefinition[] = [
{ name: 'execute', alias: 'e', type: String, description: 'Execute the given command and exit. Use a semicolon ";" to separate multiple commands.', typeLabel: '{underline command}', multiple: false },
{ name: 'no-ansi', type: Boolean, description: 'Disable ansi-escape-sequences in the output. Useful, if you want to redirect the output to a file.' },
{ name: 'script', alias: 's', type: String, description: `The sub-script to run (${scriptsText})`, multiple: false, defaultOption: true, typeLabel: '{underline files}', defaultValue: undefined },
{ name: 'config-file', type: String, description: 'The name of the configuration file to use', multiple: false }
{ name: 'config-file', type: String, description: 'The name of the configuration file to use', multiple: false },
{ name: 'r-path', type: String, description: 'The path to the R executable to use. Defaults to your PATH.', multiple: false }
]

export interface FlowrCliOptions {
Expand All @@ -51,6 +52,7 @@ export interface FlowrCliOptions {
execute: string | undefined
script: string | undefined
'config-file': string
'r-path': string | undefined
}

export const optionHelp = [
Expand Down Expand Up @@ -95,6 +97,7 @@ function retrieveShell(): RShell {
console.log(formatter.format(`R process exited with code ${code}${signalText}. Restarting...`, { color: Colors.Magenta, effect: ColorEffect.Foreground }))
console.log(italic(`If you want to exit, press either Ctrl+C twice, or enter ${bold(':quit')}`))
},
pathToRExecutable: options['r-path']
})
}

Expand Down
4 changes: 3 additions & 1 deletion src/r-bridge/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { SemVer } from 'semver'
import semver from 'semver/preload'
import { getPlatform } from '../util/os'
import fs from 'fs'
import { getConfig } from '../config'

export type OutputStreamSelector = 'stdout' | 'stderr' | 'both';

Expand Down Expand Up @@ -89,8 +90,9 @@ export interface RShellOptions extends RShellSessionOptions {
readonly sessionName: string
}

export const DEFAULT_R_PATH = getPlatform() === 'windows' ? 'R.exe' : 'R'
export const DEFAULT_R_SHELL_EXEC_OPTIONS: RShellExecutionOptions = {
pathToRExecutable: getPlatform() === 'windows' ? 'R.exe' : 'R',
pathToRExecutable: getConfig().rPath ?? DEFAULT_R_PATH,
commandLineOptions: ['--vanilla', '--quiet', '--no-echo', '--no-save'],
cwd: process.cwd(),
env: process.env,
Expand Down

4 comments on commit 84f42a6

@github-actions
Copy link

Choose a reason for hiding this comment

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

"artificial" Benchmark Suite

Benchmark suite Current: 84f42a6 Previous: d69018e Ratio
Total per-file 1504.5867199545455 ms (3719.7160633959497) 1511.494083 ms (3708.3225553463017) 1.00
Retrieve AST from R code 304.49691681818183 ms (250.2818745872516) 64.46248863636363 ms (125.66414120100016) 4.72
Normalize R AST 31.811671 ms (59.158486368147145) 94.99519236363636 ms (152.9376581920758) 0.33
Produce dataflow information 69.43535154545455 ms (171.81247119642094) 65.2556795909091 ms (167.18441854609554) 1.06
Total per-slice 1.87409080821745 ms (1.3265859688358905) 1.8724288794806876 ms (1.3873679811565907) 1.00
Static slicing 1.4062230983713706 ms (1.2755730516524568) 1.4074784311593942 ms (1.3118563756339259) 1.00
Reconstruct code 0.45248235230736417 ms (0.1915443772689536) 0.4524929302663976 ms (0.22636683004337768) 1.00
failed to reconstruct/re-parse 0 # 0 # 1
times hit threshold 0 # 0 # 1
reduction (characters) 0.7329390759026896 # 0.7329390759026896 # 1
reduction (normalized tokens) 0.7209834969577295 # 0.720988345209971 # 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark '"artificial" Benchmark Suite'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 84f42a6 Previous: d69018e Ratio
Retrieve AST from R code 304.49691681818183 ms (250.2818745872516) 64.46248863636363 ms (125.66414120100016) 4.72

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

"social-science" Benchmark Suite

Benchmark suite Current: 84f42a6 Previous: d69018e Ratio
Total per-file 3689.57712592 ms (6224.5769880536545) 3566.86774236 ms (5920.286185213901) 1.03
Retrieve AST from R code 310.6235342 ms (111.66411231736537) 72.22227936 ms (60.97026629229811) 4.30
Normalize R AST 34.885358520000004 ms (29.77746524671112) 113.02594858 ms (70.71306906384982) 0.31
Produce dataflow information 183.17387196 ms (283.6490527014584) 163.44175874 ms (276.9623037407309) 1.12
Total per-slice 9.05644707483198 ms (14.890435916534344) 8.599255365044066 ms (14.312877376595168) 1.05
Static slicing 8.571387342056639 ms (14.774655104027667) 8.071953766135923 ms (14.188089279803133) 1.06
Reconstruct code 0.4762455580698566 ms (0.23517537416643888) 0.5187709959800451 ms (0.27627204677573897) 0.92
failed to reconstruct/re-parse 9 # 9 # 1
times hit threshold 967 # 967 # 1
reduction (characters) 0.8935817303062393 # 0.898713819973478 # 0.99
reduction (normalized tokens) 0.8531248144961374 # 0.8579790415512589 # 0.99

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark '"social-science" Benchmark Suite'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 84f42a6 Previous: d69018e Ratio
Retrieve AST from R code 310.6235342 ms (111.66411231736537) 72.22227936 ms (60.97026629229811) 4.30

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.