-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
167 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Config Parser Design | ||
|
||
- build-base | ||
|
||
`From ${config.base_docker}\n` | ||
|
||
- build-env | ||
|
||
`ENV ${config.env_variables}\n` | ||
|
||
- install | ||
- export universal interface with a type and a function | ||
- conda | ||
- python os | ||
- conda command | ||
- pip command | ||
- custom command | ||
- hdfs copy | ||
|
||
- custom | ||
- publish to npm with a tag | ||
- expose a certain function | ||
- get tag list to require |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
function buildBase (config) { | ||
let dockerContent = '' | ||
dockerContent += `From ${config.base_docker}\n` | ||
return dockerContent | ||
} | ||
|
||
module.exports = { | ||
type: 'base_docker', | ||
build: buildBase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
function buildEnv (config) { | ||
let dockerContent = '' | ||
for (const envKey in config.env_variables) { | ||
dockerContent += `ENV ${envKey}=${config.env_variables[envKey]}\n` | ||
} | ||
return dockerContent | ||
} | ||
|
||
module.exports = { | ||
type: 'env_variables', | ||
build: buildEnv | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const version = require('./version') | ||
const baseDocker = require('./base_docker') | ||
const envVariables = require('./env_variables') | ||
const steps = require('./steps') | ||
const _ = require('lodash') | ||
|
||
const componentsList = [version, baseDocker, envVariables, steps] | ||
|
||
function selectComponent (type) { | ||
const component = componentsList.find(item => item.type === type) | ||
if (_.isNil(component)) { | ||
throw new Error(`cannot find component: '${type}'`) | ||
} | ||
|
||
return component | ||
} | ||
|
||
function buildConfig (config) { | ||
let dockerContent = '' | ||
|
||
if (!_.isNil(config.version)) { | ||
dockerContent += selectComponent('version').build(config) | ||
} | ||
|
||
if (!_.isNil(config.base_docker)) { | ||
dockerContent += selectComponent('base_docker').build(config) | ||
} | ||
|
||
if (!_.isNil(config.env_variables)) { | ||
dockerContent += selectComponent('env_variables').build(config) | ||
} | ||
|
||
if (!_.isNil(config.steps)) { | ||
dockerContent += selectComponent('steps').build(config) | ||
} | ||
|
||
return dockerContent | ||
} | ||
|
||
module.exports = buildConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
function buildCustom (step) { | ||
let dockerContent = '' | ||
dockerContent += `CMD ${step.config.command}\n` | ||
return dockerContent | ||
} | ||
|
||
module.exports = { | ||
'type': 'custom_command', | ||
'build': buildCustom | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
function buildDefault (step) { | ||
let dockerContent = '' | ||
dockerContent += `no processing for ${step.type}\n` | ||
return dockerContent | ||
} | ||
|
||
module.exports = { | ||
'type': 'default', | ||
'build': buildDefault | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const _ = require('lodash') | ||
|
||
const customCommand = require('./custom_command') | ||
const installPython = require('./install_python') | ||
const defaultStep = require('./default') | ||
|
||
const stepsList = [customCommand, installPython] | ||
|
||
function selectStepBuilder (stepType) { | ||
return stepsList.find(item => item.type === stepType) | ||
} | ||
|
||
function buildSteps (config) { | ||
let dockerContent = '' | ||
for (let step of config.steps) { | ||
let stepBuilder = selectStepBuilder(step.type) | ||
if (_.isNil(stepBuilder)) { | ||
// throw new Error(`cannot find step builder: '${step.type}'`) | ||
stepBuilder = defaultStep | ||
} | ||
dockerContent += stepBuilder.build(step) | ||
} | ||
|
||
return dockerContent | ||
} | ||
|
||
module.exports = { | ||
type: 'steps', | ||
build: buildSteps | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
function installPython (config) { | ||
return 'install python\n' | ||
} | ||
|
||
module.exports = { | ||
'type': 'install_python', | ||
'build': installPython | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
function buildVersion (config) { | ||
return `# version: ${config.version}\n` | ||
} | ||
|
||
module.exports = { | ||
type: 'version', | ||
build: buildVersion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
site_name: PAIFlow Docs | ||
nav: | ||
- Introduction: index.md | ||
- Work Plan: work_plan.md | ||
- Config Schema: config_schema.md | ||
theme: readthedocs | ||
- Work Plan: work-plan.md | ||
- Config Schema: config-schema.md | ||
- Config Parser: config-parser.md | ||
theme: readthedocs |