Skip to content

Commit

Permalink
Merge branch 'feature/semantic-text' into semantic-text-dense-vector
Browse files Browse the repository at this point in the history
# Conflicts:
#	server/src/main/java/org/elasticsearch/inference/ServiceSettings.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceSettings.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceSettings.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsServiceSettings.java
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceSettingsTests.java
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java
  • Loading branch information
carlosdelest committed Feb 14, 2024
2 parents f24db63 + 16762be commit e278205
Show file tree
Hide file tree
Showing 1,075 changed files with 25,341 additions and 10,126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.elasticsearch.index.mapper.ProvidedIdFieldMapper;
import org.elasticsearch.index.similarity.SimilarityService;
import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.plugins.internal.DocumentParsingObserver;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptCompiler;
import org.elasticsearch.script.ScriptContext;
Expand Down Expand Up @@ -72,8 +71,7 @@ public static MapperService create(String mappings) {
public <T> T compile(Script script, ScriptContext<T> scriptContext) {
throw new UnsupportedOperationException();
}
},
() -> DocumentParsingObserver.EMPTY_INSTANCE
}
);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.elasticsearch.index.similarity.SimilarityService;
import org.elasticsearch.indices.IndicesModule;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.plugins.internal.DocumentParsingObserver;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptCompiler;
import org.elasticsearch.script.ScriptContext;
Expand Down Expand Up @@ -187,8 +186,7 @@ protected final MapperService createMapperService(String mappings) {
public <T> T compile(Script script, ScriptContext<T> scriptContext) {
throw new UnsupportedOperationException();
}
},
() -> DocumentParsingObserver.EMPTY_INSTANCE
}
);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void apply(Project project) {
copy.filter(new Transformer<String, String>() {
@Override
public String transform(String s) {
return s.replaceAll("@@LICENSE_HEADER_TEXT@@", finalLicenseHeader);
return s.replace("@@LICENSE_HEADER_TEXT@@", finalLicenseHeader);
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,29 @@ public static SourceSetContainer getJavaSourceSets(Project project) {
return project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
}

public static File locateElasticsearchWorkspace(Gradle gradle) {
if(gradle.getRootProject().getName().startsWith("build-tools")) {
File buildToolsParent = gradle.getRootProject().getRootDir().getParentFile();
if(versionFileExists(buildToolsParent)) {
return buildToolsParent;
}
public static File locateElasticsearchWorkspace(Gradle gradle) {
if (gradle.getRootProject().getName().startsWith("build-tools")) {
File buildToolsParent = gradle.getRootProject().getRootDir().getParentFile();
if (versionFileExists(buildToolsParent)) {
return buildToolsParent;
}
if (gradle.getParent() == null) {
// See if any of these included builds is the Elasticsearch gradle
for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
if (versionFileExists(includedBuild.getProjectDir())) {
return includedBuild.getProjectDir();
}
return buildToolsParent;
}
if (gradle.getParent() == null) {
// See if any of these included builds is the Elasticsearch gradle
for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
if (versionFileExists(includedBuild.getProjectDir())) {
return includedBuild.getProjectDir();
}

// Otherwise assume this gradle is the root elasticsearch workspace
return gradle.getRootProject().getRootDir();
} else {
// We're an included build, so keep looking
return locateElasticsearchWorkspace(gradle.getParent());
}

// Otherwise assume this gradle is the root elasticsearch workspace
return gradle.getRootProject().getRootDir();
} else {
// We're an included build, so keep looking
return locateElasticsearchWorkspace(gradle.getParent());
}
}

private static boolean versionFileExists(File rootDir) {
return new File(rootDir, "build-tools-internal/version.properties").exists();
Expand Down
4 changes: 2 additions & 2 deletions build-tools-internal/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=c16d517b50dd28b3f5838f0e844b7520b8f1eb610f2f29de7e4e04a1b7c9c79b
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionSha256Sum=85719317abd2112f021d4f41f09ec370534ba288432065f4b477b6a3b652910d
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
18 changes: 14 additions & 4 deletions build-tools-internal/src/main/groovy/elasticsearch.ide.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import org.elasticsearch.gradle.util.Pair
import org.elasticsearch.gradle.util.GradleUtils
import org.elasticsearch.gradle.internal.info.BuildParams
import org.jetbrains.gradle.ext.JUnit

Expand Down Expand Up @@ -109,16 +110,25 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
}
}

// aggregate task so dependency artifacts below can can use one task name
tasks.register("generateProviderImpls").configure {
group = 'ide'
description = 'Builds all embedded provider impls'

dependsOn subprojects
.collect { GradleUtils.findByName(it.tasks, 'generateProviderImpls') }
.findAll { it != null }
}

tasks.register('buildDependencyArtifacts') {
group = 'ide'
description = 'Builds artifacts needed as dependency for IDE modules'
dependsOn([':client:rest-high-level:shadowJar',
':plugins:repository-hdfs:hadoop-client-api:shadowJar',
':libs:elasticsearch-x-content:generateImplProviderImpl',
dependsOn([':plugins:repository-hdfs:hadoop-client-api:shadowJar',
':x-pack:plugin:esql:compute:ann:jar',
':x-pack:plugin:esql:compute:gen:jar',
':server:generateModulesList',
':server:generatePluginsList'].collect { elasticsearchProject.right()?.task(it) ?: it })
':server:generatePluginsList',
':generateProviderImpls'].collect { elasticsearchProject.right()?.task(it) ?: it })
}

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void setMappings(LinkedHashMap<String, String> mappings) {
*/
protected String createURL(final String group, final String name, final String version) {
final String baseURL = "https://repo1.maven.org/maven2";
return baseURL + "/" + group.replaceAll("\\.", "/") + "/" + name + "/" + version;
return baseURL + "/" + group.replace('.', '/') + "/" + name + "/" + version;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ private void configureDependency(Project project, boolean shadowed, ProjectDepen
// Link to non-shadowed dependant projects
javadoc.dependsOn(upstreamProject.getPath() + ":javadoc");
String externalLinkName = upstreamProject.getExtensions().getByType(BasePluginExtension.class).getArchivesName().get();
String artifactPath = dep.getGroup().replaceAll("\\.", "/") + '/' + externalLinkName.replaceAll("\\.", "/") + '/' + dep
.getVersion();
String artifactPath = dep.getGroup().replace('.', '/') + '/' + externalLinkName.replace('.', '/') + '/' + dep.getVersion();
var options = (StandardJavadocDocletOptions) javadoc.getOptions();
options.linksOffline(
artifactHost(project) + "/javadoc/" + artifactPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public void execute(Task t) {
// don't track these as inputs since they contain absolute paths and break cache relocatability
File gradleUserHome = project.getGradle().getGradleUserHomeDir();
nonInputProperties.systemProperty("gradle.user.home", gradleUserHome);
nonInputProperties.systemProperty("workspace.dir", Util.locateElasticsearchWorkspace(project.getGradle()));
// we use 'temp' relative to CWD since this is per JVM and tests are forbidden from writing to CWD
nonInputProperties.systemProperty("java.io.tmpdir", test.getWorkingDir().toPath().resolve("temp"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
package org.elasticsearch.gradle.internal;

import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.Directory;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.Sync;
import org.gradle.api.tasks.TaskProvider;

import static org.elasticsearch.gradle.internal.conventions.GUtils.capitalize;
import static org.elasticsearch.gradle.util.GradleUtils.getJavaSourceSets;
Expand All @@ -23,9 +25,11 @@
public class EmbeddedProviderExtension {

private final Project project;
private final TaskProvider<Task> metaTask;

public EmbeddedProviderExtension(Project project) {
public EmbeddedProviderExtension(Project project, TaskProvider<Task> metaTask) {
this.project = project;
this.metaTask = metaTask;
}

void impl(String implName, Project implProject) {
Expand Down Expand Up @@ -55,6 +59,7 @@ void impl(String implName, Project implProject) {
spec.from(generateProviderManifest);
});
});
metaTask.configure(t -> { t.dependsOn(generateProviderImpl); });

var mainSourceSet = getJavaSourceSets(project).findByName(SourceSet.MAIN_SOURCE_SET_NAME);
mainSourceSet.getOutput().dir(generateProviderImpl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import org.elasticsearch.gradle.transform.UnzipTransform;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.attributes.Attribute;
import org.gradle.api.tasks.TaskProvider;

import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE;
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.DIRECTORY_TYPE;
Expand All @@ -29,6 +31,7 @@ public void apply(Project project) {
transformSpec.parameters(parameters -> parameters.getIncludeArtifactName().set(true));
});

project.getExtensions().create("embeddedProviders", EmbeddedProviderExtension.class, project);
TaskProvider<Task> metaTask = project.getTasks().register("generateProviderImpls");
project.getExtensions().create("embeddedProviders", EmbeddedProviderExtension.class, project, metaTask);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class InternalDistributionModuleCheckTaskProvider {
"org.elasticsearch.grok",
"org.elasticsearch.logging",
"org.elasticsearch.lz4",
"org.elasticsearch.nativeaccess",
"org.elasticsearch.plugin",
"org.elasticsearch.plugin.analysis",
"org.elasticsearch.pluginclassloader",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -75,7 +75,7 @@ public DockerAvailability getDockerAvailability() {
Version version = null;
boolean isVersionHighEnough = false;
boolean isComposeAvailable = false;
Set<Architecture> supportedArchitectures = new HashSet<>();
Set<Architecture> supportedArchitectures = EnumSet.noneOf(Architecture.class);

// Check if the Docker binary exists
final Optional<String> dockerBinary = getDockerPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private static String generatedAnchor(String input) {
final List<String> excludes = List.of("the", "is", "a", "and", "now", "that");

final String[] words = input.toLowerCase(Locale.ROOT)
.replaceAll("'", "")
.replace("'", "")
.replaceAll("[^\\w]+", "_")
.replaceFirst("^_+", "")
.replaceFirst("_+$", "")
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.5
8.6
2 changes: 1 addition & 1 deletion build-tools-internal/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ netty = 4.1.94.Final
commons_lang3 = 3.9
google_oauth_client = 1.34.1

antlr4 = 4.11.1
antlr4 = 4.13.1
# when updating this version, you need to ensure compatibility with:
# - distribution/tools/plugin-cli
# - x-pack/plugin/security
Expand Down
10 changes: 5 additions & 5 deletions build-tools/src/main/java/org/elasticsearch/gradle/OS.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
package org.elasticsearch.gradle;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

public enum OS {
Expand All @@ -34,7 +34,7 @@ public static OS current() {

public static class Conditional<T> {

private final Map<OS, Supplier<T>> conditions = new HashMap<>();
private final Map<OS, Supplier<T>> conditions = new EnumMap<>(OS.class);

public Conditional<T> onWindows(Supplier<T> supplier) {
conditions.put(WINDOWS, supplier);
Expand All @@ -58,7 +58,7 @@ public Conditional<T> onUnix(Supplier<T> supplier) {
}

public T supply() {
HashSet<OS> missingOS = new HashSet<>(Arrays.asList(OS.values()));
Set<OS> missingOS = EnumSet.allOf(OS.class);
missingOS.removeAll(conditions.keySet());
if (missingOS.isEmpty() == false) {
throw new IllegalArgumentException("No condition specified for " + missingOS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static void extendSourceSet(Project project, String parentSourceSetName,
* task execution time.
*/
public static String getProjectPathFromTask(String taskPath) {
int lastDelimiterIndex = taskPath.lastIndexOf(":");
int lastDelimiterIndex = taskPath.lastIndexOf(':');
return lastDelimiterIndex == 0 ? ":" : taskPath.substring(0, lastDelimiterIndex);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ public class TestUtils {

public static String normalizeString(String input, File projectRootDir) {
try {
String cannonicalNormalizedPathPrefix = projectRootDir.getCanonicalPath().replace("\\", "/");
String normalizedPathPrefix = projectRootDir.getAbsolutePath().replace("\\", "/");
String canonicalNormalizedPathPrefix = projectRootDir.getCanonicalPath().replace('\\', '/');
String normalizedPathPrefix = projectRootDir.getAbsolutePath().replace('\\', '/');
return input.lines()
.filter(it -> it.startsWith("Picked up JAVA_TOOL_OPTIONS") == false)
.map(it -> it.replace("\\", "/"))
.map(it -> it.replace('\\', '/'))
.map(it -> it.replaceAll("\\d+\\.\\d\\ds", "0.00s"))
.map(it -> it.replaceAll(cannonicalNormalizedPathPrefix, "."))
.map(it -> it.replaceAll(normalizedPathPrefix, "."))
.map(it -> it.replaceAll("file:/./", "file:./"))
.map(it -> it.replaceAll("Gradle Test Executor \\d", "Gradle Test Executor 1"))
.map(it -> it.replace(canonicalNormalizedPathPrefix, "."))
.map(it -> it.replace(normalizedPathPrefix, "."))
.map(it -> it.replace("file:/./", "file:./"))
.map(it -> it.replaceAll("Gradle Test Executor \\d+", "Gradle Test Executor 1"))
.collect(Collectors.joining("\n"));
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
Loading

0 comments on commit e278205

Please sign in to comment.