Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeder improvements #324

Merged
merged 4 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
PUID=1000
PGID=1000
TZ=Europe/Brussels
FIXTURE=small

# File directories
DATA_DIR="./data"
Expand Down
2 changes: 1 addition & 1 deletion backend/api/fixtures/large/large.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/api/fixtures/medium/medium.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/api/fixtures/small/small.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"model": "api.course", "pk": 1, "fields": {"name": "Reduced didactic methodology", "academic_startyear": 2024, "description": "This great generation mouth sure case memory.", "faculty": "Economie_Bedrijfskunde", "parent_course": null}}, {"model": "api.course", "pk": 2, "fields": {"name": "Ameliorated intermediate analyzer", "academic_startyear": 2023, "description": "Of together finish possible. Art rule court stage watch campaign. Professor you over throw yet site.", "faculty": "Farmaceutische_Wetenschappen", "parent_course": null}}, {"model": "api.course", "pk": 3, "fields": {"name": "Synergized holistic concept", "academic_startyear": 2023, "description": "Term hand everybody he. Thousand peace heart financial history into successful.", "faculty": "Psychologie_PedagogischeWetenschappen", "parent_course": null}}, {"model": "api.project", "pk": 1, "fields": {"name": "Enterprise-wide maximized interface", "description": "Property nation discussion peace eight economic break conference. May now almost.", "visible": false, "archived": false, "locked_groups": true, "start_date": "2024-05-03T11:09:05.408Z", "deadline": "2024-04-21T11:09:05.408Z", "max_score": 97, "score_visible": true, "group_size": 13, "course": 2}}, {"model": "api.project", "pk": 2, "fields": {"name": "Universal well-modulated instruction set", "description": "Lot discover watch single happen again energy defense. Either wait letter.", "visible": true, "archived": false, "locked_groups": true, "start_date": "2024-03-11T11:09:05.408Z", "deadline": "2024-05-31T11:09:05.408Z", "max_score": 43, "score_visible": true, "group_size": 2, "course": 1}}, {"model": "api.project", "pk": 3, "fields": {"name": "Function-based value-added challenge", "description": "Dog include to school interview any. Issue newspaper general quickly organization.", "visible": true, "archived": false, "locked_groups": false, "start_date": "2024-02-16T11:09:05.408Z", "deadline": "2024-05-22T11:09:05.408Z", "max_score": 10, "score_visible": false, "group_size": 11, "course": 2}}, {"model": "api.project", "pk": 4, "fields": {"name": "Progressive global throughput", "description": "Before project theory down money area maybe. Drug raise of purpose guy shoulder. Goal include just fill just ten.", "visible": true, "archived": false, "locked_groups": false, "start_date": "2024-06-29T11:09:05.408Z", "deadline": "2024-07-14T11:09:05.408Z", "max_score": 90, "score_visible": false, "group_size": 7, "course": 2}}, {"model": "api.student", "pk": "0", "fields": {"is_active": true, "student_id": "0", "courses": [1]}}, {"model": "api.student", "pk": "1", "fields": {"is_active": true, "student_id": "1", "courses": [1]}}, {"model": "api.student", "pk": "2", "fields": {"is_active": true, "student_id": "2", "courses": [1]}}, {"model": "api.student", "pk": "3", "fields": {"is_active": true, "student_id": "3", "courses": [1]}}, {"model": "api.student", "pk": "4", "fields": {"is_active": true, "student_id": "4", "courses": [1]}}, {"model": "api.student", "pk": "5", "fields": {"is_active": true, "student_id": "5", "courses": [1]}}, {"model": "api.student", "pk": "6", "fields": {"is_active": true, "student_id": "6", "courses": [1]}}, {"model": "api.student", "pk": "7", "fields": {"is_active": true, "student_id": "7", "courses": [1]}}, {"model": "api.student", "pk": "8", "fields": {"is_active": true, "student_id": "8", "courses": [1]}}, {"model": "api.student", "pk": "9", "fields": {"is_active": true, "student_id": "9", "courses": [1]}}, {"model": "api.group", "pk": 1, "fields": {"project": 4, "score": 29.0, "students": []}}, {"model": "api.group", "pk": 2, "fields": {"project": 1, "score": 96.0, "students": []}}, {"model": "api.group", "pk": 3, "fields": {"project": 2, "score": 0.0, "students": ["0", "2", "3", "5", "8", "9"]}}, {"model": "api.group", "pk": 4, "fields": {"project": 1, "score": 82.0, "students": ["4", "6", "7"]}}, {"model": "api.group", "pk": 5, "fields": {"project": 3, "score": 5.0, "students": []}}, {"model": "api.group", "pk": 6, "fields": {"project": 1, "score": 64.0, "students": ["1"]}}, {"model": "api.group", "pk": 7, "fields": {"project": 2, "score": 25.0, "students": []}}, {"model": "api.assistant", "pk": "10", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.assistant", "pk": "11", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.assistant", "pk": "12", "fields": {"is_active": true, "courses": [2]}}, {"model": "api.assistant", "pk": "13", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.assistant", "pk": "14", "fields": {"is_active": true, "courses": [2]}}, {"model": "api.teacher", "pk": "15", "fields": {"is_active": true, "courses": [2]}}, {"model": "api.teacher", "pk": "16", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.teacher", "pk": "17", "fields": {"is_active": true, "courses": [1]}}]
[{"model": "api.dockerimage", "pk": 1, "fields": {"name": "far.gif", "file": "/population/huge/other/identify", "owner": "15", "public": true}}, {"model": "api.dockerimage", "pk": 2, "fields": {"name": "heart.gif", "file": "/treat/enjoy", "owner": "4", "public": true}}, {"model": "api.dockerimage", "pk": 3, "fields": {"name": "price.tiff", "file": "/thus/teacher/heart", "owner": "15", "public": true}}, {"model": "api.dockerimage", "pk": 4, "fields": {"name": "strategy.jpg", "file": "/always/a/born/wonder/yes", "owner": "12", "public": true}}, {"model": "api.dockerimage", "pk": 5, "fields": {"name": "religious.bmp", "file": "/every/great/whom", "owner": "10", "public": true}}, {"model": "api.fileextension", "pk": 1, "fields": {"extension": "bmp"}}, {"model": "api.fileextension", "pk": 2, "fields": {"extension": "gif"}}, {"model": "api.fileextension", "pk": 3, "fields": {"extension": "xls"}}, {"model": "api.fileextension", "pk": 4, "fields": {"extension": "mp4"}}, {"model": "api.fileextension", "pk": 5, "fields": {"extension": "wav"}}, {"model": "api.course", "pk": 1, "fields": {"name": "Stand-alone incremental function", "academic_startyear": 2024, "description": "Perform draw exactly they. Learn fact find read lay include.", "faculty": "Ingenieurswetenschappen_Architectuur", "parent_course": null}}, {"model": "api.course", "pk": 2, "fields": {"name": "Universal client-driven architecture", "academic_startyear": 2025, "description": "Peace sound shake ever current give.", "faculty": "Letteren_Wijsbegeerte", "parent_course": null}}, {"model": "api.course", "pk": 3, "fields": {"name": "Adaptive system-worthy instruction set", "academic_startyear": 2023, "description": "Wait specific new consider. Get natural early step their third there. A resource green follow mother.", "faculty": "Bio-ingenieurswetenschappen", "parent_course": null}}, {"model": "api.project", "pk": 1, "fields": {"name": "Organized grid-enabled analyzer", "description": "Process leave character improve almost something western. Character cut remain energy prepare political.", "visible": true, "archived": false, "locked_groups": false, "start_date": "2024-03-12T21:31:28.243Z", "deadline": "2024-05-22T21:31:28.243Z", "max_score": 72, "score_visible": false, "group_size": 15, "course": 1}}, {"model": "api.project", "pk": 2, "fields": {"name": "Front-line system-worthy database", "description": "Every stand memory machine culture expect reduce record. Actually because happy again admit. Serious feel property accept century up.", "visible": true, "archived": false, "locked_groups": true, "start_date": "2024-01-18T21:31:28.243Z", "deadline": "2024-06-22T21:31:28.243Z", "max_score": 47, "score_visible": true, "group_size": 9, "course": 3}}, {"model": "api.project", "pk": 3, "fields": {"name": "Integrated encompassing utilization", "description": "Area detail ahead win. Civil according she peace something front that lot. None food none structure want will.", "visible": true, "archived": false, "locked_groups": false, "start_date": "2024-01-19T21:31:28.243Z", "deadline": "2024-07-06T21:31:28.243Z", "max_score": 75, "score_visible": true, "group_size": 3, "course": 1}}, {"model": "api.project", "pk": 4, "fields": {"name": "De-engineered interactive info-mediaries", "description": "Central pull boy address feel recognize eat. Couple radio glass special free. Ago present air doctor husband worker beat attention. Like fight data lose south same summer population.", "visible": true, "archived": false, "locked_groups": false, "start_date": "2024-05-25T21:31:28.243Z", "deadline": "2024-06-22T21:31:28.243Z", "max_score": 50, "score_visible": false, "group_size": 13, "course": 2}}, {"model": "api.structurecheck", "pk": 0, "fields": {"name": "/go/hear/believe/role/alone/determine", "project": 3, "obligated_extensions": [2, 3, 4], "blocked_extensions": [4]}}, {"model": "api.structurecheck", "pk": 1, "fields": {"name": "/enough/model/station", "project": 3, "obligated_extensions": [3], "blocked_extensions": [2, 3, 5]}}, {"model": "api.extracheck", "pk": 1, "fields": {"project": 4, "docker_image": 1, "file": "/concern/energy/trouble/kitchen/suggest", "timeout": 276, "show_log": true}}, {"model": "api.student", "pk": "0", "fields": {"is_active": true, "student_id": "0", "courses": [1]}}, {"model": "api.student", "pk": "1", "fields": {"is_active": true, "student_id": "1", "courses": [1]}}, {"model": "api.student", "pk": "2", "fields": {"is_active": true, "student_id": "2", "courses": [1]}}, {"model": "api.student", "pk": "3", "fields": {"is_active": true, "student_id": "3", "courses": [1]}}, {"model": "api.student", "pk": "4", "fields": {"is_active": true, "student_id": "4", "courses": [1]}}, {"model": "api.student", "pk": "5", "fields": {"is_active": true, "student_id": "5", "courses": [1]}}, {"model": "api.student", "pk": "6", "fields": {"is_active": true, "student_id": "6", "courses": [1]}}, {"model": "api.student", "pk": "7", "fields": {"is_active": true, "student_id": "7", "courses": [1]}}, {"model": "api.student", "pk": "8", "fields": {"is_active": true, "student_id": "8", "courses": [1]}}, {"model": "api.student", "pk": "9", "fields": {"is_active": true, "student_id": "9", "courses": [1]}}, {"model": "api.group", "pk": 1, "fields": {"project": 3, "score": 50.0, "students": []}}, {"model": "api.group", "pk": 2, "fields": {"project": 1, "score": 8.0, "students": ["0", "1", "4", "5"]}}, {"model": "api.group", "pk": 3, "fields": {"project": 1, "score": 7.0, "students": ["2", "3", "6", "7"]}}, {"model": "api.group", "pk": 4, "fields": {"project": 2, "score": 5.0, "students": []}}, {"model": "api.group", "pk": 5, "fields": {"project": 3, "score": 18.0, "students": []}}, {"model": "api.group", "pk": 6, "fields": {"project": 1, "score": 66.0, "students": []}}, {"model": "api.group", "pk": 7, "fields": {"project": 1, "score": 34.0, "students": ["8", "9"]}}, {"model": "api.submission", "pk": 1, "fields": {"group": 1, "submission_number": null, "submission_time": "2024-04-03T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 2, "fields": {"group": 5, "submission_number": null, "submission_time": "2024-04-06T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 3, "fields": {"group": 6, "submission_number": null, "submission_time": "2024-04-15T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 4, "fields": {"group": 1, "submission_number": null, "submission_time": "2024-04-11T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 5, "fields": {"group": 7, "submission_number": null, "submission_time": "2024-04-09T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 6, "fields": {"group": 6, "submission_number": null, "submission_time": "2024-04-07T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 7, "fields": {"group": 3, "submission_number": null, "submission_time": "2024-04-12T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 8, "fields": {"group": 4, "submission_number": null, "submission_time": "2024-04-05T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 9, "fields": {"group": 5, "submission_number": null, "submission_time": "2024-04-09T00:00:00Z", "is_valid": true}}, {"model": "api.submission", "pk": 10, "fields": {"group": 6, "submission_number": null, "submission_time": "2024-04-04T00:00:00Z", "is_valid": true}}, {"model": "api.submissionfile", "pk": 1, "fields": {"submission": 10, "file": "/unit/political/training/control.jpg"}}, {"model": "api.checkresult", "pk": 289528, "fields": {"polymorphic_ctype": null, "submission": 9, "result": "FAILED", "error_message": "OBLIGATED_EXTENSION_NOT_FOUND"}}, {"model": "api.checkresult", "pk": 331891, "fields": {"polymorphic_ctype": null, "submission": 4, "result": "QUEUED", "error_message": null}}, {"model": "api.checkresult", "pk": 482730, "fields": {"polymorphic_ctype": null, "submission": 2, "result": "RUNNING", "error_message": null}}, {"model": "api.checkresult", "pk": 753267, "fields": {"polymorphic_ctype": null, "submission": 1, "result": "SUCCESS", "error_message": null}}, {"model": "api.checkresult", "pk": 762341, "fields": {"polymorphic_ctype": null, "submission": 2, "result": "FAILED", "error_message": "BLOCKED_EXTENSION"}}, {"model": "api.checkresult", "pk": 879866, "fields": {"polymorphic_ctype": null, "submission": 4, "result": "RUNNING", "error_message": null}}, {"model": "api.checkresult", "pk": 899073, "fields": {"polymorphic_ctype": null, "submission": 9, "result": "SUCCESS", "error_message": null}}, {"model": "api.checkresult", "pk": 906214, "fields": {"polymorphic_ctype": null, "submission": 1, "result": "QUEUED", "error_message": null}}, {"model": "api.structurecheckresult", "pk": 289528, "fields": {"structure_check": 1}}, {"model": "api.structurecheckresult", "pk": 331891, "fields": {"structure_check": 0}}, {"model": "api.structurecheckresult", "pk": 482730, "fields": {"structure_check": 0}}, {"model": "api.structurecheckresult", "pk": 753267, "fields": {"structure_check": 0}}, {"model": "api.structurecheckresult", "pk": 762341, "fields": {"structure_check": 1}}, {"model": "api.structurecheckresult", "pk": 879866, "fields": {"structure_check": 1}}, {"model": "api.structurecheckresult", "pk": 899073, "fields": {"structure_check": 0}}, {"model": "api.structurecheckresult", "pk": 906214, "fields": {"structure_check": 1}}, {"model": "api.assistant", "pk": "10", "fields": {"is_active": true, "courses": [2]}}, {"model": "api.assistant", "pk": "11", "fields": {"is_active": true, "courses": [2]}}, {"model": "api.assistant", "pk": "12", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.assistant", "pk": "13", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.assistant", "pk": "14", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.teacher", "pk": "15", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.teacher", "pk": "16", "fields": {"is_active": true, "courses": [1]}}, {"model": "api.teacher", "pk": "17", "fields": {"is_active": true, "courses": [2]}}]
46 changes: 41 additions & 5 deletions backend/api/management/commands/seed_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
from api.models.group import Group
from api.models.project import Project
from api.models.student import Student
from api.models.submission import Submission
from api.models.teacher import Teacher
from api.seeders.faker import faker
from api.seeders.seeder import (fillFaculties, seed_assistants, seed_courses,
seed_groups, seed_projects, seed_students,
seed_submissions, seed_teachers)
from authentication.models import Faculty, User
seed_docker_images, seed_extra_checks,
seed_file_extensions, seed_groups,
seed_projects, seed_structure_checks,
seed_students, seed_submission_files,
seed_submission_results, seed_submissions,
seed_teachers)
from authentication.models import User
from django.core.management import call_command
from django.core.management.base import BaseCommand

Expand Down Expand Up @@ -109,23 +112,38 @@ def handle(self, *args, **options):
amount_of_courses = 3
amount_of_projects = 4
amount_of_groups = 7
amount_of_file_extensions = 5
amount_of_docker_images = 5
amount_of_structure_checks = 2
amount_of_extra_checks = 1
amount_of_submissions = 10
amount_of_submission_files = 20
elif size == "medium":
amount_of_students = 5_000
amount_of_assistants = 500
amount_of_teachers = 250
amount_of_courses = 250
amount_of_projects = 500
amount_of_groups = 500
amount_of_file_extensions = 32 # Max amount of file extensions in Faker
amount_of_docker_images = 50
amount_of_structure_checks = 250
amount_of_extra_checks = 125
amount_of_submissions = 500
amount_of_submission_files = 1_000
elif size == "large":
amount_of_students = 50_000
amount_of_assistants = 5_000
amount_of_teachers = 1_500
amount_of_courses = 1_500
amount_of_projects = 3_000
amount_of_groups = 3_000
amount_of_file_extensions = 32 # Max amount of file extensions in Faker
amount_of_docker_images = 50
amount_of_structure_checks = 1_500
amount_of_extra_checks = 750
amount_of_submissions = 3_000
amount_of_submission_files = 6_000
else:
self.stdout.write(self.style.ERROR("give a size from small, medium or large!"))
return
Expand All @@ -137,7 +155,7 @@ def handle(self, *args, **options):
# Seed students
fake = faker()
start_time = time.time()
seed_students(fake, amount_of_students, 0)
seed_students(fake, amount_of_students)

# Seed assistants
seed_assistants(fake, amount_of_assistants, amount_of_students)
Expand All @@ -154,9 +172,27 @@ def handle(self, *args, **options):
# Seed groups
seed_groups(faker(), amount_of_groups)

# Seed file extensions
seed_file_extensions(faker(), amount_of_file_extensions)

# Seed docker images
seed_docker_images(faker(), amount_of_docker_images)

# Seed structure checks
seed_structure_checks(faker(), amount_of_structure_checks)

# Seed extra checks
seed_extra_checks(faker(), amount_of_extra_checks)

# Seed submissions
seed_submissions(faker(), amount_of_submissions)

# Seed submission files
seed_submission_files(faker(), amount_of_submission_files)

# Seed submission results
seed_submission_results(faker())

end_time = time.time()
execution_time = end_time - start_time
self.stdout.write(self.style.SUCCESS(f"Successfully seeded db in {format_time(execution_time)}!"))
Loading
Loading