1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 11:24:35 +00:00

chore: replace env variable RSCRIPT_PATH with R_PATH

This commit is contained in:
2022-09-09 15:23:46 +05:00
parent 16b7aa6abb
commit 662b2ca36a
7 changed files with 19 additions and 19 deletions

View File

@@ -66,7 +66,7 @@ MODE=
# A comma separated string that defines the available runTimes.
# Priority is given to the runtime that comes first in the string.
# Possible options at the moment are sas and js
# Possible options at the moment are sas, js, py and r
# This string sets the priority of the available analytic runtimes
# Valid runtimes are SAS (sas), JavaScript (js), Python (py) and R (r)
@@ -85,8 +85,8 @@ NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node
# Path to Python executable
PYTHON_PATH=/usr/bin/python
# Path to Rscript
RSCRIPT_PATH=/usr/bin/Rscript
# Path to R executable
R_PATH=/usr/bin/Rscript
# Path to working directory
# This location is for SAS WORK, staged files, DRIVE, configuration etc

View File

@@ -18,7 +18,7 @@ RUN_TIMES=[sas,js,py | js,py | sas | sas,js] default considered as sas
SAS_PATH=/opt/sas/sas9/SASHome/SASFoundation/9.4/sas
NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node
PYTHON_PATH=/usr/bin/python
RSCRIPT_PATH=/usr/bin/Rscript
R_PATH=/usr/bin/Rscript
SASJS_ROOT=./sasjs_root

View File

@@ -97,7 +97,7 @@ export const processProgram = async (
otherArgs
)
codePath = path.join(session.path, 'code.r')
executablePath = process.rscriptLoc!
executablePath = process.rLoc!
break
default:

View File

@@ -3,7 +3,7 @@ declare namespace NodeJS {
sasLoc?: string
nodeLoc?: string
pythonLoc?: string
rscriptLoc?: string
rLoc?: string
driveLoc: string
logsLoc: string
logsUUID: string

View File

@@ -4,9 +4,9 @@ import { createFolder, fileExists, folderExists, isWindows } from '@sasjs/utils'
import { RunTimeType } from './verifyEnvVariables'
export const getDesktopFields = async () => {
const { SAS_PATH, NODE_PATH, PYTHON_PATH, RSCRIPT_PATH } = process.env
const { SAS_PATH, NODE_PATH, PYTHON_PATH, R_PATH } = process.env
let sasLoc, nodeLoc, pythonLoc, rscriptLoc
let sasLoc, nodeLoc, pythonLoc, rLoc
if (process.runTimes.includes(RunTimeType.SAS)) {
sasLoc = SAS_PATH ?? (await getSASLocation())
@@ -21,10 +21,10 @@ export const getDesktopFields = async () => {
}
if (process.runTimes.includes(RunTimeType.R)) {
rscriptLoc = RSCRIPT_PATH ?? (await getRScriptLocation())
rLoc = R_PATH ?? (await getRLocation())
}
return { sasLoc, nodeLoc, pythonLoc, rscriptLoc }
return { sasLoc, nodeLoc, pythonLoc, rLoc }
}
const getDriveLocation = async (): Promise<string> => {
@@ -122,9 +122,9 @@ const getPythonLocation = async (): Promise<string> => {
return targetName
}
const getRScriptLocation = async (): Promise<string> => {
const getRLocation = async (): Promise<string> => {
const validator = async (filePath: string) => {
if (!filePath) return 'Path to RScript executable is required.'
if (!filePath) return 'Path to R executable is required.'
if (!(await fileExists(filePath))) {
return 'No file found at provided path.'
@@ -136,7 +136,7 @@ const getRScriptLocation = async (): Promise<string> => {
const defaultLocation = isWindows() ? 'C:\\Rscript' : '/usr/bin/Rscript'
const targetName = await getString(
'Please enter full path to a Rscript executable: ',
'Please enter full path to a R executable: ',
validator,
defaultLocation
)

View File

@@ -29,14 +29,14 @@ export const setProcessVariables = async () => {
process.sasLoc = process.env.SAS_PATH
process.nodeLoc = process.env.NODE_PATH
process.pythonLoc = process.env.PYTHON_PATH
process.rscriptLoc = process.env.RSCRIPT_PATH
process.rLoc = process.env.R_PATH
} else {
const { sasLoc, nodeLoc, pythonLoc, rscriptLoc } = await getDesktopFields()
const { sasLoc, nodeLoc, pythonLoc, rLoc } = await getDesktopFields()
process.sasLoc = sasLoc
process.nodeLoc = nodeLoc
process.pythonLoc = pythonLoc
process.rscriptLoc = rscriptLoc
process.rLoc = rLoc
}
const { SASJS_ROOT } = process.env

View File

@@ -254,7 +254,7 @@ const verifyRUN_TIMES = (): string[] => {
const verifyExecutablePaths = () => {
const errors: string[] = []
const { RUN_TIMES, SAS_PATH, NODE_PATH, PYTHON_PATH, RSCRIPT_PATH, MODE } =
const { RUN_TIMES, SAS_PATH, NODE_PATH, PYTHON_PATH, R_PATH, MODE } =
process.env
if (MODE === ModeType.Server) {
@@ -272,8 +272,8 @@ const verifyExecutablePaths = () => {
errors.push(`- PYTHON_PATH is required for ${RunTimeType.PY} run time`)
}
if (runTimes?.includes(RunTimeType.R) && !RSCRIPT_PATH) {
errors.push(`- RSCRIPT_PATH is required for ${RunTimeType.R} run time`)
if (runTimes?.includes(RunTimeType.R) && !R_PATH) {
errors.push(`- R_PATH is required for ${RunTimeType.R} run time`)
}
}