-
Notifications
You must be signed in to change notification settings - Fork 709
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
Fixture generation utilities #9652
Conversation
Build Artifacts
|
…auth,lessons and exams apps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments inline in the code. After testing the command I've seen these issues too:
-
In
generate_auth_data
lessons and exams are always assigned to one single classroom , even if there are multiple -
kolibri manage generate_auth_data --mode=default_db --groups=5 --class_exams=3 --class_lessons=5 --classes=4
creates 2 classes instead of 4 -
In
generate_content_data
level=3 produces 400 topics and 2401 nodes, can you explain this number? becausekolibri manage generate_content_data --mode=default_db --levels=5
seems to be an infinite loop -
In
generate_content_data
only video and topics are created, no other kinds -
One test is failing in
generate_auth_data.py
, line 332, because you're trying to unpack one list inside a list with the*
operator, that only works with functions -
Creating the fixtures does not work because it looks for an unexisting directory:
start dumping fixtures for content app
CommandError: Unable to serialize database: [Errno 2] No such file or directory: 'fixtures/all_content_data.json'
Two separate comments:
- you've created the PR using your
develop
branch. It's better if you create a different branch in your repository and create the PR from it, doing that way is much easier for you to do rebase if needed, and work on several issues at the same time. - when filling a PR is good to follow the provided template , in particular the "reviewing guidance" is helpful when reviewing code that can be complex. Beware that many PR are reviewed by QA people who don't need to be developers. It's good to provide instructions on how to test and what to test.
kolibri/core/content/management/commands/generate_content_data.py
Outdated
Show resolved
Hide resolved
i tested 2 classes and 5 lessons for each it it was working! |
…h, lessons and exams apps
…h, lessons and exams apps
…ee of only that resource_kidn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @abdelrahman725 ,
code for the two first commands look good and seem to work properly.
But generate_interactions.py
does not, just executing it without any args, it fails with
File "/datos/le/mio/kolibri/kolibri/core/logger/management/commands/generate_interactions.py", line 369, in generate_interactions
generate_visitor_content_session_logs(
File "/datos/le/mio/kolibri/kolibri/core/logger/management/commands/generate_interactions.py", line 280, in generate_visitor_content_session_logs
generate_content_session_log(
File "/datos/le/mio/kolibri/kolibri/core/logger/management/commands/generate_interactions.py", line 200, in generate_content_session_log
return ContentSessionLog.objects.create(
File "/datos/le/mio/kolibri/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/datos/le/mio/kolibri/venv/lib/python3.10/site-packages/django/db/models/query.py", line 394, in create
obj.save(force_insert=True, using=self.db)
File "/datos/le/mio/kolibri/kolibri/core/logger/models.py", line 131, in save
super(ContentSessionLog, self).save(*args, **kwargs)
File "/datos/le/mio/kolibri/kolibri/core/auth/models.py", line 287, in save
self.pre_save()
File "/datos/le/mio/kolibri/kolibri/core/auth/models.py", line 282, in pre_save
self.ensure_dataset()
File "/datos/le/mio/kolibri/kolibri/core/auth/models.py", line 296, in ensure_dataset
inferred_dataset_id = self.infer_dataset(*args, **kwargs)
File "/datos/le/mio/kolibri/kolibri/core/logger/models.py", line 93, in infer_dataset
raise AssertionError("Before you can save logs, you must have a facility")
AssertionError: Before you can save logs, you must have a facility
This has been tested after running the other two commands, so the db has both content and facilities and user, but you forgot to create a device settings, so logs can not find the default faciity of the system when adding a visitor that has not facility associated.
So, in generate_auth_data.py
https://github.com/learningequality/kolibri/blob/develop/kolibri/core/device/utils.py#L93 needs to be executed
OTOH, as this PR is going to be converted into documentation for these commands, it would be good to add the default values for each of the different params the commands have. This is not a blocker anyway.
@abdelrahman725 I can confirm that using
at the end of the |
Superseded by #11859 |
GSoC Work Summary
created 3 python scripts for generating all relevant data for the following apps models
Goal
before
Kolibri was lacking authentic testing data which should represent real usage scenarios, existing data generation utilities are run during unit test runtime making them not so efficient
after
new scripts that can generate authentic data ( for models of apps specefied above ) that are representable of real Kolibri data taking in account most use cases and scenarios with the ability of being deterministic i.e. developers can choose and specify what exact data to produce (e.g. range/number of data, what fields to include) depending on the current testing scenario requirements, ability to dump these generated data into fixtures
.json files
to be used directly in unit testingFeatures
to do ..
Usage
run
kolibri manage (script_name)
with or without argumentswhere
script_name
can be :generate_content_data
for content app--channels
number of channels treesdefault 1
--levels
number of channel tree levelsdefault 2
--children
how many children for each parent node ( of kindtopic
)default 3
--resources_kind
kind of resourcesdefault random
generate_auth_data
for kolibriauth, lessons and exams apps--facilities
number of facilitiesdefault 1
--not_assigned_users
number of facility users that are not assigned to any collectiondefault 5
--admins
number of facility adminsdefault 1
--coaches
number of facility coachesdefault 1
--classes
number of classesdefault 2
--class_coaches
number of class coachesdefault 1
--class_learners
number of class learnersdefault 20
--class_lessons
number of class lessonsdefault 3
--class_exams
number of classdefault 3
--groups
number of groups per classdefault 1
--group_members
number of group membersdefault 5
--adhoc_lessons
number of lessons assigned for specific learnersdefault 0
--adhoc_lesson_learners
number of adhoc_lesson learnersdefault 0
--adhoc_exams
number of exams assigned for specific learnersdefault 0
--adhoc_exams_learners
number of adhoc_exam learnersdefault 0
generate_interactions
for logger app--users
number of authenticated usersdefault 20
--visitors
number of anonymous usersdefault 5
--start_time
Minimum start_timstamp for all logsdefault 2022-01-01
--end_time
Maximum end_timstamp for all logsdefault current run time
--session
kolibri user session duration (in mins >=15 )default 15
--n_sessions
number of user sessions in kolibri (not used yet)--n_resources
how many resources should each user interact with (not used yet)shared arguments
--mode
generated data destination ( json file as fixtures or saved in local db)default default_db
--seed
random seed value, so all operations can be randomized predictablydefault 1
--fixtures_path
fixtures file pathTesting checklist
PR process
Reviewer checklist
yarn
andpip
)