Clean up and refactor demographics collection#40
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
This PR streamlines basic demographics collection in KLibs ahead of larger changes to the participant initialization and demographics code (code versioning rewrite, multisession). This is largely based on the earlier commits in #31, with some additional cleanup and tests.
The biggest functional change is that behaviour is now less surprising when the participant columns in the database and the defined user queries are out of sync (column added without a query or query added without a column). Demographics collection will now check that every required column in the
participantstable (i.e. every non-internal column that'sNOT NULLand/or lacks a default value) has a corresponding query and will immediately raise an informative error immediately if any are missing (would previously only fail at the end of demographics collection). Conversely, if a query has been defined that doesn't have a corresponding column in theparticipantstable, it will be skipped over and a warning will be printed to the console.Another change is that the query for the participant's unique identifier is now guaranteed to always be asked first, which is necessary for future multisession support.
This PR also ensures that the participant has been initialized in the database prior to the start of the first block (otherwise trial data can't be logged), and additionally ensures that
collect_demographicsisn't called more than once (e.g. called manually in the code butP.manual_demographics_collectionwasn't enabled so it gets called again).Usage of the deprecated EntryTemplate class has been removed for simplicity, leaving trial logging as the only part of KLibs where it's still used.
Merge Checklist
closes #<issue-number>to automatically close an issue