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

fixed multivalued parameter values were not correctly recorded in output MMIF #215

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions clams/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def annotate(self, mmif: Union[str, dict, Mmif], **runtime_params: List[str]) ->
if key not in self.annotate_param_spec:
issued_warnings.append(UserWarning(f'An undefined parameter "{key}" (value: "{runtime_params[key]}") is passed'))
# this will do casting + refinement altogether
self.logger.debug(f"User parameters: {runtime_params}")
refined = self._refine_params(**runtime_params)
self.logger.debug(f"Refined parameters: {refined}")
pretty = refined.get('pretty', False)
with warnings.catch_warnings(record=True) as ws:
annotated = self._annotate(mmif, **refined)
Expand Down Expand Up @@ -202,11 +204,12 @@ def sign_view(self, view: View, runtime_conf: dict) -> None:
:param runtime_conf: runtime configuration of the app as k-v pairs
"""
view.metadata.app = self.metadata.identifier
params_map = {p.name: p for p in self.metadata.parameters}
if self._RAW_PARAMS_KEY in runtime_conf:
for k, v in runtime_conf.items():
if k == self._RAW_PARAMS_KEY:
for orik, oriv in v.items():
if orik in self.metadata.parameters and self.metadata.parameters[orik].multivalued:
if orik in params_map and params_map[orik].multivalued:
view.metadata.add_parameter(orik, str(oriv))
else:
view.metadata.add_parameter(orik, oriv[0])
Expand All @@ -215,7 +218,7 @@ def sign_view(self, view: View, runtime_conf: dict) -> None:
else:
# meaning the parameters directly from flask or argparser and values are in lists
for k, v in runtime_conf.items():
if k in self.metadata.parameters and self.metadata.parameters[k].multivalued:
if k in params_map and params_map[k].multivalued:
view.metadata.add_parameter(k, str(v))
else:
view.metadata.add_parameter(k, v[0])
Expand Down
1 change: 0 additions & 1 deletion clams/develop/templates/app/app.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ The app.py script does several things:

import argparse
import logging
from typing import Union

# Imports needed for Clams and MMIF.
# Non-NLP Clams applications will require AnnotationTypes
Expand Down
Loading