MCPcopy Create free account
hub / github.com/catboost/catboost / createConfigForVersion

Function createConfigForVersion

catboost/node-package/build_scripts/config.ts:73–113  ·  view source on GitHub ↗
(version: string)

Source from the content-addressed store, hash-verified

71}
72
73export async function createConfigForVersion(version: string): Promise<[BinaryConfig, Error|undefined]> {
74 const config: BinaryConfig = {
75 binaries: {},
76 };
77 const failedToDownload: string[] = [];
78 const platform_arch_to_binaries = getPlatformArchToBinary(version);
79 for (const platform_arch of Object.keys(platform_arch_to_binaries)) {
80 config.binaries[platform_arch] = [];
81 for (const src_and_target_file of platform_arch_to_binaries[platform_arch]) {
82 const srcFile = src_and_target_file[0];
83 const targetFile = src_and_target_file[1];
84 const url = join(GITHUB_PATH, 'v' + version, srcFile);
85 const tmpPath = join('./build/tmp/', srcFile);
86 try {
87 await downloadFile(url, tmpPath);
88 } catch(error) {
89 failedToDownload.push(srcFile);
90 config.binaries[platform_arch].push({
91 url: `Not found: ${srcFile}`,
92 sha256: '',
93 targetFile,
94 });
95 continue;
96 }
97 const sha256 = calculateFileHash(tmpPath);
98
99 config.binaries[platform_arch].push({url, sha256, targetFile});
100 }
101 }
102
103 let error: Error|undefined;
104 if (failedToDownload.length > 0) {
105 error = new Error(`\n==========================================
106The following release files failed to get auto-detected:\n${
107 failedToDownload.map(file => `\t- ${file}`).join('\n')
108 }\nPlease open 'config.json' and adjust the links and checksums manually.
109==========================================\n`);
110 }
111
112 return [config, error];
113}

Callers 1

generateConfigForVersionFunction · 0.90

Calls 6

downloadFileFunction · 0.90
calculateFileHashFunction · 0.90
getPlatformArchToBinaryFunction · 0.85
joinFunction · 0.50
pushMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected