Skip to content

Commit d83057d

Browse files
authored
fix broken build flag, move build to one directory (#2442)
* move build to one directory, fix broken flag Signed-off-by: Samuel Herman <[email protected]> * fix make path Signed-off-by: Samuel Herman <[email protected]> * changelog update Signed-off-by: Samuel Herman <[email protected]> * add fix for classpath change and for cmake discovery on macos Signed-off-by: Samuel Herman <[email protected]> * fix make discovery for gradle Signed-off-by: Samuel Herman <[email protected]> * fix cmake path for macOS Signed-off-by: Samuel Herman <[email protected]> --------- Signed-off-by: Samuel Herman <[email protected]>
1 parent 55652ca commit d83057d

18 files changed

+83
-27
lines changed

CHANGELOG.md

-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4545
* Fixing it to retrieve space_type from index setting when both method and top level don't have the value. [#2374](https://github.com/opensearch-project/k-NN/pull/2374)
4646
* Fixing the bug where setting rescore as false for on_disk knn_vector query is a no-op (#2399)[https://github.com/opensearch-project/k-NN/pull/2399]
4747
* Fixing bug where mapping accepts both dimension and model-id (#2410)[https://github.com/opensearch-project/k-NN/pull/2410]
48-
* Add version check for full field name validation (#2477)[https://github.com/opensearch-project/k-NN/pull/2477]
4948
### Infrastructure
5049
* Updated C++ version in JNI from c++11 to c++17 [#2259](https://github.com/opensearch-project/k-NN/pull/2259)
5150
* Upgrade bytebuddy and objenesis version to match OpenSearch core and, update github ci runner for macos [#2279](https://github.com/opensearch-project/k-NN/pull/2279)
@@ -58,5 +57,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5857
* Upgrade jsonpath from 2.8.0 to 2.9.0[2325](https://github.com/opensearch-project/k-NN/pull/2325)
5958
* Bump Faiss commit from 1f42e81 to 0cbc2a8 to accelerate hamming distance calculation using _mm512_popcnt_epi64 intrinsic and also add avx512-fp16 instructions to boost performance [#2381](https://github.com/opensearch-project/k-NN/pull/2381)
6059
* Enabled indices.breaker.total.use_real_memory setting via build.gradle for integTest Cluster to catch heap CB in local ITs and github CI actions [#2395](https://github.com/opensearch-project/k-NN/pull/2395/)
61-
* Fixing Lucene912Codec Issue with BWC for Lucene 10.0.1 upgrade[#2429](https://github.com/opensearch-project/k-NN/pull/2429)
6260
### Refactoring

build.gradle

+65-7
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,52 @@ task windowsPatches(type:Exec) {
329329
commandLine 'cmd', '/c', "Powershell -File $rootDir\\scripts\\windowsScript.ps1"
330330
}
331331

332-
task cmakeJniLib(type:Exec) {
333-
workingDir 'jni'
332+
def findExecutable(String executableName, List<String> additionalPaths = []) {
333+
// Print the task's environment before setting it
334+
// Print PATH specifically
335+
logger.lifecycle("\nSystem PATH:")
336+
logger.lifecycle(System.getenv("PATH"))
337+
338+
def commonBasePaths = [
339+
"/opt/homebrew/bin",
340+
"/usr/local/bin",
341+
"/usr/bin"
342+
]
343+
344+
// Start with just the executable name (will use system PATH)
345+
def execPath = executableName
346+
347+
if (Os.isFamily(Os.FAMILY_MAC)) {
348+
def searchPaths = []
349+
// Add common paths
350+
commonBasePaths.each { basePath ->
351+
searchPaths.add("${basePath}/${executableName}")
352+
}
353+
// Add any additional specific paths
354+
searchPaths.addAll(additionalPaths)
355+
356+
for (path in searchPaths) {
357+
if (new File(path).exists()) {
358+
logger.lifecycle("Found ${executableName} at: ${path}")
359+
execPath = path
360+
break
361+
}
362+
}
363+
}
364+
365+
return execPath
366+
}
367+
368+
tasks.register('cmakeJniLib', Exec) {
369+
def cmakePath = findExecutable("cmake")
370+
logger.lifecycle("Using cmake at: ${cmakePath}")
371+
// Inherit the current environment
372+
environment System.getenv()
373+
334374
def args = []
335-
args.add("cmake")
336-
args.add(".")
375+
args.add(cmakePath)
376+
args.add("-S jni")
377+
args.add("-B jni/build")
337378
args.add("-DKNN_PLUGIN_VERSION=${opensearch_version}")
338379
args.add("-DAVX2_ENABLED=${avx2_enabled}")
339380
args.add("-DAVX512_ENABLED=${avx512_enabled}")
@@ -343,7 +384,7 @@ task cmakeJniLib(type:Exec) {
343384
def javaHome = Jvm.current().getJavaHome()
344385
logger.lifecycle("Java home directory used by gradle: $javaHome")
345386
if (Os.isFamily(Os.FAMILY_MAC)) {
346-
environment('JAVA_HOME',javaHome)
387+
environment('JAVA_HOME', javaHome)
347388
}
348389
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
349390
dependsOn windowsPatches
@@ -353,13 +394,30 @@ task cmakeJniLib(type:Exec) {
353394
args.add("-DLAPACK_LIBRARIES=$rootDir\\src\\main\\resources\\windowsDependencies\\libopenblas.dll")
354395
}
355396

397+
// Print the task's environment after setting it
398+
logger.lifecycle("\nTask Environment PATH:")
399+
logger.lifecycle(environment.get('PATH'))
400+
401+
// Print the command that will be executed
402+
logger.lifecycle("CMake command: ${args.join(' ')}")
403+
def outputStream = new ByteArrayOutputStream()
356404
commandLine args
405+
standardOutput = outputStream
357406
}
358407

359408
task buildJniLib(type:Exec) {
360409
dependsOn cmakeJniLib
361-
workingDir 'jni'
362-
commandLine 'make', 'opensearchknn_nmslib', 'opensearchknn_faiss', 'opensearchknn_common', '-j', "${nproc_count}"
410+
def makePath = findExecutable("make")
411+
logger.lifecycle("Using make at: ${makePath}")
412+
println "Make path: ${makePath}"
413+
// Ensure makePath is treated as a String. If parsing to an int is required,
414+
// handle it explicitly, though a path typically should not be parsed as an int.
415+
if (makePath.isEmpty()) {
416+
throw new GradleException("Make not found in PATH. Please install Make.")
417+
}
418+
def outputStream = new ByteArrayOutputStream()
419+
commandLine makePath, '-Cjni/build','opensearchknn_nmslib', 'opensearchknn_faiss', 'opensearchknn_common', '-j', "${nproc_count}"
420+
standardOutput = outputStream
363421
}
364422

365423
test {

jni/cmake/init-faiss.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ endif()
111111
if(NOT DEFINED AVX512_SPR_ENABLED)
112112
# Check if the system is Intel(R) Sapphire Rapids or a newer-generation processor
113113
execute_process(COMMAND bash -c "lscpu | grep -q 'GenuineIntel' && lscpu | grep -i 'avx512_fp16' | grep -i 'avx512_bf16' | grep -i 'avx512_vpopcntdq'" OUTPUT_VARIABLE SPR_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
114-
if (AND NOT "${SPR_FLAGS}" STREQUAL "")
115-
set(AVX512_SPR_ENABLED true)
114+
if (NOT "${SPR_FLAGS}" STREQUAL "")
115+
set(AVX512_SPR_ENABLED true)
116116
else()
117-
set(AVX512_SPR_ENABLED false)
117+
set(AVX512_SPR_ENABLED false)
118118
endif()
119119
endif()
120120

src/main/java/org/opensearch/knn/index/KNNCircuitBreaker.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.opensearch.knn.plugin.transport.KNNStatsResponse;
1414
import org.apache.logging.log4j.LogManager;
1515
import org.apache.logging.log4j.Logger;
16-
import org.opensearch.client.Client;
16+
import org.opensearch.transport.client.Client;
1717
import org.opensearch.cluster.service.ClusterService;
1818
import org.opensearch.common.unit.TimeValue;
1919
import org.opensearch.threadpool.ThreadPool;

src/main/java/org/opensearch/knn/index/KNNSettings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.opensearch.OpenSearchParseException;
1212
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
1313
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
14-
import org.opensearch.client.Client;
14+
import org.opensearch.transport.client.Client;
1515
import org.opensearch.cluster.metadata.IndexMetadata;
1616
import org.opensearch.cluster.service.ClusterService;
1717
import org.opensearch.common.Booleans;

src/main/java/org/opensearch/knn/indices/ModelDao.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.opensearch.action.search.SearchResponse;
3737
import org.opensearch.action.support.WriteRequest;
3838
import org.opensearch.action.support.clustermanager.AcknowledgedResponse;
39-
import org.opensearch.client.Client;
39+
import org.opensearch.transport.client.Client;
4040
import org.opensearch.cluster.health.ClusterHealthStatus;
4141
import org.opensearch.cluster.health.ClusterIndexHealth;
4242
import org.opensearch.cluster.metadata.IndexMetadata;

src/main/java/org/opensearch/knn/plugin/KNNPlugin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import com.google.common.collect.ImmutableList;
5050

5151
import org.opensearch.action.ActionRequest;
52-
import org.opensearch.client.Client;
52+
import org.opensearch.transport.client.Client;
5353
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
5454
import org.opensearch.cluster.node.DiscoveryNodes;
5555
import org.opensearch.cluster.service.ClusterService;

src/main/java/org/opensearch/knn/plugin/rest/RestClearCacheHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.google.common.collect.ImmutableList;
99
import lombok.AllArgsConstructor;
1010
import lombok.extern.log4j.Log4j2;
11-
import org.opensearch.client.node.NodeClient;
11+
import org.opensearch.transport.client.node.NodeClient;
1212
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
1313
import org.opensearch.cluster.service.ClusterService;
1414
import org.opensearch.core.common.Strings;

src/main/java/org/opensearch/knn/plugin/rest/RestDeleteModelHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
package org.opensearch.knn.plugin.rest;
1313

1414
import com.google.common.collect.ImmutableList;
15-
import org.opensearch.client.node.NodeClient;
15+
import org.opensearch.transport.client.node.NodeClient;
1616
import org.opensearch.core.common.Strings;
1717
import org.opensearch.knn.plugin.KNNPlugin;
1818
import org.opensearch.knn.plugin.transport.DeleteModelAction;

src/main/java/org/opensearch/knn/plugin/rest/RestGetModelHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import com.google.common.collect.ImmutableList;
1515
import org.apache.commons.lang.StringUtils;
16-
import org.opensearch.client.node.NodeClient;
16+
import org.opensearch.transport.client.node.NodeClient;
1717
import org.opensearch.knn.plugin.KNNPlugin;
1818
import org.opensearch.knn.plugin.transport.GetModelAction;
1919
import org.opensearch.knn.plugin.transport.GetModelRequest;

src/main/java/org/opensearch/knn/plugin/rest/RestKNNStatsHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.opensearch.knn.plugin.transport.KNNStatsAction;
1212
import org.opensearch.knn.plugin.transport.KNNStatsRequest;
1313
import com.google.common.collect.ImmutableList;
14-
import org.opensearch.client.node.NodeClient;
14+
import org.opensearch.transport.client.node.NodeClient;
1515
import org.opensearch.rest.BaseRestHandler;
1616
import org.opensearch.rest.RestRequest;
1717
import org.opensearch.rest.action.RestActions;

src/main/java/org/opensearch/knn/plugin/rest/RestKNNWarmupHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.google.common.collect.ImmutableList;
1414
import org.apache.logging.log4j.LogManager;
1515
import org.apache.logging.log4j.Logger;
16-
import org.opensearch.client.node.NodeClient;
16+
import org.opensearch.transport.client.node.NodeClient;
1717
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
1818
import org.opensearch.cluster.service.ClusterService;
1919
import org.opensearch.common.settings.Settings;

src/main/java/org/opensearch/knn/plugin/rest/RestSearchModelHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import com.google.common.collect.ImmutableList;
1515
import org.opensearch.action.search.SearchRequest;
16-
import org.opensearch.client.node.NodeClient;
16+
import org.opensearch.transport.client.node.NodeClient;
1717
import org.opensearch.knn.plugin.KNNPlugin;
1818
import org.opensearch.knn.plugin.transport.SearchModelAction;
1919
import org.opensearch.rest.BaseRestHandler;

src/main/java/org/opensearch/knn/plugin/rest/RestTrainModelHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
package org.opensearch.knn.plugin.rest;
1313

1414
import com.google.common.collect.ImmutableList;
15-
import org.opensearch.client.node.NodeClient;
15+
import org.opensearch.transport.client.node.NodeClient;
1616
import org.opensearch.core.xcontent.XContentParser;
1717
import org.opensearch.index.mapper.NumberFieldMapper;
1818
import org.opensearch.knn.common.KNNConstants;

src/main/java/org/opensearch/knn/plugin/transport/TrainingJobRouterTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.opensearch.action.search.SearchRequest;
1818
import org.opensearch.action.support.ActionFilters;
1919
import org.opensearch.action.support.HandledTransportAction;
20-
import org.opensearch.client.Client;
20+
import org.opensearch.transport.client.Client;
2121
import org.opensearch.cluster.node.DiscoveryNode;
2222
import org.opensearch.cluster.service.ClusterService;
2323
import org.opensearch.common.ValidationException;

src/main/java/org/opensearch/knn/training/VectorReader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.opensearch.action.search.SearchRequestBuilder;
1818
import org.opensearch.action.search.SearchResponse;
1919
import org.opensearch.action.search.SearchScrollRequestBuilder;
20-
import org.opensearch.client.Client;
20+
import org.opensearch.transport.client.Client;
2121
import org.opensearch.cluster.metadata.IndexMetadata;
2222
import org.opensearch.cluster.service.ClusterService;
2323
import org.opensearch.common.ValidationException;

src/test/java/org/opensearch/knn/plugin/transport/TrainingJobRouterTransportActionTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import org.opensearch.core.action.ActionListener;
1717
import org.opensearch.action.search.SearchResponse;
1818
import org.opensearch.action.support.ActionFilters;
19-
import org.opensearch.client.Client;
19+
import org.opensearch.transport.client.Client;
2020
import org.opensearch.cluster.ClusterName;
2121
import org.opensearch.cluster.ClusterState;
2222
import org.opensearch.cluster.node.DiscoveryNode;

src/test/java/org/opensearch/knn/quantization/models/quantizationState/QuantizationStateCacheTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import lombok.SneakyThrows;
1010
import org.junit.After;
1111
import org.junit.Before;
12-
import org.opensearch.client.Client;
12+
import org.opensearch.transport.client.Client;
1313
import org.opensearch.cluster.service.ClusterService;
1414
import org.opensearch.common.settings.ClusterSettings;
1515
import org.opensearch.common.settings.Settings;

0 commit comments

Comments
 (0)