Skip to content

Commit 46b5e06

Browse files
authored
Merge branch 'master' into no-envars
2 parents f9241ec + 2a600a7 commit 46b5e06

File tree

13 files changed

+98
-46
lines changed

13 files changed

+98
-46
lines changed

bin/cml/comment/create.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ exports.options = kebabcaseKeys({
2626
default: 'HEAD',
2727
description: 'Commit SHA linked to this comment'
2828
},
29+
watch: {
30+
type: 'boolean',
31+
description: 'Watch for changes and automatically update the comment'
32+
},
33+
triggerFile: {
34+
type: 'string',
35+
description: 'File used to trigger the watcher',
36+
hidden: true
37+
},
2938
publish: {
3039
type: 'boolean',
3140
default: true,
@@ -37,17 +46,9 @@ exports.options = kebabcaseKeys({
3746
description: 'Self-hosted image server URL',
3847
telemetryData: 'name'
3948
},
40-
watch: {
41-
type: 'boolean',
42-
description: 'Watch for changes and automatically update the comment'
43-
},
44-
triggerFile: {
45-
type: 'string',
46-
description: 'File used to trigger the watcher',
47-
hidden: true
48-
},
49-
native: {
49+
publishNative: {
5050
type: 'boolean',
51+
alias: 'native',
5152
description:
5253
"Uses driver's native capabilities to upload assets instead of CML's storage; not available on GitHub",
5354
telemetryData: 'name'

bin/cml/comment/create.test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ describe('Comment integration tests', () => {
1818
--help Show help [boolean]
1919
2020
Options:
21-
--pr Post to an existing PR/MR associated with the
22-
specified commit [boolean]
23-
--commit-sha, --head-sha Commit SHA linked to this comment
21+
--pr Post to an existing PR/MR associated with the
22+
specified commit [boolean]
23+
--commit-sha, --head-sha Commit SHA linked to this comment
2424
[string] [default: \\"HEAD\\"]
25-
--publish Upload any local images found in the Markdown report
26-
[boolean] [default: true]
27-
--publish-url Self-hosted image server URL
25+
--watch Watch for changes and automatically update the
26+
comment [boolean]
27+
--publish Upload any local images found in the Markdown
28+
report [boolean] [default: true]
29+
--publish-url Self-hosted image server URL
2830
[string] [default: \\"https://asset.cml.dev\\"]
29-
--watch Watch for changes and automatically update the
30-
comment [boolean]
31-
--native Uses driver's native capabilities to upload assets
32-
instead of CML's storage; not available on GitHub
31+
--publish-native, --native Uses driver's native capabilities to upload assets
32+
instead of CML's storage; not available on GitHub
3333
[boolean]
34-
--rm-watermark Avoid watermark; CML needs a watermark to be able to
35-
distinguish CML comments from others [boolean]"
34+
--rm-watermark Avoid watermark; CML needs a watermark to be able
35+
to distinguish CML comments from others [boolean]"
3636
`);
3737
});
3838
});

bin/cml/runner/launch.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const kebabcaseKeys = require('kebabcase-keys');
66
const timestring = require('timestring');
77
const winston = require('winston');
88

9-
const { randid, sleep } = require('../../../src/utils');
9+
const { exec, randid, sleep } = require('../../../src/utils');
1010
const tf = require('../../../src/terraform');
1111

1212
let cml;
@@ -23,15 +23,7 @@ const shutdown = async (opts) => {
2323
RUNNER_SHUTTING_DOWN = true;
2424

2525
const { error, cloud } = opts;
26-
const {
27-
name,
28-
workdir = '',
29-
tfResource,
30-
noRetry,
31-
reason,
32-
destroyDelay
33-
} = opts;
34-
const tfPath = workdir;
26+
const { name, tfResource, noRetry, reason, destroyDelay } = opts;
3527

3628
const unregisterRunner = async () => {
3729
if (!RUNNER) return;
@@ -63,16 +55,22 @@ const shutdown = async (opts) => {
6355
}
6456
};
6557

66-
const destroyTerraform = async () => {
58+
const destroyLeo = async () => {
6759
if (!tfResource) return;
6860

6961
winston.info(`Waiting ${destroyDelay} seconds to destroy`);
7062
await sleep(destroyDelay);
7163

64+
const { cloud, id, region } = JSON.parse(
65+
Buffer.from(tfResource, 'base64').toString('utf-8')
66+
).instances[0].attributes;
67+
7268
try {
73-
winston.debug(await tf.destroy({ dir: tfPath }));
69+
return await exec(
70+
`leo destroy-runner --cloud=${cloud} --region=${region} ${id}`
71+
);
7472
} catch (err) {
75-
winston.error(`\tFailed destroying terraform: ${err.message}`);
73+
winston.error(`\tFailed destroying with LEO: ${err.message}`);
7674
}
7775
};
7876

@@ -85,7 +83,7 @@ const shutdown = async (opts) => {
8583
}
8684
}
8785

88-
await destroyTerraform();
86+
await destroyLeo();
8987

9088
if (error) throw error;
9189

bin/legacy/commands/ci.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
const { addDeprecationNotice } = require('../deprecation');
12
const { builder, handler } = require('../../cml/repo/prepare');
23

34
exports.command = 'ci';
45
exports.description = 'Prepare Git repository for CML operations';
56
exports.handler = handler;
6-
exports.builder = builder;
7+
exports.builder = addDeprecationNotice({
8+
builder,
9+
notice: '"cml ci" is deprecated, please use "cml repo prepare"'
10+
});

bin/legacy/commands/publish.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
const { addDeprecationNotice } = require('../deprecation');
12
const { builder, handler } = require('../../cml/asset/publish');
23

34
exports.command = 'publish <asset>';
45
exports.description = false;
56
exports.handler = handler;
6-
exports.builder = builder;
7+
exports.builder = addDeprecationNotice({
8+
builder,
9+
notice: '"cml publish" is deprecated, please use "cml asset publish"'
10+
});

bin/legacy/commands/rerun-workflow.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
const { addDeprecationNotice } = require('../deprecation');
12
const { builder, handler } = require('../../cml/workflow/rerun');
23

34
exports.command = 'rerun-workflow';
45
exports.description = false;
56
exports.handler = handler;
6-
exports.builder = builder;
7+
exports.builder = addDeprecationNotice({
8+
builder,
9+
notice: '"cml rerun-workflow" is deprecated, please use "cml workflow rerun"'
10+
});

bin/legacy/commands/send-comment.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
const { addDeprecationNotice } = require('../deprecation');
12
const { builder, handler } = require('../../cml/comment/create');
23

34
exports.command = 'send-comment <markdown file>';
45
exports.description = false;
56
exports.handler = handler;
6-
exports.builder = builder;
7+
exports.builder = addDeprecationNotice({
8+
builder,
9+
notice: '"cml send-comment" is deprecated, please use "cml comment create"'
10+
});
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
const { addDeprecationNotice } = require('../deprecation');
12
const { builder, handler } = require('../../cml/check/create');
23

34
exports.command = 'send-github-check <markdown file>';
45
exports.description = false;
56
exports.handler = handler;
6-
exports.builder = builder;
7+
exports.builder = addDeprecationNotice({
8+
builder,
9+
notice: '"cml send-github-check" is deprecated, please use "cml check create"'
10+
});
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
const { addDeprecationNotice } = require('../deprecation');
12
const { builder, handler } = require('../../cml/tensorboard/connect');
23

34
exports.command = 'tensorboard-dev';
45
exports.description = false;
56
exports.handler = handler;
6-
exports.builder = builder;
7+
exports.builder = addDeprecationNotice({
8+
builder,
9+
notice:
10+
'"cml tensorboard-dev" is deprecated, please use "cml tensorboard connect"'
11+
});

bin/legacy/deprecation.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const winston = require('winston');
2+
3+
// addDeprecationNotice adds middleware to the yargs chain to display a deprecation notice.
4+
const addDeprecationNotice = (opts = {}) => {
5+
const { builder, notice } = opts;
6+
return (yargs) =>
7+
builder(yargs).middleware([(opts) => deprecationNotice(opts, notice)]);
8+
};
9+
10+
const deprecationNotice = (opts, notice) => {
11+
const { cml } = opts;
12+
const driver = cml.getDriver();
13+
if (driver.warn) {
14+
driver.warn(notice);
15+
} else {
16+
winston.warn(notice);
17+
}
18+
};
19+
20+
exports.addDeprecationNotice = addDeprecationNotice;

0 commit comments

Comments
 (0)