Skip to content

The platform for continuously improving AI agents.

1.0 KB
Raw Blame
import json

from django.core.management.base import BaseCommand, CommandError

from overbae.models import Project
from overbae.services import context_graph


class Command(BaseCommand):
    help = "Project retained platform records into the shared context graph. Starts no work."

    def add_arguments(self, parser):
        selection = parser.add_mutually_exclusive_group(required=True)
        selection.add_argument("--project", action="append", dest="projects")
        selection.add_argument("--all-projects", action="store_true")

    def handle(self, *args, **options):
        projects = Project.objects.order_by("pk")
        if options["projects"]:
            projects = projects.filter(pk__in=options["projects"])
            if projects.count() != len(set(options["projects"])):
                raise CommandError("At least one selected project does not exist in this database")
        for project in projects.iterator():
            self.stdout.write(json.dumps(context_graph.refresh(project), default=str))