Skip to content

Commit

Permalink
Merge pull request #864 from facebookresearch/validation
Browse files Browse the repository at this point in the history
fix breaks in create_validation_function for screening units
  • Loading branch information
macota committed Jul 27, 2022
2 parents dea6202 + 678895e commit aa60850
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions mephisto/abstractions/blueprints/mixins/screen_task_required.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ def assert_mixin_args(cls, args: "DictConfig", shared_state: "SharedTaskState"):
"Must provide a generator function to SharedTaskState.screening_data_factory if "
"you want to generate screening tasks on the fly, or False if you can screen on any task "
)
assert (
max_screening_units > 0
), "max_screening_units must be greater than zero if using a screening_data_factory"
else:
assert (
max_screening_units == 0
), "max_screening_units must be zero if not using a screening_data_factory"

def worker_needs_screening(self, worker: "Worker") -> bool:
"""Workers that are able to access the task (not blocked) but are not passed need qualification"""
Expand Down Expand Up @@ -205,13 +212,16 @@ def create_validation_function(
failed_qualification_name = args.blueprint.block_qualification

def _wrapped_validate(unit):
if unit.unit_index >= 0:
if args.blueprint.max_screening_units > 0 and unit.unit_index >= 0:
return # We only run validation on the validatable units

agent = unit.get_assigned_agent()
if agent is None:
return # Cannot validate a unit with no agent

if (
args.blueprint.max_screening_units == 0
and agent.get_worker().is_qualified(passed_qualification_name)
):
return # Do not run validation if screening with regular tasks and worker is already qualified
validation_result = screen_unit(unit)
if validation_result is True:
agent.get_worker().grant_qualification(passed_qualification_name)
Expand Down

0 comments on commit aa60850

Please sign in to comment.