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

added back end / front end checks and tests for token field length (closes #168) #208

Merged
merged 4 commits into from
Oct 22, 2020

Conversation

carinedengler
Copy link
Contributor

Hi,

I'm opening the pull request as a WIP for the back end part first, I wanted to confirm that this is what you had in mind, and if so, for which fields the validation should be done. Also, I was wondering if the same validation shouldn't be done for any other field having a length restriction in the database schema which is set using user input, such as the corpus name.



class PyrrhaError(Exception):
"""Raised when errors specific to this application occur."""
pass


class ValidationError(Exception):
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to derive it from PyrrhaError ?

@@ -870,6 +871,9 @@ def add_batch(corpus_id, word_tokens_dict, context_left=None, context_right=None
corpus=corpus_id,
order_id=i+1 # Asked by JB Camps...
)
list(
validate_length(k, v, lengths={"form": 64}) for k, v in wt.items()
Copy link
Member

Choose a reason for hiding this comment

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

I like the current system you built. The only thing I'd like more is to show the line number potentially ? But that would mean getting the error and showing a modified message

@PonteIneptique
Copy link
Member

Looks good to me :) As for other fields, I see you have set up what's needed. I think there is less chances of a size constraint on other fields, and I wonder how the iteration over every key is gonna hurt performances. I'd probably feed the dictionary instead of key, value and iterate over the lengths Dict to avoid iterating on every object properties.

@carinedengler carinedengler changed the title WIP:added backend check / tests added back end / front end checks and tests for token field length Sep 25, 2020
@carinedengler carinedengler changed the title added back end / front end checks and tests for token field length added back end / front end checks and tests for token field length (closes #168) Sep 25, 2020
@carinedengler
Copy link
Contributor Author

hi, I updated the pull request with the front end checks and integrated your suggestions into the back end checks

@PonteIneptique
Copy link
Member

LGTM

@MrGecko
Copy link
Contributor

MrGecko commented Oct 1, 2020

Looks good to me though I didn't see the error message because the top of the page where it is inserted is off screen.
I then clicked multiple times to understand and (logically) the same message kept piling up.

@carinedengler
Copy link
Contributor Author

I was wondering just that about the error message - I put it where all of the other error messages are to be consistent with the rest of the interface, but made the focus on the line causing the error, I was wondering if an pop-up window would be more appropriate?

@PonteIneptique
Copy link
Member

Maybe a scroll to the message error would be simpler / cleaner ?

@carinedengler
Copy link
Contributor Author

after some quick tests, it seems that setSelectionRange only works when the focus is on the textArea, which is lost when the window is scrolled up

intuitively, I think it's more user-friendly when the problematic line is highlighted for the user, but I can also understand if you prefer a consistent user interface
(either way I will look into erasing the error message so that it will not pile up)

@PonteIneptique
Copy link
Member

I think scrolling to the problematic line is way better. If you find a solution for this, I'd be okay with it.

@MrGecko
Copy link
Contributor

MrGecko commented Oct 1, 2020

Scrolling to the problematic line is ok (how does it behave with multiple errors?) yet the user need to understand that what is shown is an issue. I would suggest to put the error message much closer to the input form section.

@carinedengler
Copy link
Contributor Author

Scrolling to the problematic line is ok (how does it behave with multiple errors?)

it highlights the last line containing an error and shows error messages for each faulty line (order needs to be fixed), I'm not sure if that's the best behavior though, I can think of two possible solutions

  • (my deleted comment referred to this) only highlight one erroneous line at a time when submitting the form to mirror back end behavior
  • highlight the first erroneous line, show error messages for each faulty line

@PonteIneptique
Copy link
Member

PonteIneptique commented Oct 5, 2020

I like the second option :)

I actually wonder, if the error message for each faulty line could have a link to the faulty line ?

@carinedengler
Copy link
Contributor Author

carinedengler commented Oct 5, 2020

I implemented the second solution, and also rebased onto the current dev branch

@MrGecko
Copy link
Contributor

MrGecko commented Oct 5, 2020

Given the proposed implementation it would be very easy to add the faulty line number.

Thank your for the improvements, I'll merge this PR as soon as we get this (extra useful) info in the error message.

@carinedengler
Copy link
Contributor Author

I added the line number

@PonteIneptique
Copy link
Member

I think there might be a bug in the tests: https://travis-ci.org/github/hipster-philology/pyrrha/builds/732968766#L2778

@carinedengler
Copy link
Contributor Author

I updated the error message in the test

@MrGecko MrGecko merged commit 29e3085 into hipster-philology:dev Oct 22, 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.

(Corpus Creation) Check that tokens are not larger than what can be stored in the DB
3 participants