Machine Learning Services - Model detection in predict wizard (#9609)

* Machine Learning Services - Model detection in predict wizard
This commit is contained in:
Leila Lali
2020-03-25 13:18:19 -07:00
committed by GitHub
parent 176edde2aa
commit ab82c04766
44 changed files with 2265 additions and 376 deletions

View File

@@ -22,7 +22,17 @@ export async function execCommandOnTempFile<T>(content: string, command: (filePa
return result;
}
finally {
await fs.promises.unlink(tempFilePath);
await deleteFile(tempFilePath);
}
}
/**
* Deletes a file
* @param filePath file path
*/
export async function deleteFile(filePath: string) {
if (filePath) {
await fs.promises.unlink(filePath);
}
}
@@ -215,7 +225,7 @@ export function getRegisteredModelsThreePartsName(config: Config) {
const dbName = doubleEscapeSingleBrackets(config.registeredModelDatabaseName);
const schema = doubleEscapeSingleBrackets(config.registeredModelTableSchemaName);
const tableName = doubleEscapeSingleBrackets(config.registeredModelTableName);
return `[${dbName}].${schema}.[${tableName}]`;
return `[${dbName}].[${schema}].[${tableName}]`;
}
/**
@@ -227,3 +237,14 @@ export function getRegisteredModelsTowPartsName(config: Config) {
const tableName = doubleEscapeSingleBrackets(config.registeredModelTableName);
return `[${schema}].[${tableName}]`;
}
/**
* Write a file using a hex string
* @param content file content
*/
export async function writeFileFromHex(content: string): Promise<string> {
content = content.startsWith('0x') || content.startsWith('0X') ? content.substr(2) : content;
const tempFilePath = path.join(os.tmpdir(), `ads_ml_temp_${UUID.generateUuid()}`);
await fs.promises.writeFile(tempFilePath, Buffer.from(content, 'hex'));
return tempFilePath;
}