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

perf: LSDV-4695: update Prediction model queries to take advantage of new direct project relation #4639

Merged
merged 8 commits into from Sep 12, 2023

Conversation

dredivaris
Copy link
Contributor

PR fulfills these requirements

  • Commit message(s) and PR title follows the format [fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made ex. fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
  • Tests for the changes have been added/updated (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • Best efforts were made to ensure docs/code are concise and coherent (checked for spelling/grammatical errors, commented out code, debug logs etc.)
  • Self-reviewed and ran all changes on a local instance (for bug fixes/features)

Change has impacts in these area(s)

(check all that apply)

  • Product design
  • Backend (Database)
  • Backend (API)
  • Frontend

Describe the reason for change

Prediction performance in general has not been optimal due to the necessity of querying through the task model whenever needing to filter on project (Prediction -> Task -> Project).

What does this fix?

This PR updates all Prediction queries that access project through task (a double join) to access project directly through the Prediction model's new project fk (added in this PR).

Does this change affect performance?

This PR should positively impact performance in any location Prediction queries are made on Project.

What feature flags were used to cover this change?

fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation

Does this PR introduce a breaking change?

(check only one)

  • Yes, and covered entirely by feature flag(s)
  • Yes, and covered partially by feature flag(s)
  • No
  • Not sure (briefly explain the situation below)

What level of testing was included in the change?

(check all that apply)

  • e2e
  • integration
  • unit

Which logical domain(s) does this change affect?

Predictions

…ove performance

Also update anywhere in the code where Predictions are created so project is also connected and adds a failsafe in the Predition save method to add a project if it was not added before
@netlify
Copy link

netlify bot commented Aug 16, 2023

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit 08675c8
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-docs-new-theme/deploys/64ff7a4ea2a3ae00087fc385

@netlify
Copy link

netlify bot commented Aug 16, 2023

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit 08675c8
🔍 Latest deploy log https://app.netlify.com/sites/heartex-docs/deploys/64ff7a4e5cfc1b0008e2b72c

@github-actions github-actions bot added the perf label Aug 16, 2023
@codecov
Copy link

codecov bot commented Aug 16, 2023

Codecov Report

Patch has no changes to coverable lines.

❗ Current head dd3d95a differs from pull request most recent head 08675c8. Consider uploading reports for the commit 08675c8 to get more accurate results

📢 Thoughts on this report? Let us know!.

@dredivaris dredivaris requested a review from makseq August 25, 2023 15:19
# Conflicts:
#	label_studio/data_import/api.py
#	label_studio/tasks/migrations/0042_auto_20230810_2304.py
label_studio/core/old_ls_migration.py Outdated Show resolved Hide resolved
label_studio/ml/models.py Outdated Show resolved Hide resolved
label_studio/tasks/serializers.py Outdated Show resolved Hide resolved
# Conflicts:
#	label_studio/tasks/serializers.py
@dredivaris
Copy link
Contributor Author

dredivaris commented Sep 12, 2023

/git merge develop

Already up-to-date. Nothing to commit.

Workflow run

@farioas farioas merged commit 7130291 into develop Sep 12, 2023
28 of 39 checks passed
jombooth pushed a commit that referenced this pull request Sep 13, 2023
… new direct project relation (#4639)

* perf: LSDV-4695: add new project relation to Prediction model to improve performance

Also update anywhere in the code where Predictions are created so project is also connected and adds a failsafe in the Predition save method to add a project if it was not added before

* Add data migration to update predictions with direct fk to their project

* perf: LSDV-4695: update queries to handle new Prediction -> project pk

* Add missing import
shayantabatabaee pushed a commit to shayantabatabaee/label-studio that referenced this pull request Sep 19, 2023
… new direct project relation (HumanSignal#4639)

* perf: LSDV-4695: add new project relation to Prediction model to improve performance

Also update anywhere in the code where Predictions are created so project is also connected and adds a failsafe in the Predition save method to add a project if it was not added before

* Add data migration to update predictions with direct fk to their project

* perf: LSDV-4695: update queries to handle new Prediction -> project pk

* Add missing import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants