Skip to content

Commit

Permalink
Fix environment variable aliases (#1247)
Browse files Browse the repository at this point in the history
* Fix environment variable aliases

* Fix linter nitpick

* Invert order of operations

* remove ..

Co-authored-by: DavidGOrtega <[email protected]>
  • Loading branch information
0x2b3bfa0 and DavidGOrtega committed Nov 1, 2022
1 parent fc9e235 commit 1a2b245
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions bin/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,7 @@ const yargs = require('yargs');
const CML = require('../src/cml').default;
const { jitsuEventPayload, send } = require('../src/analytics');

const setupOpts = (opts) => {
const legacyEnvironmentVariables = {
TB_CREDENTIALS: 'CML_TENSORBOARD_CREDENTIALS',
DOCKER_MACHINE: 'CML_RUNNER_DOCKER_MACHINE',
RUNNER_IDLE_TIMEOUT: 'CML_RUNNER_IDLE_TIMEOUT',
RUNNER_LABELS: 'CML_RUNNER_LABELS',
RUNNER_SINGLE: 'CML_RUNNER_SINGLE',
RUNNER_REUSE: 'CML_RUNNER_REUSE',
RUNNER_NO_RETRY: 'CML_RUNNER_NO_RETRY',
RUNNER_DRIVER: 'CML_RUNNER_DRIVER',
RUNNER_REPO: 'CML_RUNNER_REPO',
RUNNER_PATH: 'CML_RUNNER_PATH'
};

for (const [oldName, newName] of Object.entries(legacyEnvironmentVariables)) {
if (process.env[oldName]) process.env[newName] = process.env[oldName];
}

const aliasLegacyEnvironmentVariables = () => {
const legacyEnvironmentPrefixes = {
CML_CI: 'CML_REPO',
CML_PUBLISH: 'CML_ASSET',
Expand All @@ -46,6 +29,25 @@ const setupOpts = (opts) => {
}
}

const legacyEnvironmentVariables = {
TB_CREDENTIALS: 'CML_TENSORBOARD_CREDENTIALS',
DOCKER_MACHINE: 'CML_RUNNER_DOCKER_MACHINE',
RUNNER_IDLE_TIMEOUT: 'CML_RUNNER_IDLE_TIMEOUT',
RUNNER_LABELS: 'CML_RUNNER_LABELS',
RUNNER_SINGLE: 'CML_RUNNER_SINGLE',
RUNNER_REUSE: 'CML_RUNNER_REUSE',
RUNNER_NO_RETRY: 'CML_RUNNER_NO_RETRY',
RUNNER_DRIVER: 'CML_RUNNER_DRIVER',
RUNNER_REPO: 'CML_RUNNER_REPO',
RUNNER_PATH: 'CML_RUNNER_PATH'
};

for (const [oldName, newName] of Object.entries(legacyEnvironmentVariables)) {
if (process.env[oldName]) process.env[newName] = process.env[oldName];
}
};

const setupOpts = (opts) => {
const { markdownfile } = opts;
opts.markdownFile = markdownfile;
opts.cml = new CML(opts);
Expand Down Expand Up @@ -117,6 +119,7 @@ const handleError = (message, error) => {
};

(async () => {
aliasLegacyEnvironmentVariables();
setupLogger({ log: 'debug' });

try {
Expand Down

0 comments on commit 1a2b245

Please sign in to comment.