Skip to content

seed

django_spire.knowledge.seeding.seed

parent_collections = CollectionSeeder.seed_database(count=5) module-attribute

child_collections = CollectionSeeder.seed_child_collections(count=15) module-attribute

CollectionSeeder

Bases: DjangoModelSeeder

model_class = models.Collection class-attribute instance-attribute

fields = {'id': 'exclude', 'parent': 'exclude', 'name': ('llm', 'A name for a collection of documents. Make it fun and give it a theme'), 'description': ('llm', 'Short description on the what the documents are about, keep it related to the name.')} class-attribute instance-attribute

seed_child_collections classmethod

Source code in django_spire/knowledge/collection/seeding/seeder.py
@classmethod
def seed_child_collections(cls, count: int = 1) -> list[models.Collection]:
    return cls._correct_order(
        cls.seed_database(
            count=count,
            fields=cls.fields | {
                'parent_id': ('custom', 'fk_random', {'model_class': models.Collection})
            },
        )
    )

EntrySeeder

Bases: DjangoModelSeeder

model_class = models.Entry class-attribute instance-attribute

cache_name = 'entry_seeder' class-attribute instance-attribute

fields = {'id': 'exclude', 'current_version': 'exclude', 'collection_id': ('custom', 'fk_random', {'model_class': Collection}), 'name': ('llm', 'A name for a document. Make it fun and give it a theme')} class-attribute instance-attribute

seed_database classmethod

Source code in django_spire/knowledge/entry/seeding/seeder.py
@classmethod
def seed_database(
        cls,
        count: int = 1,
        fields: dict | None = None
) -> list[models.Entry]:
    entries = super().seed_database(
        count=count,
        fields=fields
    )

    cls._correct_order(entries)
    return cls._set_current_version(entries=entries, count=count)