USE 558 - Write fulltext records to TIMDEX dataset#11
Merged
Conversation
Why these changes are being introduced: The final leg of the journey of harvesting fulltext for this app is writing fulltexts back to the TIMDEX dataset to live alongside the records they are associated with. We should still support writing locally to JSONLines for debugging. How this addresses that need: In direct support of this goal, - functions from `harvest.py` now yield `DatasetFulltext` instances which are expected by timdex-dataset-api (TDA) library for writing to the "fulltexts" data type - refactor `TIMDEXThesesRecords` to accept an instantiated `TIMDEXDataset` instance such that it can be created once, then reused for reading + writing - update `harvest` CLI command to default to writing back to the TIMDEX dataset Related to this work was some refactoring, - updated `record_and_fulltext_iter()` to use the `joblib` library to offload the complexities of parallel work to a well known library Side effects of this change: * By default, this CLI application will attempt to write the fulltext records back to the TIMDEX dataset Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/USE-558
ghukill
commented
May 19, 2026
|
|
||
| [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.
NOTE: this PR relies on MITLibraries/timdex-dataset-api#189, and will get a force push to revert the timdex-dataset-api version back from a pinned branch.
ghukill
commented
May 19, 2026
Comment on lines
+31
to
+38
| parallel_client = Parallel( | ||
| n_jobs=max_workers, | ||
| prefer="threads", | ||
| return_as="generator_unordered", | ||
| ) | ||
| worker_func = delayed(_get_record_with_fulltext) | ||
|
|
||
| results = parallel_client(worker_func(record) for record in records) |
Collaborator
Author
There was a problem hiding this comment.
This is the joblib library 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:
- use of
delayed(...)should wrap your "worker" function Parallel(...)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.
Definitely cleans the code up! Noted for potential future use
ehanson8
approved these changes
May 20, 2026
Comment on lines
+31
to
+38
| parallel_client = Parallel( | ||
| n_jobs=max_workers, | ||
| prefer="threads", | ||
| return_as="generator_unordered", | ||
| ) | ||
| worker_func = delayed(_get_record_with_fulltext) | ||
|
|
||
| results = parallel_client(worker_func(record) for record in records) |
There was a problem hiding this comment.
Definitely cleans the code up! Noted for potential future use
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
NOTE: this PR relies on MITLibraries/timdex-dataset-api#189, and will get a force push to revert the
timdex-dataset-apiversion back from a pinned branch.Purpose and background context
Why these changes are being introduced:
The final leg of the journey of harvesting fulltext for this app is writing fulltexts back to the TIMDEX dataset to live alongside the records they are associated with. We should still support writing locally to JSONLines for debugging.
How this addresses that need:
In direct support of this goal,
harvest.pynow yieldDatasetFulltextinstances which are expected bytimdex-dataset-api(TDA) library for writing to the "fulltexts" data typeTIMDEXThesesRecordsto accept an instantiatedTIMDEXDatasetinstance such that it can be created once, then reused for reading + writingharvestCLI command to default to writing back to the TIMDEX datasetRelated to this work was some refactoring,
record_and_fulltext_iter()to use thejobliblibrary to offload the complexities of parallel work to a well known libraryHow can a reviewer manually see the effects of these changes?
1- Set
TimdexMangersDev1 credentials2- Set env vars (DSpace credentials shared offline of PR):
3- Run CLI, omitting
--output-jsonlwhich will now default to TIMDEX dataset:uv run --env-file .env dfh --verbose \ harvest \ --run-id="5e11f27e-fe05-44f4-8bcb-5acbdb032cf3" \ --record-limit=100This CLI command:
4- Start an ipython shell:
5- Read the fulltext records we just wrote:
Includes new or updated dependencies?
YES
Changes expectations for external applications?
YES
What are the relevant tickets?
Code review