mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-01 13:13:10 +00:00
MINOR: fix: application triggers in day-1 (#20324)
* fix: application triggers in day-1 * fix filter for day 1 ai agents * format
This commit is contained in:
parent
42754a5335
commit
ab5cc03e1b
@ -4,6 +4,7 @@ import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
|||||||
import static org.openmetadata.service.util.EntityUtil.Fields.EMPTY_FIELDS;
|
import static org.openmetadata.service.util.EntityUtil.Fields.EMPTY_FIELDS;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.json.JsonPatch;
|
import javax.json.JsonPatch;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
@ -64,22 +65,18 @@ public class RunAppImpl {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
App updatedApp = getUpdatedApp(app, service);
|
|
||||||
|
|
||||||
updateApp(appRepository, app, updatedApp);
|
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
long timeoutMillis = timeoutSeconds * 1000;
|
long timeoutMillis = timeoutSeconds * 1000;
|
||||||
boolean success = true;
|
|
||||||
|
|
||||||
|
Map<String, Object> config = getConfig(app, service);
|
||||||
if (app.getAppType().equals(AppType.Internal)) {
|
if (app.getAppType().equals(AppType.Internal)) {
|
||||||
success = runApp(appRepository, app, waitForCompletion, startTime, timeoutMillis);
|
return runApp(appRepository, app, config, waitForCompletion, startTime, timeoutMillis);
|
||||||
} else {
|
} else {
|
||||||
success = runApp(pipelineServiceClient, app, waitForCompletion, startTime, timeoutMillis);
|
App updatedApp = JsonUtils.deepCopy(app, App.class);
|
||||||
|
updatedApp.setAppConfiguration(config);
|
||||||
|
updateApp(appRepository, app, app);
|
||||||
|
return runApp(pipelineServiceClient, app, waitForCompletion, startTime, timeoutMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateApp(appRepository, updatedApp, app);
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateAppShouldRun(App app, ServiceEntityInterface service) {
|
private boolean validateAppShouldRun(App app, ServiceEntityInterface service) {
|
||||||
@ -89,62 +86,62 @@ public class RunAppImpl {
|
|||||||
&& List.of("CollateAIApplication", "CollateAIQualityAgentApplication")
|
&& List.of("CollateAIApplication", "CollateAIQualityAgentApplication")
|
||||||
.contains(app.getName())) {
|
.contains(app.getName())) {
|
||||||
return true;
|
return true;
|
||||||
} else if (List.of("DataInsightsApplication", "CollateAITierAgentApplication")
|
} else
|
||||||
.contains(app.getName())) {
|
return List.of("DataInsightsApplication", "CollateAITierAgentApplication")
|
||||||
return true;
|
.contains(app.getName());
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private App getUpdatedApp(App app, ServiceEntityInterface service) {
|
private Map<String, Object> getConfig(App app, ServiceEntityInterface service) {
|
||||||
App updatedApp = JsonUtils.deepCopy(app, App.class);
|
Object config = JsonUtils.deepCopy(app.getAppConfiguration(), Object.class);
|
||||||
Object updatedConfig = JsonUtils.deepCopy(app.getAppConfiguration(), Object.class);
|
|
||||||
|
|
||||||
if (app.getName().equals("CollateAIApplication")) {
|
switch (app.getName()) {
|
||||||
(JsonUtils.convertValue(updatedConfig, CollateAIAppConfig.class))
|
case "CollateAIApplication" -> config =
|
||||||
.withFilter(
|
(JsonUtils.convertValue(config, CollateAIAppConfig.class))
|
||||||
String.format(
|
.withFilter(
|
||||||
"{\"query\":{\"bool\":{\"must\":[{\"bool\":{\"must\":[{\"term\":{\"Tier.TagFQN\":\"Tier.Tier1\"}}]}},{\"bool\":{\"must\":[{\"term\":{\"entityType\":\"table\"}}]}},{\"bool\":{\"must\":[{\"term\":{\"service.name.keyword\":\"%s\"}}]}}]}}}",
|
String.format(
|
||||||
service.getName().toLowerCase()));
|
"{\"query\":{\"bool\":{\"must\":[{\"bool\":{\"must\":[{\"term\":{\"Tier.TagFQN\":\"Tier.Tier1\"}},{\"term\":{\"entityType\":\"table\"}},{\"term\":{\"service.displayName.keyword\":\"%s\"}}]}}]}}}",
|
||||||
} else if (app.getName().equals("CollateAIQualityAgentApplication")) {
|
service.getName()));
|
||||||
(JsonUtils.convertValue(updatedConfig, CollateAIQualityAgentAppConfig.class))
|
case "CollateAIQualityAgentApplication" -> config =
|
||||||
.withFilter(
|
(JsonUtils.convertValue(config, CollateAIQualityAgentAppConfig.class))
|
||||||
String.format(
|
.withFilter(
|
||||||
"{\"query\":{\"bool\":{\"must\":[{\"bool\":{\"must\":[{\"term\":{\"Tier.TagFQN\":\"Tier.Tier1\"}}]}},{\"bool\":{\"must\":[{\"term\":{\"entityType\":\"table\"}}]}},{\"bool\":{\"must\":[{\"term\":{\"service.name.keyword\":\"%s\"}}]}}]}}}",
|
String.format(
|
||||||
service.getName().toLowerCase()));
|
"{\"query\":{\"bool\":{\"must\":[{\"bool\":{\"must\":[{\"term\":{\"entityType\":\"table\"}},{\"term\":{\"service.displayName.keyword\":\"%s\"}}]}}]}}}",
|
||||||
} else if (app.getName().equals("CollateAITierAgentApplication")) {
|
service.getName()));
|
||||||
(JsonUtils.convertValue(updatedConfig, CollateAITierAgentAppConfig.class))
|
case "CollateAITierAgentApplication" -> config =
|
||||||
.withFilter(
|
(JsonUtils.convertValue(config, CollateAITierAgentAppConfig.class))
|
||||||
String.format(
|
.withFilter(
|
||||||
"{\"query\":{\"bool\":{\"must\":[{\"bool\":{\"must\":[{\"term\":{\"entityType\":\"table\"}}]}},{\"bool\":{\"must\":[{\"term\":{\"service.name.keyword\":\"%s\"}}]}}]}}}",
|
String.format(
|
||||||
service.getName().toLowerCase()));
|
"{\"query\":{\"bool\":{\"must\":[{\"bool\":{\"must\":[{\"term\":{\"entityType\":\"table\"}},{\"term\":{\"service.displayName.keyword\":\"%s\"}}]}}]}}}",
|
||||||
} else if (app.getName().equals("DataInsightsApplication")) {
|
service.getName()));
|
||||||
DataInsightsAppConfig updatedAppConfig =
|
case "DataInsightsApplication" -> {
|
||||||
(JsonUtils.convertValue(updatedConfig, DataInsightsAppConfig.class));
|
DataInsightsAppConfig updatedAppConfig =
|
||||||
ModuleConfiguration updatedModuleConfig =
|
(JsonUtils.convertValue(config, DataInsightsAppConfig.class));
|
||||||
updatedAppConfig
|
ModuleConfiguration updatedModuleConfig =
|
||||||
.getModuleConfiguration()
|
updatedAppConfig
|
||||||
.withAppAnalytics(new AppAnalyticsConfig().withEnabled(false))
|
.getModuleConfiguration()
|
||||||
.withCostAnalysis(new CostAnalysisConfig().withEnabled(false))
|
.withAppAnalytics(new AppAnalyticsConfig().withEnabled(false))
|
||||||
.withDataQuality(new DataQualityConfig().withEnabled(false))
|
.withCostAnalysis(new CostAnalysisConfig().withEnabled(false))
|
||||||
.withDataAssets(
|
.withDataQuality(new DataQualityConfig().withEnabled(false))
|
||||||
new DataAssetsConfig()
|
.withDataAssets(
|
||||||
.withRetention(
|
new DataAssetsConfig()
|
||||||
updatedAppConfig.getModuleConfiguration().getDataAssets().getRetention())
|
.withRetention(
|
||||||
.withServiceFilter(
|
updatedAppConfig
|
||||||
new ServiceFilter()
|
.getModuleConfiguration()
|
||||||
.withServiceName(service.getName())
|
.getDataAssets()
|
||||||
.withServiceType(Entity.getEntityTypeFromObject(service))));
|
.getRetention())
|
||||||
|
.withServiceFilter(
|
||||||
|
new ServiceFilter()
|
||||||
|
.withServiceName(service.getName())
|
||||||
|
.withServiceType(Entity.getEntityTypeFromObject(service))));
|
||||||
|
|
||||||
updatedConfig =
|
config =
|
||||||
updatedAppConfig
|
updatedAppConfig
|
||||||
.withBackfillConfiguration(new BackfillConfiguration().withEnabled(false))
|
.withBackfillConfiguration(new BackfillConfiguration().withEnabled(false))
|
||||||
.withRecreateDataAssetsIndex(false)
|
.withRecreateDataAssetsIndex(false)
|
||||||
.withModuleConfiguration(updatedModuleConfig);
|
.withModuleConfiguration(updatedModuleConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updatedApp.withAppConfiguration(JsonUtils.getMap(updatedConfig));
|
return JsonUtils.getMap(config);
|
||||||
return updatedApp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateApp(AppRepository repository, App originalApp, App updatedApp) {
|
private void updateApp(AppRepository repository, App originalApp, App updatedApp) {
|
||||||
@ -157,12 +154,13 @@ public class RunAppImpl {
|
|||||||
private boolean runApp(
|
private boolean runApp(
|
||||||
AppRepository repository,
|
AppRepository repository,
|
||||||
App app,
|
App app,
|
||||||
|
Map<String, Object> config,
|
||||||
boolean waitForCompletion,
|
boolean waitForCompletion,
|
||||||
long startTime,
|
long startTime,
|
||||||
long timeoutMillis) {
|
long timeoutMillis) {
|
||||||
ApplicationHandler.getInstance()
|
ApplicationHandler.getInstance()
|
||||||
.triggerApplicationOnDemand(
|
.triggerApplicationOnDemand(
|
||||||
app, Entity.getCollectionDAO(), Entity.getSearchRepository(), null);
|
app, Entity.getCollectionDAO(), Entity.getSearchRepository(), config);
|
||||||
|
|
||||||
if (waitForCompletion) {
|
if (waitForCompletion) {
|
||||||
return waitForCompletion(repository, app, startTime, timeoutMillis);
|
return waitForCompletion(repository, app, startTime, timeoutMillis);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user