Skip to content

Conversation

@Enkidu93
Copy link
Collaborator

@Enkidu93 Enkidu93 commented Jun 26, 2025

Fixes #193


This change is Reviewable

@Enkidu93 Enkidu93 requested review from ddaspit and isaac091 June 26, 2025 19:51
@Enkidu93
Copy link
Collaborator Author

A couple questions:

  • I don't love passing the raw "alignment_info" string into the metadata object. I could create a constant in the PlaceMarkers... class?
  • Do you think this could present any issues in certain verse range contexts, @isaac091?

Copy link
Collaborator

@isaac091 isaac091 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 9 files reviewed, 1 unresolved discussion (waiting on @ddaspit)


machine/corpora/update_usfm_parser_handler.py line 314 at r1 (raw file):

                    # grab the text - both source and row will be incremented in due time...
                    row_texts.append(text)
                    row_metadata = metadata

No issues that I can think of

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

Yes, I think it makes sense to define alignment_info as a constant.

Reviewed 9 of 9 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Enkidu93)


machine/corpora/place_markers_usfm_update_block_handler.py line 12 at r1 (raw file):

class PlaceMarkersAlignmentInfo(TypedDict):

I think this is only used in unit tests. We could cast alignment_info to this class when we use it. See my comment below. If we don't use it here, we should just move it to the unit test.


machine/corpora/place_markers_usfm_update_block_handler.py line 28 at r1 (raw file):

            len(elements) == 0
            or "alignment_info" not in block.metadata
            or not isinstance(block.metadata["alignment_info"], dict)

It is correct to thoroughly validate the metadata before using it. We could probably get away with doing less. You could just check that alignment_info exists, and then cast it to PlaceMarkersAlignmentInfo. We just assume that the data structure is correct if alignment_info exists. If it isn't correct, it will probablly cause a crash, which is fine, because it would indicate a coding error.

Copy link
Collaborator Author

@Enkidu93 Enkidu93 left a comment

Choose a reason for hiding this comment

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

OK, done.

Reviewable status: 8 of 9 files reviewed, 3 unresolved discussions (waiting on @ddaspit and @isaac091)


machine/corpora/place_markers_usfm_update_block_handler.py line 12 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

I think this is only used in unit tests. We could cast alignment_info to this class when we use it. See my comment below. If we don't use it here, we should just move it to the unit test.

Makes sense


machine/corpora/place_markers_usfm_update_block_handler.py line 28 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

It is correct to thoroughly validate the metadata before using it. We could probably get away with doing less. You could just check that alignment_info exists, and then cast it to PlaceMarkersAlignmentInfo. We just assume that the data structure is correct if alignment_info exists. If it isn't correct, it will probablly cause a crash, which is fine, because it would indicate a coding error.

OK, done.


machine/corpora/update_usfm_parser_handler.py line 314 at r1 (raw file):

Previously, isaac091 (Isaac Schifferer) wrote…

No issues that I can think of

Cool

@codecov-commenter
Copy link

codecov-commenter commented Jul 1, 2025

Codecov Report

Attention: Patch coverage is 95.91837% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.89%. Comparing base (d8aa497) to head (de10ada).

Files with missing lines Patch % Lines
machine/corpora/usfm_update_block.py 85.71% 1 Missing ⚠️
tests/corpora/test_usfm_manual.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #202      +/-   ##
==========================================
- Coverage   88.91%   88.89%   -0.03%     
==========================================
  Files         282      282              
  Lines       17056    17050       -6     
==========================================
- Hits        15166    15156      -10     
- Misses       1890     1894       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @isaac091)

@Enkidu93 Enkidu93 merged commit 531934a into main Jul 2, 2025
13 of 14 checks passed
@Enkidu93 Enkidu93 deleted the update_block_metadata branch July 2, 2025 14:58
benjaminking pushed a commit that referenced this pull request Jul 17, 2025
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.

Refactor UpdateUsfmParserHandler to accept rows with custom metadata

5 participants