Skip to content

Commit

Permalink
Merge pull request #1368 from sasjs/issue-1367
Browse files Browse the repository at this point in the history
Issue 1367
  • Loading branch information
allanbowe authored Aug 15, 2023
2 parents 643fe8e + d6bd61f commit 751a282
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 193 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ module.exports = {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
statements: 73.44,
branches: 60.45,
statements: 73.51,
branches: 60.6,
functions: 73.56,
lines: 74.09
lines: 74.17
}
},

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"lint": "npx prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
"preinstall": "npm run nodeVersionMessage",
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true",
"doc": "npx compodoc -p tsconfig.doc.json --coverageTest 15 --coverageTestThresholdFail"
"doc": "npx compodoc -p tsconfig.doc.json --coverageTest 16 --coverageTestThresholdFail"
},
"testServerTypes": "sasjs",
"release": {
Expand Down Expand Up @@ -51,7 +51,7 @@
"access": "public"
},
"dependencies": {
"@sasjs/adapter": "4.8.0",
"@sasjs/adapter": "4.9.0",
"@sasjs/core": "4.46.3",
"@sasjs/lint": "2.3.1",
"@sasjs/utils": "3.4.0",
Expand Down
7 changes: 5 additions & 2 deletions src/commands/flow/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ export async function execute(
deadlockChain!.join(' -> ')
)

// job state poll options
// maxPollCount and pollInterval are set to 0 to use default polling options
// configured in @sasjs/adapter/src/api/viya/pollJobState.ts
const pollOptions: PollOptions = {
maxPollCount: 24 * 60 * 60,
pollInterval: 1000,
maxPollCount: 0,
pollInterval: 0,
streamLog,
logFolderPath: logFolderRealPath
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/flow/internal/spec/executeFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import * as normalizeFilePath from '../normalizeFilePath'
import csvColumns from '../csvColumns'

const pollOptions: PollOptions = {
maxPollCount: 24 * 60 * 60,
pollInterval: 1000,
maxPollCount: 0,
pollInterval: 0,
streamLog: false,
logFolderPath: 'fake/log/folder/path'
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/help/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export async function printHelpText() {
`[2spaces]NOTE: Providing output flag (--output or -o) is optional. If present, CLI will immediately print out the response JSON. If value is provided, it will be treated as file path to save the response JSON.`,
`[2spaces]NOTE: Providing log flag (--log or -l) is optional. If present, CLI will fetch and save job log to local file.`,
`[2spaces]NOTE: Providing ignore warnings (--ignoreWarnings or -i) flag is optional. If present, CLI will return status '0', when the job state is warning.`,
`[2spaces]NOTE: Providing verbose (--verbose or -v) flag is optional. If present, CLI will log summary of every HTTP response.`
`[2spaces]NOTE: Providing verbose (--verbose or -v) flag is optional. If present, CLI will log summary of every HTTP response. If set to 'bleached', CLI will log summary of every HTTP response without extra colors.`
]
},
{
Expand Down
21 changes: 7 additions & 14 deletions src/commands/job/internal/execute/sasjs.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
import { SASjsApiClient, SasjsRequestClient } from '@sasjs/adapter/node'
import { Target } from '@sasjs/utils'
import { getAuthConfig, isSasJsServerInServerMode } from '../../../../utils'
import { AuthConfig, Target } from '@sasjs/utils'
import { saveLog, saveOutput } from '../utils'
import SASjs from '@sasjs/adapter/node'

/**
* Triggers existing job for execution on SASJS server.
* @param {object} sasjs - configuration object of SAS adapter.
* @param target - SASJS server configuration.
* @param jobPath - location of the job.
* @param logFile - flag indicating if CLI should fetch and save log to provided file path. If filepath wasn't provided, {job}.log file will be created in current folder.
* @param output - flag indicating if CLI should save output to provided file path.
* @returns - promise that resolves into an object with log and output.
*/
export async function executeJobSasjs(
sasjs: SASjs,
target: Target,
jobPath: string,
logFile?: string,
output?: string
output?: string,
authConfig?: AuthConfig
) {
// get authentication configuration if SASJS server is in server mode.
const authConfig = (await isSasJsServerInServerMode(target))
? await getAuthConfig(target)
: undefined

const sasjsApiClient = new SASjsApiClient(
new SasjsRequestClient(target.serverUrl, target.httpsAgentOptions)
)

const response = await sasjsApiClient.executeJob(
const response = await sasjs.executeJob(
{
_program: jobPath
},
Expand Down
15 changes: 7 additions & 8 deletions src/commands/job/internal/execute/viya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { saveLog } from '../utils'
* @param {boolean} ignoreWarnings - flag indicating if CLI should return status '0', when the job state is warning.
* @param {string | undefined} source - an optional path to a JSON file containing macro variables.
* @param {boolean} streamLog - a flag indicating if the logs should be streamed to the supplied log path during job execution. This is useful for getting feedback on long running jobs.
* @param {boolean} verbose - enables verbose mode that logs summary of every HTTP response.
*/
export async function executeJobViya(
sasjs: SASjs,
Expand All @@ -48,13 +47,14 @@ export async function executeJobViya(
statusFile: string | undefined,
ignoreWarnings: boolean,
source: string | undefined,
streamLog: boolean,
verbose: boolean
streamLog: boolean
) {
// job status poll options
// job state poll options
// maxPollCount and pollInterval are set to 0 to use default polling options
// configured in @sasjs/adapter/src/api/viya/pollJobState.ts
const pollOptions: PollOptions = {
maxPollCount: 24 * 60 * 60,
pollInterval: 1000,
maxPollCount: 0,
pollInterval: 0,
streamLog,
logFolderPath: logFile
}
Expand Down Expand Up @@ -108,8 +108,7 @@ export async function executeJobViya(
waitForJob || !!logFile,
pollOptions,
true,
macroVars?.macroVars,
verbose || undefined
macroVars?.macroVars
)
.catch(async (err) => {
// handle error
Expand Down
Loading

0 comments on commit 751a282

Please sign in to comment.