Skip to content

Add on-demand 'trigger-ml' CLI command for machine learning workers (fixes #2920)#3624

Open
sohampirale wants to merge 3 commits intochaoss:mainfrom
sohampirale:trigger-ml-tasks
Open

Add on-demand 'trigger-ml' CLI command for machine learning workers (fixes #2920)#3624
sohampirale wants to merge 3 commits intochaoss:mainfrom
sohampirale:trigger-ml-tasks

Conversation

@sohampirale
Copy link

Description

  • Please include a summary of the change.
    This PR implements on-demand starting of machine learning workers in Augur. Previously, ML workers were triggered periodically according to a fixed schedule. With these changes, they now start only when an explicit command is issued to an Augur instance, giving more control over when ML processing runs (e.g., via CLI or other command-based triggers).
    This addresses the feature request to move away from always-scheduled execution toward user/command-driven activation, which can help with resource efficiency and targeted usage.
    This PR fixes Start Machine Learning Workers on Demand #2920

Notes for Reviewers

  • The changes are contained in the last 3 commits on the trigger-ml branch.
  • Key modifications include:
    • Created a dedicated Celery task helper specifically for triggering ML workers on demand.
    • Removed the ML task triggering logic from the existing scheduled function to eliminate periodic execution.
    • Added a new CLI command trigger-ml under the augur tasks group, allowing to manually start the ML workers when needed.
  • No impact on non-ML workers, other scheduled tasks, or core data collection processes.
  • Please review the commit messages for more granular details on what was changed (e.g., exact files modified, new task definitions, removal of schedule calls, CLI group updates).
  • I am open to any suggested changes, improvements, or feedback from reviewers.

Signed commits

  • Yes, I signed my commits.

Copy link
Contributor

@MoralCode MoralCode left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. After reviewing the specific code changes, im a little confused on what your intent is with this PR.

Augur uses celery as a task broker and starts up workers for all enabled processing phases/task pipelines at startup. It is then up to the scheduler to send tasks into the pipeline to be run.

If you are having issues getting the ML workers to show up in the flower dashboard for monitoring running tasks, you may need to enable the ML workers in your config and restart augur.

If you see the ML workers but they arent doing anything, there may be an issue with the scheduler that you should report so we can look into it.

I'd be happy to chat about this in more detail over on the CHAOSS Slack in the #wg-augur-8knot channel if you'd like to discuss what your goal is and how we can help you get there.

logger = logging.getLogger(trigger_ml_phase.__name__)
enabled_phase_names = get_enabled_phase_names_from_config(engine, logger)

if RUNNING_DOCKER or machine_learning_phase.__name__ not in enabled_phase_names:
Copy link
Contributor

Choose a reason for hiding this comment

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

why is docker being excluded here?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh i see, because it was excluded in the original logic

Comment on lines +100 to +102
logger.info("Starting ML tasks")
trigger_ml_phase.delay()
logger.info("ML tasks started")
Copy link
Contributor

Choose a reason for hiding this comment

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

If the ml workers are not enabled in the config, this will still print a message saying they were started - this seems like it could very easily be confusing

ml_interval = config.get_value('Tasks', 'ml_collection_interval_days') or 40
ml_phase_request.append(build_ml_repo_collect_request(session, logger, enabled_phase_names, ml_interval))

main_routine = AugurTaskRoutine(logger, ml_phase_request)
Copy link
Contributor

Choose a reason for hiding this comment

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

Im not sure if creating a new instance of the augur task routine here could lead to issues or not, especially since we already have one

@MoralCode MoralCode added the more info needed Issues that need additional context and information to be resolved. label Jan 26, 2026
@sgoggins sgoggins added the add-feature Adds new features label Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-feature Adds new features more info needed Issues that need additional context and information to be resolved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start Machine Learning Workers on Demand

3 participants