-
Notifications
You must be signed in to change notification settings - Fork 75
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
[WIP] adding tasks/assignments dynamically #188
Conversation
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.
A bit of a miscommunication on design here - the thought is that if either of the parameters that would require a generator thread be set up, the TaskLauncher
would run a single thread to keep track of the generators. Otherwise, it'd run regularly (without any threads).
Operational flags to keep track of would be what type of generation would be needed (perhaps an enum of none
, unit
, or assignment
(as if the assignment is a generator, the units must be as well since more units will be added later)), and what parts have been launched (did_launch_assignments
, and did_launch_units
for instance).
If it's running as a generator, you would set up a single thread to act as the main at the end of __init__
. This thread would check the values of did_create_assignments
and did_launch_units
respectively in order to decide whether or not to call _try_launch_units
and _try_create_assignments
.
TaskLauncher
itself is not turning assignment_data_list
into a generator. You can use isinstance(assignment_data, types.GeneratorType)
(after importing types
) to see if the provided list is a generator.
The only way to test this initially will be by writing a new test case. It will define a generator (like the generate_units
you've created here) and pass that instead of a list as the argument for assignment_data_list
(which we should probably rename to assignment_data_iterator
).
Adding block qual as default argument for blueprints
Making it possible to set mturk-specific qualifications
…ephisto into assignments_generator merging local branch to the repo one
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.
Generally looking closer, though as we discussed a bit back it may make sense to just have two generator threads.
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.
This is beginning to look correct from an implementation perspective - what do the tests say?
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.
Alright this is 99% of the way there - the only remaining thing to do is ensure that you join the generator threads at the end of expire_units
. You'll be able to tell you've done this properly when test/core/test_operator.py
passes.
@JackUrb I added the Mephisto/mephisto/core/operator.py Line 307 in 10a9d10
the number of items in self._task_runs_tracked dictionary is zero.
|
Ah this is a fair point - the correct course of action here would be to move the flag-setting and joining to a new Having a |
mephisto/core/task_launcher.py
Outdated
UNIT_GENERATOR_WAIT_SECONDS = 1 | ||
ASSIGNMENT_GENERATOR_WAIT_SECONDS = 0.05 |
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.
Why change these times?
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.
there was a test in the test_operator.py
making sure that consecutive assignments finish after certain amount of time, when they are as large as before it fails, so I changed it and was about to ask you (how can we define these numbers efficiently? and should the test in the test_operator.py
be changed 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.
I'd update the test_operator
to use a timeout style test rather than a direct check, like the style of:
start_time = time.time()
while (condition is not met):
assert time.time - start_time is not more than some amount
as the timeouts defined initially here seem better than these really rapid ones.
So do the operator tests pass now? Have you made that change as well? |
Now |
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.
Looks ready to go at this point! Thanks for bearing with me through all the changes.
@JackUrb Thank you for bearing with me and mentoring me and teaching me alot :) |
I've started with Jack's first suggestion in the issue#99:
try_launch_units()
andtry_create_assignments()
threads.generate_assignment()
with its current version will work ifself.assignment_data_list
is changing its size (which is what I expect as the required task is to allow dynamic size of this list) but I need to think about how to test it to know if it works.