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

[REVERTED] issue 157 - warn users when any language is missing a tranlsation and blanking fields #287

Merged
merged 3 commits into from
Jul 19, 2019

Conversation

KeynesYouDigIt
Copy link
Contributor

@KeynesYouDigIt KeynesYouDigIt commented Apr 15, 2019

I was having trouble detecting media columns and the like early, and I realized the media column wasn't really the problem here, it was the unlabelled column.

So I dug for where the - was being literally added to the XML as an answer value and added the warning there.


def test_no_default_language_should_warn_with_unlabeled_media_tags(self):
# form should test media tag w NO default language set.
survey = self.md_to_pyxform_survey("""
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome that you are starting with a test! 👍

I believe that this form is fine and should not result in a warning (a good test to have!) because none of the columns for user-facing strings specify a language. The issue is when only a subset of the columns do. That is, if you had label::French (fr) and media::image, there'd be a problem because the former specifies a language and the later doesn't. Similarly, label::French (fr) and media::image::French (fr) is fine but label and media::image::French (fr) is a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep thats exactly the problem I hit when I ran that test. Fixed now should be good to go! :shipit:

@codecov-io
Copy link

codecov-io commented Apr 16, 2019

Codecov Report

Merging #287 into master will increase coverage by 0.48%.
The diff coverage is 89.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #287      +/-   ##
==========================================
+ Coverage   81.74%   82.22%   +0.48%     
==========================================
  Files          23       23              
  Lines        3215     3230      +15     
  Branches      750      753       +3     
==========================================
+ Hits         2628     2656      +28     
+ Misses        447      438       -9     
+ Partials      140      136       -4
Impacted Files Coverage Δ
pyxform/survey.py 90.29% <89.28%> (+0.87%) ⬆️
pyxform/xls2json.py 77.76% <0%> (+0.32%) ⬆️
pyxform/xform2json.py 80.5% <0%> (+0.41%) ⬆️
pyxform/builder.py 75.4% <0%> (+0.53%) ⬆️
pyxform/survey_element.py 90.14% <0%> (+0.98%) ⬆️
pyxform/validators/util.py 77.89% <0%> (+2.1%) ⬆️
pyxform/validators/odk_validate/__init__.py 74.5% <0%> (+3.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d36f97...4f2e7bd. Read the comment docs.

@KeynesYouDigIt KeynesYouDigIt marked this pull request as ready for review April 16, 2019 01:13
@KeynesYouDigIt
Copy link
Contributor Author

KeynesYouDigIt commented Apr 16, 2019

This one should be good to go! resolves #157

@KeynesYouDigIt
Copy link
Contributor Author

@lognaturel should be good to go?

@KeynesYouDigIt KeynesYouDigIt changed the title Vince issue 157 issue 157 - warn users when "default" is the default language and its blanking fields Apr 27, 2019
| | opts | opt2 | Opt2 | 1 | |
| settings| | | | | |
| | form_title | form_id | public_key | default_lanuage | |
| | opts_form | abc1 | | English (en) | |
Copy link
Contributor

Choose a reason for hiding this comment

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

This change doesn't make sense -- there is no column that uses the English (en) name. Also, this test was for another feature so please leave it as-is and add add additional tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

eek good point, not sure where my head was at

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I was using this to figure something else out, sorry!

os.unlink(tmp.name)

def test_no_default_language_should_warn_with_unlabeled_media_tags(self):
# form should test media tag w NO default language set.
Copy link
Contributor

Choose a reason for hiding this comment

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

This test should very narrowly identify the issue. For example, a label with English (en) set as the language and media::image with no language and no other columns. It would be good to also have a test with something like label::English (en) and media::image::French (fr). There should be a warning any time that a language doesn't have complete translations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I follow, tests added lmk if they do the trick!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also going to try and cover untranslated choices and other stuff, not jsut media tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So with the current functionality, each language known to miss at least one field will get at least one warning. This prevents warnings from being overly verbose when there are multiple translations missing.... but is that what we want? or should I extend warnings to add a warning for each question/field missing a translation? Slack me if that question is confusing and I will try to jump on.

@lognaturel
Copy link
Contributor

I haven't had a chance to look at this in detail yet but I made a couple of comments on the tests. In particular, the coverage is not complete.

Changing several core methods to take in a warnings parameter doesn't look like it should be necessary but I haven't yet dug in very deep. I think it should be possible to address just with local state.

@KeynesYouDigIt KeynesYouDigIt changed the title issue 157 - warn users when "default" is the default language and its blanking fields issue 157 - warn users when any language is missing a tranlsation and blanking fields May 4, 2019
@KeynesYouDigIt
Copy link
Contributor Author

I really think I wasn't updating the tests with my improved understanding of the problem as time went on here, gotta slowdown and do that. @lognaturel check out the new tests and let me know if they are closer to what you were thinking

@KeynesYouDigIt
Copy link
Contributor Author

KeynesYouDigIt commented May 5, 2019

After some thought I redisigned and added more tests. I'm curious about a particular case though --

"""
| survey  |                     |              |                                   |                            |
|              | type             | name    | label::English (en)      | hint                      |
|              | integer         | nums    | How many nums?      | nums is numbers |
"""

Doesnt seem to generate a warning since theres no attempt to translate anything into default when running this. Why does a media tag generate this mysterious default translation but a hint doesn't?

@KeynesYouDigIt
Copy link
Contributor Author

@lognaturel or @ukanga got a chance to review?

@KeynesYouDigIt
Copy link
Contributor Author

Changing several core methods to take in a warnings parameter doesn't look like it should be necessary but I haven't yet dug in very deep. I think it should be possible to address just with local state.

I could add a sort of self.warnings attribute if this seems much more readable to everybody

@KeynesYouDigIt
Copy link
Contributor Author

bump @lognaturel / @ukanga

@KeynesYouDigIt KeynesYouDigIt force-pushed the Vince_issue_157 branch 2 times, most recently from 6fbfdfe to ae3620c Compare June 1, 2019 22:50
@KeynesYouDigIt
Copy link
Contributor Author

bit of rebasing craziness today but should be shippable now!

@KeynesYouDigIt
Copy link
Contributor Author

Anybody around to take another look at this? @ukanga / @lognaturel ?

ukanga
ukanga previously approved these changes Jun 14, 2019
@ukanga
Copy link
Contributor

ukanga commented Jun 14, 2019

Would it be ideal to be able to point out which columns a user should check to apply the recommended changes? It is hard to be able to tell which columns a user should, especially in situations where there may be a high number of columns. The warnings:

Warnings:
        Missing field translations found for French (fr) field may not appear as expected
        Missing field translations found for English (en) field may not appear as expected
        Missing field translations found for English field may not appear as expected
        Missing field translations found for French field may not appear as expected
        The following language declarations do not contain valid machine-readable codes: English, French. Learn more: http://xlsform.org#multiple-language-support

This warnings are generated with the column headers as below:

type name label::English (en) label::French (fr) hint::English hint::French

There is less searching in my opinion if the message included the columns that are likely affected such as:

Warnings:
        Missing field translations found for French (fr) field may not appear as expected (hint)
        Missing field translations found for English (en) field may not appear as expected (hint)
        Missing field translations found for English field may not appear as expected (label)
        Missing field translations found for French field may not appear as expected (label)
        The following language declarations do not contain valid machine-readable codes: English, French. Learn more: http://xlsform.org#multiple-language-support

@ukanga
Copy link
Contributor

ukanga commented Jun 14, 2019

@KeynesYouDigIt I apologise for the delay. See my comment above.

@KeynesYouDigIt
Copy link
Contributor Author

@ukanga not sure why its failing but 7a666d6 should take care of it!!

@KeynesYouDigIt
Copy link
Contributor Author

@ukanga / @lognaturel code should be good, I am afraid I dont understand the circle errors at all. Is something wrong with the form validator CI is using?

Copy link
Contributor

@yanokwa yanokwa left a comment

Choose a reason for hiding this comment

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

There are three tests failing and it's not a CI issue. To narrow it down, run the following.

  • nosetests pyxform.tests.xlsform_spec_test
  • nosetests pyxform.tests.xform2json_test

self._translations[lang][path][content_type] = u"-"
# missing question thingy thats like media
if not this_path_has_warning:
# the path has a translation but the content type is missing one.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont love this path_has_warning pattern at all. is there a list of content_types we support? couldnt find it in the spec for some reason, but id be happy to jsut make sure the content_type actually needs translation. That said if y'all are OK with this pattern then it should be fine to merge.

@KeynesYouDigIt
Copy link
Contributor Author

KeynesYouDigIt commented Jul 14, 2019

Yep! squashing and rebasing now, then ill flip warnings to be a class fields. The simplest way to squash was to go to one commit, will that be OK or is it important to you to enforce strictness on commits being a single related change?

@lognaturel
Copy link
Contributor

Awesome, @KeynesYouDigIt!

ill flip warnings to be a class fields

If you haven't done this already, I'd say hold off. I think the scope can be tightened rather than broadened. But as @ukanga says, that could be a later refactor pass through.

@ukanga
Copy link
Contributor

ukanga commented Jul 14, 2019

I will be okay with one commit if it does not include the .circleci changes, you got about 2 commits in this PR.

@ukanga
Copy link
Contributor

ukanga commented Jul 14, 2019

I created an issue for the refactor at #330.

@ukanga
Copy link
Contributor

ukanga commented Jul 14, 2019

The OpenJDK-8-JRE-headless install issues have to do with the package being discontinued. We have resolved this failure in the current master branch, please rebase and drop the commits affecting .circleci/config.yml.

@KeynesYouDigIt KeynesYouDigIt force-pushed the Vince_issue_157 branch 2 times, most recently from 03fd64c to 3dd0213 Compare July 14, 2019 19:14
@KeynesYouDigIt KeynesYouDigIt force-pushed the Vince_issue_157 branch 2 times, most recently from 75cf659 to e1f08b3 Compare July 14, 2019 21:49
@ukanga ukanga merged commit d4ad1af into XLSForm:master Jul 19, 2019
@KeynesYouDigIt KeynesYouDigIt changed the title issue 157 - warn users when any language is missing a tranlsation and blanking fields [REVERTED] issue 157 - warn users when any language is missing a tranlsation and blanking fields Oct 25, 2020
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.

5 participants