Skip to content
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

Refactor PipelinesDataFlowModelParser to take in an InputStream instead of a file path #4289

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

graytaylor0
Copy link
Member

@graytaylor0 graytaylor0 commented Mar 14, 2024

Description

This change refactors the PipelinesDataFlowModelParser to not be dependent on files, but to be dependent on InputStreams.

This is done with

  • An interface PipelineConfigurationReader that is passed to the PipelinesDataFlowModelParser.
  • An implementation PipelineConfigurationFileReader that is created via dependency injection, and contains the former chunk s of PipelinesDataFlowModelParser that was relevant to reading the files

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

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.

Copy link
Collaborator

@chenqi0805 chenqi0805 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change looks good to me. Question -- What is the motivation for this change?

@graytaylor0
Copy link
Member Author

change looks good to me. Question -- What is the motivation for this change?

The motivation is to make this library extendible to support non-files, such as raw strings of the pipeline config

Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very nice improvement to this code. Thanks!

I do have one comment about exceptions that we should resolve.


if (configurationLocation.isFile()) {
return Stream.of(configurationLocation).map(this::getInputStreamForFile)
.filter(Objects::nonNull).collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I think we should throw an exception since we are looking for a single file.

try {
return new FileInputStream(pipelineConfigurationFile);
} catch (IOException e) {
LOG.warn("Pipeline configuration file {} not found", pipelineConfigurationFile.getName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should include the exception message here and remove the "not found" part. This could happen if you don't have read permissions on the file.

Signed-off-by: Taylor Gray <[email protected]>
@graytaylor0 graytaylor0 merged commit 8faf7d1 into opensearch-project:main Mar 20, 2024
40 of 47 checks passed
@graytaylor0 graytaylor0 deleted the RefactorParser2 branch March 20, 2024 21:35
@kkondaka kkondaka added this to the v2.8 milestone May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants