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

[Feature Request] Automatically only launch tasks during certain hours. #605

Open
JackUrb opened this issue Nov 16, 2021 · 2 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@JackUrb
Copy link
Contributor

JackUrb commented Nov 16, 2021

Overview

Anecdotally, crowdsourcing quality is often better on certain hours of the day. It would be nice to have some method to only launch tasks during these hours.

Implementation

In either case, the core functionality for this lives in the TaskLauncher.

Simple - for use with max_num_concurrent_units

This implementation is simple, we just don't launch additional tasks outside the specified hours. We can do this by sleeping the additional-launching thread outside of working hours. It could go here:

time.sleep(UNIT_GENERATOR_WAIT_SECONDS)

If we're outside of set hours, sleep until the next approved hour.

Complex - actively take down tasks outside hours

This implementation is less clear, but may be desired. The goal here would be to expire all of the units that are still alive outside of working hours, and then relaunch them later. This would likely involve creating new assignments that are copies of incomplete ones, and then relaunching those. If this is necessary, can comment and I'll scope further.

@JackUrb JackUrb added enhancement New feature or request help wanted Extra attention is needed labels Nov 16, 2021
@JackUrb JackUrb added the good first issue Good for newcomers label Mar 1, 2022
@ajyl
Copy link

ajyl commented Mar 4, 2022

What would be a good way to add tests for this functionality?

@JackUrb
Copy link
Contributor Author

JackUrb commented Mar 4, 2022

Hi @ajyl: Your best bet would be to mock time.time, and work through a test similar to the tests in test_operator.py, most likely this one:

def test_run_jobs_with_restrictions(self):

You could first launch a task with 1 concurrent unit max, then update the time, complete the unit, note that a new worker is provided with no possible units, update the time again, and then note that a new unit is launched and able to be completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants