BI-2132 - Create new experiment workflow#366
Conversation
|
TraitControllerIntegrationTest tests are failing with null program cache, seems like something is messed up with DI. Application stuff related to traits seems to work fine... I'm seeing the same errors locally on develop but not in github actions. There was a failure in github actions but for something different: Error: Failures: |
mlm483
left a comment
There was a problem hiding this comment.
Some minor changes suggested, otherwise I approve.
src/main/java/org/breedinginsight/brapps/importer/model/imports/DomainImportService.java
Outdated
Show resolved
Hide resolved
src/main/java/org/breedinginsight/brapps/importer/controllers/UploadController.java
Show resolved
Hide resolved
src/main/java/org/breedinginsight/brapps/importer/model/imports/DomainImportService.java
Outdated
Show resolved
Hide resolved
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class ImportServiceContext { | ||
| private String workflow; |
There was a problem hiding this comment.
Maybe it would be more clear if this were renamed to workflowName? That way it would be clear that it's not the UUID converted to a string or something else.
There was a problem hiding this comment.
What about workflowId? It's called id in the Workflow enum in ExperimentWorkflowNavigator. May make sense to change that in the previous workflowName suggestion as well if you're good with it.
There was a problem hiding this comment.
@nickpalladino I think workflowId makes sense for the reason you said. WorkflowName is used for the display name. Also, see my comment in the UploadController about using workflowId there for consistency.
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| // TODO: move to common higher level location |
There was a problem hiding this comment.
Clarified comment, let me know if that makes more sense
| @ToString | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class PendingImportObjectData { |
There was a problem hiding this comment.
Will anything analogous be needed for Germplasm?
There was a problem hiding this comment.
I could see doing something similar for other processors in the future to try and clean things up a bit but it's not required.
There was a problem hiding this comment.
Ok, just wondering if the class name should be specific to experiment to prepare for that possibility.
There was a problem hiding this comment.
It could be, it's already under the experiment package namespace so I guess it's a matter of preference. Could we leave it as-is until the point we may do some Germplasm or other processor work?
src/main/java/org/breedinginsight/brapps/importer/services/FileImportService.java
Outdated
Show resolved
Hide resolved
...pps/importer/services/processors/experiment/create/workflow/CreateNewExperimentWorkflow.java
Show resolved
Hide resolved
...pps/importer/services/processors/experiment/create/workflow/CreateNewExperimentWorkflow.java
Outdated
Show resolved
Hide resolved
| public ProcessedData process(ProcessContext context, ProcessedPhenotypeData phenotypeData) | ||
| throws MissingRequiredInfoException, UnprocessableEntityException, ApiException { | ||
|
|
||
| Table data = context.getImportContext().getData(); | ||
| ImportUpload upload = context.getImportContext().getUpload(); | ||
| ImportContext importContext = context.getImportContext(); | ||
|
|
||
| populatePendingImportObjects(context, phenotypeData); | ||
|
|
||
|
|
||
| // TODO: implement | ||
| return new ProcessedData(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Is the TODO to return data instead of mutating in-place? Or something else?
There was a problem hiding this comment.
Ya, I'll clean up the interface and add some comments so it's clear what's actually happening
Co-authored-by: mlm483 <128052931+mlm483@users.noreply.github.com>
| @ProgramSecured(roles = {ProgramSecuredRole.BREEDER, ProgramSecuredRole.SYSTEM_ADMIN}) | ||
| public HttpResponse<Response<ImportResponse>> commitData(@PathVariable UUID programId, @PathVariable UUID mappingId, | ||
| @PathVariable String workflow, @PathVariable UUID uploadId, | ||
| @Body @Nullable Map<String, Object> userInput) { | ||
| try { |
There was a problem hiding this comment.
Changing workflow to workflowId would be more consistent with the use here and with the enum.
| // TODO: delete processor fields once WorkflowNavigator is used | ||
| @Inject | ||
| public ExperimentImportService(Provider<ExperimentProcessor> experimentProcessorProvider, Provider<ProcessorManager> processorManagerProvider) | ||
| public ExperimentImportService(Provider<ExperimentProcessor> experimentProcessorProvider, | ||
| Provider<ProcessorManager> processorManagerProvider, | ||
| ExperimentWorkflowNavigator workflowNavigator) | ||
| { | ||
| this.experimentProcessorProvider = experimentProcessorProvider; | ||
| this.processorManagerProvider = processorManagerProvider; | ||
| super(experimentProcessorProvider, processorManagerProvider, workflowNavigator); | ||
| } |
|
|
||
| @Override | ||
| public List<ImportWorkflow> getWorkflows() throws Exception { | ||
| // Each workflow returns in the field workflow the metadata about the workflow that processed the import context. | ||
| // Loop over all workflows, processing a null context, to collect just the metadata |
There was a problem hiding this comment.
The throws Exception doesn't apply here since there isn't a scenario where getWorkflows() would ever pass up an exception from a lower level; it's only here because throws Exception was added to the Workflow#process signature. See my comments in BI-2134 on using the caughtException field instead.
There was a problem hiding this comment.
The throws Exception was added there because ExperimentWorkflowNavigator::getWorkflows calls process on the ExperimentWorkflow and the process method in CreateNewExperimentWorkflow can throw exceptions. The particular code path for returning workflows wouldn't but the method in general can. I'll look at the BI-2134 stuff.
| public static void validateObservationValue(Trait variable, String value, | ||
| String columnHeader, ValidationErrors validationErrors, int row) { | ||
| if (StringUtils.isBlank(value)) { | ||
| log.debug(String.format("skipping validation of observation because there is no value.\n\tvariable: %s\n\trow: %d", variable.getObservationVariableName(), row)); | ||
| return; | ||
| } | ||
|
|
||
| if (isNAObservation(value)) { | ||
| log.debug(String.format("skipping validation of observation because it is NA.\n\tvariable: %s\n\trow: %d", variable.getObservationVariableName(), row)); |
There was a problem hiding this comment.
In BI-2134, I put these validations into instances of the ObservationValidator functional interface with FieldValidator acting as the primary. The package is at the service level, so it can be used for both workflows.
There was a problem hiding this comment.
I created a card BI-2230 to do cleanup and reduce code duplication between workflows to limit the scope of changes in this PR.
| // TODO: unify usage of single import context type throughout | ||
| ImportContext importContext = ImportContext.from(context); |
There was a problem hiding this comment.
Agree. I suggest for ImportServiceContext renaming workflow to workflowId, brapiImports to importRows, and adding the Map<Integer, PendingImport> mappedBrAPIImport field. Then eliminating the ImportContext class.
There was a problem hiding this comment.
I created a card BI-2230 to do cleanup and reduce code duplication between workflows to limit the scope of changes in this PR.
| newExperimentWorkflowId = getNewExperimentWorkflowId(); | ||
| } | ||
|
|
||
| /** | ||
| * TODO: assumes new workflow is first in list, doesn't look at position property, would be more robust to | ||
| * look at that instead of assuming order | ||
| * @return | ||
| */ | ||
| public String getNewExperimentWorkflowId() { |
There was a problem hiding this comment.
I've merged this into BI-2134 and renamed to ExperimentFileImportTest#getExperimentWorkflowId with an integer argument for selecting the workflow id from the list fetched by getWorkflows().
| // Start processing the import... | ||
| ImportPreviewResponse response = runWorkflow(importContext); | ||
|
|
||
| result = Optional.of(ImportWorkflowResult.builder() | ||
| .workflow(workflow) | ||
| .importPreviewResponse(Optional.of(response)) | ||
| .build()); |
There was a problem hiding this comment.
When merging with BI-2134, just wrap the runWorkflow() call in a try-catch as below, and any exceptions will be passed and handled by the higher levels as usual. No other changes are needed.
| // Start processing the import... | |
| ImportPreviewResponse response = runWorkflow(importContext); | |
| result = Optional.of(ImportWorkflowResult.builder() | |
| .workflow(workflow) | |
| .importPreviewResponse(Optional.of(response)) | |
| .build()); | |
| // Start processing the import... | |
| try { | |
| ImportPreviewResponse successResponse; | |
| successResponse = runWorkflow(importContext); | |
| result.ifPresent(importWorkflowResult -> importWorkflowResult.setImportPreviewResponse(Optional.of(successResponse))); | |
| } catch (Exception e) { | |
| result.ifPresent(importWorkflowResult -> importWorkflowResult.setCaughtException(Optional.of(e))); | |
| } | |
| return result; |
There was a problem hiding this comment.
Thanks, just about have it done. Need to remove Exception stuff on method signatures.
Description
Story: BI-2132
Workflow selection code (BI-2122) will be shown as changes in here until it is merged into develop
Updated experiment import integration tests
Checked for ExperimentProcessor work done after refactor branched off develop
Workflow organization
Dependencies
Testing
Regression testing ideas:
Checklist: