hgboldt / Tangled-Web

Tools to publish Gramps data on WordPress
GNU General Public License v2.0
1 stars 0 forks source link

Crash when exporting #3

Open SNoiraud opened 2 years ago

SNoiraud commented 2 years ago

I get the following: 2021-12-28 18:45:52.763: ERROR: _reportdialog.py: line 748: Failed to run report. Traceback (most recent call last): File "/home/gramps/gramps51/gramps/gui/plug/report/_reportdialog.py", line 706, in report my_report = report_class(dialog.db, dialog.options, user) File "/home/serge/.gramps/gramps51/plugins/TangledWeb/TangledWeb.py", line 235, in init indi_count = self.process_individuals(opts) File "/home/serge/.gramps/gramps51/plugins/TangledWeb/TangledWeb.py", line 357, in process_individuals info = person.get_info() File "/home/serge/.gramps/gramps51/plugins/TangledWeb/TWHelper.py", line 295, in get_info info['events'] = self._handle_event_info() File "/home/serge/.gramps/gramps51/plugins/TangledWeb/TWHelper.py", line 508, in _handle_event_info event_info = self._handle_one_event(ev['event'], ev['role']) File "/home/serge/.gramps/gramps51/plugins/TangledWeb/TWHelper.py", line 624, in _handle_one_event (participants, EventRoleType.PRIMARY)[0][1] IndexError: list index out of range

The current person died at the age of two months.

hgboldt commented 2 years ago

Looking at the code, I think this can happen if you have an event without a primary individual. To investigate further, I'll need to work with your data. Please send me the Gramps XML (without media).

SNoiraud commented 2 years ago

Difficult to reproduce. Here is a sample which reproduce the problem: tangled-web.2.gramps.txt

hgboldt commented 2 years ago

What options do you specify? I can't reproduce on my computer, and I can't find any issues with the data that might cause the code to abend in the described manner.

If you'd like, try out the code in the "dev" branch, which contains the current version of the code under development.

(Anyways, thank you for the Gramps XML. Using it, I've fixed a couple of problems in the PHP code.)

SNoiraud commented 2 years ago

I'll try the dev branch. For the options, I selected all the options in the Include tab In the first tab, I chose all the database and all data for people alive

my OS : ubuntu 18.04 last update

SNoiraud commented 2 years ago

Same problem with dev.

print("handle :", self._filter_participants \ (participants, EventRoleType.PRIMARY))

return [ ] when the problem occurs.

I solve the problem with:

            part = self._filter_participants(participants, \
                  EventRoleType.PRIMARY)
            if part:
                child_handle = self._filter_participants \
                          (participants, EventRoleType.PRIMARY)[0][1]
                child = self.db.get_person_from_handle(child_handle)
                link = self._get_person_link(child)
                if link:
                    event_data['child'] = link
hgboldt commented 2 years ago

Yes, of course that is one possible fix. But first, I'd like to understand why there's no primary person for that particular event. In this case, it should be either a birth or a death event, which of course should have a primary.

If possible, can you share a Gramps XML file of your entire database?

emyoulation commented 2 years ago

It is very easy to be without a Primary (or Family) role entity for an Event.

If you drag'n'drop an Event to connect it to another place in the Tree, the Role is set to "Unknown". You have to remember to reset the Role properly. The next obvious step is to delete it from the original connection.

SNoiraud commented 2 years ago

All my events are primary. I never use drag and drop. My .gramps is 3.8MB (9100 persons, 3320 families, 14500 events, 580 places, 2300 sources, 11160 citations, 13900 notes) Did you receive my email ?

hgboldt commented 2 years ago

Brian: I understand that an event might not have a primary. The issue here is that at the point of abend, I expect to see a primary. So I suspect the real problem is somewhere else in the code. I suspect there might be an issue that depends on the order in which events are processed, but I'll need to debug with the actual data.

Serge: I received your XML. I'm taking a break from Gramps today, but I'll get back to it tomorrow.

BTW, there are a couple of fixes in the PHP code in the dev branch that should address some of the issues you mentioned in your email. Regarding the location of the data directory, I'll add that to my todo list.

On Thu, Dec 30, 2021, 11:02 AM Serge Noiraud, @.***> wrote:

All my events are primary. I never use drag and drop. My .gramps is 3.8MB (9100 persons, 3320 families, 14500 events, 580 places, 2300 sources, 11160 citations, 13900 notes) Did you receive my email ?

— Reply to this email directly, view it on GitHub https://github.com/hgboldt/Tangled-Web/issues/3#issuecomment-1003089166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIPVAGJDXCSZMJOGDLQVUQDUTR7CHANCNFSM5K4RI2TQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

hgboldt commented 2 years ago

Serge: This is going to take a bit more investigation on my part. With the full Gramps file, I'm still not seeing the abend. That suggests that there's some subtle ordering issue with the processing of events.

It would be helpful if you could make a code change and try the report again. Replace the abending line of code with this, then then tell me what's being printed out when running Gramps from the command line. In the meantime, I'll study the code further to try to figure out what might be happening here.

            try:
                child_handle = self._filter_participants \
                      (participants, EventRoleType.PRIMARY)[0][1]
            except:
                print(self.person.gramps_id)
                print(event.date)
                print(participants)

Thanks!

SNoiraud commented 2 years ago

This problem occurs 4171 times on my database. So I think this is normal to have this.

emyoulation commented 2 years ago

Perhaps the data state cannot be reproduced from the XML? Maybe it is a database state that freshly imported reconstructs differently than Serge's workflow sets?

Doesn't the export filter strip some 'irrelevant' records?

For instance, one bug report documents how closing spawned windows out of order will invisibly orphan new records. (See https://gramps-project.org/bugs/view.php?id=7924 )

Could Serge import the XML sent to Hans into a fresh tree & see if the error still reproduces 4171 times?

If the abend goes away, there are additional question raised: what data condition cannot be conveyed with XML export/import? How are those conditions created with the GUI? Are they "error" conditions that need a repair tool? (For instance, an "Unknown" Role is ALWAYS wrong for an Event where there is a reference to a Person or Family. Although it might be valid for Event that have been created but not yet applied to anywhere.)

SNoiraud commented 2 years ago

I think the problem is in the program. My database contains only valid information since 15 years on gramps. All reportps works correctly even the dynamic web or the narrative web. I don't know what the program want at this moment. I never add participants to an event. Perhaps this is why I get [ ]

Could Serge import the XML sent to Hans into a fresh tree & see if the error still reproduces 4171 times?

Yes, it does. I tried it before sending it.

hgboldt commented 2 years ago

Serge: Please try out the current "dev" branch. (On the "Destination" tab, select "Local file system". The "WordPress" destination is only partially implemented.)

Since you got the error 4171 times, it's probably not a corruption of your database. I'm going on the theory that the abend was due to some stupid coding on my part with respect to internationalization.

Let me know if the latest change fixes the abend.

hgboldt commented 2 years ago

By the way, I know I haven't properly addressed i18n yet. At the moment, I'm not fully sure how to do i18n properly since there are 3 different programming languages and environments involved. At a minimum, I think I need to be able to output web content in the same language as the Gramps system.

SNoiraud commented 2 years ago

You need to have two pot file. One for gramps and one for the web plugin. For gramps one directory named po with a pot file for english and one po for each languages (de.po, fr.po, ar.po...) For the web plugin one directory named languages and the same than for gramps (use the sprintf function in your php file)

hgboldt commented 2 years ago

Serge: Have you tried the current "dev" branch yet? If it fixes your abend, I'll close off this issue, and open a new issue to track the necessary i18n work.

I18n has some tricky bits. My plan is to try to present the web content in the same language as the Gramps installation. I think this should be satisfactory since notes, source text, etc. will most likely be in the researcher's language.

One complication is with custom events, roles, and attributes. For example, I use the custom event "Stillbirth". This cannot be easily translated. Since I make a special case of that particular event in my code, I'm going to have to add a tab in the Reports dialog to allow for "Stillbirth" in other languages.