Skip to content

Conversation

kfindeisen
Copy link
Member

This PR adds a pipeline configuration variable (PIPELINES_CONFIG) to the service setup, which maps surveys to pipelines. This allows the target pipeline(s) to be controlled from prompt-proto-service.yaml instead of being hardcoded into MiddlewareInterface.py.

This class will encapsulate pipeline selection configuration and
transfer the information between the activator and MiddlewareInterface.
The current class is a stub with no functionality.
The initial implementation is a copy of
MiddlewareInterface._get_pipeline_file.
This change completes the transfer of existing pipeline-selection
functionality from MiddlewareInterface to PipelinesConfig.
"""
# Use regex instead of str.split, in case keys or values also have spaces.
node = re.compile(r'\s*\(survey="(?P<survey>[\w\s]+)"\)='
r'(?P<filename>[-\w./${} ]*[-\w./${}])(?:\s+|$)')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably just a matter of taste. Would r'(?P<filename>[^=,]*[^=, ])(?:\s+|$)')
be slightly easier to read and still correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had that before, actually, but then got worried that that might match some unexpected (and possibly malicious) string. I figured it's best to err on the side of being too restrictive.

I agree that ^=, would be easier to read.

The input only supports simple survey-pipeline mappings for now, but
is designed with future selection criteria in mind.
The pipeline was only used by test_middleware_interface.py, but had to
go into `pipelines/` because that location was assumed by the
application code.
The survey field is not always populated for test data.
All but the shortest config strings provided through environment
variables are likely to be multiline, so this case must be supported.
@kfindeisen kfindeisen merged commit 62ad613 into main Jun 15, 2023
@kfindeisen kfindeisen deleted the tickets/DM-37253 branch June 15, 2023 18:32
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.

2 participants