Merge pull request #1418 from github/aeisenberg/resolve-ml-libs

Resolve ml-queries from directory
This commit is contained in:
Andrew Eisenberg
2022-06-30 08:56:15 -07:00
committed by GitHub
2 changed files with 3 additions and 4 deletions

View File

@@ -606,7 +606,8 @@ export class CodeQLCliServer implements Disposable {
/** Resolves the ML models that should be available when evaluating a query. */
async resolveMlModels(additionalPacks: string[], queryPath: string): Promise<MlModelsInfo> {
const args = await this.cliConstraints.supportsPreciseResolveMlModels()
? [...this.getAdditionalPacksArg(additionalPacks), queryPath]
// use the dirname of the path so that we can handle query libraries
? [...this.getAdditionalPacksArg(additionalPacks), path.dirname(queryPath)]
: this.getAdditionalPacksArg(additionalPacks);
return await this.runJsonCodeQlCliCommand<MlModelsInfo>(
['resolve', 'ml-models'],

View File

@@ -789,9 +789,7 @@ export async function compileAndRunQueryAgainstDatabase(
const metadata = await tryGetQueryMetadata(cliServer, qlProgram.queryPath);
let availableMlModels: cli.MlModelInfo[] = [];
if (!initialInfo.queryPath.endsWith('.ql')) {
void logger.log('Quick evaluation within a query library does not currently support using ML models. Continuing without any ML models.');
} else if (!await cliServer.cliConstraints.supportsResolveMlModels()) {
if (!await cliServer.cliConstraints.supportsResolveMlModels()) {
void logger.log('Resolving ML models is unsupported by this version of the CLI. Running the query without any ML models.');
} else {
try {