Repository navigation
Add endpoints for fetching job and dataset rows of a task - #876
Merged
Merged
Conversation
The live-case harness reads the jobs and the datasets of a task through db_read, which waits behind the greps of the async daemon: a fetch holding one took 10.8 s at the median against 0.3 s without. No sync endpoint gives these rows: get_job_ids has PandaIDs only, get_job_descriptions peeks every job, and get_datasets_and_files and get_details give a few dataset columns. - GET /v1/task/get_job_rows returns 11 columns of the jobs of a task from jobsDefined4, jobsActive4, jobsArchived4 and the archive, read by one UNION statement as getPandaIDsWithTaskID reads them, ordered by PandaID and cut at 1000 rows with truncated, and the number of jobs by jobStatus from a second statement. - jobsArchived4 and the archive are read in a window on modificationTime: from since, or from the creation of the task, less 10 minutes and down to the day, up to the day after the database time, which leaves out the partitions made ahead. The index lookups of both statements are held to db_read_probe_budget, and a call over it is refused. - GET /v1/task/get_dataset_rows returns every JEDI_Datasets column of the task, cut at 1000 rows. - Both give as_of, like the other history and key reads.
task/get_job_rows returns at most 1000 rows, and the harness already sees tasks with 1002-2464 live rows plus archived ones. after_panda_id returns only the jobs with a larger PandaID, in the same order and under the same cap, so a caller reads a task page by page until truncated is false. The page is put on every table of the union, where the jediTaskID+PandaID index can start from it, and since the pages are ordered over all tables a job moving between tables from one page to the next is still read once. The counts take no page: every call counts every job in the window.
Postgres takes the standard FETCH FIRST n ROWS ONLY as it is, so the per-backend LIMIT branch in db_read compose and row_limit_clause() are not needed.
task/get_dataset_rows returns at most 1000 rows, and a task with more datasets than that could not be read past the first 1000. after_dataset_id returns only the datasets with a larger datasetID, in the same order and under the same cap, so a caller reads a task page by page until truncated is false, as with after_panda_id on task/get_job_rows. Without it the answer is as before.
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.
This pull request introduces two new paginated API endpoints to retrieve job and dataset rows for a given task, along with the necessary backend and test support. It also standardizes SQL query pagination syntax for compatibility across Oracle and PostgreSQL. The changes improve data access flexibility for clients and ensure consistent query behavior across supported databases.
New API Endpoints:
get_job_rowsendpoint totask_api.pyfor retrieving job rows of a task, supporting pagination and windowing by modification time, with robust error handling and detailed response structure.get_dataset_rowsendpoint totask_api.pyfor retrieving dataset rows of a task, with pagination support and full column output.Backend and Data Handling Enhancements:
TaskBuffer.pyandtask_standalone_module.pyto support the new endpoints, including logic for partitioning, windowing, and row selection. [1] [2]SQL Query Standardization:
LIMITclauses with the ANSI-compliantFETCH FIRST ... ROWS ONLYsyntax, ensuring compatibility with both Oracle and PostgreSQL. Updated related unit tests accordingly. [1] [2] [3]Testing:
task_api_tests.py, including normal operation, pagination, invalid input, and edge cases.These changes collectively improve the API's usability, consistency, and maintainability.