Skip to content
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

DM-46389: Update query documentation for new query system #1082

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

dhirving
Copy link
Contributor

@dhirving dhirving commented Sep 18, 2024

Updated the query documentation to prefer the use of methods from the new query system where available, and reflect the current status of the code.

Some effort was also made to add examples and remove verbose technical information that isn't relevant to most users.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes
  • (if changing dimensions.yaml) make a copy of dimensions.yaml in configs/old_dimensions

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.69%. Comparing base (ec1fe6a) to head (480ba3e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1082   +/-   ##
=======================================
  Coverage   89.69%   89.69%           
=======================================
  Files         360      360           
  Lines       47061    47061           
  Branches     9661     9661           
=======================================
  Hits        42213    42213           
  Misses       3480     3480           
  Partials     1368     1368           

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

@dhirving dhirving marked this pull request as ready for review September 18, 2024 23:44
Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

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

Thanks for this cleanup.

@@ -41,8 +49,7 @@ Collection expressions
Arguments that specify one or more collections are similar to those for dataset types; they can take:

- `str` values (the full collection name);
- `str` values using glob wildcard syntax which will be converted to `re.Pattern`;
- `re.Pattern` values (matched to the collection name, via `~re.Pattern.fullmatch`);
- `str` values using glob wildcard syntax (like ``u/someone/*`` to find all collections starting with "u/someone/".)
- iterables of any of the above, empty collection cannot match anything, methods always return an empty result set in this case;
- the special value "``...``", which matches all collections;
Copy link
Member

Choose a reason for hiding this comment

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

Aren't we phasing this out?


- The definitions of `~CollectionType.CHAINED` collections
- `Butler.get`
- `Butler.put`
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this only take a single RUN collection?

@@ -441,23 +442,26 @@ Few examples of valid expressions using some of the constructs:
Query result ordering
---------------------

Few query methods (`~Registry.queryDataIds` and `~Registry.queryDimensionRecords`) support special constructs for ordering and limiting the number of the returned records. These methods return iterable objects which have ``order_by()`` and ``limit()`` methods. Methods modify the iterable object and should be used before iterating over resulting records, for convenience the methods can be chained, see example below.
Butler query methods (`Butler.query_datasets`, `Butler.query_data_ids`, and
Copy link
Member

Choose a reason for hiding this comment

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

General comment that RST preferred style is one sentence per line rather than line breaks mid sentence.


- A dimension name, corresponding to the value of the dimension primary key, e.g. ``"visit"``
- A dimension name and a field name separated bey a dot. Field name can refer to any of the dimension's metadata or key, e.g. ``"visit.name"``, ``"detector.raft"``. Special field names ``"timespan.begin"`` and ``"timespan.end"`` can be used for temporal dimensions (visit and exposure).
- A field name without dimension name, in that case field is searched in all dimensions used by the query, and it has to be unique. E.g. ``"cell_x"`` means the same as ``"patch.cell_x"``.
- To reverse ordering for the field it is prefixed with a minus sign, e.g. ``"-visit.timespan.begin"``.

The ``limit()`` method accepts two positional integer arguments - limit for the number of returned records and offset (number of records to skip). The offset argument is optional, if not provided it is equivalent to offset 0.
The ``limit`` parameter accepts an integer specifying the maximum number of results to return.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe mention the difference between positive and negative limit and what happens by default if no results are returned (but limit=0 does not complain for no results since you asked for none).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered that originally but decided it was Too Much Information for an overview document -- the parameter description into the API documentation covers that in detail already.

Updated the query documentation to prefer the use of methods from the new query system where available, and reflect the current status of the code.

Some effort was also made to add examples and remove verbose technical information that isn't relevant to most users.
@dhirving dhirving merged commit 568f80b into main Sep 19, 2024
18 checks passed
@dhirving dhirving deleted the tickets/DM-46389 branch September 19, 2024 20:24
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.

2 participants