Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snyk] Upgrade pseudoexec from 0.1.4 to 0.2.0 #755

Merged
merged 6 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bin/cml/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const runCloud = async (opts) => {
cloud,
cloudRegion: region,
cloudType: type,
cloudMetadata: metadata,
cloudGpu: gpu,
cloudHddSize: hddSize,
cloudSshPrivate: sshPrivate,
Expand Down Expand Up @@ -151,6 +152,7 @@ const runCloud = async (opts) => {
cloud,
region,
type,
metadata,
gpu: gpu === 'tesla' ? 'v100' : gpu,
hddSize,
sshPrivate,
Expand Down Expand Up @@ -190,6 +192,7 @@ const runCloud = async (opts) => {
instanceLaunchTime: attributes.instance_launch_time,
instanceType: attributes.instance_type,
labels: attributes.labels,
metadata: attributes.metadata,
name: attributes.name,
region: attributes.region,
repo: attributes.repo,
Expand Down Expand Up @@ -467,6 +470,19 @@ exports.builder = (yargs) =>
description:
'Instance type. Choices: [m, l, xl]. Also supports native types like i.e. t2.micro'
},
cloudMetadata: {
type: 'array',
string: true,
coerce: (items) => {
const keyValuePairs = items.map((item) => [
...item.split(/=(.+)/),
null
]);
return Object.fromEntries(keyValuePairs);
},
description:
'Key Value pairs to associate cml-runner instance on the provider i.e. tags/labels "key=value"'
},
cloudGpu: {
type: 'string',
choices: ['nogpu', 'k80', 'v100', 'tesla'],
Expand Down
3 changes: 3 additions & 0 deletions bin/cml/runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Options:
[string] [default: \\"us-west\\"]
--cloud-type Instance type. Choices: [m, l, xl]. Also supports
native types like i.e. t2.micro [string]
--cloud-metadata Key Value pairs to associate cml-runner instance
on the provider i.e. tags/labels \\"key=value\\"
[array]
--cloud-gpu GPU type.
[string] [choices: \\"nogpu\\", \\"k80\\", \\"v100\\", \\"tesla\\"]
--cloud-hdd-size HDD size in GB [number]
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"node-forge": "^0.10.0",
"node-ssh": "^12.0.0",
"proxy-agent": "^5.0.0",
"pseudoexec": "^0.1.4",
"pseudoexec": "^0.2.0",
"semver": "^7.3.5",
"simple-git": "^2.45.1",
"strip-url-auth": "^1.0.1",
Expand Down
12 changes: 11 additions & 1 deletion src/terraform.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const destroy = async (opts = {}) => {
);
};

const mapCloudMetadata = (metadata) =>
Object.entries(metadata).map(([key, value]) => `${key} = "${value || ''}"`);

const iterativeProviderTpl = () => {
return `
terraform {
Expand All @@ -74,6 +77,7 @@ const iterativeCmlRunnerTpl = (opts = {}) => {
name,
single,
type,
metadata,
gpu,
hddSize,
sshPrivate,
Expand All @@ -83,7 +87,7 @@ const iterativeCmlRunnerTpl = (opts = {}) => {
awsSecurityGroup
} = opts;

return `
const template = `
${iterativeProviderTpl()}

resource "iterative_cml_runner" "runner" {
Expand All @@ -108,8 +112,14 @@ resource "iterative_cml_runner" "runner" {
${spotPrice ? `spot_price = ${spotPrice}` : ''}
${startupScript ? `startup_script = "${startupScript}"` : ''}
${awsSecurityGroup ? `aws_security_group = "${awsSecurityGroup}"` : ''}
${
metadata
? `metadata = {\n ${mapCloudMetadata(metadata).join('\n ')}\n }`
: ''
}
}
`;
return template;
};

const checkMinVersion = async () => {
Expand Down
Loading