-
Notifications
You must be signed in to change notification settings - Fork 12
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
Problems sending senses to api_update_gloss #1360
Comments
It hasn't been changed. It's still the same. (There are some other issues about the database getting locked.) You want the empty value to erase the value? |
Ok, using "-" works! Thank you very much. About gloss HUREN-C; TransactionManagementError at /dictionary/api_update_gloss/5/49249/ This is what i have sent: {"Handedness": "N/A", "Strong Hand": "-", "Weak Hand": "B", "Handshape Change": "-", "Relation Between Articulators": "-", "Location": "-", "Contact Type": "-", "Movement Shape": "-", "Movement Direction": "-", "Repeated Movement": "", "Alternating Movement": "", "Relative Orientation: Movement": "-", "Relative Orientation: Location": "-", "Orientation Change": "-", "Virtual Object": "-", "Phonology Other": "-", "Mouth Gesture": "-", "Mouthing": "-", "Phonetic Variation": "-", "Senses": "{"en": [["hire"], ["rent, lease"]], "nl": [["huren"], ["huren"]]}"} |
Repeated Movement and Alternating Movement are supposed to be Booleans. from the code:
The atomic block error would be caused by other errors. It can't do a save because probably some other things are saved. (I'll have to try to simulate your error with extra print statements to see where it is blocking.) |
Phonology Other fields dont seem to be updated too. Modifing the values to the ones you mentioned didnt help, it is causing only by this gloss but it could happen at other glosses too. |
Does your error message mention a specific line of code? It's true that if it finds an error in the input fields, it will not do the update. (It's implemented as all or nothing, otherwise the transaction would be inconsistent.) Do you want Handedness to be N/A ? There is the Weak Hand set, so is that Handedness 1 or is it something else? |
These fields: "Virtual Object": "-", "Phonology Other": "-", "Mouth Gesture": "-", "Mouthing": "-", "Phonetic Variation": "-", are strings, so you can just put empty strings (the ones that are choices need to be "-") If you don't want to set any value, you can exclude them from the json dictionary. |
I looked up the gloss on Signbank. |
I can't find any errors related to the HUREN gloss. So the code thinks it's working correctly.
(That's all it reports, nothing about what specifically. I'll add that exception to the code in order to catch it explicitly.) In the logs, there is an error for ANTONI GAUDI
The only place in the code where it explicitly uses "ascii" is in the For the zip files, you don't need to put the gloss annotation in the zipped filename. It can be something else, like videos_archive.zip |
There is definitely something wrong with HUREN-C, as i am trying to send this: {"Handedness": "1", "Strong Hand": "-", "Weak Hand": "-", "Handshape Change": "-", "Relation Between Articulators": "-", "Location": "-", "Contact Type": "-", "Movement Shape": "-", "Movement Direction": "-", "Repeated Movement": "False", "Alternating Movement": "False", "Relative Orientation: Movement": "-", "Relative Orientation: Location": "-", "Orientation Change": "-", "Virtual Object": "-", "Phonology Other": "-", "Mouth Gesture": "-", "Mouthing": "-", "Phonetic Variation": "-", "Senses": "{"en": [["hire"], ["rent, lease"]], "nl": [["huren"], ["huren"]]}"} Interestingly, the update goes through when i send like this: {"Handedness": "1", "Strong Hand": "-", "Weak Hand": "-", "Handshape Change": "-", "Relation Between Articulators": "-", "Location": "-", "Contact Type": "-", "Movement Shape": "-", "Movement Direction": "-", "Repeated Movement": "False", "Alternating Movement": "False", "Relative Orientation: Movement": "-", "Relative Orientation: Location": "-", "Orientation Change": "-", "Virtual Object": "-", "Phonology Other": "-", "Mouth Gesture": "-", "Mouthing": "-", "Phonetic Variation": "-"} So that's JSON payload without Senses. Something is going wrong with Senses field? |
Okay, that helps us to know! |
@rem0g I found the problem. This has to do with the use of two different formats for representing the senses internally. The json package considers them language-related fields and they are described as "Senses: Dutch" I wrote a new function to test whether the senses field in the update differs from that in the database. You need to omit the quotes around the Senses right-hand side. It's already in json. (It's not a string.)
This has been deployed. |
#1360: Fixed check on whether senses are being updated by API.
It works again! Thank you |
@rem0g One more thing relevant to this issue: We clearly did not document this well ;) |
Senses update doesnt work anymore again: Payload:
AttributeError at /dictionary/api_update_gloss/5/47662/'dict' object has no attribute 'strip' |
The format is wrong that you show above. @rem0g can you please stop putting "empty" "not changed" things in the "update" request? The gloss you show has hundreds of entries in the revision history. https://signbank.cls.ru.nl/dictionary/gloss/47662/history That causes extreme payload and causes the database to get locked. Hundreds of comparisons are being made to check if things are changed and hundreds of objects are being created for all the revision histories. It is likely that something else is causing the problem or the operation is failing because the database is getting locked. Think "thrashing" (too many operations are competing for resources) Every API request is a transaction. So the more "empty" things you put that need to be processed the more computations need to be done inside that transaction. |
Can you please explain why is the format wrong? It's the format i got from the API documentation: With omitted strings as you mentioned before. About the empty requests, yes I will be soon working on that soon. :) |
I looks like you have return characters in it? The processing needs to parse it, so it should be without pretty printing. (It's a Python library that parses it.) Normally, "strip" is done to make sure there are no spaces in the input. Can you post your actual input value for the field? I will find out if there is a parsing error. |
The fix isn't live yet!!! |
This is incorrect:
There should not be quotes around this:
The length of the lists for each language are compared. It's a list. |
I just deployed and restarted signbank now. |
Please ignore what is in the Swagger description. It is misleading.
There used to be examples in a separate page in the Wiki. That page was deleted by @Woseseltops.
We can't get it back.
|
Still not working, sorry. Please send me your code of how you update your Senses including the API connection to |
There's some example code in the html temptates (used for debugging) signbank/dictionary/templates/dictionary/ signbank/dictionary/templates/dictionary/virtual_machine_gloss_update_api.html The ones that say "token" in the filename you can open locally in the browser using "file://" The one that doesn't say token (first one), you can open in Signbank using dictionary/test_am_update_gloss/5/49249/ (using the dataset ID and the gloss ID in the url. There is a template set up in views.py that just allows that to be processed. The first one: you can set the interface language and the field names change language. There are some other templates for video files, But those have become obsolete when we started to use Swagger. |
@rem0g I should note that to actually UPDATE the senses, there is still a bug. A new issue has been made for that #1461 (I'm working on that now, but I need help from @vanlummelhuizen for the signal that has a bug. When a sense is deleted, a signal is called that renumbers the remaining senses. But we don't want to do this, because the API is going to replace all the senses and create them again. The signal is where the bug is.) The bug you found has to do with the "input" part of the request. |
Using https://github.com/Signbank/Global-signbank/blob/master/signbank/dictionary/templates/dictionary/virtual_machine_gloss_update_api_token_en.html is giving me same HTTP 500 error with this input in the field senses: {"en": [["hire"], ["rent, lease"]], "nl": [["huren"], ["huren"]]} |
Does it give any other information in the browser? You are using it as file://...... |
There is a consistency constraint violation in this part: "nl": [["huren"], ["huren"]]} because they are identical. I don't know whether that is correct or if that's a bug in the code. I thought it was allowed to use the same keywords if the matching translation if the other language is different. |
I have modified the console output as it produces HTTP 500 error in html code:
When using
Can you please post your script when you have managed to update your Senses via Python using requests.post Python module? I am curious to how you have managed to update it. |
This is mine:
|
You are using solely Python and Javascript on your side?
I am relying on what is stored in the database, so making use of objects on the processing side.
It worked when the input senses was the same as what was already in the database. (So it did not need to actually update anything.) However, Unfortunately @Jetske isn't here anymore. She wrote the update senses code. I need to rewrite it entirely since it isn't working at all now. (I'm working on it locally to get it to stop causing constraint violations.) Unfortunately, neither @Woseseltops nor @vanlummelhuizen worked on the senses code. |
No I am using two different approaches to update Senses via Python (my script) or Javascript per script you provided. I would like to ask you to reproduce the problem for me and try to debug the function |
Explicitly erase translations. Create objects in dictionary before filling
I've got it working now!! I just rewrote the code that updates the senses. The code is kind of sloppy at the moment. I'll put in on the branch, then you can see it there. #1463 The code is on Normally, we need to review the code. Since it's very sloppy looking, I think @Woseseltops ought to review it. You can try it out there to make sure it works. I only used it locally with oodles of print statements. The updates also show up in the gloss and the revision history. |
Did anyone carefully read what @Jetske wrote (which she didn't have to since she is not working for the RU anymore (I hope you had a nice vacation 🌞 ))? See #1360 (comment) She says that, although not the best implementation, the dict with the senses should be send as a string: {"Senses": "<a dict serialized as string>"} That dict-string is than later interpreted here: Global-signbank/signbank/gloss_update.py Lines 147 to 170 in 372ef1b
The API docs are confusing. So, the code should probably be improved upon. But this could have been solved by reading things carefully, both code and relevant Github comments. |
It does not work when it's a string. The code is indeed called, but not on the actual "json" string.
@Woseseltops deleted the original API docs where all the examples were. Now there is only Swagger. (There are bugs in the Swagger.)
At the time the comments were written, there was no Swagger. All the video API calls were modified after that so that Swagger would work. |
There is a bug, yes. But it is not because it is a string. It is this: diff --git a/signbank/gloss_update.py b/signbank/gloss_update.py
index fc082ff7..1db25a31 100755
--- a/signbank/gloss_update.py
+++ b/signbank/gloss_update.py
@@ -478,7 +478,7 @@ def gloss_update_do_changes(user, gloss, changes, language_code):
original_senses = collect_revision_history_for_senses(gloss)
update_senses(gloss, new_value)
new_senses = collect_revision_history_for_senses(gloss)
- changes_done.append((field.name, original_senses, new_senses))
+ changes_done.append((field, original_senses, new_senses))
elif field.name == 'semField':
update_semantic_field(gloss, new_value, language_code)
changes_done.append((field.name, original_value, new_value)) My API test: > curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <my-secret-key>" \
-d "{\"Senses\": \"{'en': [['hire'], ['rent, lease']], 'nl': [['huren'], ['huren']]}\"}" \
localhost:8001/dictionary/api_update_gloss/5/47662/
{"glossid": "47662", "errors": {}, "updatestatus": "Success"} Note that |
Yes, I already fixed that in the pull request. This did not used to happen because nobody was updating the senses. They have been using Batch Edit on Signbank. |
@vanlummelhuizen this is the bug that reopened this issue. It's about a string. There was already a pull request and merge for the "parsing" part of the input. But then another bug happened. If the senses field had changed from the stored senses, then the "update" caused constraint violations due to the transactions being duplicated. That was caused by the "reorder_senses" method that was being called in a signal. |
Okay, we have a quick solution (provided by @vanlummelhuizen ) and a larger solution (proposed by @susanodd) in PR #1463 . The quick solution is already live in production. I have tested both using the Manual test results:
Seems like we need to review PR #1463 as quickly as possible; to be continued there. |
URGENT disable updating senses in the API, before the API accidentally deletes senses |
I am noticing a lot of errors regarding this gloss:
While submitting request to update phonology I am getting error Database locked at HUREN-C.
WHen submitting empty phonology feature such as:
"Handshape Change": ""
The handshape change is still not modified to empty value.
The text was updated successfully, but these errors were encountered: