def run()

in mozperftest_tools/mozperftest_tools/lull_scheduler.py [0:0]


    def run(self, revision, branch, tasks_to_run):
        """Run the lull scheduler to select which tasks to run.

        Given a revision, branch, and a set of tasks that can be selected from,
        this will return the set of tasks that should be scheduled. The tasks
        are expected to have the format:
        {
            "task-name": 1 # Frequency in days
        }

        See select_tasks_to_run for more information on how the tasks are
        selected to run.

        :param revision str: The revision that tasks will be created on.
        :param branch str: The branch of the revision.
        :param tasks_to_run dict: Dictionary of the name of tasks to run as
            keys, and the frequency that they should be scheduled at as the
            value.
        """
        tasks_in_revision = get_tasks_in_revisions([revision], branch)
        all_task_names = {}
        for task in tasks_in_revision:
            all_task_names[task["task"]["metadata"]["name"]] = True

        (
            avg_task_time_data,
            avg_platform_time_data,
            number_tasks_scheduled,
            number_machines_available,
            last_task_run_dates,
        ) = self.fetch_all_data()

        platforms_to_schedule = self.get_platforms_to_schedule(
            number_tasks_scheduled, number_machines_available, avg_platform_time_data
        )

        print("Platforms to schedule:")
        print(json.dumps(platforms_to_schedule, indent=4))

        tasks_selected, total_time_per_platform = self.select_tasks_to_run(
            tasks_to_run,
            platforms_to_schedule,
            avg_task_time_data,
            avg_platform_time_data,
            all_task_names,
            last_task_run_dates,
        )

        print("Tasks selected to run:")
        print(json.dumps(tasks_selected, indent=4))

        print("Total CPU minutes added to platforms:")
        print(json.dumps(total_time_per_platform, indent=4))

        return tasks_selected, total_time_per_platform