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

Allow complex Filters #2145

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft

Conversation

ychiucco
Copy link
Collaborator

closes #1401

Checklist before merging

  • I added an appropriate entry to CHANGELOG.md
  • I added logging to new code - if appropriate.
  • I merged main into the current branch.

@ychiucco ychiucco linked an issue Dec 16, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Dec 16, 2024

Benchmark comparison

GET /api/alive/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 0.8 1.0 0.80 0.0 0.0
power 0.8 0.9 0.89 0.0 0.0
dataset 0.8 0.9 0.89 0.0 0.0
project 0.8 0.9 0.89 0.0 0.0
job 0.8 0.9 0.89 0.0 0.0

GET /api/v2/dataset/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 10.3 9.4 1.10 0.7 0.6
power 434.9 410.8 1.06 404.6 366.2
dataset 162.9 149.7 1.09 147.4 134.0
project 51.3 43.2 1.19 52.0 47.2
job 30.0 29.3 1.02 35.6 32.4

GET /api/v2/job/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 6.6 6.4 1.03 2.2 2.2
power 149.9 141.4 1.06 665.0 652.2
dataset 151.6 146.8 1.03 918.0 905.2
project 49.0 49.0 1.00 287.8 283.8
job 40.3 42.3 0.95 228.1 224.9

GET /api/v2/project/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 7.8 7.4 1.05 0.1 0.1
power 7.5 7.1 1.06 0.1 0.1
dataset 7.7 7.3 1.05 0.1 0.1
project 9.5 9.5 1.00 2.3 2.3
job 7.6 7.4 1.03 0.1 0.1

GET /api/v2/task/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 6.4 5.8 1.10 0.8 0.8
power 6.3 5.7 1.11 0.8 0.8
dataset 7.0 6.1 1.15 0.8 0.8
project 6.1 5.9 1.03 0.8 0.8
job 5.6 6.2 0.90 0.8 0.8

GET /api/v2/task-group/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 6.9 7.6 0.91 1.6 1.6
power 6.7 7.5 0.89 1.6 1.6
dataset 6.8 7.4 0.92 1.6 1.6
project 6.8 7.3 0.93 1.6 1.6
job 6.9 7.3 0.95 1.6 1.6

GET /api/v2/workflow/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 14.2 10.8 1.31 0.9 0.8
power 25.6 24.8 1.03 30.4 29.1
dataset 19.7 20.0 0.98 17.4 16.7
project 23.1 22.2 1.04 21.8 21.0
job 10.9 12.0 0.91 0.9 0.8

POST /api/v2/project/3/dataset/417/images/query/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
dataset 155.9 152.4 1.02 275.1 275.1

GET /auth/current-user/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
vanilla 4.7 4.8 0.98 0.2 0.2
power 4.4 4.8 0.92 0.2 0.2
dataset 4.5 4.8 0.94 0.2 0.2
project 4.5 4.8 0.94 0.2 0.2
job 4.4 4.8 0.92 0.1 0.1

POST /auth/token/login/

User Time current (ms) Time main (ms) Ratio current/main Size current (Kb) Size main (Kb)
dataset 274.3 273.8 1.00 0.2 0.2

Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  fractal_server
  __init__.py
  fractal_server/app/models/v2
  dataset.py
  workflowtask.py
  fractal_server/app/routes/api/v2
  images.py
  fractal_server/app/runner/executors/slurm/sudo
  executor.py
  fractal_server/app/runner/v2
  runner.py
  fractal_server/app/runner/v2/_local_experimental
  executor.py
  fractal_server/images
  models.py
  tools.py
Project Total  

This report was generated by python-coverage-comment-action

Comment on lines +11 to +18
class FiltersMock(TypedDict):
types: dict[str, bool]
attributes_include: dict[str, list[Any]]
attributes_exclude: dict[str, list[Any]]

@classmethod
def get_default(cls):
return cls(types={}, attributes_include={}, attributes_exclude={})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's re-use something like for sqlmodel models, and move it to fractal_server/images/models.py next to the actual Filters model.

] = Field(
sa_column=Column(
JSON,
nullable=False,
server_default='{"attributes": {}, "types": {}}',
server_default=json.dumps(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use a FILTERS_DEFAULT_JSON variable, defined in fractal_server/images/models.py. It would be something equivalent to

FILTERS_DEFAULT_JSON = json.dumps(FiltersMock.get_defaults())  # replace FiltersMock with name

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.

Allow complex filters being set
2 participants