Skip to content

Commit 1a2b245

Browse files
Fix environment variable aliases (#1247)
* Fix environment variable aliases * Fix linter nitpick * Invert order of operations * remove .. Co-authored-by: DavidGOrtega <g.ortega.david@gmail.com>
1 parent fc9e235 commit 1a2b245

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

bin/cml.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,7 @@ const yargs = require('yargs');
1010
const CML = require('../src/cml').default;
1111
const { jitsuEventPayload, send } = require('../src/analytics');
1212

13-
const setupOpts = (opts) => {
14-
const legacyEnvironmentVariables = {
15-
TB_CREDENTIALS: 'CML_TENSORBOARD_CREDENTIALS',
16-
DOCKER_MACHINE: 'CML_RUNNER_DOCKER_MACHINE',
17-
RUNNER_IDLE_TIMEOUT: 'CML_RUNNER_IDLE_TIMEOUT',
18-
RUNNER_LABELS: 'CML_RUNNER_LABELS',
19-
RUNNER_SINGLE: 'CML_RUNNER_SINGLE',
20-
RUNNER_REUSE: 'CML_RUNNER_REUSE',
21-
RUNNER_NO_RETRY: 'CML_RUNNER_NO_RETRY',
22-
RUNNER_DRIVER: 'CML_RUNNER_DRIVER',
23-
RUNNER_REPO: 'CML_RUNNER_REPO',
24-
RUNNER_PATH: 'CML_RUNNER_PATH'
25-
};
26-
27-
for (const [oldName, newName] of Object.entries(legacyEnvironmentVariables)) {
28-
if (process.env[oldName]) process.env[newName] = process.env[oldName];
29-
}
30-
13+
const aliasLegacyEnvironmentVariables = () => {
3114
const legacyEnvironmentPrefixes = {
3215
CML_CI: 'CML_REPO',
3316
CML_PUBLISH: 'CML_ASSET',
@@ -46,6 +29,25 @@ const setupOpts = (opts) => {
4629
}
4730
}
4831

32+
const legacyEnvironmentVariables = {
33+
TB_CREDENTIALS: 'CML_TENSORBOARD_CREDENTIALS',
34+
DOCKER_MACHINE: 'CML_RUNNER_DOCKER_MACHINE',
35+
RUNNER_IDLE_TIMEOUT: 'CML_RUNNER_IDLE_TIMEOUT',
36+
RUNNER_LABELS: 'CML_RUNNER_LABELS',
37+
RUNNER_SINGLE: 'CML_RUNNER_SINGLE',
38+
RUNNER_REUSE: 'CML_RUNNER_REUSE',
39+
RUNNER_NO_RETRY: 'CML_RUNNER_NO_RETRY',
40+
RUNNER_DRIVER: 'CML_RUNNER_DRIVER',
41+
RUNNER_REPO: 'CML_RUNNER_REPO',
42+
RUNNER_PATH: 'CML_RUNNER_PATH'
43+
};
44+
45+
for (const [oldName, newName] of Object.entries(legacyEnvironmentVariables)) {
46+
if (process.env[oldName]) process.env[newName] = process.env[oldName];
47+
}
48+
};
49+
50+
const setupOpts = (opts) => {
4951
const { markdownfile } = opts;
5052
opts.markdownFile = markdownfile;
5153
opts.cml = new CML(opts);
@@ -117,6 +119,7 @@ const handleError = (message, error) => {
117119
};
118120

119121
(async () => {
122+
aliasLegacyEnvironmentVariables();
120123
setupLogger({ log: 'debug' });
121124

122125
try {

0 commit comments

Comments
 (0)