Skip to content

Added sorting functionality #767

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 5 commits into from
Mar 25, 2025
Merged

Added sorting functionality #767

merged 5 commits into from
Mar 25, 2025

Conversation

kzscisoft
Copy link
Collaborator

@kzscisoft kzscisoft commented Mar 13, 2025

Sorting of Runs, Artifacts, Tags, Folders, Alerts

Issue: #766

Python Version(s) Tested: 3.13

Operating System(s): Ubuntu 24.10

Documentation PR: N/A

📝 Summary

Adds compatibility with the server side sorting when using GET to retrieve objects.

🔄 Changes

Added additional argument sorting to relevant low level API classes where the user then provides the sorting list:

Alert.get(sorting=[{"column": "created", "descending": True}])

Also adds same functionality to user API:

Client().get_runs(sort_by_columns=[("created", True)])

✔️ Checklist

  • Unit and integration tests passing.
  • Pre-commit hooks passing.
  • Quality checks passing.
  • Updated the documentation.

@kzscisoft kzscisoft requested a review from wk9874 March 13, 2025 14:38
@kzscisoft kzscisoft added the enhancement New feature or request label Mar 13, 2025
@kzscisoft kzscisoft added this to the v2.1.0-rc1 milestone Mar 13, 2025
Copy link
Collaborator

@wk9874 wk9874 left a comment

Choose a reason for hiding this comment

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

You'll need to show me how to actually use this so that I can test it :)

@@ -125,6 +126,20 @@ def abort(self) -> bool:
"""Retrieve if alert can abort simulations"""
return self._get_attribute("abort")

@property
@staging_check
def delay(self) -> int:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait what is this? You can delay the start of an alert?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If that's the case then we should also add this functionality into the Run class in another MR :)

Copy link
Collaborator Author

@kzscisoft kzscisoft Mar 19, 2025

Choose a reason for hiding this comment

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

Not sure, this is just a value available in the RestAPI response, @alahiff ?

@@ -65,6 +78,8 @@ def get(
limit the number of results, default of None returns all.
offset : int, optional
start index for returned results, default of None starts at 0.
sorting : list[dict] | None, optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really clear what this would be, what does each item in the list correspond to? Wouldnt you just want one sorting parameter for all the things youre getting?

Copy link
Collaborator Author

@kzscisoft kzscisoft Mar 19, 2025

Choose a reason for hiding this comment

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

This is the low level API so just mirrors the RestAPI which expects a list in the form [{"id": <column>, "desc": <if-descending-else-ascending>}]

@pydantic.field_validator("column")
@classmethod
def check_column(cls, column: str) -> str:
if column and column not in ("name", "created"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be really useful to have a column which sorts by time set to critical, no idea if thats possible

@wk9874 wk9874 assigned kzscisoft and unassigned wk9874 Mar 17, 2025
@wk9874 wk9874 merged commit 072eb35 into dev Mar 25, 2025
12 checks passed
@wk9874 wk9874 deleted the feature/sorting branch March 25, 2025 10:59
@kzscisoft kzscisoft changed the title Added sorting functionality to low level API Added sorting functionality Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants