This is an automated email from the ASF dual-hosted git repository.
lahirujayathilake pushed a commit to branch agent-framewok-refactoring
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/agent-framewok-refactoring by
this push:
new ec4a624ad2 application interface pulled by the group
ec4a624ad2 is described below
commit ec4a624ad24312895b59e26fd74da7a66c47a4f5
Author: lahiruj <[email protected]>
AuthorDate: Tue Feb 18 01:17:53 2025 -0500
application interface pulled by the group
---
.../service/handlers/AgentManagementHandler.java | 4 ++--
.../connection/service/models/LaunchAgentRequest.java | 15 +++++++++++++++
.../connection/service/services/AiravataService.java | 8 +++++---
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git
a/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/handlers/AgentManagementHandler.java
b/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/handlers/AgentManagementHandler.java
index 4d3a00eccc..bf339233e2 100644
---
a/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/handlers/AgentManagementHandler.java
+++
b/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/handlers/AgentManagementHandler.java
@@ -103,7 +103,7 @@ public class AgentManagementHandler {
String experimentName = req.getExperimentName();
String projectId =
airavataService.extractDefaultProjectId(airavataClient);
- String appInterfaceId =
clusterApplicationConfig.getApplicationInterfaceIdByCluster(req.getRemoteCluster());
+ String appInterfaceId =
clusterApplicationConfig.getApplicationInterfaceIdByCluster(req.getApplicationInterfaceName());
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setExperimentName(experimentName);
@@ -118,7 +118,7 @@ public class AgentManagementHandler {
computationalResourceSchedulingModel.setTotalCPUCount(req.getCpuCount());
computationalResourceSchedulingModel.setWallTimeLimit(req.getWallTime());
computationalResourceSchedulingModel.setTotalPhysicalMemory(req.getMemory());
-
computationalResourceSchedulingModel.setResourceHostId(airavataService.extractComputeResourceId(airavataClient,
req.getRemoteCluster()));
+
computationalResourceSchedulingModel.setResourceHostId(airavataService.extractComputeResourceId(airavataClient,
req.getGroup(), req.getApplicationInterfaceName()));
UserConfigurationDataModel userConfigurationDataModel = new
UserConfigurationDataModel();
userConfigurationDataModel.setComputationalResourceScheduling(computationalResourceSchedulingModel);
diff --git
a/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/models/LaunchAgentRequest.java
b/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/models/LaunchAgentRequest.java
index c6378f2b5e..edbb00c9f2 100644
---
a/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/models/LaunchAgentRequest.java
+++
b/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/models/LaunchAgentRequest.java
@@ -1,9 +1,12 @@
package org.apache.airavata.agent.connection.service.models;
+import org.apache.commons.lang3.StringUtils;
+
public class LaunchAgentRequest {
private String experimentName;
private String remoteCluster;
+ private String group;
private String queue = "shared";
private int wallTime = 30;
@@ -66,4 +69,16 @@ public class LaunchAgentRequest {
public void setMemory(int memory) {
this.memory = memory;
}
+
+ public String getGroup() {
+ return group;
+ }
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+ public String getApplicationInterfaceName() {
+ return remoteCluster + (StringUtils.isNotBlank(group) ? ("_" + group)
: "");
+ }
}
diff --git
a/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataService.java
b/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataService.java
index 5151c0f1ed..9031a15ba2 100644
---
a/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataService.java
+++
b/modules/agent-framework/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataService.java
@@ -1,5 +1,6 @@
package org.apache.airavata.agent.connection.service.services;
+import io.micrometer.common.util.StringUtils;
import org.apache.airavata.agent.connection.service.UserContext;
import org.apache.airavata.api.Airavata;
import org.apache.airavata.api.client.AiravataClientFactory;
@@ -71,14 +72,15 @@ public class AiravataService {
throw new RuntimeException("Could not find a Default project for the
user: " + UserContext.username());
}
- public String extractComputeResourceId(Airavata.Client airavataClient,
String remoteCluster) throws TException {
+ public String extractComputeResourceId(Airavata.Client airavataClient,
String group, String applicationInterfaceName) throws TException {
List<GroupResourceProfile> groupResourceList =
airavataClient.getGroupResourceList(UserContext.authzToken(),
UserContext.gatewayId());
+ String groupProfileName = StringUtils.isNotBlank(group) ? group :
"Default";
return groupResourceList.stream()
- .filter(profile ->
"Default".equals(profile.getGroupResourceProfileName())) // TODO parameterized
the group resource profile
+ .filter(profile ->
groupProfileName.equalsIgnoreCase(profile.getGroupResourceProfileName()))
.flatMap(profile -> profile.getComputePreferences().stream())
.map(GroupComputeResourcePreference::getComputeResourceId)
- .filter(computeResourceId ->
computeResourceId.startsWith(remoteCluster))
+ .filter(computeResourceId ->
computeResourceId.startsWith(applicationInterfaceName))
.findFirst()
.orElseThrow(() -> new RuntimeException("Could not find a
Compute Resource in the Default group resource profile for the user: " +
UserContext.username()));
}