Skip to content

Commit

Permalink
Merge branch 'release_24.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Sep 25, 2024
2 parents 7dd606a + c80ce1d commit c1bf181
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
6 changes: 5 additions & 1 deletion client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export interface paths {
};
/**
* Displays information about and/or content of a dataset.
* @description **Note**: Due to the multipurpose nature of this endpoint, which can receive a wild variety of parameters
* @description **Note**: Due to the multipurpose nature of this endpoint, which can receive a wide variety of parameters
* and return different kinds of responses, the documentation here will be limited.
* To get more information please check the source code.
*/
Expand Down Expand Up @@ -18388,6 +18388,10 @@ export interface operations {
hda_ldda?: components["schemas"]["DatasetSourceType"];
/** @description The type of information about the dataset to be requested. Each of these values may require additional parameters in the request and may return different responses. */
data_type?: components["schemas"]["RequestDataType"] | null;
/** @description Maximum number of items to return. Currently only applies to `data_type=raw_data` requests */
limit?: number | null;
/** @description Starts at the beginning skip the first ( offset - 1 ) items and begin returning at the Nth item. Currently only applies to `data_type=raw_data` requests */
offset?: number | null;
/** @description View to be passed to the serializer */
view?: string | null;
/** @description Comma-separated list of keys to be passed to the serializer */
Expand Down
14 changes: 7 additions & 7 deletions lib/galaxy/datatypes/dataproviders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def stop( self ): self.endpoint = source.tell(); raise StopIteration()
Building a giant list by sweeping all possible dprov classes doesn't make sense
For now - I'm burying them in the class __init__s - but I don't like that
"""
MAX_LIMIT = 10000


# ----------------------------------------------------------------------------- base classes
Expand Down Expand Up @@ -233,21 +234,20 @@ class LimitedOffsetDataProvider(FilteredDataProvider):
settings = {"limit": "int", "offset": "int"}

# TODO: may want to squash this into DataProvider
def __init__(self, source, offset=0, limit=None, **kwargs):
def __init__(self, source, offset=0, limit=MAX_LIMIT, **kwargs):
"""
:param offset: the number of data to skip before providing.
:param limit: the final number of data to provide.
"""
super().__init__(source, **kwargs)

# how many valid data to skip before we start outputing data - must be positive
# (diff to support neg. indeces - must be pos.)
self.offset = max(offset, 0)
# how many valid data to skip before we start outputting data - must be positive
self.offset = offset

# how many valid data to return - must be positive (None indicates no limit)
# how many valid data to return - must be positive
if limit is None:
limit = MAX_LIMIT
self.limit = limit
if self.limit is not None:
self.limit = max(self.limit, 0)

def __iter__(self):
"""
Expand Down
24 changes: 21 additions & 3 deletions lib/galaxy/webapps/galaxy/api/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from typing_extensions import Annotated

from galaxy.datatypes.dataproviders.base import MAX_LIMIT
from galaxy.schema import (
FilterQueryParams,
SerializationParams,
Expand Down Expand Up @@ -429,18 +430,35 @@ def show(
"may return different responses."
),
),
limit: Annotated[
Optional[int],
Query(
ge=1,
le=MAX_LIMIT,
description="Maximum number of items to return. Currently only applies to `data_type=raw_data` requests",
),
] = MAX_LIMIT,
offset: Annotated[
Optional[int],
Query(
ge=0,
description="Starts at the beginning skip the first ( offset - 1 ) items and begin returning at the Nth item. Currently only applies to `data_type=raw_data` requests",
),
] = 0,
serialization_params: SerializationParams = Depends(query_serialization_params),
):
"""
**Note**: Due to the multipurpose nature of this endpoint, which can receive a wild variety of parameters
**Note**: Due to the multipurpose nature of this endpoint, which can receive a wide variety of parameters
and return different kinds of responses, the documentation here will be limited.
To get more information please check the source code.
"""
exclude_params = {"hda_ldda", "data_type"}
exclude_params = {"hda_ldda", "data_type", "limit", "offset"}
exclude_params.update(SerializationParams.model_fields.keys())
extra_params = get_query_parameters_from_request_excluding(request, exclude_params)

return self.service.show(trans, dataset_id, hda_ldda, serialization_params, data_type, **extra_params)
return self.service.show(
trans, dataset_id, hda_ldda, serialization_params, data_type, limit=limit, offset=offset, **extra_params
)

@router.get(
"/api/datasets/{dataset_id}/content/{content_type}",
Expand Down

0 comments on commit c1bf181

Please sign in to comment.