Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Error uploading calculate item with default but no calculation #416

Closed
pbowen-oc opened this issue Dec 23, 2020 · 6 comments
Closed

Error uploading calculate item with default but no calculation #416

pbowen-oc opened this issue Dec 23, 2020 · 6 comments
Assignees
Milestone

Comments

@pbowen-oc
Copy link

pbowen-oc commented Dec 23, 2020

This form - demo-vitals-grid-v32-calculate test.zip - fails with a lengthy error from Pyxform when uploaded:

Traceback (most recent call last): File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/xls2xform.py", line 195, in main_cli() File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/xls2xform.py", line 177, in main_cli enketo=args.enketo_validate, File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/xls2xform.py", line 49, in xls2xform_convert enketo=enketo, File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 1055, in print_xform_to_file raise error File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 1051, in print_xform_to_file file_obj.write(self._to_ugly_xml()) File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 838, in _to_ugly_xml return '' + self.xml().toxml() File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 243, in xml node("h:head", node("h:title", self.title), self.xml_model()), File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 546, in xml_model model_children += self.xml_bindings() File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey_element.py", line 479, in xml_bindings dynamic_default = e.get_setvalue_node_for_dynamic_default() File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey_element.py", line 369, in get_setvalue_node_for_dynamic_default default_with_xpath_paths = self.get_root().insert_xpaths(self.default, self) File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 996, in insert_xpaths return re.sub(BRACKETED_TAG_REGEX, _var_repl_function, unicode(text)) File "/usr/lib64/python3.6/re.py", line 191, in sub return _compile(pattern, flags).sub(repl, string, count) File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 993, in _var_repl_function matchobj, context, use_current, reference_parent File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 976, in _var_repl_function if _is_return_relative_path(): File "/opt/transformer/XLSForm-repo/src/pyxform/pyxform/survey.py", line 960, in _is_return_relative_path and "indexed-repeat" in context["bind"]["calculate"] KeyError: 'calculate'

If I add a dummy calculation to the calculate item ${cohort} (such as once(.)), this error does not occur. Note that other scenarios with a default defined with no calculation do not cause this issue. The dummy calculation can be removed from calculate item ${rndm} without causing this error.

Given the message at the end, is this related to #398 / XLSForm/pyxform#484 ?

@pbowen-oc pbowen-oc added this to the Next milestone Dec 23, 2020
@pbowen-oc
Copy link
Author

Less important, but still one I'd like to get changed: if the calculate item's default is static (for example, 5) and it does not have a calculation, a "Missing calculation." error occurs. This still requires a dummy calculation to get around, but at least it identifies the error and row number it came from.

@MartijnR
Copy link
Member

Hey Paul, The zip file seems to be empty.

@pbowen-oc
Copy link
Author

@MartijnR - Sorry about that, I uploaded a new copy of the file that should work.

@MartijnR
Copy link
Member

MartijnR commented Dec 28, 2020

  • check output in latest pyxform for this calculation (there is something particular about this calculation)
  • file pyxform issue for above

These use cases (and all uses for type=calculate) really call for type=hidden. I wonder if this should be promoted more (and perhaps also in pyxform warning output)

  • check support for these uses with type=hidden - 👍 https://docs.google.com/spreadsheets/d/1FCjHRUJDarJblbqpxzEEOVv65Kqe1geP_UoVayBZyVM/edit#gid=0
  • consider deprecating type=calculate (in documentation only initially - note type=calculate does not exist in XForms, it's an xlsform invention).
  • file a discussion issue about type=calculate and type=hidden and the confusion between what is a calculation and what isn't.
  • file issue about static value for type=calculate without a calculation

@MartijnR
Copy link
Member

MartijnR commented Dec 28, 2020

bug: XLSForm/pyxform#507

discussion about type=calculate confusions: XLSForm/pyxform#508

@pbowen-oc
Copy link
Author

Looks good in testing.

MartijnR added a commit that referenced this issue May 18, 2022
…than 1 form with the same title exist in the local database, closes #416
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants