-
Notifications
You must be signed in to change notification settings - Fork 52
Move sensor data ingestion to job queue #2101
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
Changes from 12 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
5d4dd2e
Initial plan
Copilot ec03f05
Move data ingestion logic to job queue (ingestion queue)
Copilot ea634db
Fix code review comments: use for loop and move imports to module level
Copilot 3a98da8
Add warning when ingestion queue is not configured
Copilot eb0f886
docs: add changelog entry and upgrade notice for ingestion queue warn…
Copilot b1681e9
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
joshuaunity 5d5b921
chore: remvoe wrong log entry
joshuaunity be2d019
docs: add ingestion queue changelog entry and upgrade notice to v0.33.0
Copilot bd53637
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
joshuaunity 0bc6580
chore: remove duplicate changelog entry
joshuaunity 842eae6
fix: update job queue command to include ingestion
joshuaunity c811cf0
docs: add ingestion queue to worker examples in forecasting_schedulin…
Copilot 7d275a9
refactor: update data ingestion logic to enqueue forecasting jobs
joshuaunity cb133ee
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
joshuaunity acfb144
refactor: eliminate duplicated save/enqueue logic in save_and_enqueue…
Copilot aff5b0b
refactor: enhance comparison logic for unchanged beliefs to support j…
joshuaunity 974cb78
feat: implement serialization and deserialization for ingestion data,…
joshuaunity 6380541
refactor: improve cross-session comparison logic by using source_id f…
joshuaunity 99cc90a
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
joshuaunity da441ef
Update API version to 0.32.0
joshuaunity 513a81e
fix: pass keep_only_most_recent_belief=True to resample_events in fil…
Copilot 0dd844f
fix: improve test docstring and remove debug print from new upload test
Copilot 588f0ea
fix: add db.engine.dispose() to ingestion job function to fix forked …
Copilot 3c8d776
fix: address code review comments - clearer test comment and simpler …
Copilot 719ac8f
fix: enhance timezone handling in data ingestion serialization and de…
joshuaunity 3b41915
revert: undo db.engine.dispose() ingestion fix and related changes
Copilot 7df88bf
fix: update test_fetch_sensor_stats expected values to account for ne…
Copilot 59e32a6
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
joshuaunity 27654d5
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
joshuaunity 706caf3
fix: remove unused event_start variable in time_series.py (flake8 F841)
Copilot 3402684
fix: filter bdf_db by event_start in _drop_unchanged_beliefs_compared…
Copilot 2e052f6
chore: modify chnagelog
joshuaunity 25c63c5
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
joshuaunity 06f86c9
feat: implement job status polling for background data processing
joshuaunity 3c4d717
feat: enhance job status polling with in-progress notifications
joshuaunity 38c81d0
move all work to the jobs, including resampling. Just a thin acceptan…
nhoening 37c2823
also log that data has been saved successfully, the logs are not clea…
nhoening be2596e
move all work to the jobs, including resampling. Just a thin acceptan…
nhoening 8efd483
Improve poling and Toasting
nhoening a3fd6ab
Use full sensor data range in delete dialog
nhoening 08cc8e6
smaller self-review changes
nhoening b9ac887
make constants out of our various success messages
nhoening 14f0b85
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
nhoening e89be4e
Merge remote-tracking branch 'origin/main' into copilot/move-post-dat…
Flix6x e8edfe0
docs: suggest revised command to run a worker assigned to our 3 stand…
Flix6x fed6da1
feat: let the docker compose worker also handle ingestion
Flix6x 2a80e46
fix: if users can create children on the sensor, they should be allow…
Flix6x 3002a19
refactor: utils work on any AuthModelMixin, not just on Asset
Flix6x 7ea92ad
refactor: move auth utils to module that is not asset specific
Flix6x c626a19
Merge branch 'copilot/move-post-data-logic-to-job-queue' of github.co…
nhoening fef8dac
remove Toast about job acceptance
nhoening dced659
in uploaded data, we (keep) allow(ing) multiple beliefs per event
nhoening 3816994
add comment on default ingestion limit
nhoening a387996
Merge branch 'main' into copilot/move-post-data-logic-to-job-queue
nhoening 1bd5ac8
feat: adding TTL to ingestion jobs
joshuaunity 9328aaf
docs: add comment explaining the TTL choice for ingestion
Flix6x 4d55596
fix: put back filters for the sake of UX (speed)
Flix6x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| """ | ||
| Logic around data ingestion (jobs) | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from flask import current_app | ||
| from rq.job import Job | ||
| import timely_beliefs as tb | ||
|
|
||
| from flexmeasures.data import db | ||
| from flexmeasures.data.utils import save_to_db | ||
|
|
||
|
|
||
| def add_beliefs_to_database( | ||
|
joshuaunity marked this conversation as resolved.
Outdated
|
||
| data: tb.BeliefsDataFrame | list[tb.BeliefsDataFrame], | ||
| forecasting_jobs: list[Job] | None = None, | ||
| save_changed_beliefs_only: bool = True, | ||
| ) -> str: | ||
| """Save sensor data to the database and optionally enqueue forecasting jobs. | ||
|
|
||
| This function is intended to be called as an RQ job by an ingestion queue worker, | ||
| but can also be called directly (e.g. as a fallback when no workers are available). | ||
|
|
||
| :param data: BeliefsDataFrame (or list thereof) to be saved. | ||
| :param forecasting_jobs: Optional list of forecasting Jobs to enqueue after saving. | ||
| :param save_changed_beliefs_only: If True, skip saving beliefs whose value hasn't changed. | ||
| :returns: Status string, one of: | ||
| - 'success' | ||
| - 'success_with_unchanged_beliefs_skipped' | ||
| - 'success_but_nothing_new' | ||
| """ | ||
| status = save_to_db(data, save_changed_beliefs_only=save_changed_beliefs_only) | ||
| db.session.commit() | ||
|
|
||
| # Only enqueue forecasting jobs upon successfully saving new data | ||
| if status[:7] == "success" and status != "success_but_nothing_new": | ||
| if forecasting_jobs is not None: | ||
| for job in forecasting_jobs: | ||
| current_app.queues["forecasting"].enqueue_job(job) | ||
|
|
||
| return status | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.