-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate Processor - Added file_path functionality for local files #3034
Translate Processor - Added file_path functionality for local files #3034
Conversation
Signed-off-by: Vishal Boinapalli <[email protected]>
Signed-off-by: Vishal Boinapalli <[email protected]>
Signed-off-by: Vishal Boinapalli <[email protected]>
//todo | ||
mappingsConfig = translateProcessorConfig.getCombinedParameterConfigs(); | ||
Optional.ofNullable(mappingsConfig) | ||
.ifPresent(configs -> configs.forEach(MappingsParameterConfig::parseMappings)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to stop the pipeline if only file_path option is present and the file is invalid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. If the mappings provided in the file_path
option are not configured properly, pipeline will fail during the config check. This behavior is irrespective of only file_path
option provided or both file_path
and mappings
options provided.
@JsonProperty("mappings") | ||
@Valid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these annotations doing anything? This isn't a part of the user configuration right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeahh.
@JsonProperty : The file provided will consist of option mappings
, under which translations will be provided. Since I am using a different variable name fileMappingConfigs
in the FilePathPraser.Class
, @JsonProperty
is required to indicate that mappings
filed should be mapped to fileMappingConfigs
@Valid : The type of fileMappingConfigs
is List<MappingParameterConfig>
. MappingParameterConfig.Class
consists of validation checks for the options provided under mappings like source
, targets
. To validate those checks we need to provide the @Valid
annotation.
return (Objects.nonNull(mappingsParameterConfigs) && !mappingsParameterConfigs.isEmpty()) || Objects.nonNull(filePath); | ||
} | ||
|
||
@AssertTrue(message = "\"mappings\" option should not be empty.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the @NotEmpty
annotation not working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works. But in this particular case, the pipeline should succeed even if only file_path
option is provided. @NotEmpty
annotation checks if the field is either empty or null. So if the mappings
option is not provided it fails, even if file_path
option is provided. This check I provided is required because if the user configures mappings:
option but there are no sub-options configured, the pipeline should fail. Like in the scenario below:
processor:
- translate:
file_path: "/path/to/file.yaml"
mappings:
Optional<List<MappingsParameterConfig>> optionalCombinedConfigs = fileParser.getCombinedMappings(mappingsParameterConfigs); | ||
optionalCombinedConfigs.ifPresent(combinedConfigs -> combinedParameterConfigs = combinedConfigs); | ||
return Optional.ofNullable(combinedParameterConfigs).map(configs -> true).orElse(false); | ||
} catch (IOException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we log this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will address this in the next PR.
Signed-off-by: Vishal Boinapalli <[email protected]>
@@ -71,6 +73,8 @@ private boolean readFileMappings(String filePath) { | |||
optionalCombinedConfigs.ifPresent(combinedConfigs -> combinedParameterConfigs = combinedConfigs); | |||
return Optional.ofNullable(combinedParameterConfigs).map(configs -> true).orElse(false); | |||
} catch (IOException ex) { | |||
Logger LOG = LoggerFactory.getLogger(TranslateProcessor.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should declare these at the top private static final Logger LOG = ...
Description
Added implementation for
file_path
option for local files. Fixed some bugs. Changedtarget_type
totype
. Test cases for added features.Issues Resolved
#1914
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.