def create_task()

in mozci/console/commands/decision.py [0:0]


    def create_task(self, push: Push) -> str:
        """
        Create a children task linked to the current task
        that will classify a single push
        """
        environment = self.option("environment")

        # Expose non-production environment in sub routes
        route_prefix = (
            "index.project.mozci.classification"
            if environment == "production"
            else f"index.project.mozci.{environment}.classification"
        )

        task_id = taskcluster.slugId()
        task = {
            "taskGroupId": self.current_task["taskGroupId"],
            "created": taskcluster.stringDate(datetime.utcnow()),
            "deadline": taskcluster.stringDate(taskcluster.fromNow("1 hour")),
            "dependencies": [
                self.current_task["id"],
            ],
            "scopes": [
                f"docker-worker:cache:mozci-classifications-{environment}",
                f"generic-worker:cache:mozci-classifications-{environment}",
                f"secrets:get:project/mozci/{environment}",
                "queue:route:notify.email.release-mgmt-analysis@mozilla.com.on-failed",
                "notify:email:*",
                "notify:matrix-room:!vNAdpBnFtfGfispLtR:mozilla.org",
            ],
            "metadata": {
                "name": f"mozci classify {push.branch}@{push.rev}",
                "description": "mozci classification task",
                "owner": "mcastelluccio@mozilla.com",
                "source": "https://github.com/mozilla/mozci",
            },
            "payload": {
                "maxRunTime": 3600,
                "image": self.current_task["payload"]["image"],
                "env": {
                    "TASKCLUSTER_CONFIG_SECRET": f"project/mozci/{environment}",
                },
                "features": {
                    "taskclusterProxy": True,
                },
                "command": [
                    "push",
                    "classify",
                    push.branch,
                    f"--rev={push.rev}",
                    "--output=/tmp",
                    f"--environment={environment}",
                ],
                "cache": {
                    f"mozci-classifications-{environment}": "/cache",
                },
                "artifacts": {
                    "public/classification.json": {
                        "expires": taskcluster.stringDate(
                            taskcluster.fromNow("3 months")
                        ),
                        "path": f"/tmp/classify_output_{push.branch}_{push.rev}.json",
                        "type": "file",
                    }
                },
            },
            "routes": [
                f"{route_prefix}.{push.branch}.revision.{push.rev}",
                f"{route_prefix}.{push.branch}.push.{push.id}",
                "notify.email.release-mgmt-analysis@mozilla.com.on-failed",
            ],
            "provisionerId": self.current_task["provisionerId"],
            "workerType": self.current_task["workerType"],
        }

        self.queue.createTask(task_id, task)

        return task_id