-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add experimental queue experiments from csv command
- Loading branch information
1 parent
91fa1a4
commit 832c39c
Showing
11 changed files
with
119 additions
and
4 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
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
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,42 @@ | ||
import { exists, readCsv } from '../fileSystem' | ||
import { join } from '../test/util/path' | ||
import { definedAndNonEmpty } from '../util/array' | ||
import { delay } from '../util/time' | ||
|
||
const reduceRow = (row: Record<string, unknown>) => | ||
Object.entries(row).reduce((acc, [k, v]) => { | ||
const key = k.trim() | ||
const value = (v as string).trim() | ||
|
||
if (key !== '' && value !== '') { | ||
acc.push('-S') | ||
const str = [key, value].join('=') | ||
acc.push(str) | ||
} | ||
|
||
return acc | ||
}, [] as string[]) | ||
|
||
export const readToQueueFromCsv = (path: string): Promise<string[][]> => | ||
new Promise(resolve => { | ||
const toQueue: string[][] = [] | ||
readCsv(path) | ||
.on('data', row => { | ||
const arr = reduceRow(row) | ||
if (definedAndNonEmpty(arr)) { | ||
toQueue.push(arr) | ||
} | ||
}) | ||
.on('end', () => { | ||
resolve(toQueue) | ||
}) | ||
}) | ||
|
||
export const waitForLock = async (cwd: string): Promise<void> => { | ||
const lock = join(cwd, '.dvc', 'rwlock') | ||
|
||
if (exists(lock)) { | ||
await delay(2000) | ||
return waitForLock(cwd) | ||
} | ||
} |
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
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
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