-
Notifications
You must be signed in to change notification settings - Fork 52.6k
Fix cron dashboard trigger-now execution #46956
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
Open
LeonSGP43
wants to merge
1
commit into
NousResearch:main
Choose a base branch
from
LeonSGP43:fix-46918-cron-trigger-now
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+92
−1
Open
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6780,6 +6780,30 @@ def _call_cron_for_profile(profile: Optional[str], func_name: str, *args, **kwar | |
| return result | ||
|
|
||
|
|
||
| def _call_cron_scheduler_for_profile(profile: Optional[str], func_name: str, *args, **kwargs): | ||
| """Run cron.scheduler helpers against the selected profile home.""" | ||
| profile_name, home = _cron_profile_home(profile) | ||
| with _CRON_PROFILE_LOCK: | ||
| from cron import jobs as cron_jobs | ||
| from cron import scheduler as cron_scheduler | ||
|
|
||
| old_cron_dir = cron_jobs.CRON_DIR | ||
| old_jobs_file = cron_jobs.JOBS_FILE | ||
| old_output_dir = cron_jobs.OUTPUT_DIR | ||
| old_scheduler_home = cron_scheduler._hermes_home | ||
| cron_jobs.CRON_DIR = home / "cron" | ||
| cron_jobs.JOBS_FILE = cron_jobs.CRON_DIR / "jobs.json" | ||
| cron_jobs.OUTPUT_DIR = cron_jobs.CRON_DIR / "output" | ||
| cron_scheduler._hermes_home = home | ||
| try: | ||
| return getattr(cron_scheduler, func_name)(*args, **kwargs) | ||
| finally: | ||
| cron_scheduler._hermes_home = old_scheduler_home | ||
| cron_jobs.CRON_DIR = old_cron_dir | ||
| cron_jobs.JOBS_FILE = old_jobs_file | ||
| cron_jobs.OUTPUT_DIR = old_output_dir | ||
|
|
||
|
|
||
| def _find_cron_job_profile(job_id: str) -> Optional[str]: | ||
| for profile in _cron_profile_dicts(): | ||
| name = str(profile.get("name") or "") | ||
|
|
@@ -6955,7 +6979,9 @@ async def trigger_cron_job(job_id: str, profile: Optional[str] = None): | |
| job = _call_cron_for_profile(selected, "trigger_job", job_id) | ||
| if not job: | ||
| raise HTTPException(status_code=404, detail="Job not found") | ||
| return job | ||
| _call_cron_scheduler_for_profile(selected, "tick") | ||
| refreshed = _call_cron_for_profile(selected, "get_job", job_id) | ||
| return refreshed or job | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| @app.delete("/api/cron/jobs/{job_id}") | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current main deliberately makes these globals fallback-only and routes cross-profile calls through
use_cron_store()to avoid retargeting concurrent ticker I/O (cron/jobs.py:67-69,118-134). Please rework this around the existing profile-scoped_fire_cron_job_for_profilepath instead of restoring process-global routing.