Skip to content

Commit 6976e93

Browse files
Resolve deprecations in AppComputeService, TaskManagerService, and ResultService (#616)
1 parent 1092760 commit 6976e93

File tree

10 files changed

+76
-39
lines changed

10 files changed

+76
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
1717

1818
- Reorder `static` and `final` keywords. (#614)
1919
- Improve code maintainability in test classes. (#615)
20+
- Resolve deprecations caused by `TaskDescription` in `AppComputeService`, `TaskManagerService`, and `ResultService`. (#616)
2021

2122
### Dependency Upgrades
2223

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version=8.5.0
22
iexecCommonVersion=8.5.0
33
iexecCommonsContainersVersion=1.2.2
4-
iexecCommonsPocoVersion=4.1.0
4+
iexecCommonsPocoVersion=4.1.0-NEXT-SNAPSHOT
55
iexecResultVersion=8.5.0
66
iexecSmsVersion=8.6.0
77
iexecCoreVersion=8.5.0

src/main/java/com/iexec/worker/compute/app/AppComputeService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -95,7 +95,7 @@ public AppComputeResponse runCompute(TaskDescription taskDescription,
9595
.chainTaskId(chainTaskId)
9696
.imageUri(taskDescription.getAppUri())
9797
.containerName(getTaskContainerName(chainTaskId))
98-
.cmd(taskDescription.getCmd())
98+
.cmd(taskDescription.getDealParams().getIexecArgs())
9999
.env(env)
100100
.maxExecutionTime(taskDescription.getMaxExecutionTime())
101101
.sgxDriverMode(

src/main/java/com/iexec/worker/executor/TaskManagerService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ ReplicateActionResponse start(TaskDescription taskDescription) {
108108
}
109109

110110
// result encryption is not supported for standard tasks
111-
if (!taskDescription.isTeeTask() && taskDescription.isResultEncryption()) {
111+
if (!taskDescription.isTeeTask() && taskDescription.getDealParams().isIexecResultEncryption()) {
112112
return getFailureResponseAndPrintError(TASK_DESCRIPTION_INVALID,
113113
context, chainTaskId);
114114
}
@@ -125,7 +125,7 @@ ReplicateActionResponse start(TaskDescription taskDescription) {
125125
}
126126

127127
final WorkerpoolAuthorization workerpoolAuthorization = contributionService.getWorkerpoolAuthorization(chainTaskId);
128-
final String resultProxyUrl = taskDescription.getResultStorageProxy();
128+
final String resultProxyUrl = taskDescription.getDealParams().getIexecResultStorageProxy();
129129
final String token = resultService.getIexecUploadToken(workerpoolAuthorization, resultProxyUrl);
130130
smsService.pushToken(workerpoolAuthorization, token);
131131
}
@@ -200,7 +200,7 @@ ReplicateActionResponse downloadData(TaskDescription taskDescription) {
200200
log.info("No input files for this task [chainTaskId:{}]", chainTaskId);
201201
} else {
202202
log.info("Downloading input files [chainTaskId:{}]", chainTaskId);
203-
dataService.downloadStandardInputFiles(chainTaskId, taskDescription.getInputFiles());
203+
dataService.downloadStandardInputFiles(chainTaskId, taskDescription.getDealParams().getIexecInputFiles());
204204
}
205205
} catch (WorkflowException e) {
206206
return triggerPostComputeHookOnError(chainTaskId, context, taskDescription,

src/main/java/com/iexec/worker/result/ResultService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public boolean writeErrorToIexecOut(String chainTaskId, ReplicateStatus errorSta
118118
public void saveResultInfo(String chainTaskId, TaskDescription taskDescription, ComputedFile computedFile) {
119119
ResultInfo resultInfo = ResultInfo.builder()
120120
.image(taskDescription.getAppUri())
121-
.cmd(taskDescription.getCmd())
121+
.cmd(taskDescription.getDealParams().getIexecArgs())
122122
.deterministHash(computedFile != null ? computedFile.getResultDigest() : "")
123123
.datasetUri(taskDescription.getDatasetUri())
124124
.build();
@@ -194,8 +194,8 @@ public String uploadResultAndGetLink(WorkerpoolAuthorization workerpoolAuthoriza
194194
}
195195

196196
// Cloud computing - basic
197-
final boolean isIpfsStorageRequest = IPFS_RESULT_STORAGE_PROVIDER.equals(task.getResultStorageProvider());
198-
final String resultProxyURL = task.getResultStorageProxy();
197+
final boolean isIpfsStorageRequest = IPFS_RESULT_STORAGE_PROVIDER.equals(task.getDealParams().getIexecResultStorageProvider());
198+
final String resultProxyURL = task.getDealParams().getIexecResultStorageProxy();
199199
final boolean isUpload = upload(workerpoolAuthorization, resultProxyURL);
200200
if (isIpfsStorageRequest && isUpload) {
201201
log.info("Web2 storage, just uploaded (with basic) [chainTaskId:{}]", chainTaskId);
@@ -229,12 +229,12 @@ private boolean upload(final WorkerpoolAuthorization workerpoolAuthorization,
229229

230230
private String getWeb2ResultLink(final TaskDescription task) {
231231
final String chainTaskId = task.getChainTaskId();
232-
final String storage = task.getResultStorageProvider();
232+
final String storage = task.getDealParams().getIexecResultStorageProvider();
233233

234234
switch (storage) {
235235
case IPFS_RESULT_STORAGE_PROVIDER:
236236
try {
237-
final String resultProxyUrl = task.getResultStorageProxy();
237+
final String resultProxyUrl = task.getDealParams().getIexecResultStorageProxy();
238238
final String ipfsHash = publicConfigurationService
239239
.createResultProxyClientFromURL(resultProxyUrl)
240240
.getIpfsHashForTask(chainTaskId);

src/test/java/com/iexec/worker/compute/ComputeManagerServiceTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.iexec.common.result.ComputedFile;
2121
import com.iexec.commons.containers.DockerLogs;
2222
import com.iexec.commons.containers.client.DockerClientInstance;
23+
import com.iexec.commons.poco.chain.DealParams;
2324
import com.iexec.commons.poco.chain.WorkerpoolAuthorization;
2425
import com.iexec.commons.poco.dapp.DappType;
2526
import com.iexec.commons.poco.task.TaskDescription;
@@ -48,7 +49,7 @@
4849
import java.io.File;
4950
import java.time.Duration;
5051
import java.time.temporal.ChronoUnit;
51-
import java.util.Arrays;
52+
import java.util.List;
5253
import java.util.stream.Stream;
5354

5455
import static org.assertj.core.api.Assertions.assertThat;
@@ -96,13 +97,16 @@ class ComputeManagerServiceTests {
9697
private ResultService resultService;
9798

9899
private TaskDescription.TaskDescriptionBuilder createTaskDescriptionBuilder(boolean isTeeTask) {
100+
final DealParams dealParams = DealParams.builder()
101+
.iexecInputFiles(List.of("file0", "file1"))
102+
.build();
99103
return TaskDescription.builder()
100104
.chainTaskId(CHAIN_TASK_ID)
101105
.appType(DappType.DOCKER)
102106
.appUri(APP_URI)
103107
.datasetUri(DATASET_URI)
104108
.maxExecutionTime(MAX_EXECUTION_TIME)
105-
.inputFiles(Arrays.asList("file0", "file1"))
109+
.dealParams(dealParams)
106110
.isTeeTask(isTeeTask)
107111
.maxExecutionTime(3000);
108112
}

src/test/java/com/iexec/worker/compute/app/AppComputeServiceTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.iexec.commons.containers.DockerRunRequest;
2626
import com.iexec.commons.containers.DockerRunResponse;
2727
import com.iexec.commons.containers.SgxDriverMode;
28+
import com.iexec.commons.poco.chain.DealParams;
2829
import com.iexec.commons.poco.task.TaskDescription;
2930
import com.iexec.commons.poco.tee.TeeEnclaveConfiguration;
3031
import com.iexec.sms.api.TeeSessionGenerationResponse;
@@ -64,12 +65,16 @@ class AppComputeServiceTests {
6465
private static final String IEXEC_OUT = "IEXEC_OUT";
6566
public static final long HEAP_SIZE = 1024;
6667

68+
private final DealParams dealParams = DealParams.builder()
69+
.iexecInputFiles(Arrays.asList("file0", "file1"))
70+
.build();
71+
6772
private final TaskDescription.TaskDescriptionBuilder taskDescriptionBuilder = TaskDescription.builder()
6873
.chainTaskId(CHAIN_TASK_ID)
6974
.appUri(APP_URI)
7075
.datasetUri(DATASET_URI)
7176
.maxExecutionTime(MAX_EXECUTION_TIME)
72-
.inputFiles(Arrays.asList("file0", "file1"))
77+
.dealParams(dealParams)
7378
.isTeeTask(true);
7479

7580
@InjectMocks

src/test/java/com/iexec/worker/compute/pre/PreComputeServiceTests.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.iexec.commons.containers.DockerRunResponse;
2323
import com.iexec.commons.containers.SgxDriverMode;
2424
import com.iexec.commons.containers.client.DockerClientInstance;
25+
import com.iexec.commons.poco.chain.DealParams;
2526
import com.iexec.commons.poco.chain.WorkerpoolAuthorization;
2627
import com.iexec.commons.poco.task.TaskDescription;
2728
import com.iexec.commons.poco.tee.TeeEnclaveConfiguration;
@@ -131,7 +132,10 @@ void beforeEach() {
131132
//region runTeePreCompute
132133
@Test
133134
void shouldRunTeePreComputeAndPrepareInputDataWhenDatasetAndInputFilesArePresent() throws TeeSessionGenerationException {
134-
final TaskDescription taskDescription = taskDescriptionBuilder.inputFiles(List.of("input-file1")).build();
135+
final DealParams dealParams = DealParams.builder()
136+
.iexecInputFiles(List.of("input-file1"))
137+
.build();
138+
final TaskDescription taskDescription = taskDescriptionBuilder.dealParams(dealParams).build();
135139

136140
when(smsService.createTeeSession(workerpoolAuthorization)).thenReturn(secureSession);
137141
when(preComputeProperties.getImage()).thenReturn(PRE_COMPUTE_IMAGE);
@@ -204,9 +208,12 @@ void shouldRunTeePreComputeAndPrepareInputDataWhenOnlyDatasetIsPresent() throws
204208

205209
@Test
206210
void shouldRunTeePreComputeAndPrepareInputDataWhenOnlyInputFilesArePresent() throws TeeSessionGenerationException {
211+
final DealParams dealParams = DealParams.builder()
212+
.iexecInputFiles(List.of("input-file1"))
213+
.build();
207214
final TaskDescription taskDescription = taskDescriptionBuilder
208215
.datasetAddress("")
209-
.inputFiles(List.of("input-file1"))
216+
.dealParams(dealParams)
210217
.build();
211218

212219
when(smsService.createTeeSession(workerpoolAuthorization)).thenReturn(secureSession);

src/test/java/com/iexec/worker/executor/TaskManagerServiceTests.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.iexec.common.replicate.ReplicateStatusDetails;
2424
import com.iexec.common.result.ComputedFile;
2525
import com.iexec.commons.poco.chain.ChainReceipt;
26+
import com.iexec.commons.poco.chain.DealParams;
2627
import com.iexec.commons.poco.chain.WorkerpoolAuthorization;
2728
import com.iexec.commons.poco.dapp.DappType;
2829
import com.iexec.commons.poco.task.TaskDescription;
@@ -52,7 +53,6 @@
5253
import org.mockito.Mock;
5354
import org.mockito.junit.jupiter.MockitoExtension;
5455

55-
import java.util.Collections;
5656
import java.util.List;
5757
import java.util.Optional;
5858

@@ -118,6 +118,9 @@ void init() {
118118
}
119119

120120
TaskDescription.TaskDescriptionBuilder getTaskDescriptionBuilder(boolean isTeeTask) {
121+
final DealParams dealParams = DealParams.builder()
122+
.iexecInputFiles(List.of("https://ab.cd/ef.jpeg"))
123+
.build();
121124
return TaskDescription.builder()
122125
.chainTaskId(CHAIN_TASK_ID)
123126
.appType(DappType.DOCKER)
@@ -127,7 +130,7 @@ TaskDescription.TaskDescriptionBuilder getTaskDescriptionBuilder(boolean isTeeTa
127130
.datasetChecksum("datasetChecksum")
128131
.datasetUri("datasetUri")
129132
.isTeeTask(isTeeTask)
130-
.inputFiles(List.of("http://file1"));
133+
.dealParams(dealParams);
131134
}
132135

133136
//region start
@@ -156,9 +159,12 @@ void shouldNotStartSinceCannotContributeStatusIsPresent() {
156159

157160
@Test
158161
void shouldNotStartSinceStandardTaskWithEncryption() {
162+
final DealParams dealParams = DealParams.builder()
163+
.iexecResultEncryption(true)
164+
.build();
159165
final TaskDescription taskDescription = TaskDescription.builder()
160166
.chainTaskId(CHAIN_TASK_ID)
161-
.isResultEncryption(true)
167+
.dealParams(dealParams)
162168
.build();
163169
when(contributionService.getCannotContributeStatusCause(CHAIN_TASK_ID))
164170
.thenReturn(Optional.empty());
@@ -307,9 +313,12 @@ void shouldNotDownloadDataSinceCannotContributeStatusIsPresent() {
307313

308314
@Test
309315
void shouldReturnSuccessAndNotDownloadDataSinceEmptyUrls() throws Exception {
316+
final DealParams dealParams = DealParams.builder()
317+
.iexecInputFiles(null)
318+
.build();
310319
final TaskDescription taskDescription = getTaskDescriptionBuilder(false)
311320
.datasetUri("")
312-
.inputFiles(null)
321+
.dealParams(dealParams)
313322
.build();
314323
when(contributionService.getCannotContributeStatusCause(CHAIN_TASK_ID))
315324
.thenReturn(Optional.empty());
@@ -344,8 +353,11 @@ void shouldDownloadDatasetAndInputFiles() throws Exception {
344353

345354
@Test
346355
void shouldDownloadDatasetAndNotInputFiles() throws Exception {
356+
final DealParams dealParams = DealParams.builder()
357+
.iexecInputFiles(null)
358+
.build();
347359
final TaskDescription taskDescription = getTaskDescriptionBuilder(false)
348-
.inputFiles(null)
360+
.dealParams(dealParams)
349361
.build();
350362
when(contributionService.getCannotContributeStatusCause(CHAIN_TASK_ID))
351363
.thenReturn(Optional.empty());
@@ -503,33 +515,31 @@ void shouldHandleWorkflowExceptionInDownloadDataAndTriggerPostComputeHookWithSuc
503515
void shouldWithInputFilesDownloadData() throws Exception {
504516
final TaskDescription taskDescription = getTaskDescriptionBuilder(false)
505517
.datasetUri("")
506-
.inputFiles(Collections.singletonList("https://ab.cd/ef.jpeg"))
507518
.build();
508519
when(contributionService.getCannotContributeStatusCause(CHAIN_TASK_ID))
509520
.thenReturn(Optional.empty());
510521
doNothing().when(dataService).downloadStandardInputFiles(CHAIN_TASK_ID,
511-
taskDescription.getInputFiles());
522+
taskDescription.getDealParams().getIexecInputFiles());
512523

513524
ReplicateActionResponse actionResponse =
514525
taskManagerService.downloadData(taskDescription);
515526

516527
assertThat(actionResponse.isSuccess()).isTrue();
517528
verify(dataService).downloadStandardInputFiles(CHAIN_TASK_ID,
518-
taskDescription.getInputFiles());
529+
taskDescription.getDealParams().getIexecInputFiles());
519530
}
520531

521532
@Test
522533
void shouldWithInputFilesDataDownloadFailedAndTriggerPostComputeHookWithSuccess()
523534
throws Exception {
524535
final TaskDescription taskDescription = getTaskDescriptionBuilder(false)
525536
.datasetUri("")
526-
.inputFiles(Collections.singletonList("https://ab.cd/ef.jpeg"))
527537
.build();
528538
when(contributionService.getCannotContributeStatusCause(CHAIN_TASK_ID))
529539
.thenReturn(Optional.empty());
530540
WorkflowException e = new WorkflowException(INPUT_FILES_DOWNLOAD_FAILED);
531541
doThrow(e).when(dataService).downloadStandardInputFiles(CHAIN_TASK_ID,
532-
taskDescription.getInputFiles());
542+
taskDescription.getDealParams().getIexecInputFiles());
533543
when(resultService.writeErrorToIexecOut(anyString(), any(), any()))
534544
.thenReturn(true);
535545
when(computeManagerService.runPostCompute(taskDescription, null))
@@ -548,13 +558,12 @@ void shouldWithInputFilesDataDownloadFailedAndTriggerPostComputeHookWithFailure1
548558
throws Exception {
549559
final TaskDescription taskDescription = getTaskDescriptionBuilder(false)
550560
.datasetUri("")
551-
.inputFiles(Collections.singletonList("https://ab.cd/ef.jpeg"))
552561
.build();
553562
when(contributionService.getCannotContributeStatusCause(CHAIN_TASK_ID))
554563
.thenReturn(Optional.empty());
555564
WorkflowException e = new WorkflowException(INPUT_FILES_DOWNLOAD_FAILED);
556565
doThrow(e).when(dataService).downloadStandardInputFiles(CHAIN_TASK_ID,
557-
taskDescription.getInputFiles());
566+
taskDescription.getDealParams().getIexecInputFiles());
558567
when(resultService.writeErrorToIexecOut(anyString(), any(), any()))
559568
.thenReturn(false);
560569

@@ -572,13 +581,12 @@ void shouldWithInputFilesDataDownloadFailedAndTriggerPostComputeHookWithFailure2
572581
throws Exception {
573582
final TaskDescription taskDescription = getTaskDescriptionBuilder(false)
574583
.datasetUri("")
575-
.inputFiles(Collections.singletonList("https://ab.cd/ef.jpeg"))
576584
.build();
577585
when(contributionService.getCannotContributeStatusCause(CHAIN_TASK_ID))
578586
.thenReturn(Optional.empty());
579587
WorkflowException e = new WorkflowException(INPUT_FILES_DOWNLOAD_FAILED);
580588
doThrow(e).when(dataService).downloadStandardInputFiles(CHAIN_TASK_ID,
581-
taskDescription.getInputFiles());
589+
taskDescription.getDealParams().getIexecInputFiles());
582590
when(resultService.writeErrorToIexecOut(anyString(), any(), any()))
583591
.thenReturn(true);
584592
when(computeManagerService.runPostCompute(taskDescription, null))

0 commit comments

Comments
 (0)