-
Notifications
You must be signed in to change notification settings - Fork 0
USE 558 - Write fulltext records to TIMDEX dataset #11
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ requires-python = ">=3.13" | |
| dependencies = [ | ||
| "click>=8.2.1", | ||
| "dspace-rest-client>=0.1.17", | ||
| "joblib>=1.5.3", | ||
| "jsonlines>=4.0.0", | ||
| "requests>=2.33.1", | ||
| "sentry-sdk>=2.34.1", | ||
|
|
@@ -20,6 +21,7 @@ dependencies = [ | |
| dev = [ | ||
| "coveralls>=4.0.1", | ||
| "ipython>=9.13.0", | ||
| "joblib-stubs>=1.5.3.1.20260117", | ||
| "mypy>=1.17.1", | ||
| "pip-audit>=2.9.0", | ||
| "pre-commit>=4.3.0", | ||
|
|
@@ -107,7 +109,7 @@ dfh = "dfh.cli:main" | |
| include = ["dfh", "dfh.*"] | ||
|
|
||
| [tool.uv.sources] | ||
| timdex-dataset-api = { git = "https://github.com/MITLibraries/timdex-dataset-api" } | ||
| timdex-dataset-api = { git = "https://github.com/MITLibraries/timdex-dataset-api", rev = "USE-531-fulltext-data-type-add" } | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: this PR relies on MITLibraries/timdex-dataset-api#189, and will get a force push to revert the |
||
|
|
||
| [build-system] | ||
| requires = ["setuptools>=61"] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import json | ||
|
|
||
| from timdex_dataset_api.data_types import DatasetFulltext | ||
|
|
||
| from dfh.cli import write_jsonlines_output | ||
|
|
||
| RUN_RECORD_OFFSET = 12 | ||
|
|
||
|
|
||
| def test_write_jsonlines_output_serializes_dataset_fulltext(tmp_path): | ||
| output_jsonl = tmp_path / "fulltexts.jsonl" | ||
| dataset_fulltexts = iter( | ||
| [ | ||
| DatasetFulltext( | ||
| timdex_record_id="dspace:123", | ||
| run_id="run-1", | ||
| run_record_offset=RUN_RECORD_OFFSET, | ||
| fulltext_timestamp="2026-05-18T12:34:56+00:00", | ||
| fulltext=b"fulltext content", | ||
| ), | ||
| ] | ||
| ) | ||
|
|
||
| write_jsonlines_output(str(output_jsonl), dataset_fulltexts) | ||
|
|
||
| output_record = json.loads(output_jsonl.read_text().strip()) | ||
| assert output_record == { | ||
| "timdex_record_id": "dspace:123", | ||
| "run_id": "run-1", | ||
| "run_record_offset": RUN_RECORD_OFFSET, | ||
| "fulltext_timestamp": "2026-05-18T12:34:56+00:00", | ||
| "fulltext_md5": "1fd0a1296d0665461f688201f63a37f1", | ||
| "fulltext": "fulltext content", | ||
| "year": "2026", | ||
| "month": "05", | ||
| "day": "18", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the
jobliblibrary in action here.In a way, it's more intuitive in that you are basically calling your function, with args, over an iterator of items.
What's not immediately intuitive:
delayed(...)should wrap your "worker" functionParallel(...)arguments are really important, setting threads vs processes, if unordered is okay, etc.But overall, really liking it so far, and very nice to offload this finicky parallel work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely cleans the code up! Noted for potential future use