hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
⌀
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
8a1dc5ceeb00e396702b8dacc06fcdc8dbdacc57
bbt-t/simple-bot_discord
handlers/all_handlers.py
[ "MIT" ]
Python
on_member_join
null
async def on_member_join(member): """ Registration of a new user in the DB. :param member: user-object :return: greeting to PM """ db.add_user(user_id=member.id, name=member.name, reg_time=time_now.date()) await member.send(embed=Embed(description=f'Привееет {member.name}! Рад тебя видеть!\n...
Registration of a new user in the DB. :param member: user-object :return: greeting to PM
Registration of a new user in the DB.
[ "Registration", "of", "a", "new", "user", "in", "the", "DB", "." ]
async def on_member_join(member): db.add_user(user_id=member.id, name=member.name, reg_time=time_now.date()) await member.send(embed=Embed(description=f'Привееет {member.name}! Рад тебя видеть!\n' f'На этом сервере я тебе буду помогать, пиши ``!info`` чтобы посмотре...
[ "async", "def", "on_member_join", "(", "member", ")", ":", "db", ".", "add_user", "(", "user_id", "=", "member", ".", "id", ",", "name", "=", "member", ".", "name", ",", "reg_time", "=", "time_now", ".", "date", "(", ")", ")", "await", "member", ".",...
Registration of a new user in the DB.
[ "Registration", "of", "a", "new", "user", "in", "the", "DB", "." ]
[ "\"\"\"\n Registration of a new user in the DB.\n :param member: user-object\n :return: greeting to PM\n \"\"\"" ]
[ { "param": "member", "type": null } ]
{ "returns": [ { "docstring": "greeting to PM", "docstring_tokens": [ "greeting", "to", "PM" ], "type": null } ], "raises": [], "params": [ { "identifier": "member", "type": null, "docstring": null, "docstring_tokens": [ ...
e44005a655d6d40187fd36f3b5830d29ca70cc70
Newbas/beiwe-backend
libs/file_processing/data_qty_stats.py
[ "BSD-3-Clause" ]
Python
calculate_data_quantity_stats
null
def calculate_data_quantity_stats( participant: Participant, earliest_time_bin_number: Optional[int] = None, latest_time_bin_number: Optional[int] = None, ): """ Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data earliest_time_bin_number -- expressed in h...
Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data earliest_time_bin_number -- expressed in hours since 1/1/1970 latest_time_bin_number -- expressed in hours since 1/1/1970
Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data earliest_time_bin_number -- expressed in hours since 1/1/1970 latest_time_bin_number -- expressed in hours since 1/1/1970
[ "Update", "the", "SummaryStatisticDaily", "stats", "for", "a", "participant", "using", "ChunkRegistry", "data", "earliest_time_bin_number", "--", "expressed", "in", "hours", "since", "1", "/", "1", "/", "1970", "latest_time_bin_number", "--", "expressed", "in", "hou...
def calculate_data_quantity_stats( participant: Participant, earliest_time_bin_number: Optional[int] = None, latest_time_bin_number: Optional[int] = None, ): study_timezone = participant.study.timezone query = ChunkRegistry.objects.filter(participant=participant) if earliest_time_bin...
[ "def", "calculate_data_quantity_stats", "(", "participant", ":", "Participant", ",", "earliest_time_bin_number", ":", "Optional", "[", "int", "]", "=", "None", ",", "latest_time_bin_number", ":", "Optional", "[", "int", "]", "=", "None", ",", ")", ":", "study_ti...
Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data earliest_time_bin_number -- expressed in hours since 1/1/1970 latest_time_bin_number -- expressed in hours since 1/1/1970
[ "Update", "the", "SummaryStatisticDaily", "stats", "for", "a", "participant", "using", "ChunkRegistry", "data", "earliest_time_bin_number", "--", "expressed", "in", "hours", "since", "1", "/", "1", "/", "1970", "latest_time_bin_number", "--", "expressed", "in", "hou...
[ "\"\"\" Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data\n earliest_time_bin_number -- expressed in hours since 1/1/1970\n latest_time_bin_number -- expressed in hours since 1/1/1970 \"\"\"", "# Filter by date range", "# Round down to the beginning of the included day, i...
[ { "param": "participant", "type": "Participant" }, { "param": "earliest_time_bin_number", "type": "Optional[int]" }, { "param": "latest_time_bin_number", "type": "Optional[int]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "participant", "type": "Participant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "earliest_time_bin_number", "type": "Optional[int]", ...
6d9ae30dbe6ceb0c1972306297da6fc70a8f58f2
Newbas/beiwe-backend
api/survey_api.py
[ "BSD-3-Clause" ]
Python
update_survey
<not_specific>
def update_survey(survey_id=None): """ Updates the survey when the 'Save & Deploy button on the edit_survey page is hit. Expects content, weekly_timings, absolute_timings, relative_timings, and settings in the request body """ try: survey = Survey.objects.get(pk=survey_id) except ...
Updates the survey when the 'Save & Deploy button on the edit_survey page is hit. Expects content, weekly_timings, absolute_timings, relative_timings, and settings in the request body
Updates the survey when the 'Save & Deploy button on the edit_survey page is hit. Expects content, weekly_timings, absolute_timings, relative_timings, and settings in the request body
[ "Updates", "the", "survey", "when", "the", "'", "Save", "&", "Deploy", "button", "on", "the", "edit_survey", "page", "is", "hit", ".", "Expects", "content", "weekly_timings", "absolute_timings", "relative_timings", "and", "settings", "in", "the", "request", "bod...
def update_survey(survey_id=None): try: survey = Survey.objects.get(pk=survey_id) except Survey.DoesNotExist: return abort(404) json_content = request.values.get('content') content = None if json_content != '""': content = recursive_survey_content_json_decode(json_content) ...
[ "def", "update_survey", "(", "survey_id", "=", "None", ")", ":", "try", ":", "survey", "=", "Survey", ".", "objects", ".", "get", "(", "pk", "=", "survey_id", ")", "except", "Survey", ".", "DoesNotExist", ":", "return", "abort", "(", "404", ")", "json_...
Updates the survey when the 'Save & Deploy button on the edit_survey page is hit.
[ "Updates", "the", "survey", "when", "the", "'", "Save", "&", "Deploy", "button", "on", "the", "edit_survey", "page", "is", "hit", "." ]
[ "\"\"\"\r\n Updates the survey when the 'Save & Deploy button on the edit_survey page is hit. Expects\r\n content, weekly_timings, absolute_timings, relative_timings, and settings in the request body\r\n \"\"\"", "# BUG: There is an unknown situation where the frontend sends a string requiring an extra\r...
[ { "param": "survey_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "survey_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d9ae30dbe6ceb0c1972306297da6fc70a8f58f2
Newbas/beiwe-backend
api/survey_api.py
[ "BSD-3-Clause" ]
Python
recursive_survey_content_json_decode
<not_specific>
def recursive_survey_content_json_decode(json_entity: str): """ Decodes through up to 100 attempts a json entity until it has deserialized to a list. """ count = 100 decoded_json = None while not isinstance(decoded_json, list): count -= 1 if count < 0: raise Exception(...
Decodes through up to 100 attempts a json entity until it has deserialized to a list.
Decodes through up to 100 attempts a json entity until it has deserialized to a list.
[ "Decodes", "through", "up", "to", "100", "attempts", "a", "json", "entity", "until", "it", "has", "deserialized", "to", "a", "list", "." ]
def recursive_survey_content_json_decode(json_entity: str): count = 100 decoded_json = None while not isinstance(decoded_json, list): count -= 1 if count < 0: raise Exception("could not decode json entity to list") decoded_json = json.loads(json_entity) return decoded...
[ "def", "recursive_survey_content_json_decode", "(", "json_entity", ":", "str", ")", ":", "count", "=", "100", "decoded_json", "=", "None", "while", "not", "isinstance", "(", "decoded_json", ",", "list", ")", ":", "count", "-=", "1", "if", "count", "<", "0", ...
Decodes through up to 100 attempts a json entity until it has deserialized to a list.
[ "Decodes", "through", "up", "to", "100", "attempts", "a", "json", "entity", "until", "it", "has", "deserialized", "to", "a", "list", "." ]
[ "\"\"\" Decodes through up to 100 attempts a json entity until it has deserialized to a list. \"\"\"" ]
[ { "param": "json_entity", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "json_entity", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d9ae30dbe6ceb0c1972306297da6fc70a8f58f2
Newbas/beiwe-backend
api/survey_api.py
[ "BSD-3-Clause" ]
Python
make_slider_min_max_values_strings
<not_specific>
def make_slider_min_max_values_strings(json_content): """ Turns min/max int values into strings, because the iOS app expects strings. This is for backwards compatibility; when all the iOS apps involved in studies can handle ints, we can remove this function. """ for question in json_content: ...
Turns min/max int values into strings, because the iOS app expects strings. This is for backwards compatibility; when all the iOS apps involved in studies can handle ints, we can remove this function.
Turns min/max int values into strings, because the iOS app expects strings. This is for backwards compatibility; when all the iOS apps involved in studies can handle ints, we can remove this function.
[ "Turns", "min", "/", "max", "int", "values", "into", "strings", "because", "the", "iOS", "app", "expects", "strings", ".", "This", "is", "for", "backwards", "compatibility", ";", "when", "all", "the", "iOS", "apps", "involved", "in", "studies", "can", "han...
def make_slider_min_max_values_strings(json_content): for question in json_content: if 'max' in question: question['max'] = str(question['max']) if 'min' in question: question['min'] = str(question['min']) return json_content
[ "def", "make_slider_min_max_values_strings", "(", "json_content", ")", ":", "for", "question", "in", "json_content", ":", "if", "'max'", "in", "question", ":", "question", "[", "'max'", "]", "=", "str", "(", "question", "[", "'max'", "]", ")", "if", "'min'",...
Turns min/max int values into strings, because the iOS app expects strings.
[ "Turns", "min", "/", "max", "int", "values", "into", "strings", "because", "the", "iOS", "app", "expects", "strings", "." ]
[ "\"\"\" Turns min/max int values into strings, because the iOS app expects strings. This is for\r\n backwards compatibility; when all the iOS apps involved in studies can handle ints,\r\n we can remove this function. \"\"\"" ]
[ { "param": "json_content", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "json_content", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b05db02c96cc08d1fc5438e18d689711bd8c807
Newbas/beiwe-backend
api/tableau_api/web_data_connector.py
[ "BSD-3-Clause" ]
Python
register_urls
null
def register_urls(cls, app): """ Register this class' URLs with Flask """ app.add_url_rule(cls.path, view_func=cls.as_view("web_data_connector_view"))
Register this class' URLs with Flask
Register this class' URLs with Flask
[ "Register", "this", "class", "'", "URLs", "with", "Flask" ]
def register_urls(cls, app): app.add_url_rule(cls.path, view_func=cls.as_view("web_data_connector_view"))
[ "def", "register_urls", "(", "cls", ",", "app", ")", ":", "app", ".", "add_url_rule", "(", "cls", ".", "path", ",", "view_func", "=", "cls", ".", "as_view", "(", "\"web_data_connector_view\"", ")", ")" ]
Register this class' URLs with Flask
[ "Register", "this", "class", "'", "URLs", "with", "Flask" ]
[ "\"\"\"\n Register this class' URLs with Flask\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "app", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "app", "type": null, "docstring": null, "docstring_tokens": [],...
4ccdeeadaba62f2ae5bf19d998bbc5bd3cb74b90
Newbas/beiwe-backend
database/data_access_models.py
[ "BSD-3-Clause" ]
Python
update_registered_unchunked_data
null
def update_registered_unchunked_data(cls, data_type, chunk_path, file_contents): """ Updates the data in case a user uploads an unchunkable file more than once, and updates the file size just in case it changed. """ if data_type in CHUNKABLE_FILES: raise ChunkableDataTypeError ...
Updates the data in case a user uploads an unchunkable file more than once, and updates the file size just in case it changed.
Updates the data in case a user uploads an unchunkable file more than once, and updates the file size just in case it changed.
[ "Updates", "the", "data", "in", "case", "a", "user", "uploads", "an", "unchunkable", "file", "more", "than", "once", "and", "updates", "the", "file", "size", "just", "in", "case", "it", "changed", "." ]
def update_registered_unchunked_data(cls, data_type, chunk_path, file_contents): if data_type in CHUNKABLE_FILES: raise ChunkableDataTypeError chunk = cls.objects.get(chunk_path=chunk_path) chunk.file_size = len(file_contents) chunk.save()
[ "def", "update_registered_unchunked_data", "(", "cls", ",", "data_type", ",", "chunk_path", ",", "file_contents", ")", ":", "if", "data_type", "in", "CHUNKABLE_FILES", ":", "raise", "ChunkableDataTypeError", "chunk", "=", "cls", ".", "objects", ".", "get", "(", ...
Updates the data in case a user uploads an unchunkable file more than once, and updates the file size just in case it changed.
[ "Updates", "the", "data", "in", "case", "a", "user", "uploads", "an", "unchunkable", "file", "more", "than", "once", "and", "updates", "the", "file", "size", "just", "in", "case", "it", "changed", "." ]
[ "\"\"\" Updates the data in case a user uploads an unchunkable file more than once,\r\n and updates the file size just in case it changed. \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "data_type", "type": null }, { "param": "chunk_path", "type": null }, { "param": "file_contents", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data_type", "type": null, "docstring": null, "docstring_tokens...
4ccdeeadaba62f2ae5bf19d998bbc5bd3cb74b90
Newbas/beiwe-backend
database/data_access_models.py
[ "BSD-3-Clause" ]
Python
normalize_s3_file_path
<not_specific>
def normalize_s3_file_path(file_path: str, study_object_id: str): """ whatever the reason for this file path transform is has been lost to the mists of time. We force the start of the path to the object id string of the study. """ if file_path[:24] == study_object_id: return ...
whatever the reason for this file path transform is has been lost to the mists of time. We force the start of the path to the object id string of the study.
whatever the reason for this file path transform is has been lost to the mists of time. We force the start of the path to the object id string of the study.
[ "whatever", "the", "reason", "for", "this", "file", "path", "transform", "is", "has", "been", "lost", "to", "the", "mists", "of", "time", ".", "We", "force", "the", "start", "of", "the", "path", "to", "the", "object", "id", "string", "of", "the", "stud...
def normalize_s3_file_path(file_path: str, study_object_id: str): if file_path[:24] == study_object_id: return file_path else: return study_object_id + '/' + file_path
[ "def", "normalize_s3_file_path", "(", "file_path", ":", "str", ",", "study_object_id", ":", "str", ")", ":", "if", "file_path", "[", ":", "24", "]", "==", "study_object_id", ":", "return", "file_path", "else", ":", "return", "study_object_id", "+", "'/'", "+...
whatever the reason for this file path transform is has been lost to the mists of time.
[ "whatever", "the", "reason", "for", "this", "file", "path", "transform", "is", "has", "been", "lost", "to", "the", "mists", "of", "time", "." ]
[ "\"\"\" whatever the reason for this file path transform is has been lost to the mists of time.\r\n We force the start of the path to the object id string of the study. \"\"\"" ]
[ { "param": "file_path", "type": "str" }, { "param": "study_object_id", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file_path", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "study_object_id", "type": "str", "docstring": null, "do...
4ccdeeadaba62f2ae5bf19d998bbc5bd3cb74b90
Newbas/beiwe-backend
database/data_access_models.py
[ "BSD-3-Clause" ]
Python
reprocess_originals_from_chunk_path
null
def reprocess_originals_from_chunk_path(cls, chunk_path): """ Takes a processed file (chunk) s3 path, identifies the original source files, and prepares a FileToProcess entry so that the source data will be re-processed and merged into the existing data. This is mostly a utility func...
Takes a processed file (chunk) s3 path, identifies the original source files, and prepares a FileToProcess entry so that the source data will be re-processed and merged into the existing data. This is mostly a utility function, it was originally part of a script, but it is quite com...
Takes a processed file (chunk) s3 path, identifies the original source files, and prepares a FileToProcess entry so that the source data will be re-processed and merged into the existing data. This is mostly a utility function, it was originally part of a script, but it is quite complex to accomplish, and worth holding...
[ "Takes", "a", "processed", "file", "(", "chunk", ")", "s3", "path", "identifies", "the", "original", "source", "files", "and", "prepares", "a", "FileToProcess", "entry", "so", "that", "the", "source", "data", "will", "be", "re", "-", "processed", "and", "m...
def reprocess_originals_from_chunk_path(cls, chunk_path): path_components = chunk_path.split("/") if len(path_components) != 5: raise Exception("chunked file paths contain exactly 5 components separated by a slash.") chunk_files_text, study_obj_id, username, data_stream, timestamp = ...
[ "def", "reprocess_originals_from_chunk_path", "(", "cls", ",", "chunk_path", ")", ":", "path_components", "=", "chunk_path", ".", "split", "(", "\"/\"", ")", "if", "len", "(", "path_components", ")", "!=", "5", ":", "raise", "Exception", "(", "\"chunked file pat...
Takes a processed file (chunk) s3 path, identifies the original source files, and prepares a FileToProcess entry so that the source data will be re-processed and merged into the existing data.
[ "Takes", "a", "processed", "file", "(", "chunk", ")", "s3", "path", "identifies", "the", "original", "source", "files", "and", "prepares", "a", "FileToProcess", "entry", "so", "that", "the", "source", "data", "will", "be", "re", "-", "processed", "and", "m...
[ "\"\"\" Takes a processed file (chunk) s3 path, identifies the original source files,\r\n and prepares a FileToProcess entry so that the source data will be re-processed\r\n and merged into the existing data.\r\n This is mostly a utility function, it was originally part of a script, but it is\r...
[ { "param": "cls", "type": null }, { "param": "chunk_path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "chunk_path", "type": null, "docstring": null, "docstring_token...
88f28cfa31d06f67bc38785a86abc33d3cea01fd
Newbas/beiwe-backend
pages/system_admin_pages.py
[ "BSD-3-Clause" ]
Python
validate_android_credentials
<not_specific>
def validate_android_credentials(credentials): """Ensure basic formatting and field validation for android firebase credential json file uploads the credentials argument should contain a decoded string of such a file""" try: json_obj = json.dumps(credentials) # keys are inconsistent in prese...
Ensure basic formatting and field validation for android firebase credential json file uploads the credentials argument should contain a decoded string of such a file
Ensure basic formatting and field validation for android firebase credential json file uploads the credentials argument should contain a decoded string of such a file
[ "Ensure", "basic", "formatting", "and", "field", "validation", "for", "android", "firebase", "credential", "json", "file", "uploads", "the", "credentials", "argument", "should", "contain", "a", "decoded", "string", "of", "such", "a", "file" ]
def validate_android_credentials(credentials): try: json_obj = json.dumps(credentials) if "project_info" not in json_obj or "project_id" not in json_obj: return False except Exception: return False return True
[ "def", "validate_android_credentials", "(", "credentials", ")", ":", "try", ":", "json_obj", "=", "json", ".", "dumps", "(", "credentials", ")", "if", "\"project_info\"", "not", "in", "json_obj", "or", "\"project_id\"", "not", "in", "json_obj", ":", "return", ...
Ensure basic formatting and field validation for android firebase credential json file uploads the credentials argument should contain a decoded string of such a file
[ "Ensure", "basic", "formatting", "and", "field", "validation", "for", "android", "firebase", "credential", "json", "file", "uploads", "the", "credentials", "argument", "should", "contain", "a", "decoded", "string", "of", "such", "a", "file" ]
[ "\"\"\"Ensure basic formatting and field validation for android firebase credential json file uploads\n the credentials argument should contain a decoded string of such a file\"\"\"", "# keys are inconsistent in presence, but these should be present in all. (one is structure,", "# one is a critical data poi...
[ { "param": "credentials", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "credentials", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
88f28cfa31d06f67bc38785a86abc33d3cea01fd
Newbas/beiwe-backend
pages/system_admin_pages.py
[ "BSD-3-Clause" ]
Python
validate_ios_credentials
<not_specific>
def validate_ios_credentials(credentials): """Ensure basic formatting and field validation for ios firebase credential plist file uploads the credentials argument should contain a decoded string of such a file""" try: plist_obj = plistlib.loads(str.encode(credentials)) # ios has different ke...
Ensure basic formatting and field validation for ios firebase credential plist file uploads the credentials argument should contain a decoded string of such a file
Ensure basic formatting and field validation for ios firebase credential plist file uploads the credentials argument should contain a decoded string of such a file
[ "Ensure", "basic", "formatting", "and", "field", "validation", "for", "ios", "firebase", "credential", "plist", "file", "uploads", "the", "credentials", "argument", "should", "contain", "a", "decoded", "string", "of", "such", "a", "file" ]
def validate_ios_credentials(credentials): try: plist_obj = plistlib.loads(str.encode(credentials)) if "API_KEY" not in plist_obj: return False except Exception: return False return True
[ "def", "validate_ios_credentials", "(", "credentials", ")", ":", "try", ":", "plist_obj", "=", "plistlib", ".", "loads", "(", "str", ".", "encode", "(", "credentials", ")", ")", "if", "\"API_KEY\"", "not", "in", "plist_obj", ":", "return", "False", "except",...
Ensure basic formatting and field validation for ios firebase credential plist file uploads the credentials argument should contain a decoded string of such a file
[ "Ensure", "basic", "formatting", "and", "field", "validation", "for", "ios", "firebase", "credential", "plist", "file", "uploads", "the", "credentials", "argument", "should", "contain", "a", "decoded", "string", "of", "such", "a", "file" ]
[ "\"\"\"Ensure basic formatting and field validation for ios firebase credential plist file uploads\n the credentials argument should contain a decoded string of such a file\"\"\"", "# ios has different key values than android, and they are somewhat opaque and inconsistently", "# present when generated. Just ...
[ { "param": "credentials", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "credentials", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c0e8d210ab173879e65c2faeb9225d62e3ab3312
Newbas/beiwe-backend
database/schedule_models.py
[ "BSD-3-Clause" ]
Python
create_absolute_schedules
bool
def create_absolute_schedules(timings: List[List[int]], survey: Survey) -> bool: """ Creates new AbsoluteSchedule objects from a frontend-style list of dates and times""" survey.absolute_schedules.all().delete() if survey.deleted or not timings: return False duplicat...
Creates new AbsoluteSchedule objects from a frontend-style list of dates and times
Creates new AbsoluteSchedule objects from a frontend-style list of dates and times
[ "Creates", "new", "AbsoluteSchedule", "objects", "from", "a", "frontend", "-", "style", "list", "of", "dates", "and", "times" ]
def create_absolute_schedules(timings: List[List[int]], survey: Survey) -> bool: survey.absolute_schedules.all().delete() if survey.deleted or not timings: return False duplicated = False for year, month, day, num_seconds in timings: _, created = AbsoluteSchedule....
[ "def", "create_absolute_schedules", "(", "timings", ":", "List", "[", "List", "[", "int", "]", "]", ",", "survey", ":", "Survey", ")", "->", "bool", ":", "survey", ".", "absolute_schedules", ".", "all", "(", ")", ".", "delete", "(", ")", "if", "survey"...
Creates new AbsoluteSchedule objects from a frontend-style list of dates and times
[ "Creates", "new", "AbsoluteSchedule", "objects", "from", "a", "frontend", "-", "style", "list", "of", "dates", "and", "times" ]
[ "\"\"\" Creates new AbsoluteSchedule objects from a frontend-style list of dates and times\"\"\"" ]
[ { "param": "timings", "type": "List[List[int]]" }, { "param": "survey", "type": "Survey" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "timings", "type": "List[List[int]]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "survey", "type": "Survey", "docstring": null, ...
c0e8d210ab173879e65c2faeb9225d62e3ab3312
Newbas/beiwe-backend
database/schedule_models.py
[ "BSD-3-Clause" ]
Python
create_relative_schedules
bool
def create_relative_schedules(timings: List[List[int]], survey: Survey) -> bool: """ Creates new RelativeSchedule objects from a frontend-style list of interventions and times If you modify this please update create_relative_schedules_by_name in libs.copy_study too. """ surv...
Creates new RelativeSchedule objects from a frontend-style list of interventions and times If you modify this please update create_relative_schedules_by_name in libs.copy_study too.
Creates new RelativeSchedule objects from a frontend-style list of interventions and times If you modify this please update create_relative_schedules_by_name in libs.copy_study too.
[ "Creates", "new", "RelativeSchedule", "objects", "from", "a", "frontend", "-", "style", "list", "of", "interventions", "and", "times", "If", "you", "modify", "this", "please", "update", "create_relative_schedules_by_name", "in", "libs", ".", "copy_study", "too", "...
def create_relative_schedules(timings: List[List[int]], survey: Survey) -> bool: survey.relative_schedules.all().delete() if survey.deleted or not timings: return False duplicated = False for intervention_id, days_after, num_seconds in timings: _, created = Relati...
[ "def", "create_relative_schedules", "(", "timings", ":", "List", "[", "List", "[", "int", "]", "]", ",", "survey", ":", "Survey", ")", "->", "bool", ":", "survey", ".", "relative_schedules", ".", "all", "(", ")", ".", "delete", "(", ")", "if", "survey"...
Creates new RelativeSchedule objects from a frontend-style list of interventions and times If you modify this please update create_relative_schedules_by_name in libs.copy_study too.
[ "Creates", "new", "RelativeSchedule", "objects", "from", "a", "frontend", "-", "style", "list", "of", "interventions", "and", "times", "If", "you", "modify", "this", "please", "update", "create_relative_schedules_by_name", "in", "libs", ".", "copy_study", "too", "...
[ "\"\"\"\r\n Creates new RelativeSchedule objects from a frontend-style list of interventions and times\r\n If you modify this please update create_relative_schedules_by_name in libs.copy_study too.\r\n \"\"\"", "# using get_or_create to catch duplicate schedules\r" ]
[ { "param": "timings", "type": "List[List[int]]" }, { "param": "survey", "type": "Survey" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "timings", "type": "List[List[int]]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "survey", "type": "Survey", "docstring": null, ...
c0e8d210ab173879e65c2faeb9225d62e3ab3312
Newbas/beiwe-backend
database/schedule_models.py
[ "BSD-3-Clause" ]
Python
create_weekly_schedules
bool
def create_weekly_schedules(timings: List[List[int]], survey: Survey) -> bool: """ Creates new WeeklySchedule objects from a frontend-style list of seconds into the day. """ if survey.deleted or not timings: survey.weekly_schedules.all().delete() return False # a...
Creates new WeeklySchedule objects from a frontend-style list of seconds into the day.
Creates new WeeklySchedule objects from a frontend-style list of seconds into the day.
[ "Creates", "new", "WeeklySchedule", "objects", "from", "a", "frontend", "-", "style", "list", "of", "seconds", "into", "the", "day", "." ]
def create_weekly_schedules(timings: List[List[int]], survey: Survey) -> bool: if survey.deleted or not timings: survey.weekly_schedules.all().delete() return False if len(timings) != 7: raise Exception( f"Must have schedule for every day of the week, ...
[ "def", "create_weekly_schedules", "(", "timings", ":", "List", "[", "List", "[", "int", "]", "]", ",", "survey", ":", "Survey", ")", "->", "bool", ":", "if", "survey", ".", "deleted", "or", "not", "timings", ":", "survey", ".", "weekly_schedules", ".", ...
Creates new WeeklySchedule objects from a frontend-style list of seconds into the day.
[ "Creates", "new", "WeeklySchedule", "objects", "from", "a", "frontend", "-", "style", "list", "of", "seconds", "into", "the", "day", "." ]
[ "\"\"\" Creates new WeeklySchedule objects from a frontend-style list of seconds into the day. \"\"\"", "# asserts are not bypassed in production. Keep.\r", "# should be all ints, use integer division.\r", "# using get_or_create to catch duplicate schedules\r" ]
[ { "param": "timings", "type": "List[List[int]]" }, { "param": "survey", "type": "Survey" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "timings", "type": "List[List[int]]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "survey", "type": "Survey", "docstring": null, ...
c0e8d210ab173879e65c2faeb9225d62e3ab3312
Newbas/beiwe-backend
database/schedule_models.py
[ "BSD-3-Clause" ]
Python
export_survey_timings
List[List[int]]
def export_survey_timings(cls, survey: Survey) -> List[List[int]]: """Returns a json formatted list of weekly timings for use on the frontend""" # this weird sort order results in correctly ordered output. fields_ordered = ("hour", "minute", "day_of_week") timings = [[], [], [], [], ...
Returns a json formatted list of weekly timings for use on the frontend
Returns a json formatted list of weekly timings for use on the frontend
[ "Returns", "a", "json", "formatted", "list", "of", "weekly", "timings", "for", "use", "on", "the", "frontend" ]
def export_survey_timings(cls, survey: Survey) -> List[List[int]]: fields_ordered = ("hour", "minute", "day_of_week") timings = [[], [], [], [], [], [], []] schedule_components = WeeklySchedule.objects. \ filter(survey=survey).order_by(*fields_ordered).values_list(*fields_ordered) ...
[ "def", "export_survey_timings", "(", "cls", ",", "survey", ":", "Survey", ")", "->", "List", "[", "List", "[", "int", "]", "]", ":", "fields_ordered", "=", "(", "\"hour\"", ",", "\"minute\"", ",", "\"day_of_week\"", ")", "timings", "=", "[", "[", "]", ...
Returns a json formatted list of weekly timings for use on the frontend
[ "Returns", "a", "json", "formatted", "list", "of", "weekly", "timings", "for", "use", "on", "the", "frontend" ]
[ "\"\"\"Returns a json formatted list of weekly timings for use on the frontend\"\"\"", "# this weird sort order results in correctly ordered output.\r", "# get, calculate, append, dump.\r" ]
[ { "param": "cls", "type": null }, { "param": "survey", "type": "Survey" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "survey", "type": "Survey", "docstring": null, "docstring_token...
c0e8d210ab173879e65c2faeb9225d62e3ab3312
Newbas/beiwe-backend
database/schedule_models.py
[ "BSD-3-Clause" ]
Python
find_pending_events
null
def find_pending_events( participant: Participant = None, survey: Survey or str = None, tz: tzinfo = gettz('America/New_York'), ): """ THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it w...
THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work 'tz' will normalize timestamps to that timezone, default is us east.
THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work 'tz' will normalize timestamps to that timezone, default is us east.
[ "THIS", "FUNCTION", "IS", "FOR", "DEBUGGING", "PURPOSES", "ONLY", "Throw", "in", "a", "participant", "and", "or", "survey", "object", "OR", "THEIR", "IDENTIFYING", "STRING", "and", "we", "make", "it", "work", "'", "tz", "'", "will", "normalize", "timestamps"...
def find_pending_events( participant: Participant = None, survey: Survey or str = None, tz: tzinfo = gettz('America/New_York'), ): filters = {} if participant: filters['participant'] = participant if survey: filters["survey"] = survey e...
[ "def", "find_pending_events", "(", "participant", ":", "Participant", "=", "None", ",", "survey", ":", "Survey", "or", "str", "=", "None", ",", "tz", ":", "tzinfo", "=", "gettz", "(", "'America/New_York'", ")", ",", ")", ":", "filters", "=", "{", "}", ...
THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work 'tz' will normalize timestamps to that timezone, default is us east.
[ "THIS", "FUNCTION", "IS", "FOR", "DEBUGGING", "PURPOSES", "ONLY", "Throw", "in", "a", "participant", "and", "or", "survey", "object", "OR", "THEIR", "IDENTIFYING", "STRING", "and", "we", "make", "it", "work", "'", "tz", "'", "will", "normalize", "timestamps"...
[ "\"\"\" THIS FUNCTION IS FOR DEBUGGING PURPOSES ONLY\r\n\r\n Throw in a participant and or survey object, OR THEIR IDENTIFYING STRING and we make it work\r\n 'tz' will normalize timestamps to that timezone, default is us east.\r\n \"\"\"", "# this is a simplified, modified version ofg the fin...
[ { "param": "participant", "type": "Participant" }, { "param": "survey", "type": "Survey or str" }, { "param": "tz", "type": "tzinfo" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "participant", "type": "Participant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "survey", "type": "Survey or str", "docstring": null...
18bcf5bb9065fe29676520dd7385ee9f6057769c
Newbas/beiwe-backend
api/push_notifications_api.py
[ "BSD-3-Clause" ]
Python
send_notification
<not_specific>
def send_notification(): """ Sends a push notification to the participant, used for testing Expects a patient_id in the request body. """ print(check_firebase_instance()) message = messaging.Message( data={ 'type': 'fake', 'content': 'hello good sir', ...
Sends a push notification to the participant, used for testing Expects a patient_id in the request body.
Sends a push notification to the participant, used for testing Expects a patient_id in the request body.
[ "Sends", "a", "push", "notification", "to", "the", "participant", "used", "for", "testing", "Expects", "a", "patient_id", "in", "the", "request", "body", "." ]
def send_notification(): print(check_firebase_instance()) message = messaging.Message( data={ 'type': 'fake', 'content': 'hello good sir', }, token=get_session_participant().get_fcm_token().token, ) response = messaging.send(message) print('Successfull...
[ "def", "send_notification", "(", ")", ":", "print", "(", "check_firebase_instance", "(", ")", ")", "message", "=", "messaging", ".", "Message", "(", "data", "=", "{", "'type'", ":", "'fake'", ",", "'content'", ":", "'hello good sir'", ",", "}", ",", "token...
Sends a push notification to the participant, used for testing Expects a patient_id in the request body.
[ "Sends", "a", "push", "notification", "to", "the", "participant", "used", "for", "testing", "Expects", "a", "patient_id", "in", "the", "request", "body", "." ]
[ "\"\"\"\r\n Sends a push notification to the participant, used for testing\r\n Expects a patient_id in the request body.\r\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
18bcf5bb9065fe29676520dd7385ee9f6057769c
Newbas/beiwe-backend
api/push_notifications_api.py
[ "BSD-3-Clause" ]
Python
send_survey_notification
<not_specific>
def send_survey_notification(): """ Sends a push notification to the participant with survey data, used for testing Expects a patient_id in the request body """ participant = get_session_participant() survey_ids = list( participant.study.surveys.filter(deleted=False).exclude(surve...
Sends a push notification to the participant with survey data, used for testing Expects a patient_id in the request body
Sends a push notification to the participant with survey data, used for testing Expects a patient_id in the request body
[ "Sends", "a", "push", "notification", "to", "the", "participant", "with", "survey", "data", "used", "for", "testing", "Expects", "a", "patient_id", "in", "the", "request", "body" ]
def send_survey_notification(): participant = get_session_participant() survey_ids = list( participant.study.surveys.filter(deleted=False).exclude(survey_type="image_survey") .values_list("object_id", flat=True)[:4] ) message = messaging.Message( data={ 'type': 's...
[ "def", "send_survey_notification", "(", ")", ":", "participant", "=", "get_session_participant", "(", ")", "survey_ids", "=", "list", "(", "participant", ".", "study", ".", "surveys", ".", "filter", "(", "deleted", "=", "False", ")", ".", "exclude", "(", "su...
Sends a push notification to the participant with survey data, used for testing Expects a patient_id in the request body
[ "Sends", "a", "push", "notification", "to", "the", "participant", "with", "survey", "data", "used", "for", "testing", "Expects", "a", "patient_id", "in", "the", "request", "body" ]
[ "\"\"\"\r\n Sends a push notification to the participant with survey data, used for testing\r\n Expects a patient_id in the request body\r\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c7a1976da6893d5b2a4508b7653617472f44f759
Newbas/beiwe-backend
api/participant_administration.py
[ "BSD-3-Clause" ]
Python
reset_participant_password
<not_specific>
def reset_participant_password(): """ Takes a patient ID and resets its password. Returns the new random password.""" patient_id = request.values['patient_id'] study_id = request.values['study_id'] try: participant = Participant.objects.get(patient_id=patient_id) except Participant.DoesNotE...
Takes a patient ID and resets its password. Returns the new random password.
Takes a patient ID and resets its password. Returns the new random password.
[ "Takes", "a", "patient", "ID", "and", "resets", "its", "password", ".", "Returns", "the", "new", "random", "password", "." ]
def reset_participant_password(): patient_id = request.values['patient_id'] study_id = request.values['study_id'] try: participant = Participant.objects.get(patient_id=patient_id) except Participant.DoesNotExist: flash(f'The participant {patient_id} does not exist', 'danger') ret...
[ "def", "reset_participant_password", "(", ")", ":", "patient_id", "=", "request", ".", "values", "[", "'patient_id'", "]", "study_id", "=", "request", ".", "values", "[", "'study_id'", "]", "try", ":", "participant", "=", "Participant", ".", "objects", ".", ...
Takes a patient ID and resets its password.
[ "Takes", "a", "patient", "ID", "and", "resets", "its", "password", "." ]
[ "\"\"\" Takes a patient ID and resets its password. Returns the new random password.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c7a1976da6893d5b2a4508b7653617472f44f759
Newbas/beiwe-backend
api/participant_administration.py
[ "BSD-3-Clause" ]
Python
reset_device
<not_specific>
def reset_device(): """ Resets a participant's device. The participant will not be able to connect until they register a new device. """ patient_id = request.values['patient_id'] study_id = request.values['study_id'] try: participant = Participant.objects.get(patient_id=patient_id)...
Resets a participant's device. The participant will not be able to connect until they register a new device.
Resets a participant's device. The participant will not be able to connect until they register a new device.
[ "Resets", "a", "participant", "'", "s", "device", ".", "The", "participant", "will", "not", "be", "able", "to", "connect", "until", "they", "register", "a", "new", "device", "." ]
def reset_device(): patient_id = request.values['patient_id'] study_id = request.values['study_id'] try: participant = Participant.objects.get(patient_id=patient_id) except Participant.DoesNotExist: flash(f'The participant {patient_id} does not exist', 'danger') return redirect(f...
[ "def", "reset_device", "(", ")", ":", "patient_id", "=", "request", ".", "values", "[", "'patient_id'", "]", "study_id", "=", "request", ".", "values", "[", "'study_id'", "]", "try", ":", "participant", "=", "Participant", ".", "objects", ".", "get", "(", ...
Resets a participant's device.
[ "Resets", "a", "participant", "'", "s", "device", "." ]
[ "\"\"\"\n Resets a participant's device. The participant will not be able to connect until they\n register a new device.\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c7a1976da6893d5b2a4508b7653617472f44f759
Newbas/beiwe-backend
api/participant_administration.py
[ "BSD-3-Clause" ]
Python
unregister_participant
<not_specific>
def unregister_participant(): """ Block participant from uploading further data """ patient_id = request.values['patient_id'] study_id = request.values['study_id'] try: participant = Participant.objects.get(patient_id=patient_id) except Participant.DoesNotExist: flash(f'The...
Block participant from uploading further data
Block participant from uploading further data
[ "Block", "participant", "from", "uploading", "further", "data" ]
def unregister_participant(): patient_id = request.values['patient_id'] study_id = request.values['study_id'] try: participant = Participant.objects.get(patient_id=patient_id) except Participant.DoesNotExist: flash(f'The participant {patient_id} does not exist', 'danger') return ...
[ "def", "unregister_participant", "(", ")", ":", "patient_id", "=", "request", ".", "values", "[", "'patient_id'", "]", "study_id", "=", "request", ".", "values", "[", "'study_id'", "]", "try", ":", "participant", "=", "Participant", ".", "objects", ".", "get...
Block participant from uploading further data
[ "Block", "participant", "from", "uploading", "further", "data" ]
[ "\"\"\"\n Block participant from uploading further data\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c7a1976da6893d5b2a4508b7653617472f44f759
Newbas/beiwe-backend
api/participant_administration.py
[ "BSD-3-Clause" ]
Python
create_new_participant
<not_specific>
def create_new_participant(): """ Creates a new user, generates a password and keys, pushes data to s3 and user database, adds user to the study they are supposed to be attached to and returns a string containing password and patient id. """ study_id = request.values['study_id'] patient_id,...
Creates a new user, generates a password and keys, pushes data to s3 and user database, adds user to the study they are supposed to be attached to and returns a string containing password and patient id.
Creates a new user, generates a password and keys, pushes data to s3 and user database, adds user to the study they are supposed to be attached to and returns a string containing password and patient id.
[ "Creates", "a", "new", "user", "generates", "a", "password", "and", "keys", "pushes", "data", "to", "s3", "and", "user", "database", "adds", "user", "to", "the", "study", "they", "are", "supposed", "to", "be", "attached", "to", "and", "returns", "a", "st...
def create_new_participant(): study_id = request.values['study_id'] patient_id, password = Participant.create_with_password(study_id=study_id) participant = Participant.objects.get(patient_id=patient_id) study = Study.objects.get(id=study_id) add_fields_and_interventions(participant, study) stud...
[ "def", "create_new_participant", "(", ")", ":", "study_id", "=", "request", ".", "values", "[", "'study_id'", "]", "patient_id", ",", "password", "=", "Participant", ".", "create_with_password", "(", "study_id", "=", "study_id", ")", "participant", "=", "Partici...
Creates a new user, generates a password and keys, pushes data to s3 and user database, adds user to the study they are supposed to be attached to and returns a string containing password and patient id.
[ "Creates", "a", "new", "user", "generates", "a", "password", "and", "keys", "pushes", "data", "to", "s3", "and", "user", "database", "adds", "user", "to", "the", "study", "they", "are", "supposed", "to", "be", "attached", "to", "and", "returns", "a", "st...
[ "\"\"\"\n Creates a new user, generates a password and keys, pushes data to s3 and user database, adds\n user to the study they are supposed to be attached to and returns a string containing\n password and patient id.\n \"\"\"", "# Create an empty file on S3 indicating that this user exists" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c7a1976da6893d5b2a4508b7653617472f44f759
Newbas/beiwe-backend
api/participant_administration.py
[ "BSD-3-Clause" ]
Python
create_many_patients
<not_specific>
def create_many_patients(study_id=None): """ Creates a number of new users at once for a study. Generates a password and keys for each one, pushes data to S3 and the user database, adds users to the study they're supposed to be attached to, and returns a CSV file for download with a mapping of Patient IDs ...
Creates a number of new users at once for a study. Generates a password and keys for each one, pushes data to S3 and the user database, adds users to the study they're supposed to be attached to, and returns a CSV file for download with a mapping of Patient IDs and passwords.
Creates a number of new users at once for a study. Generates a password and keys for each one, pushes data to S3 and the user database, adds users to the study they're supposed to be attached to, and returns a CSV file for download with a mapping of Patient IDs and passwords.
[ "Creates", "a", "number", "of", "new", "users", "at", "once", "for", "a", "study", ".", "Generates", "a", "password", "and", "keys", "for", "each", "one", "pushes", "data", "to", "S3", "and", "the", "user", "database", "adds", "users", "to", "the", "st...
def create_many_patients(study_id=None): number_of_new_patients = int(request.form.get('number_of_new_patients', 0)) desired_filename = request.form.get('desired_filename', '') filename_spaces_to_underscores = sub(r'[\ =]', '_', desired_filename) filename = sub(r'[^a-zA-Z0-9_\.=]', '', filename_spaces_t...
[ "def", "create_many_patients", "(", "study_id", "=", "None", ")", ":", "number_of_new_patients", "=", "int", "(", "request", ".", "form", ".", "get", "(", "'number_of_new_patients'", ",", "0", ")", ")", "desired_filename", "=", "request", ".", "form", ".", "...
Creates a number of new users at once for a study.
[ "Creates", "a", "number", "of", "new", "users", "at", "once", "for", "a", "study", "." ]
[ "\"\"\" Creates a number of new users at once for a study. Generates a password and keys for\n each one, pushes data to S3 and the user database, adds users to the study they're supposed\n to be attached to, and returns a CSV file for download with a mapping of Patient IDs and\n passwords. \"\"\"" ]
[ { "param": "study_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "study_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c7a1976da6893d5b2a4508b7653617472f44f759
Newbas/beiwe-backend
api/participant_administration.py
[ "BSD-3-Clause" ]
Python
add_fields_and_interventions
null
def add_fields_and_interventions(participant: Participant, study: Study): """ Creates empty ParticipantFieldValue and InterventionDate objects for newly created participants, doesn't affect existing instances. """ for field in study.fields.all(): ParticipantFieldValue.objects.get_or_create(particip...
Creates empty ParticipantFieldValue and InterventionDate objects for newly created participants, doesn't affect existing instances.
Creates empty ParticipantFieldValue and InterventionDate objects for newly created participants, doesn't affect existing instances.
[ "Creates", "empty", "ParticipantFieldValue", "and", "InterventionDate", "objects", "for", "newly", "created", "participants", "doesn", "'", "t", "affect", "existing", "instances", "." ]
def add_fields_and_interventions(participant: Participant, study: Study): for field in study.fields.all(): ParticipantFieldValue.objects.get_or_create(participant=participant, field=field) for intervention in study.interventions.all(): InterventionDate.objects.get_or_create(participant=participa...
[ "def", "add_fields_and_interventions", "(", "participant", ":", "Participant", ",", "study", ":", "Study", ")", ":", "for", "field", "in", "study", ".", "fields", ".", "all", "(", ")", ":", "ParticipantFieldValue", ".", "objects", ".", "get_or_create", "(", ...
Creates empty ParticipantFieldValue and InterventionDate objects for newly created participants, doesn't affect existing instances.
[ "Creates", "empty", "ParticipantFieldValue", "and", "InterventionDate", "objects", "for", "newly", "created", "participants", "doesn", "'", "t", "affect", "existing", "instances", "." ]
[ "\"\"\" Creates empty ParticipantFieldValue and InterventionDate objects for newly created\n participants, doesn't affect existing instances. \"\"\"" ]
[ { "param": "participant", "type": "Participant" }, { "param": "study", "type": "Study" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "participant", "type": "Participant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "study", "type": "Study", "docstring": null, "...
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
construct_summary_statistics
<not_specific>
def construct_summary_statistics(self): """ Construct summary statistics from forest output, returning whether or not any SummaryStatisticDaily has potentially been created or updated. """ if not os.path.exists(self.forest_results_path): return False if self....
Construct summary statistics from forest output, returning whether or not any SummaryStatisticDaily has potentially been created or updated.
Construct summary statistics from forest output, returning whether or not any SummaryStatisticDaily has potentially been created or updated.
[ "Construct", "summary", "statistics", "from", "forest", "output", "returning", "whether", "or", "not", "any", "SummaryStatisticDaily", "has", "potentially", "been", "created", "or", "updated", "." ]
def construct_summary_statistics(self): if not os.path.exists(self.forest_results_path): return False if self.forest_tree == ForestTree.jasmine: task_attribute = "jasmine_task" elif self.forest_tree == ForestTree.willow: task_attribute = "willow_task" ...
[ "def", "construct_summary_statistics", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "forest_results_path", ")", ":", "return", "False", "if", "self", ".", "forest_tree", "==", "ForestTree", ".", "jasmine", ":", "t...
Construct summary statistics from forest output, returning whether or not any SummaryStatisticDaily has potentially been created or updated.
[ "Construct", "summary", "statistics", "from", "forest", "output", "returning", "whether", "or", "not", "any", "SummaryStatisticDaily", "has", "potentially", "been", "created", "or", "updated", "." ]
[ "\"\"\"\n Construct summary statistics from forest output, returning whether or not any\n SummaryStatisticDaily has potentially been created or updated.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
clean_up_files
null
def clean_up_files(self): """ Delete temporary input and output files from this Forest run. """ shutil.rmtree(self.data_base_path)
Delete temporary input and output files from this Forest run.
Delete temporary input and output files from this Forest run.
[ "Delete", "temporary", "input", "and", "output", "files", "from", "this", "Forest", "run", "." ]
def clean_up_files(self): shutil.rmtree(self.data_base_path)
[ "def", "clean_up_files", "(", "self", ")", ":", "shutil", ".", "rmtree", "(", "self", ".", "data_base_path", ")" ]
Delete temporary input and output files from this Forest run.
[ "Delete", "temporary", "input", "and", "output", "files", "from", "this", "Forest", "run", "." ]
[ "\"\"\"\n Delete temporary input and output files from this Forest run.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
data_base_path
<not_specific>
def data_base_path(self): """ Return the path to the base data folder, creating it if it doesn't already exist. """ return os.path.join("/tmp", str(self.external_id), self.forest_tree)
Return the path to the base data folder, creating it if it doesn't already exist.
Return the path to the base data folder, creating it if it doesn't already exist.
[ "Return", "the", "path", "to", "the", "base", "data", "folder", "creating", "it", "if", "it", "doesn", "'", "t", "already", "exist", "." ]
def data_base_path(self): return os.path.join("/tmp", str(self.external_id), self.forest_tree)
[ "def", "data_base_path", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "\"/tmp\"", ",", "str", "(", "self", ".", "external_id", ")", ",", "self", ".", "forest_tree", ")" ]
Return the path to the base data folder, creating it if it doesn't already exist.
[ "Return", "the", "path", "to", "the", "base", "data", "folder", "creating", "it", "if", "it", "doesn", "'", "t", "already", "exist", "." ]
[ "\"\"\"\n Return the path to the base data folder, creating it if it doesn't already exist.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
data_input_path
<not_specific>
def data_input_path(self): """ Return the path to the input data folder, creating it if it doesn't already exist. """ return os.path.join(self.data_base_path, "data")
Return the path to the input data folder, creating it if it doesn't already exist.
Return the path to the input data folder, creating it if it doesn't already exist.
[ "Return", "the", "path", "to", "the", "input", "data", "folder", "creating", "it", "if", "it", "doesn", "'", "t", "already", "exist", "." ]
def data_input_path(self): return os.path.join(self.data_base_path, "data")
[ "def", "data_input_path", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "data_base_path", ",", "\"data\"", ")" ]
Return the path to the input data folder, creating it if it doesn't already exist.
[ "Return", "the", "path", "to", "the", "input", "data", "folder", "creating", "it", "if", "it", "doesn", "'", "t", "already", "exist", "." ]
[ "\"\"\"\n Return the path to the input data folder, creating it if it doesn't already exist.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
data_output_path
<not_specific>
def data_output_path(self): """ Return the path to the output data folder, creating it if it doesn't already exist. """ return os.path.join(self.data_base_path, "output")
Return the path to the output data folder, creating it if it doesn't already exist.
Return the path to the output data folder, creating it if it doesn't already exist.
[ "Return", "the", "path", "to", "the", "output", "data", "folder", "creating", "it", "if", "it", "doesn", "'", "t", "already", "exist", "." ]
def data_output_path(self): return os.path.join(self.data_base_path, "output")
[ "def", "data_output_path", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "data_base_path", ",", "\"output\"", ")" ]
Return the path to the output data folder, creating it if it doesn't already exist.
[ "Return", "the", "path", "to", "the", "output", "data", "folder", "creating", "it", "if", "it", "doesn", "'", "t", "already", "exist", "." ]
[ "\"\"\"\n Return the path to the output data folder, creating it if it doesn't already exist.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
forest_results_path
<not_specific>
def forest_results_path(self): """ Return the path to the file that contains the output of Forest. """ return os.path.join(self.data_output_path, f"{self.participant.patient_id}.csv")
Return the path to the file that contains the output of Forest.
Return the path to the file that contains the output of Forest.
[ "Return", "the", "path", "to", "the", "file", "that", "contains", "the", "output", "of", "Forest", "." ]
def forest_results_path(self): return os.path.join(self.data_output_path, f"{self.participant.patient_id}.csv")
[ "def", "forest_results_path", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "data_output_path", ",", "f\"{self.participant.patient_id}.csv\"", ")" ]
Return the path to the file that contains the output of Forest.
[ "Return", "the", "path", "to", "the", "file", "that", "contains", "the", "output", "of", "Forest", "." ]
[ "\"\"\"\n Return the path to the file that contains the output of Forest.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
params_dict
<not_specific>
def params_dict(self): """ Return a dict of params to pass into the Forest function. """ other_params = { "output_folder": self.data_output_path, "study_folder": self.data_input_path, # Need to add a day since this model tracks time end inclusively, bu...
Return a dict of params to pass into the Forest function.
Return a dict of params to pass into the Forest function.
[ "Return", "a", "dict", "of", "params", "to", "pass", "into", "the", "Forest", "function", "." ]
def params_dict(self): other_params = { "output_folder": self.data_output_path, "study_folder": self.data_input_path, "time_end": datetime_to_list(self.data_date_end + datetime.timedelta(days=1)), "time_start": datetime_to_list(self.data_date_start), } ...
[ "def", "params_dict", "(", "self", ")", ":", "other_params", "=", "{", "\"output_folder\"", ":", "self", ".", "data_output_path", ",", "\"study_folder\"", ":", "self", ".", "data_input_path", ",", "\"time_end\"", ":", "datetime_to_list", "(", "self", ".", "data_...
Return a dict of params to pass into the Forest function.
[ "Return", "a", "dict", "of", "params", "to", "pass", "into", "the", "Forest", "function", "." ]
[ "\"\"\"\n Return a dict of params to pass into the Forest function.\n \"\"\"", "# Need to add a day since this model tracks time end inclusively, but Forest expects", "# it exclusively" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
generate_all_bv_set_s3_key
<not_specific>
def generate_all_bv_set_s3_key(self): """ Generate the S3 key that all_bv_set_s3_key should live in (whereas the direct all_bv_set_s3_key field on the instance is where it currently lives, regardless of how generation changes). """ return os.path.join(self.s3_base_folder,...
Generate the S3 key that all_bv_set_s3_key should live in (whereas the direct all_bv_set_s3_key field on the instance is where it currently lives, regardless of how generation changes).
Generate the S3 key that all_bv_set_s3_key should live in (whereas the direct all_bv_set_s3_key field on the instance is where it currently lives, regardless of how generation changes).
[ "Generate", "the", "S3", "key", "that", "all_bv_set_s3_key", "should", "live", "in", "(", "whereas", "the", "direct", "all_bv_set_s3_key", "field", "on", "the", "instance", "is", "where", "it", "currently", "lives", "regardless", "of", "how", "generation", "chan...
def generate_all_bv_set_s3_key(self): return os.path.join(self.s3_base_folder, 'all_bv_set.pkl')
[ "def", "generate_all_bv_set_s3_key", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "s3_base_folder", ",", "'all_bv_set.pkl'", ")" ]
Generate the S3 key that all_bv_set_s3_key should live in (whereas the direct all_bv_set_s3_key field on the instance is where it currently lives, regardless of how generation changes).
[ "Generate", "the", "S3", "key", "that", "all_bv_set_s3_key", "should", "live", "in", "(", "whereas", "the", "direct", "all_bv_set_s3_key", "field", "on", "the", "instance", "is", "where", "it", "currently", "lives", "regardless", "of", "how", "generation", "chan...
[ "\"\"\"\n Generate the S3 key that all_bv_set_s3_key should live in (whereas the direct\n all_bv_set_s3_key field on the instance is where it currently lives, regardless\n of how generation changes).\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9f77fad167ad960a1df52146616494604bb8a1b8
Newbas/beiwe-backend
database/tableau_api_models.py
[ "BSD-3-Clause" ]
Python
generate_all_memory_dict_s3_key
<not_specific>
def generate_all_memory_dict_s3_key(self): """ Generate the S3 key that all_memory_dict_s3_key should live in (whereas the direct all_memory_dict_s3_key field on the instance is where it currently lives, regardless of how generation changes). """ return os.path.join(self....
Generate the S3 key that all_memory_dict_s3_key should live in (whereas the direct all_memory_dict_s3_key field on the instance is where it currently lives, regardless of how generation changes).
Generate the S3 key that all_memory_dict_s3_key should live in (whereas the direct all_memory_dict_s3_key field on the instance is where it currently lives, regardless of how generation changes).
[ "Generate", "the", "S3", "key", "that", "all_memory_dict_s3_key", "should", "live", "in", "(", "whereas", "the", "direct", "all_memory_dict_s3_key", "field", "on", "the", "instance", "is", "where", "it", "currently", "lives", "regardless", "of", "how", "generation...
def generate_all_memory_dict_s3_key(self): return os.path.join(self.s3_base_folder, 'all_memory_dict.pkl')
[ "def", "generate_all_memory_dict_s3_key", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "s3_base_folder", ",", "'all_memory_dict.pkl'", ")" ]
Generate the S3 key that all_memory_dict_s3_key should live in (whereas the direct all_memory_dict_s3_key field on the instance is where it currently lives, regardless of how generation changes).
[ "Generate", "the", "S3", "key", "that", "all_memory_dict_s3_key", "should", "live", "in", "(", "whereas", "the", "direct", "all_memory_dict_s3_key", "field", "on", "the", "instance", "is", "where", "it", "currently", "lives", "regardless", "of", "how", "generation...
[ "\"\"\"\n Generate the S3 key that all_memory_dict_s3_key should live in (whereas the direct\n all_memory_dict_s3_key field on the instance is where it currently lives, regardless\n of how generation changes).\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0fbfac9bbdd2da12f57b522080dad6bfc6ea7df8
Newbas/beiwe-backend
services/celery_push_notifications.py
[ "BSD-3-Clause" ]
Python
celery_send_push_notification
<not_specific>
def celery_send_push_notification(fcm_token: str, survey_obj_ids: List[str], schedule_pks: List[int]): ''' Celery task that sends push notifications. Note that this list of pks may contain duplicates.''' # Oh. The reason we need the patient_id is so that we can debug anything ever. lol... patient_id = Part...
Celery task that sends push notifications. Note that this list of pks may contain duplicates.
Celery task that sends push notifications. Note that this list of pks may contain duplicates.
[ "Celery", "task", "that", "sends", "push", "notifications", ".", "Note", "that", "this", "list", "of", "pks", "may", "contain", "duplicates", "." ]
def celery_send_push_notification(fcm_token: str, survey_obj_ids: List[str], schedule_pks: List[int]): patient_id = ParticipantFCMHistory.objects.filter(token=fcm_token) \ .values_list("participant__patient_id", flat=True).get() with make_error_sentry(sentry_type=SentryTypes.data_processing): if...
[ "def", "celery_send_push_notification", "(", "fcm_token", ":", "str", ",", "survey_obj_ids", ":", "List", "[", "str", "]", ",", "schedule_pks", ":", "List", "[", "int", "]", ")", ":", "patient_id", "=", "ParticipantFCMHistory", ".", "objects", ".", "filter", ...
Celery task that sends push notifications.
[ "Celery", "task", "that", "sends", "push", "notifications", "." ]
[ "''' Celery task that sends push notifications. Note that this list of pks may contain duplicates.'''", "# Oh. The reason we need the patient_id is so that we can debug anything ever. lol...", "# use the earliest timed schedule as our reference for the sent_time parameter. (why?)", "# already deduped; whate...
[ { "param": "fcm_token", "type": "str" }, { "param": "survey_obj_ids", "type": "List[str]" }, { "param": "schedule_pks", "type": "List[int]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fcm_token", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "survey_obj_ids", "type": "List[str]", "docstring": null, ...
3a2fc409837822733ad287784881a10d07dc7af9
Newbas/beiwe-backend
cluster_management/launch_script.py
[ "BSD-3-Clause" ]
Python
load_git_repo
null
def load_git_repo(): """ Get a local copy of the git repository """ # Git clone the repository into the remote beiwe-backend folder # git operations print to both stderr *and* stdout, so redirect them both to the log file run(f'cd {REMOTE_HOME_DIR}; git clone https://github.com/onnela-lab/beiwe-backend....
Get a local copy of the git repository
Get a local copy of the git repository
[ "Get", "a", "local", "copy", "of", "the", "git", "repository" ]
def load_git_repo(): run(f'cd {REMOTE_HOME_DIR}; git clone https://github.com/onnela-lab/beiwe-backend.git 2>> {LOG_FILE}') if DEV_MODE: branch = environ.get("DEV_BRANCH", "development") else: branch = "main" run(f'cd {REMOTE_HOME_DIR}/beiwe-backend; git checkout {branch} 1>> {LOG_FILE} ...
[ "def", "load_git_repo", "(", ")", ":", "run", "(", "f'cd {REMOTE_HOME_DIR}; git clone https://github.com/onnela-lab/beiwe-backend.git 2>> {LOG_FILE}'", ")", "if", "DEV_MODE", ":", "branch", "=", "environ", ".", "get", "(", "\"DEV_BRANCH\"", ",", "\"development\"", ")", "e...
Get a local copy of the git repository
[ "Get", "a", "local", "copy", "of", "the", "git", "repository" ]
[ "\"\"\" Get a local copy of the git repository \"\"\"", "# Git clone the repository into the remote beiwe-backend folder", "# git operations print to both stderr *and* stdout, so redirect them both to the log file" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
3a2fc409837822733ad287784881a10d07dc7af9
Newbas/beiwe-backend
cluster_management/launch_script.py
[ "BSD-3-Clause" ]
Python
do_create_single_server_ami
null
def do_create_single_server_ami(ip_address, key_filename): """ Set up a beiwe-backend deployment on a single server suitable for turning into an AMI :param ip_address: IP address of the server you're setting up as an AMI :param key_filename: Full filepath of the key that lets you SSH into that server ...
Set up a beiwe-backend deployment on a single server suitable for turning into an AMI :param ip_address: IP address of the server you're setting up as an AMI :param key_filename: Full filepath of the key that lets you SSH into that server
Set up a beiwe-backend deployment on a single server suitable for turning into an AMI
[ "Set", "up", "a", "beiwe", "-", "backend", "deployment", "on", "a", "single", "server", "suitable", "for", "turning", "into", "an", "AMI" ]
def do_create_single_server_ami(ip_address, key_filename): configure_fabric(None, ip_address, key_filename=key_filename) push_home_directory_files() apt_installs(single_server_ami=True) load_git_repo() setup_python() push_beiwe_configuration(None, single_server_ami=True) configure_local_post...
[ "def", "do_create_single_server_ami", "(", "ip_address", ",", "key_filename", ")", ":", "configure_fabric", "(", "None", ",", "ip_address", ",", "key_filename", "=", "key_filename", ")", "push_home_directory_files", "(", ")", "apt_installs", "(", "single_server_ami", ...
Set up a beiwe-backend deployment on a single server suitable for turning into an AMI
[ "Set", "up", "a", "beiwe", "-", "backend", "deployment", "on", "a", "single", "server", "suitable", "for", "turning", "into", "an", "AMI" ]
[ "\"\"\"\n Set up a beiwe-backend deployment on a single server suitable for turning into an AMI\n :param ip_address: IP address of the server you're setting up as an AMI\n :param key_filename: Full filepath of the key that lets you SSH into that server\n \"\"\"" ]
[ { "param": "ip_address", "type": null }, { "param": "key_filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ip_address", "type": null, "docstring": "IP address of the server you're setting up as an AMI", "docstring_tokens": [ "IP", "address", "of", "the", "server", "you", "'", ...
3add3bb29df4dabf8d424746b22a065a3a3a2cde
Newbas/beiwe-backend
libs/celery_control.py
[ "BSD-3-Clause" ]
Python
safe_apply_async
<not_specific>
def safe_apply_async(a_task_for_a_celery_queue, *args, **kwargs): """ Enqueuing a new task, for which we use Celery's most flexible `apply_async` function, can fail deep inside amqp/transport.py with an OperationalError. Use this common wrapper to handle that case. An "a_task_for_a_celery_queue" is eit...
Enqueuing a new task, for which we use Celery's most flexible `apply_async` function, can fail deep inside amqp/transport.py with an OperationalError. Use this common wrapper to handle that case. An "a_task_for_a_celery_queue" is either a "@celery_app.task"-wrapped function' or it is a FalseCeleryApp....
Enqueuing a new task, for which we use Celery's most flexible `apply_async` function, can fail deep inside amqp/transport.py with an OperationalError. Use this common wrapper to handle that case. An "a_task_for_a_celery_queue" is either a "@celery_app.task"-wrapped function' or it is a FalseCeleryApp. FalseCeleryApps ...
[ "Enqueuing", "a", "new", "task", "for", "which", "we", "use", "Celery", "'", "s", "most", "flexible", "`", "apply_async", "`", "function", "can", "fail", "deep", "inside", "amqp", "/", "transport", ".", "py", "with", "an", "OperationalError", ".", "Use", ...
def safe_apply_async(a_task_for_a_celery_queue, *args, **kwargs): for i in range(10): try: return a_task_for_a_celery_queue.apply_async(*args, **kwargs) except OperationalError: if i >= 3: raise
[ "def", "safe_apply_async", "(", "a_task_for_a_celery_queue", ",", "*", "args", ",", "**", "kwargs", ")", ":", "for", "i", "in", "range", "(", "10", ")", ":", "try", ":", "return", "a_task_for_a_celery_queue", ".", "apply_async", "(", "*", "args", ",", "**"...
Enqueuing a new task, for which we use Celery's most flexible `apply_async` function, can fail deep inside amqp/transport.py with an OperationalError.
[ "Enqueuing", "a", "new", "task", "for", "which", "we", "use", "Celery", "'", "s", "most", "flexible", "`", "apply_async", "`", "function", "can", "fail", "deep", "inside", "amqp", "/", "transport", ".", "py", "with", "an", "OperationalError", "." ]
[ "\"\"\" Enqueuing a new task, for which we use Celery's most flexible `apply_async` function,\n can fail deep inside amqp/transport.py with an OperationalError. Use this common wrapper to\n handle that case.\n\n An \"a_task_for_a_celery_queue\" is either a \"@celery_app.task\"-wrapped function' or it is a\...
[ { "param": "a_task_for_a_celery_queue", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a_task_for_a_celery_queue", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7d7fdf71fdca90d240ef0fe72471937a9d524e99
Newbas/beiwe-backend
libs/sentry.py
[ "BSD-3-Clause" ]
Python
make_error_sentry
<not_specific>
def make_error_sentry(sentry_type:str, tags:dict=None): """ Creates an ErrorSentry, defaults to error limit 10. If the applicable sentry DSN is missing will return an ErrorSentry, but if null truthy a NullErrorHandler will be returned instead. """ if FORCE_SENTRY_OFF: return null_error_ha...
Creates an ErrorSentry, defaults to error limit 10. If the applicable sentry DSN is missing will return an ErrorSentry, but if null truthy a NullErrorHandler will be returned instead.
Creates an ErrorSentry, defaults to error limit 10. If the applicable sentry DSN is missing will return an ErrorSentry, but if null truthy a NullErrorHandler will be returned instead.
[ "Creates", "an", "ErrorSentry", "defaults", "to", "error", "limit", "10", ".", "If", "the", "applicable", "sentry", "DSN", "is", "missing", "will", "return", "an", "ErrorSentry", "but", "if", "null", "truthy", "a", "NullErrorHandler", "will", "be", "returned",...
def make_error_sentry(sentry_type:str, tags:dict=None): if FORCE_SENTRY_OFF: return null_error_handler tags = tags or {} tags["sentry_type"] = sentry_type try: return ErrorSentry( get_dsn_from_string(sentry_type), sentry_client_kwargs={'tags': tags, 'transport': H...
[ "def", "make_error_sentry", "(", "sentry_type", ":", "str", ",", "tags", ":", "dict", "=", "None", ")", ":", "if", "FORCE_SENTRY_OFF", ":", "return", "null_error_handler", "tags", "=", "tags", "or", "{", "}", "tags", "[", "\"sentry_type\"", "]", "=", "sent...
Creates an ErrorSentry, defaults to error limit 10.
[ "Creates", "an", "ErrorSentry", "defaults", "to", "error", "limit", "10", "." ]
[ "\"\"\" Creates an ErrorSentry, defaults to error limit 10.\r\n If the applicable sentry DSN is missing will return an ErrorSentry,\r\n but if null truthy a NullErrorHandler will be returned instead. \"\"\"" ]
[ { "param": "sentry_type", "type": "str" }, { "param": "tags", "type": "dict" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sentry_type", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tags", "type": "dict", "docstring": null, "docstring_...
fd41ae0c3cf36af6460c35ba500f21e65d4aaa6a
Newbas/beiwe-backend
database/survey_models.py
[ "BSD-3-Clause" ]
Python
create_with_settings
<not_specific>
def create_with_settings(cls, survey_type: str, **kwargs): """ Create a new Survey with the provided survey type and attached to the given Study, as well as any other given keyword arguments. If the Survey is audio/image and no other settings are given, give it the default audio/image su...
Create a new Survey with the provided survey type and attached to the given Study, as well as any other given keyword arguments. If the Survey is audio/image and no other settings are given, give it the default audio/image survey settings.
Create a new Survey with the provided survey type and attached to the given Study, as well as any other given keyword arguments. If the Survey is audio/image and no other settings are given, give it the default audio/image survey settings.
[ "Create", "a", "new", "Survey", "with", "the", "provided", "survey", "type", "and", "attached", "to", "the", "given", "Study", "as", "well", "as", "any", "other", "given", "keyword", "arguments", ".", "If", "the", "Survey", "is", "audio", "/", "image", "...
def create_with_settings(cls, survey_type: str, **kwargs): if survey_type == cls.AUDIO_SURVEY and 'settings' not in kwargs: kwargs['settings'] = json.dumps(AUDIO_SURVEY_SETTINGS) elif survey_type == cls.IMAGE_SURVEY and 'settings' not in kwargs: kwargs['settings'] = json.dumps(IM...
[ "def", "create_with_settings", "(", "cls", ",", "survey_type", ":", "str", ",", "**", "kwargs", ")", ":", "if", "survey_type", "==", "cls", ".", "AUDIO_SURVEY", "and", "'settings'", "not", "in", "kwargs", ":", "kwargs", "[", "'settings'", "]", "=", "json",...
Create a new Survey with the provided survey type and attached to the given Study, as well as any other given keyword arguments.
[ "Create", "a", "new", "Survey", "with", "the", "provided", "survey", "type", "and", "attached", "to", "the", "given", "Study", "as", "well", "as", "any", "other", "given", "keyword", "arguments", "." ]
[ "\"\"\"\n Create a new Survey with the provided survey type and attached to the given Study,\n as well as any other given keyword arguments. If the Survey is audio/image and no other\n settings are given, give it the default audio/image survey settings.\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "survey_type", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "survey_type", "type": "str", "docstring": null, "docstring_tok...
fd41ae0c3cf36af6460c35ba500f21e65d4aaa6a
Newbas/beiwe-backend
database/survey_models.py
[ "BSD-3-Clause" ]
Python
weekly_timings
<not_specific>
def weekly_timings(self): """ Returns a json serializable object that represents the weekly schedules of this survey. The return object is a list of 7 lists of ints """ from database.schedule_models import WeeklySchedule return WeeklySchedule.export_survey_timings(self)
Returns a json serializable object that represents the weekly schedules of this survey. The return object is a list of 7 lists of ints
Returns a json serializable object that represents the weekly schedules of this survey. The return object is a list of 7 lists of ints
[ "Returns", "a", "json", "serializable", "object", "that", "represents", "the", "weekly", "schedules", "of", "this", "survey", ".", "The", "return", "object", "is", "a", "list", "of", "7", "lists", "of", "ints" ]
def weekly_timings(self): from database.schedule_models import WeeklySchedule return WeeklySchedule.export_survey_timings(self)
[ "def", "weekly_timings", "(", "self", ")", ":", "from", "database", ".", "schedule_models", "import", "WeeklySchedule", "return", "WeeklySchedule", ".", "export_survey_timings", "(", "self", ")" ]
Returns a json serializable object that represents the weekly schedules of this survey.
[ "Returns", "a", "json", "serializable", "object", "that", "represents", "the", "weekly", "schedules", "of", "this", "survey", "." ]
[ "\"\"\"\n Returns a json serializable object that represents the weekly schedules of this survey.\n The return object is a list of 7 lists of ints\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd41ae0c3cf36af6460c35ba500f21e65d4aaa6a
Newbas/beiwe-backend
database/survey_models.py
[ "BSD-3-Clause" ]
Python
relative_timings
<not_specific>
def relative_timings(self): """ Returns a json serializable object that represents the relative schedules of the survey The return object is a list of lists of intervention ids, days offset, and seconds offset. """ schedules = [] for schedule in self.relative_schedules.al...
Returns a json serializable object that represents the relative schedules of the survey The return object is a list of lists of intervention ids, days offset, and seconds offset.
Returns a json serializable object that represents the relative schedules of the survey The return object is a list of lists of intervention ids, days offset, and seconds offset.
[ "Returns", "a", "json", "serializable", "object", "that", "represents", "the", "relative", "schedules", "of", "the", "survey", "The", "return", "object", "is", "a", "list", "of", "lists", "of", "intervention", "ids", "days", "offset", "and", "seconds", "offset...
def relative_timings(self): schedules = [] for schedule in self.relative_schedules.all(): num_seconds = schedule.minute * 60 + schedule.hour * 3600 schedules.append([schedule.intervention.id, schedule.days_after, num_seconds]) return schedules
[ "def", "relative_timings", "(", "self", ")", ":", "schedules", "=", "[", "]", "for", "schedule", "in", "self", ".", "relative_schedules", ".", "all", "(", ")", ":", "num_seconds", "=", "schedule", ".", "minute", "*", "60", "+", "schedule", ".", "hour", ...
Returns a json serializable object that represents the relative schedules of the survey The return object is a list of lists of intervention ids, days offset, and seconds offset.
[ "Returns", "a", "json", "serializable", "object", "that", "represents", "the", "relative", "schedules", "of", "the", "survey", "The", "return", "object", "is", "a", "list", "of", "lists", "of", "intervention", "ids", "days", "offset", "and", "seconds", "offset...
[ "\"\"\"\n Returns a json serializable object that represents the relative schedules of the survey\n The return object is a list of lists of intervention ids, days offset, and seconds offset.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd41ae0c3cf36af6460c35ba500f21e65d4aaa6a
Newbas/beiwe-backend
database/survey_models.py
[ "BSD-3-Clause" ]
Python
relative_timings_by_name
<not_specific>
def relative_timings_by_name(self): """ Returns a json serializable object that represents the relative schedules of the survey The return object is a list of lists of intervention names, days offset, and seconds offset. """ schedules = [] for schedule in self.relative_sc...
Returns a json serializable object that represents the relative schedules of the survey The return object is a list of lists of intervention names, days offset, and seconds offset.
Returns a json serializable object that represents the relative schedules of the survey The return object is a list of lists of intervention names, days offset, and seconds offset.
[ "Returns", "a", "json", "serializable", "object", "that", "represents", "the", "relative", "schedules", "of", "the", "survey", "The", "return", "object", "is", "a", "list", "of", "lists", "of", "intervention", "names", "days", "offset", "and", "seconds", "offs...
def relative_timings_by_name(self): schedules = [] for schedule in self.relative_schedules.all(): num_seconds = schedule.minute * 60 + schedule.hour * 3600 schedules.append([schedule.intervention.name, schedule.days_after, num_seconds]) return schedules
[ "def", "relative_timings_by_name", "(", "self", ")", ":", "schedules", "=", "[", "]", "for", "schedule", "in", "self", ".", "relative_schedules", ".", "all", "(", ")", ":", "num_seconds", "=", "schedule", ".", "minute", "*", "60", "+", "schedule", ".", "...
Returns a json serializable object that represents the relative schedules of the survey The return object is a list of lists of intervention names, days offset, and seconds offset.
[ "Returns", "a", "json", "serializable", "object", "that", "represents", "the", "relative", "schedules", "of", "the", "survey", "The", "return", "object", "is", "a", "list", "of", "lists", "of", "intervention", "names", "days", "offset", "and", "seconds", "offs...
[ "\"\"\"\n Returns a json serializable object that represents the relative schedules of the survey\n The return object is a list of lists of intervention names, days offset, and seconds offset.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd41ae0c3cf36af6460c35ba500f21e65d4aaa6a
Newbas/beiwe-backend
database/survey_models.py
[ "BSD-3-Clause" ]
Python
absolute_timings
<not_specific>
def absolute_timings(self): """ Returns a json serializable object that represents the absolute schedules of the survey The return object is a list of lists of the year, month, day and seconds within the day. """ schedules = [] for schedule in self.absolute_schedules.all(...
Returns a json serializable object that represents the absolute schedules of the survey The return object is a list of lists of the year, month, day and seconds within the day.
Returns a json serializable object that represents the absolute schedules of the survey The return object is a list of lists of the year, month, day and seconds within the day.
[ "Returns", "a", "json", "serializable", "object", "that", "represents", "the", "absolute", "schedules", "of", "the", "survey", "The", "return", "object", "is", "a", "list", "of", "lists", "of", "the", "year", "month", "day", "and", "seconds", "within", "the"...
def absolute_timings(self): schedules = [] for schedule in self.absolute_schedules.all(): event_time = schedule.event_time num_seconds = event_time.minute * 60 + event_time.hour * 3600 schedules.append([event_time.year, event_time.month, event_time.day, num_seconds]) ...
[ "def", "absolute_timings", "(", "self", ")", ":", "schedules", "=", "[", "]", "for", "schedule", "in", "self", ".", "absolute_schedules", ".", "all", "(", ")", ":", "event_time", "=", "schedule", ".", "event_time", "num_seconds", "=", "event_time", ".", "m...
Returns a json serializable object that represents the absolute schedules of the survey The return object is a list of lists of the year, month, day and seconds within the day.
[ "Returns", "a", "json", "serializable", "object", "that", "represents", "the", "absolute", "schedules", "of", "the", "survey", "The", "return", "object", "is", "a", "list", "of", "lists", "of", "the", "year", "month", "day", "and", "seconds", "within", "the"...
[ "\"\"\"\n Returns a json serializable object that represents the absolute schedules of the survey\n The return object is a list of lists of the year, month, day and seconds within the day.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd41ae0c3cf36af6460c35ba500f21e65d4aaa6a
Newbas/beiwe-backend
database/survey_models.py
[ "BSD-3-Clause" ]
Python
format_survey_for_study
<not_specific>
def format_survey_for_study(self): """ Returns a dict with the values of the survey fields for download to the app """ survey_dict = self.as_unpacked_native_python() # Make the dict look like the old Mongolia-style dict that the frontend is expecting survey_dict.pop('id')...
Returns a dict with the values of the survey fields for download to the app
Returns a dict with the values of the survey fields for download to the app
[ "Returns", "a", "dict", "with", "the", "values", "of", "the", "survey", "fields", "for", "download", "to", "the", "app" ]
def format_survey_for_study(self): survey_dict = self.as_unpacked_native_python() survey_dict.pop('id') survey_dict.pop('deleted') survey_dict['_id'] = survey_dict.pop('object_id') from database.schedule_models import WeeklySchedule survey_dict['timings'] = WeeklySchedule...
[ "def", "format_survey_for_study", "(", "self", ")", ":", "survey_dict", "=", "self", ".", "as_unpacked_native_python", "(", ")", "survey_dict", ".", "pop", "(", "'id'", ")", "survey_dict", ".", "pop", "(", "'deleted'", ")", "survey_dict", "[", "'_id'", "]", ...
Returns a dict with the values of the survey fields for download to the app
[ "Returns", "a", "dict", "with", "the", "values", "of", "the", "survey", "fields", "for", "download", "to", "the", "app" ]
[ "\"\"\"\n Returns a dict with the values of the survey fields for download to the app\n \"\"\"", "# Make the dict look like the old Mongolia-style dict that the frontend is expecting", "# the old timings object does need to be provided" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fd41ae0c3cf36af6460c35ba500f21e65d4aaa6a
Newbas/beiwe-backend
database/survey_models.py
[ "BSD-3-Clause" ]
Python
archive
<not_specific>
def archive(self): """ Create an archive if there were any changes to the data since the last archive was created, or if no archive exists. """ # get self as dictionary representation, remove fields that don't exist, extract last # updated and the survey id. new_data = self.as_d...
Create an archive if there were any changes to the data since the last archive was created, or if no archive exists.
Create an archive if there were any changes to the data since the last archive was created, or if no archive exists.
[ "Create", "an", "archive", "if", "there", "were", "any", "changes", "to", "the", "data", "since", "the", "last", "archive", "was", "created", "or", "if", "no", "archive", "exists", "." ]
def archive(self): new_data = self.as_dict() archive_start = new_data.pop("last_updated") survey_id = new_data.pop("id") new_data.pop("object_id") new_data.pop("created_on") new_data.pop("study") try: prior_archive = self.most_recent_archive().as_dict(...
[ "def", "archive", "(", "self", ")", ":", "new_data", "=", "self", ".", "as_dict", "(", ")", "archive_start", "=", "new_data", ".", "pop", "(", "\"last_updated\"", ")", "survey_id", "=", "new_data", ".", "pop", "(", "\"id\"", ")", "new_data", ".", "pop", ...
Create an archive if there were any changes to the data since the last archive was created, or if no archive exists.
[ "Create", "an", "archive", "if", "there", "were", "any", "changes", "to", "the", "data", "since", "the", "last", "archive", "was", "created", "or", "if", "no", "archive", "exists", "." ]
[ "\"\"\" Create an archive if there were any changes to the data since the last archive was\n created, or if no archive exists. \"\"\"", "# get self as dictionary representation, remove fields that don't exist, extract last", "# updated and the survey id.", "# Get the most recent archive for this Survey...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
69846b2aac527ec8fe3c4a6814eeb217bab94d37
Newbas/beiwe-backend
authentication/admin_authentication.py
[ "BSD-3-Clause" ]
Python
is_logged_in
<not_specific>
def is_logged_in(): """ automatically logs out the researcher if their session is timed out. """ if EXPIRY_NAME in session: expiry_datetime = session[EXPIRY_NAME] if is_naive(expiry_datetime): if expiry_datetime > datetime.now(): return SESSION_UUID in session ...
automatically logs out the researcher if their session is timed out.
automatically logs out the researcher if their session is timed out.
[ "automatically", "logs", "out", "the", "researcher", "if", "their", "session", "is", "timed", "out", "." ]
def is_logged_in(): if EXPIRY_NAME in session: expiry_datetime = session[EXPIRY_NAME] if is_naive(expiry_datetime): if expiry_datetime > datetime.now(): return SESSION_UUID in session else: if expiry_datetime > timezone.now(): return SE...
[ "def", "is_logged_in", "(", ")", ":", "if", "EXPIRY_NAME", "in", "session", ":", "expiry_datetime", "=", "session", "[", "EXPIRY_NAME", "]", "if", "is_naive", "(", "expiry_datetime", ")", ":", "if", "expiry_datetime", ">", "datetime", ".", "now", "(", ")", ...
automatically logs out the researcher if their session is timed out.
[ "automatically", "logs", "out", "the", "researcher", "if", "their", "session", "is", "timed", "out", "." ]
[ "\"\"\" automatically logs out the researcher if their session is timed out. \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
69846b2aac527ec8fe3c4a6814eeb217bab94d37
Newbas/beiwe-backend
authentication/admin_authentication.py
[ "BSD-3-Clause" ]
Python
assert_admin
<not_specific>
def assert_admin(study_id): """ This function will throw a 403 forbidden error and stop execution. Note that the abort directly raises the 403 error, if we don't hit that return True. """ session_researcher = get_session_researcher() if not session_researcher.site_admin and not session_researcher.c...
This function will throw a 403 forbidden error and stop execution. Note that the abort directly raises the 403 error, if we don't hit that return True.
This function will throw a 403 forbidden error and stop execution. Note that the abort directly raises the 403 error, if we don't hit that return True.
[ "This", "function", "will", "throw", "a", "403", "forbidden", "error", "and", "stop", "execution", ".", "Note", "that", "the", "abort", "directly", "raises", "the", "403", "error", "if", "we", "don", "'", "t", "hit", "that", "return", "True", "." ]
def assert_admin(study_id): session_researcher = get_session_researcher() if not session_researcher.site_admin and not session_researcher.check_study_admin(study_id): flash("This user does not have admin privilages on this study.", "danger") return abort(403) return True
[ "def", "assert_admin", "(", "study_id", ")", ":", "session_researcher", "=", "get_session_researcher", "(", ")", "if", "not", "session_researcher", ".", "site_admin", "and", "not", "session_researcher", ".", "check_study_admin", "(", "study_id", ")", ":", "flash", ...
This function will throw a 403 forbidden error and stop execution.
[ "This", "function", "will", "throw", "a", "403", "forbidden", "error", "and", "stop", "execution", "." ]
[ "\"\"\" This function will throw a 403 forbidden error and stop execution. Note that the abort\n directly raises the 403 error, if we don't hit that return True. \"\"\"", "# allow usage in if statements" ]
[ { "param": "study_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "study_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
69846b2aac527ec8fe3c4a6814eeb217bab94d37
Newbas/beiwe-backend
authentication/admin_authentication.py
[ "BSD-3-Clause" ]
Python
assert_researcher_under_admin
<not_specific>
def assert_researcher_under_admin(researcher, study=None): """ Asserts that the researcher provided is allowed to be edited by the session user. If study is provided then the admin test is strictly for that study, otherwise it checks for admin status anywhere. """ session_researcher = get_sessio...
Asserts that the researcher provided is allowed to be edited by the session user. If study is provided then the admin test is strictly for that study, otherwise it checks for admin status anywhere.
Asserts that the researcher provided is allowed to be edited by the session user. If study is provided then the admin test is strictly for that study, otherwise it checks for admin status anywhere.
[ "Asserts", "that", "the", "researcher", "provided", "is", "allowed", "to", "be", "edited", "by", "the", "session", "user", ".", "If", "study", "is", "provided", "then", "the", "admin", "test", "is", "strictly", "for", "that", "study", "otherwise", "it", "c...
def assert_researcher_under_admin(researcher, study=None): session_researcher = get_session_researcher() if session_researcher.site_admin: return if researcher.site_admin: flash("This user is a site administrator, action rejected.", "danger") return abort(403) kwargs = dict(relat...
[ "def", "assert_researcher_under_admin", "(", "researcher", ",", "study", "=", "None", ")", ":", "session_researcher", "=", "get_session_researcher", "(", ")", "if", "session_researcher", ".", "site_admin", ":", "return", "if", "researcher", ".", "site_admin", ":", ...
Asserts that the researcher provided is allowed to be edited by the session user.
[ "Asserts", "that", "the", "researcher", "provided", "is", "allowed", "to", "be", "edited", "by", "the", "session", "user", "." ]
[ "\"\"\" Asserts that the researcher provided is allowed to be edited by the session user.\n If study is provided then the admin test is strictly for that study, otherwise it checks\n for admin status anywhere. \"\"\"" ]
[ { "param": "researcher", "type": null }, { "param": "study", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "researcher", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "study", "type": null, "docstring": null, "docstring_tok...
69846b2aac527ec8fe3c4a6814eeb217bab94d37
Newbas/beiwe-backend
authentication/admin_authentication.py
[ "BSD-3-Clause" ]
Python
forest_enabled
<not_specific>
def forest_enabled(func): """ Decorator for validating that Forest is enabled for this study. """ @functools.wraps(func) def wrapped(*args, **kwargs): try: study = Study.objects.get(id=kwargs.get("study_id", None)) except Study.DoesNotExist: return abort(404) ...
Decorator for validating that Forest is enabled for this study.
Decorator for validating that Forest is enabled for this study.
[ "Decorator", "for", "validating", "that", "Forest", "is", "enabled", "for", "this", "study", "." ]
def forest_enabled(func): @functools.wraps(func) def wrapped(*args, **kwargs): try: study = Study.objects.get(id=kwargs.get("study_id", None)) except Study.DoesNotExist: return abort(404) if not study.forest_enabled: return abort(404) return fu...
[ "def", "forest_enabled", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapped", "(", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "study", "=", "Study", ".", "objects", ".", "get", "(", "id", "=", "k...
Decorator for validating that Forest is enabled for this study.
[ "Decorator", "for", "validating", "that", "Forest", "is", "enabled", "for", "this", "study", "." ]
[ "\"\"\"\n Decorator for validating that Forest is enabled for this study.\n \"\"\"" ]
[ { "param": "func", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "func", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e028eb49bb2978411f0d0b3b6ee85fef8e48c7e0
Newbas/beiwe-backend
api/study_api.py
[ "BSD-3-Clause" ]
Python
delete_intervention
<not_specific>
def delete_intervention(study_id=None): """Deletes the specified Intervention. Expects intervention in the request body.""" study = Study.objects.get(pk=study_id) intervention_id = request.values.get('intervention') if intervention_id: try: intervention = Intervention.objects.g...
Deletes the specified Intervention. Expects intervention in the request body.
Deletes the specified Intervention. Expects intervention in the request body.
[ "Deletes", "the", "specified", "Intervention", ".", "Expects", "intervention", "in", "the", "request", "body", "." ]
def delete_intervention(study_id=None): study = Study.objects.get(pk=study_id) intervention_id = request.values.get('intervention') if intervention_id: try: intervention = Intervention.objects.get(id=intervention_id) except Intervention.DoesNotExist: intervention = No...
[ "def", "delete_intervention", "(", "study_id", "=", "None", ")", ":", "study", "=", "Study", ".", "objects", ".", "get", "(", "pk", "=", "study_id", ")", "intervention_id", "=", "request", ".", "values", ".", "get", "(", "'intervention'", ")", "if", "int...
Deletes the specified Intervention.
[ "Deletes", "the", "specified", "Intervention", "." ]
[ "\"\"\"Deletes the specified Intervention. Expects intervention in the request body.\"\"\"" ]
[ { "param": "study_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "study_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e028eb49bb2978411f0d0b3b6ee85fef8e48c7e0
Newbas/beiwe-backend
api/study_api.py
[ "BSD-3-Clause" ]
Python
edit_intervention
<not_specific>
def edit_intervention(study_id=None): """ Edits the name of the intervention. Expects intervention_id and edit_intervention in the request body """ study = Study.objects.get(pk=study_id) intervention_id = request.values.get('intervention_id', None) new_name = request.values.get('edit_...
Edits the name of the intervention. Expects intervention_id and edit_intervention in the request body
Edits the name of the intervention. Expects intervention_id and edit_intervention in the request body
[ "Edits", "the", "name", "of", "the", "intervention", ".", "Expects", "intervention_id", "and", "edit_intervention", "in", "the", "request", "body" ]
def edit_intervention(study_id=None): study = Study.objects.get(pk=study_id) intervention_id = request.values.get('intervention_id', None) new_name = request.values.get('edit_intervention', None) if intervention_id: try: intervention = Intervention.objects.get(id=intervention_id) ...
[ "def", "edit_intervention", "(", "study_id", "=", "None", ")", ":", "study", "=", "Study", ".", "objects", ".", "get", "(", "pk", "=", "study_id", ")", "intervention_id", "=", "request", ".", "values", ".", "get", "(", "'intervention_id'", ",", "None", "...
Edits the name of the intervention.
[ "Edits", "the", "name", "of", "the", "intervention", "." ]
[ "\"\"\"\r\n Edits the name of the intervention. Expects intervention_id and edit_intervention in the\r\n request body\r\n \"\"\"" ]
[ { "param": "study_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "study_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e028eb49bb2978411f0d0b3b6ee85fef8e48c7e0
Newbas/beiwe-backend
api/study_api.py
[ "BSD-3-Clause" ]
Python
delete_field
<not_specific>
def delete_field(study_id=None): """Deletes the specified Custom Field. Expects field in the request body.""" study = Study.objects.get(pk=study_id) field = request.values.get('field', None) if field: try: study_field = StudyField.objects.get(study=study, id=field) exc...
Deletes the specified Custom Field. Expects field in the request body.
Deletes the specified Custom Field. Expects field in the request body.
[ "Deletes", "the", "specified", "Custom", "Field", ".", "Expects", "field", "in", "the", "request", "body", "." ]
def delete_field(study_id=None): study = Study.objects.get(pk=study_id) field = request.values.get('field', None) if field: try: study_field = StudyField.objects.get(study=study, id=field) except StudyField.DoesNotExist: study_field = None try: if ...
[ "def", "delete_field", "(", "study_id", "=", "None", ")", ":", "study", "=", "Study", ".", "objects", ".", "get", "(", "pk", "=", "study_id", ")", "field", "=", "request", ".", "values", ".", "get", "(", "'field'", ",", "None", ")", "if", "field", ...
Deletes the specified Custom Field.
[ "Deletes", "the", "specified", "Custom", "Field", "." ]
[ "\"\"\"Deletes the specified Custom Field. Expects field in the request body.\"\"\"" ]
[ { "param": "study_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "study_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e028eb49bb2978411f0d0b3b6ee85fef8e48c7e0
Newbas/beiwe-backend
api/study_api.py
[ "BSD-3-Clause" ]
Python
edit_custom_field
<not_specific>
def edit_custom_field(study_id=None): """Edits the name of a Custom field. Expects field_id anf edit_custom_field in request body""" field_id = request.values.get("field_id") new_field_name = request.values.get("edit_custom_field") if field_id: try: field = StudyField.objects.g...
Edits the name of a Custom field. Expects field_id anf edit_custom_field in request body
Edits the name of a Custom field. Expects field_id anf edit_custom_field in request body
[ "Edits", "the", "name", "of", "a", "Custom", "field", ".", "Expects", "field_id", "anf", "edit_custom_field", "in", "request", "body" ]
def edit_custom_field(study_id=None): field_id = request.values.get("field_id") new_field_name = request.values.get("edit_custom_field") if field_id: try: field = StudyField.objects.get(id=field_id) except StudyField.DoesNotExist: field = None if field and new...
[ "def", "edit_custom_field", "(", "study_id", "=", "None", ")", ":", "field_id", "=", "request", ".", "values", ".", "get", "(", "\"field_id\"", ")", "new_field_name", "=", "request", ".", "values", ".", "get", "(", "\"edit_custom_field\"", ")", "if", "field_...
Edits the name of a Custom field.
[ "Edits", "the", "name", "of", "a", "Custom", "field", "." ]
[ "\"\"\"Edits the name of a Custom field. Expects field_id anf edit_custom_field in request body\"\"\"", "# this apparent insanity is a hopefully unnecessary confirmation of the study id\r" ]
[ { "param": "study_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "study_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4326d61916e26b22505bfdd27b897898d9a5a26c
Newbas/beiwe-backend
api/copy_study_api.py
[ "BSD-3-Clause" ]
Python
export_study_settings_file
<not_specific>
def export_study_settings_file(study_id): """ Endpoint that returns a json representation of a study. """ study = Study.objects.get(pk=study_id) filename = study.name.replace(' ', '_') + "_surveys_and_settings.json" return Response( format_study(study), mimetype="application/json", ...
Endpoint that returns a json representation of a study.
Endpoint that returns a json representation of a study.
[ "Endpoint", "that", "returns", "a", "json", "representation", "of", "a", "study", "." ]
def export_study_settings_file(study_id): study = Study.objects.get(pk=study_id) filename = study.name.replace(' ', '_') + "_surveys_and_settings.json" return Response( format_study(study), mimetype="application/json", headers={'Content-Disposition': 'attachment;filename=' + filename...
[ "def", "export_study_settings_file", "(", "study_id", ")", ":", "study", "=", "Study", ".", "objects", ".", "get", "(", "pk", "=", "study_id", ")", "filename", "=", "study", ".", "name", ".", "replace", "(", "' '", ",", "'_'", ")", "+", "\"_surveys_and_s...
Endpoint that returns a json representation of a study.
[ "Endpoint", "that", "returns", "a", "json", "representation", "of", "a", "study", "." ]
[ "\"\"\" Endpoint that returns a json representation of a study. \"\"\"" ]
[ { "param": "study_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "study_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4326d61916e26b22505bfdd27b897898d9a5a26c
Newbas/beiwe-backend
api/copy_study_api.py
[ "BSD-3-Clause" ]
Python
import_study_settings_file
<not_specific>
def import_study_settings_file(study_id): """ Endpoint that takes the output of export_study_settings_file and creates a new study. """ study = Study.objects.get(pk=study_id) file = request.files.get('upload', None) if not file: abort(400) if not allowed_file_extension(file.filename): ...
Endpoint that takes the output of export_study_settings_file and creates a new study.
Endpoint that takes the output of export_study_settings_file and creates a new study.
[ "Endpoint", "that", "takes", "the", "output", "of", "export_study_settings_file", "and", "creates", "a", "new", "study", "." ]
def import_study_settings_file(study_id): study = Study.objects.get(pk=study_id) file = request.files.get('upload', None) if not file: abort(400) if not allowed_file_extension(file.filename): flash("You can only upload .json files!", 'danger') return redirect(request.referrer) ...
[ "def", "import_study_settings_file", "(", "study_id", ")", ":", "study", "=", "Study", ".", "objects", ".", "get", "(", "pk", "=", "study_id", ")", "file", "=", "request", ".", "files", ".", "get", "(", "'upload'", ",", "None", ")", "if", "not", "file"...
Endpoint that takes the output of export_study_settings_file and creates a new study.
[ "Endpoint", "that", "takes", "the", "output", "of", "export_study_settings_file", "and", "creates", "a", "new", "study", "." ]
[ "\"\"\" Endpoint that takes the output of export_study_settings_file and creates a new study. \"\"\"", "# initial_image_surveys = study.objects.filter(survey_type=Survey.IMAGE_SURVEY).count()", "# end_image_surveys = study.objects.filter(survey_type=Survey.IMAGE_SURVEY).count()" ]
[ { "param": "study_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "study_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cc1e511f912d2b318b82b9a20284af5f231ec619
Newbas/beiwe-backend
libs/firebase_config.py
[ "BSD-3-Clause" ]
Python
update_firebase_instance
None
def update_firebase_instance(rucur_depth=3) -> None: """ Creates or destroys the firebase app, handling basic credential errors. """ junk_creds = False encoded_credentials = None # IDE complains try: encoded_credentials = json.loads(safely_get_db_credential(BACKEND_FIREBASE_CREDENTIALS)) e...
Creates or destroys the firebase app, handling basic credential errors.
Creates or destroys the firebase app, handling basic credential errors.
[ "Creates", "or", "destroys", "the", "firebase", "app", "handling", "basic", "credential", "errors", "." ]
def update_firebase_instance(rucur_depth=3) -> None: junk_creds = False encoded_credentials = None try: encoded_credentials = json.loads(safely_get_db_credential(BACKEND_FIREBASE_CREDENTIALS)) except (JSONDecodeError, TypeError): junk_creds = True try: delete_firebase_insta...
[ "def", "update_firebase_instance", "(", "rucur_depth", "=", "3", ")", "->", "None", ":", "junk_creds", "=", "False", "encoded_credentials", "=", "None", "try", ":", "encoded_credentials", "=", "json", ".", "loads", "(", "safely_get_db_credential", "(", "BACKEND_FI...
Creates or destroys the firebase app, handling basic credential errors.
[ "Creates", "or", "destroys", "the", "firebase", "app", "handling", "basic", "credential", "errors", "." ]
[ "\"\"\" Creates or destroys the firebase app, handling basic credential errors. \"\"\"", "# IDE complains", "# occurs when get_firebase_app() fails, delete_firebase_instance is only called if it succeeds.", "# can now ~safely initialize the firebase app, re-casting any errors for runime scenarios", "# error...
[ { "param": "rucur_depth", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rucur_depth", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8e38e010bd96aef3252b428bf4bf53db51cadbd0
Newbas/beiwe-backend
api/mobile_api.py
[ "BSD-3-Clause" ]
Python
upload
<not_specific>
def upload(OS_API=""): """ Entry point to upload GPS, Accelerometer, Audio, PowerState, Calls Log, Texts Log, Survey Response, and debugging files to s3. Behavior: The Beiwe app is supposed to delete the uploaded file if it receives an html 200 response. The API returns a 200 response when the file...
Entry point to upload GPS, Accelerometer, Audio, PowerState, Calls Log, Texts Log, Survey Response, and debugging files to s3. Behavior: The Beiwe app is supposed to delete the uploaded file if it receives an html 200 response. The API returns a 200 response when the file has A) been successfully hand...
Entry point to upload GPS, Accelerometer, Audio, PowerState, Calls Log, Texts Log, Survey Response, and debugging files to s3. The Beiwe app is supposed to delete the uploaded file if it receives an html 200 response. The API returns a 200 response when the file has A) been successfully handled, B) the file it has bee...
[ "Entry", "point", "to", "upload", "GPS", "Accelerometer", "Audio", "PowerState", "Calls", "Log", "Texts", "Log", "Survey", "Response", "and", "debugging", "files", "to", "s3", ".", "The", "Beiwe", "app", "is", "supposed", "to", "delete", "the", "uploaded", "...
def upload(OS_API=""): file_name = request.values.get("file_name", None) if ( not bool(file_name) or file_name.startswith("rList") or file_name.startswith("PersistedInstallation") or not contains_valid_extension(file_name) ): return render_template('bl...
[ "def", "upload", "(", "OS_API", "=", "\"\"", ")", ":", "file_name", "=", "request", ".", "values", ".", "get", "(", "\"file_name\"", ",", "None", ")", "if", "(", "not", "bool", "(", "file_name", ")", "or", "file_name", ".", "startswith", "(", "\"rList\...
Entry point to upload GPS, Accelerometer, Audio, PowerState, Calls Log, Texts Log, Survey Response, and debugging files to s3.
[ "Entry", "point", "to", "upload", "GPS", "Accelerometer", "Audio", "PowerState", "Calls", "Log", "Texts", "Log", "Survey", "Response", "and", "debugging", "files", "to", "s3", "." ]
[ "\"\"\" Entry point to upload GPS, Accelerometer, Audio, PowerState, Calls Log, Texts Log,\n Survey Response, and debugging files to s3.\n\n Behavior:\n The Beiwe app is supposed to delete the uploaded file if it receives an html 200 response.\n The API returns a 200 response when the file has A) been s...
[ { "param": "OS_API", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "OS_API", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8e38e010bd96aef3252b428bf4bf53db51cadbd0
Newbas/beiwe-backend
api/mobile_api.py
[ "BSD-3-Clause" ]
Python
register_user
<not_specific>
def register_user(OS_API=""): """ Checks that the patient id has been granted, and that there is no device registered with that id. If the patient id has no device registered it registers this device and logs the bluetooth mac address. Check the documentation in user_authentication to ensure you have p...
Checks that the patient id has been granted, and that there is no device registered with that id. If the patient id has no device registered it registers this device and logs the bluetooth mac address. Check the documentation in user_authentication to ensure you have provided the proper credentials. R...
Checks that the patient id has been granted, and that there is no device registered with that id. If the patient id has no device registered it registers this device and logs the bluetooth mac address. Check the documentation in user_authentication to ensure you have provided the proper credentials. Returns the encryp...
[ "Checks", "that", "the", "patient", "id", "has", "been", "granted", "and", "that", "there", "is", "no", "device", "registered", "with", "that", "id", ".", "If", "the", "patient", "id", "has", "no", "device", "registered", "it", "registers", "this", "device...
def register_user(OS_API=""): patient_id = request.values['patient_id'] phone_number = request.values['phone_number'] device_id = request.values['device_id'] device_os = request.values.get('device_os', "none") os_version = request.values.get('os_version', "none") product = request.values.get("pr...
[ "def", "register_user", "(", "OS_API", "=", "\"\"", ")", ":", "patient_id", "=", "request", ".", "values", "[", "'patient_id'", "]", "phone_number", "=", "request", ".", "values", "[", "'phone_number'", "]", "device_id", "=", "request", ".", "values", "[", ...
Checks that the patient id has been granted, and that there is no device registered with that id.
[ "Checks", "that", "the", "patient", "id", "has", "been", "granted", "and", "that", "there", "is", "no", "device", "registered", "with", "that", "id", "." ]
[ "\"\"\" Checks that the patient id has been granted, and that there is no device registered with\n that id. If the patient id has no device registered it registers this device and logs the\n bluetooth mac address.\n Check the documentation in user_authentication to ensure you have provided the proper cred...
[ { "param": "OS_API", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "OS_API", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4d68cdc3eb4dee714fe22a454d12624cb0b2dee6
Newbas/beiwe-backend
services/celery_data_processing.py
[ "BSD-3-Clause" ]
Python
create_file_processing_tasks
null
def create_file_processing_tasks(): """ Generates tasks to enqueue. This is called every 6 minutes, and tasks have a lifetime of 6 minutes. Note that tasks are not removed from the queue by RabbitMQ, but by Celery. inspecting the queue will continue to display the tasks that have not been sent to Celery ...
Generates tasks to enqueue. This is called every 6 minutes, and tasks have a lifetime of 6 minutes. Note that tasks are not removed from the queue by RabbitMQ, but by Celery. inspecting the queue will continue to display the tasks that have not been sent to Celery until the most recent job is finished. ...
Generates tasks to enqueue. This is called every 6 minutes, and tasks have a lifetime of 6 minutes. Note that tasks are not removed from the queue by RabbitMQ, but by Celery. inspecting the queue will continue to display the tasks that have not been sent to Celery until the most recent job is finished. Also, for som...
[ "Generates", "tasks", "to", "enqueue", ".", "This", "is", "called", "every", "6", "minutes", "and", "tasks", "have", "a", "lifetime", "of", "6", "minutes", ".", "Note", "that", "tasks", "are", "not", "removed", "from", "the", "queue", "by", "RabbitMQ", "...
def create_file_processing_tasks(): expiry = (datetime.utcnow() + timedelta(minutes=5)).replace(second=30, microsecond=0) with make_error_sentry(sentry_type=SentryTypes.data_processing): participant_set = set( Participant.objects.filter(files_to_process__isnull=False) .distin...
[ "def", "create_file_processing_tasks", "(", ")", ":", "expiry", "=", "(", "datetime", ".", "utcnow", "(", ")", "+", "timedelta", "(", "minutes", "=", "5", ")", ")", ".", "replace", "(", "second", "=", "30", ",", "microsecond", "=", "0", ")", "with", ...
Generates tasks to enqueue.
[ "Generates", "tasks", "to", "enqueue", "." ]
[ "\"\"\" Generates tasks to enqueue. This is called every 6 minutes, and tasks have a lifetime\n of 6 minutes. Note that tasks are not removed from the queue by RabbitMQ, but by Celery.\n inspecting the queue will continue to display the tasks that have not been sent to Celery\n until the most recent job ...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
4d68cdc3eb4dee714fe22a454d12624cb0b2dee6
Newbas/beiwe-backend
services/celery_data_processing.py
[ "BSD-3-Clause" ]
Python
celery_process_file_chunks
null
def celery_process_file_chunks(participant_id): """ This is the function is queued up, it runs through all new uploads from a specific user and 'chunks' them. Handles logic for skipping bad files, raising errors. """ # celery doesn't clean up after itself very well, either memory or open network connection...
This is the function is queued up, it runs through all new uploads from a specific user and 'chunks' them. Handles logic for skipping bad files, raising errors.
This is the function is queued up, it runs through all new uploads from a specific user and 'chunks' them. Handles logic for skipping bad files, raising errors.
[ "This", "is", "the", "function", "is", "queued", "up", "it", "runs", "through", "all", "new", "uploads", "from", "a", "specific", "user", "and", "'", "chunks", "'", "them", ".", "Handles", "logic", "for", "skipping", "bad", "files", "raising", "errors", ...
def celery_process_file_chunks(participant_id): try: time_start = datetime.now() participant = Participant.objects.get(id=participant_id) number_bad_files = 0 tags = {'user_id': participant.patient_id} error_sentry = make_error_sentry(sentry_type=SentryTypes.data_processing) ...
[ "def", "celery_process_file_chunks", "(", "participant_id", ")", ":", "try", ":", "time_start", "=", "datetime", ".", "now", "(", ")", "participant", "=", "Participant", ".", "objects", ".", "get", "(", "id", "=", "participant_id", ")", "number_bad_files", "="...
This is the function is queued up, it runs through all new uploads from a specific user and 'chunks' them.
[ "This", "is", "the", "function", "is", "queued", "up", "it", "runs", "through", "all", "new", "uploads", "from", "a", "specific", "user", "and", "'", "chunks", "'", "them", "." ]
[ "\"\"\" This is the function is queued up, it runs through all new uploads from a specific user and\n 'chunks' them. Handles logic for skipping bad files, raising errors. \"\"\"", "# celery doesn't clean up after itself very well, either memory or open network connections.", "# this probably has something to...
[ { "param": "participant_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "participant_id", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
380d8a14e965244c01afb9e20fb07b52ee2de4fc
Newbas/beiwe-backend
database/migrations/0061_historical_data_qty_stats.py
[ "BSD-3-Clause" ]
Python
calculate_data_quantity_stats
null
def calculate_data_quantity_stats(participant: Participant): """ Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data """ study_timezone = gettz(participant.study.timezone_name) query = ChunkRegistry.objects.filter(participant=participant) daily_data_quant...
Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data
Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data
[ "Update", "the", "SummaryStatisticDaily", "stats", "for", "a", "participant", "using", "ChunkRegistry", "data" ]
def calculate_data_quantity_stats(participant: Participant): study_timezone = gettz(participant.study.timezone_name) query = ChunkRegistry.objects.filter(participant=participant) daily_data_quantities = defaultdict(lambda: defaultdict(int)) for chunkregistry in query.values_list('time_bi...
[ "def", "calculate_data_quantity_stats", "(", "participant", ":", "Participant", ")", ":", "study_timezone", "=", "gettz", "(", "participant", ".", "study", ".", "timezone_name", ")", "query", "=", "ChunkRegistry", ".", "objects", ".", "filter", "(", "participant",...
Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data
[ "Update", "the", "SummaryStatisticDaily", "stats", "for", "a", "participant", "using", "ChunkRegistry", "data" ]
[ "\"\"\" Update the SummaryStatisticDaily stats for a participant, using ChunkRegistry data \"\"\"", "# Construct a dict formatted like this: dict[date][data_type] = total_bytes", "# For each date, create a DataQuantity object" ]
[ { "param": "participant", "type": "Participant" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "participant", "type": "Participant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c1e813284ebece2db43a334aba04ee9dc832cd53
Newbas/beiwe-backend
database/study_models.py
[ "BSD-3-Clause" ]
Python
save
null
def save(self, *args, **kwargs): """ Ensure there is a study device settings attached to this study. """ # First we just save. This code has vacillated between throwing a validation error and not # during study creation. Our current fix is to save, then test whether a device settings # ...
Ensure there is a study device settings attached to this study.
Ensure there is a study device settings attached to this study.
[ "Ensure", "there", "is", "a", "study", "device", "settings", "attached", "to", "this", "study", "." ]
def save(self, *args, **kwargs): try: self.forest_param except ObjectDoesNotExist: self.forest_param = ForestParam.objects.get(default=True) super().save(*args, **kwargs) try: self.device_settings except ObjectDoesNotExist: settings...
[ "def", "save", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "self", ".", "forest_param", "except", "ObjectDoesNotExist", ":", "self", ".", "forest_param", "=", "ForestParam", ".", "objects", ".", "get", "(", "default", "=", ...
Ensure there is a study device settings attached to this study.
[ "Ensure", "there", "is", "a", "study", "device", "settings", "attached", "to", "this", "study", "." ]
[ "\"\"\" Ensure there is a study device settings attached to this study. \"\"\"", "# First we just save. This code has vacillated between throwing a validation error and not", "# during study creation. Our current fix is to save, then test whether a device settings", "# object exists. If not, create it.", ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c1e813284ebece2db43a334aba04ee9dc832cd53
Newbas/beiwe-backend
database/study_models.py
[ "BSD-3-Clause" ]
Python
_get_data_time_bin
Optional[datetime]
def _get_data_time_bin(self, earliest=True, only_after_epoch: bool = True, only_before_now: bool = True) -> Optional[datetime]: """ Return the earliest ChunkRegistry time bin datetime for this study. Note: As of 2021-07-01, running the query as a QuerySet filt...
Return the earliest ChunkRegistry time bin datetime for this study. Note: As of 2021-07-01, running the query as a QuerySet filter or sorting the QuerySet can take upwards of 30 seconds. Doing the logic in python speeds this up tremendously. Args: earliest: if...
Return the earliest ChunkRegistry time bin datetime for this study. Note: As of 2021-07-01, running the query as a QuerySet filter or sorting the QuerySet can take upwards of 30 seconds. Doing the logic in python speeds this up tremendously.
[ "Return", "the", "earliest", "ChunkRegistry", "time", "bin", "datetime", "for", "this", "study", ".", "Note", ":", "As", "of", "2021", "-", "07", "-", "01", "running", "the", "query", "as", "a", "QuerySet", "filter", "or", "sorting", "the", "QuerySet", "...
def _get_data_time_bin(self, earliest=True, only_after_epoch: bool = True, only_before_now: bool = True) -> Optional[datetime]: time_bins = self.chunk_registries.values_list("time_bin", flat=True) comparator = operator.lt if earliest else operator.gt now = timezone.now...
[ "def", "_get_data_time_bin", "(", "self", ",", "earliest", "=", "True", ",", "only_after_epoch", ":", "bool", "=", "True", ",", "only_before_now", ":", "bool", "=", "True", ")", "->", "Optional", "[", "datetime", "]", ":", "time_bins", "=", "self", ".", ...
Return the earliest ChunkRegistry time bin datetime for this study.
[ "Return", "the", "earliest", "ChunkRegistry", "time", "bin", "datetime", "for", "this", "study", "." ]
[ "\"\"\"\n Return the earliest ChunkRegistry time bin datetime for this study.\n \n Note: As of 2021-07-01, running the query as a QuerySet filter or sorting the QuerySet can\n take upwards of 30 seconds. Doing the logic in python speeds this up tremendously.\n Args:\n ...
[ { "param": "self", "type": null }, { "param": "earliest", "type": null }, { "param": "only_after_epoch", "type": "bool" }, { "param": "only_before_now", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "earliest", "type": null, "docstring": "if True, will return earlies...
e3d76597b34c9806c579afe966d279acb6b7601b
Newbas/beiwe-backend
libs/file_processing/file_processing_core.py
[ "BSD-3-Clause" ]
Python
do_process_user_file_chunks
<not_specific>
def do_process_user_file_chunks( page_size: int, error_handler: ErrorHandler, position: int, participant: Participant ): """ Run through the files to process, pull their data, put it into s3 bins. Run the file through the appropriate logic path based on file type. If a file is empty put its ftp...
Run through the files to process, pull their data, put it into s3 bins. Run the file through the appropriate logic path based on file type. If a file is empty put its ftp object to the empty_files_list, we can't delete objects in-place while iterating over the db. All files except for the audio r...
Run through the files to process, pull their data, put it into s3 bins. Run the file through the appropriate logic path based on file type. If a file is empty put its ftp object to the empty_files_list, we can't delete objects in-place while iterating over the db. All files except for the audio recording files are in...
[ "Run", "through", "the", "files", "to", "process", "pull", "their", "data", "put", "it", "into", "s3", "bins", ".", "Run", "the", "file", "through", "the", "appropriate", "logic", "path", "based", "on", "file", "type", ".", "If", "a", "file", "is", "em...
def do_process_user_file_chunks( page_size: int, error_handler: ErrorHandler, position: int, participant: Participant ): all_binified_data = defaultdict(lambda: ([], [])) ftps_to_remove = set() pool = ThreadPool(CONCURRENT_NETWORK_OPS) survey_id_dict = {} print(len(participant.files_to_pro...
[ "def", "do_process_user_file_chunks", "(", "page_size", ":", "int", ",", "error_handler", ":", "ErrorHandler", ",", "position", ":", "int", ",", "participant", ":", "Participant", ")", ":", "all_binified_data", "=", "defaultdict", "(", "lambda", ":", "(", "[", ...
Run through the files to process, pull their data, put it into s3 bins.
[ "Run", "through", "the", "files", "to", "process", "pull", "their", "data", "put", "it", "into", "s3", "bins", "." ]
[ "\"\"\"\n Run through the files to process, pull their data, put it into s3 bins. Run the file through\n the appropriate logic path based on file type.\n\n If a file is empty put its ftp object to the empty_files_list, we can't delete objects\n in-place while iterating over the db.\n\n All files exce...
[ { "param": "page_size", "type": "int" }, { "param": "error_handler", "type": "ErrorHandler" }, { "param": "position", "type": "int" }, { "param": "participant", "type": "Participant" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "page_size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "error_handler", "type": "ErrorHandler", "docstring": null, ...
e3d76597b34c9806c579afe966d279acb6b7601b
Newbas/beiwe-backend
libs/file_processing/file_processing_core.py
[ "BSD-3-Clause" ]
Python
process_one_file
<not_specific>
def process_one_file( file_for_processing: FileForProcessing, survey_id_dict: dict, all_binified_data: DefaultDict, ftps_to_remove: set ): """ This function is the inner loop of the chunking process. """ if file_for_processing.exception: file_for_processing.raise_data_processing_error()...
This function is the inner loop of the chunking process.
This function is the inner loop of the chunking process.
[ "This", "function", "is", "the", "inner", "loop", "of", "the", "chunking", "process", "." ]
def process_one_file( file_for_processing: FileForProcessing, survey_id_dict: dict, all_binified_data: DefaultDict, ftps_to_remove: set ): if file_for_processing.exception: file_for_processing.raise_data_processing_error() if file_for_processing.chunkable: newly_binified_data, su...
[ "def", "process_one_file", "(", "file_for_processing", ":", "FileForProcessing", ",", "survey_id_dict", ":", "dict", ",", "all_binified_data", ":", "DefaultDict", ",", "ftps_to_remove", ":", "set", ")", ":", "if", "file_for_processing", ".", "exception", ":", "file_...
This function is the inner loop of the chunking process.
[ "This", "function", "is", "the", "inner", "loop", "of", "the", "chunking", "process", "." ]
[ "\"\"\" This function is the inner loop of the chunking process. \"\"\"", "# there are two cases: chunkable data that can be stuck into \"time bins\" for each hour, and", "# files that do not need to be \"binified\" and pretty much just go into the ChunkRegistry unmodified.", "# survey answers store the surve...
[ { "param": "file_for_processing", "type": "FileForProcessing" }, { "param": "survey_id_dict", "type": "dict" }, { "param": "all_binified_data", "type": "DefaultDict" }, { "param": "ftps_to_remove", "type": "set" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file_for_processing", "type": "FileForProcessing", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "survey_id_dict", "type": "dict", "doc...
e3d76597b34c9806c579afe966d279acb6b7601b
Newbas/beiwe-backend
libs/file_processing/file_processing_core.py
[ "BSD-3-Clause" ]
Python
upload_binified_data
<not_specific>
def upload_binified_data(binified_data, error_handler, survey_id_dict): """ Takes in binified csv data and handles uploading/downloading+updating older data to/from S3 for each chunk. Returns a set of concatenations that have succeeded and can be removed. Returns the number of failed FTPS so...
Takes in binified csv data and handles uploading/downloading+updating older data to/from S3 for each chunk. Returns a set of concatenations that have succeeded and can be removed. Returns the number of failed FTPS so that we don't retry them. Returns the earliest and latest time bins ha...
Takes in binified csv data and handles uploading/downloading+updating older data to/from S3 for each chunk. Returns a set of concatenations that have succeeded and can be removed. Returns the number of failed FTPS so that we don't retry them. Returns the earliest and latest time bins handled Raises any errors on the pa...
[ "Takes", "in", "binified", "csv", "data", "and", "handles", "uploading", "/", "downloading", "+", "updating", "older", "data", "to", "/", "from", "S3", "for", "each", "chunk", ".", "Returns", "a", "set", "of", "concatenations", "that", "have", "succeeded", ...
def upload_binified_data(binified_data, error_handler, survey_id_dict): failed_ftps = set([]) ftps_to_retire = set([]) upload_these = [] earliest_time_bin = None latest_time_bin = None for data_bin, (data_rows_list, ftp_list) in binified_data.items(): with error_handler: try:...
[ "def", "upload_binified_data", "(", "binified_data", ",", "error_handler", ",", "survey_id_dict", ")", ":", "failed_ftps", "=", "set", "(", "[", "]", ")", "ftps_to_retire", "=", "set", "(", "[", "]", ")", "upload_these", "=", "[", "]", "earliest_time_bin", "...
Takes in binified csv data and handles uploading/downloading+updating older data to/from S3 for each chunk.
[ "Takes", "in", "binified", "csv", "data", "and", "handles", "uploading", "/", "downloading", "+", "updating", "older", "data", "to", "/", "from", "S3", "for", "each", "chunk", "." ]
[ "\"\"\" Takes in binified csv data and handles uploading/downloading+updating\n older data to/from S3 for each chunk.\n Returns a set of concatenations that have succeeded and can be removed.\n Returns the number of failed FTPS so that we don't retry them.\n Returns the earliest and late...
[ { "param": "binified_data", "type": null }, { "param": "error_handler", "type": null }, { "param": "survey_id_dict", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "binified_data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "error_handler", "type": null, "docstring": null, "do...
7508e4702a25641614b751eb73de5ba5211b7921
ivan866/smoothPursuitClassification
parsers/DataExporter.py
[ "MIT" ]
Python
createDir
str
def createDir(self, prefix:str = 'OUTPUT', dryRun:bool = False) -> str: """Creates timestamped directory to save data into. :param prefix: directory name prefix. :param dryRun: whether to actually create the dir or just generate the path :return: Directory path str. """ ...
Creates timestamped directory to save data into. :param prefix: directory name prefix. :param dryRun: whether to actually create the dir or just generate the path :return: Directory path str.
Creates timestamped directory to save data into.
[ "Creates", "timestamped", "directory", "to", "save", "data", "into", "." ]
def createDir(self, prefix:str = 'OUTPUT', dryRun:bool = False) -> str: if self.settingsReader.check(full=True): now = datetime.now().strftime('%Y-%m-%d %H_%M_%S') dateTag = ET.Element('date') dateTag.text = now self.settingsReader.settings.append(dateTag) ...
[ "def", "createDir", "(", "self", ",", "prefix", ":", "str", "=", "'OUTPUT'", ",", "dryRun", ":", "bool", "=", "False", ")", "->", "str", ":", "if", "self", ".", "settingsReader", ".", "check", "(", "full", "=", "True", ")", ":", "now", "=", "dateti...
Creates timestamped directory to save data into.
[ "Creates", "timestamped", "directory", "to", "save", "data", "into", "." ]
[ "\"\"\"Creates timestamped directory to save data into.\n\n :param prefix: directory name prefix.\n :param dryRun: whether to actually create the dir or just generate the path\n :return: Directory path str.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "prefix", "type": "str" }, { "param": "dryRun", "type": "bool" } ]
{ "returns": [ { "docstring": "Directory path str.", "docstring_tokens": [ "Directory", "path", "str", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstrin...
7508e4702a25641614b751eb73de5ba5211b7921
ivan866/smoothPursuitClassification
parsers/DataExporter.py
[ "MIT" ]
Python
copyMeta
None
def copyMeta(self, saveDir:str = '') -> None: """Writes settings and report to previously created save directory. :param saveDir: :return: """ if self.settingsReader.check(): if saveDir: metaDir = saveDir else: metaDir = se...
Writes settings and report to previously created save directory. :param saveDir: :return:
Writes settings and report to previously created save directory.
[ "Writes", "settings", "and", "report", "to", "previously", "created", "save", "directory", "." ]
def copyMeta(self, saveDir:str = '') -> None: if self.settingsReader.check(): if saveDir: metaDir = saveDir else: metaDir = self.saveDir self.settingsReader.save(metaDir) self.main.printToOut('Current settings copied to output.') ...
[ "def", "copyMeta", "(", "self", ",", "saveDir", ":", "str", "=", "''", ")", "->", "None", ":", "if", "self", ".", "settingsReader", ".", "check", "(", ")", ":", "if", "saveDir", ":", "metaDir", "=", "saveDir", "else", ":", "metaDir", "=", "self", "...
Writes settings and report to previously created save directory.
[ "Writes", "settings", "and", "report", "to", "previously", "created", "save", "directory", "." ]
[ "\"\"\"Writes settings and report to previously created save directory.\n\n :param saveDir:\n :return:\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "saveDir", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
7508e4702a25641614b751eb73de5ba5211b7921
ivan866/smoothPursuitClassification
parsers/DataExporter.py
[ "MIT" ]
Python
exportCSV
None
def exportCSV(self, multiData:object, format:str='csv') -> None: """Writes all data to CSV files. :param multiData: :param format: :return: """ if self.settingsReader.check() and multiData.check(): self.main.printToOut('Exporting data channels to {0}.'.format...
Writes all data to CSV files. :param multiData: :param format: :return:
Writes all data to CSV files.
[ "Writes", "all", "data", "to", "CSV", "files", "." ]
def exportCSV(self, multiData:object, format:str='csv') -> None: if self.settingsReader.check() and multiData.check(): self.main.printToOut('Exporting data channels to {0}.'.format(format.upper())) saveDir = self.createDir() for type in multiData.multiData.keys(): ...
[ "def", "exportCSV", "(", "self", ",", "multiData", ":", "object", ",", "format", ":", "str", "=", "'csv'", ")", "->", "None", ":", "if", "self", ".", "settingsReader", ".", "check", "(", ")", "and", "multiData", ".", "check", "(", ")", ":", "self", ...
Writes all data to CSV files.
[ "Writes", "all", "data", "to", "CSV", "files", "." ]
[ "\"\"\"Writes all data to CSV files.\n\n :param multiData:\n :param format:\n :return:\n \"\"\"", "#TODO switch to tagging mode if more than 1 id in settings", "#data = multiData.getChannelAndTag(channel, id, block='interval', format='dataframe', ignoreEmpty=False)", "#----" ]
[ { "param": "self", "type": null }, { "param": "multiData", "type": "object" }, { "param": "format", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
0a376419afd1b5e4f4d34742f35e50b5b4b724ff
ivan866/smoothPursuitClassification
algo/IVTFilter.py
[ "MIT" ]
Python
printParams
str
def printParams(self) -> str: """Returns a str describing the parameters set. :return: all parameters for this filter. """ res=[] for k,v in self.params.items(): res.append('{0}: {1}'.format(k,v)) return '; '.join(res)
Returns a str describing the parameters set. :return: all parameters for this filter.
Returns a str describing the parameters set.
[ "Returns", "a", "str", "describing", "the", "parameters", "set", "." ]
def printParams(self) -> str: res=[] for k,v in self.params.items(): res.append('{0}: {1}'.format(k,v)) return '; '.join(res)
[ "def", "printParams", "(", "self", ")", "->", "str", ":", "res", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "params", ".", "items", "(", ")", ":", "res", ".", "append", "(", "'{0}: {1}'", ".", "format", "(", "k", ",", "v", ")", "...
Returns a str describing the parameters set.
[ "Returns", "a", "str", "describing", "the", "parameters", "set", "." ]
[ "\"\"\"Returns a str describing the parameters set.\n\n :return: all parameters for this filter.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "all parameters for this filter.", "docstring_tokens": [ "all", "parameters", "for", "this", "filter", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": ...
0a376419afd1b5e4f4d34742f35e50b5b4b724ff
ivan866/smoothPursuitClassification
algo/IVTFilter.py
[ "MIT" ]
Python
runJob
None
def runJob(self, data:DataFrame, min_velocity:float, noise_level:float, min_static:float, min_motion:float) -> None: """Sets filter parameters, processes the data and returns the filtered result. :param data: pandas dataframe with only 2 columns - time and speed :param min_velocity: min saccad...
Sets filter parameters, processes the data and returns the filtered result. :param data: pandas dataframe with only 2 columns - time and speed :param min_velocity: min saccade velocity, otherwise consider as fixation :param noise_level: max noise velocity, what counts as saccade border ...
Sets filter parameters, processes the data and returns the filtered result.
[ "Sets", "filter", "parameters", "processes", "the", "data", "and", "returns", "the", "filtered", "result", "." ]
def runJob(self, data:DataFrame, min_velocity:float, noise_level:float, min_static:float, min_motion:float) -> None: self.setParameter('min_velocity', min_velocity) self.setParameter('noise_level', noise_level) self.setParameter('min_static', min_static) self.setParameter('min_motion', ...
[ "def", "runJob", "(", "self", ",", "data", ":", "DataFrame", ",", "min_velocity", ":", "float", ",", "noise_level", ":", "float", ",", "min_static", ":", "float", ",", "min_motion", ":", "float", ")", "->", "None", ":", "self", ".", "setParameter", "(", ...
Sets filter parameters, processes the data and returns the filtered result.
[ "Sets", "filter", "parameters", "processes", "the", "data", "and", "returns", "the", "filtered", "result", "." ]
[ "\"\"\"Sets filter parameters, processes the data and returns the filtered result.\n\n :param data: pandas dataframe with only 2 columns - time and speed\n :param min_velocity: min saccade velocity, otherwise consider as fixation\n :param noise_level: max noise velocity, what counts as saccade ...
[ { "param": "self", "type": null }, { "param": "data", "type": "DataFrame" }, { "param": "min_velocity", "type": "float" }, { "param": "noise_level", "type": "float" }, { "param": "min_static", "type": "float" }, { "param": "min_motion", "type": "fl...
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
0a376419afd1b5e4f4d34742f35e50b5b4b724ff
ivan866/smoothPursuitClassification
algo/IVTFilter.py
[ "MIT" ]
Python
traverseOffsets
tuple
def traverseOffsets(self, data, sindex:int, eindex:int, thres:float) -> tuple: """Runs step by step through data in given direction and finds nearest threshold value. :param data: :param sindex: start index :param eindex: end index :param thres: value to search for :retu...
Runs step by step through data in given direction and finds nearest threshold value. :param data: :param sindex: start index :param eindex: end index :param thres: value to search for :return: found indices
Runs step by step through data in given direction and finds nearest threshold value.
[ "Runs", "step", "by", "step", "through", "data", "in", "given", "direction", "and", "finds", "nearest", "threshold", "value", "." ]
def traverseOffsets(self, data, sindex:int, eindex:int, thres:float) -> tuple: myRange = data[:sindex] myRange = myRange[myRange <= thres] if len(myRange): svalue = myRange.index[-1] else: svalue = data.index[0] myRange = data[eindex:] myRange = my...
[ "def", "traverseOffsets", "(", "self", ",", "data", ",", "sindex", ":", "int", ",", "eindex", ":", "int", ",", "thres", ":", "float", ")", "->", "tuple", ":", "myRange", "=", "data", "[", ":", "sindex", "]", "myRange", "=", "myRange", "[", "myRange",...
Runs step by step through data in given direction and finds nearest threshold value.
[ "Runs", "step", "by", "step", "through", "data", "in", "given", "direction", "and", "finds", "nearest", "threshold", "value", "." ]
[ "\"\"\"Runs step by step through data in given direction and finds nearest threshold value.\n\n :param data:\n :param sindex: start index\n :param eindex: end index\n :param thres: value to search for\n :return: found indices\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "data", "type": null }, { "param": "sindex", "type": "int" }, { "param": "eindex", "type": "int" }, { "param": "thres", "type": "float" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
0a376419afd1b5e4f4d34742f35e50b5b4b724ff
ivan866/smoothPursuitClassification
algo/IVTFilter.py
[ "MIT" ]
Python
filterValues
DataFrame
def filterValues(self, values:DataFrame) -> DataFrame: """Filter out results based on condition. :param values: data to filter :return: filtered data """ dur = [] minMotion = self.getParameter('min_motion') values.apply(lambda x: dur.append(x['max'] - x['min']), ...
Filter out results based on condition. :param values: data to filter :return: filtered data
Filter out results based on condition.
[ "Filter", "out", "results", "based", "on", "condition", "." ]
def filterValues(self, values:DataFrame) -> DataFrame: dur = [] minMotion = self.getParameter('min_motion') values.apply(lambda x: dur.append(x['max'] - x['min']), axis=1) values['dur'] = dur res = values[values['dur'] >= minMotion] return res
[ "def", "filterValues", "(", "self", ",", "values", ":", "DataFrame", ")", "->", "DataFrame", ":", "dur", "=", "[", "]", "minMotion", "=", "self", ".", "getParameter", "(", "'min_motion'", ")", "values", ".", "apply", "(", "lambda", "x", ":", "dur", "."...
Filter out results based on condition.
[ "Filter", "out", "results", "based", "on", "condition", "." ]
[ "\"\"\"Filter out results based on condition.\n\n :param values: data to filter\n :return: filtered data\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "values", "type": "DataFrame" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
bc0bed69667f1b6b6c57108a65fd4d8af9f2ffeb
ivan866/smoothPursuitClassification
SmoothPursuitClassification.py
[ "MIT" ]
Python
printError
None
def printError(self) -> None: """Prints current Exception info to console. :return: None. """ eInfo = sys.exc_info() text = '{0}: {1}.'.format(eInfo[0].__name__, eInfo[1]) self.consoleContents += f'{text}\n' print(text)
Prints current Exception info to console. :return: None.
Prints current Exception info to console.
[ "Prints", "current", "Exception", "info", "to", "console", "." ]
def printError(self) -> None: eInfo = sys.exc_info() text = '{0}: {1}.'.format(eInfo[0].__name__, eInfo[1]) self.consoleContents += f'{text}\n' print(text)
[ "def", "printError", "(", "self", ")", "->", "None", ":", "eInfo", "=", "sys", ".", "exc_info", "(", ")", "text", "=", "'{0}: {1}.'", ".", "format", "(", "eInfo", "[", "0", "]", ".", "__name__", ",", "eInfo", "[", "1", "]", ")", "self", ".", "con...
Prints current Exception info to console.
[ "Prints", "current", "Exception", "info", "to", "console", "." ]
[ "\"\"\"Prints current Exception info to console.\n\n :return: None.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
bc0bed69667f1b6b6c57108a65fd4d8af9f2ffeb
ivan866/smoothPursuitClassification
SmoothPursuitClassification.py
[ "MIT" ]
Python
saveConsole
None
def saveConsole(self, saveDir:str) -> None: """Write current console contents to file. :param saveDir: Path to write into. :return: """ reportFile = open(saveDir + '/console.txt', 'w') reportFile.write(self.consoleContents) reportFile.close() self.printTo...
Write current console contents to file. :param saveDir: Path to write into. :return:
Write current console contents to file.
[ "Write", "current", "console", "contents", "to", "file", "." ]
def saveConsole(self, saveDir:str) -> None: reportFile = open(saveDir + '/console.txt', 'w') reportFile.write(self.consoleContents) reportFile.close() self.printToOut('Console contents saved to file.')
[ "def", "saveConsole", "(", "self", ",", "saveDir", ":", "str", ")", "->", "None", ":", "reportFile", "=", "open", "(", "saveDir", "+", "'/console.txt'", ",", "'w'", ")", "reportFile", ".", "write", "(", "self", ".", "consoleContents", ")", "reportFile", ...
Write current console contents to file.
[ "Write", "current", "console", "contents", "to", "file", "." ]
[ "\"\"\"Write current console contents to file.\n\n :param saveDir: Path to write into.\n :return:\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "saveDir", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
select
None
def select(self, file:str=None) -> None: """Selects file with settings, specified literally by path string, opens dialog otherwise. :param file: Path string. :return: None """ if not file: self.settingsFile = filedialog.askopenfilename(filetypes = (("eXtensib...
Selects file with settings, specified literally by path string, opens dialog otherwise. :param file: Path string. :return: None
Selects file with settings, specified literally by path string, opens dialog otherwise.
[ "Selects", "file", "with", "settings", "specified", "literally", "by", "path", "string", "opens", "dialog", "otherwise", "." ]
def select(self, file:str=None) -> None: if not file: self.settingsFile = filedialog.askopenfilename(filetypes = (("eXtensible Markup Language","*.xml"),("all files","*.*"))) else: self.settingsFile = file if self.settingsFile: self.dataDir = os.path.dirname(s...
[ "def", "select", "(", "self", ",", "file", ":", "str", "=", "None", ")", "->", "None", ":", "if", "not", "file", ":", "self", ".", "settingsFile", "=", "filedialog", ".", "askopenfilename", "(", "filetypes", "=", "(", "(", "\"eXtensible Markup Language\"",...
Selects file with settings, specified literally by path string, opens dialog otherwise.
[ "Selects", "file", "with", "settings", "specified", "literally", "by", "path", "string", "opens", "dialog", "otherwise", "." ]
[ "\"\"\"Selects file with settings, specified literally by path string, opens dialog otherwise.\n \n :param file: Path string.\n :return: None\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "file", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
read
None
def read(self) -> None: """Actually reads and parses xml file contents. :return: """ #self.main.logger.debug('reading settings...') try: self.settingsTree = ET.parse(self.settingsFile) self.settings = self.settingsTree.getroot() except xml.etree....
Actually reads and parses xml file contents. :return:
Actually reads and parses xml file contents.
[ "Actually", "reads", "and", "parses", "xml", "file", "contents", "." ]
def read(self) -> None: try: self.settingsTree = ET.parse(self.settingsFile) self.settings = self.settingsTree.getroot() except xml.etree.ElementTree.ParseError: self.main.printError() self.main.printToOut('ERROR: Bad settings file. Check your XML is valid...
[ "def", "read", "(", "self", ")", "->", "None", ":", "try", ":", "self", ".", "settingsTree", "=", "ET", ".", "parse", "(", "self", ".", "settingsFile", ")", "self", ".", "settings", "=", "self", ".", "settingsTree", ".", "getroot", "(", ")", "except"...
Actually reads and parses xml file contents.
[ "Actually", "reads", "and", "parses", "xml", "file", "contents", "." ]
[ "\"\"\"Actually reads and parses xml file contents.\n\n :return: \n \"\"\"", "#self.main.logger.debug('reading settings...')" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
genTypeFile
object
def genTypeFile(self, type:str) -> object: """Generator of ids of particular type present in settings. :param type: :return: File XML element from settings, if such file exists on disk. """ found=False if self.check(full=True): for elem in self.getTypes(type)...
Generator of ids of particular type present in settings. :param type: :return: File XML element from settings, if such file exists on disk.
Generator of ids of particular type present in settings.
[ "Generator", "of", "ids", "of", "particular", "type", "present", "in", "settings", "." ]
def genTypeFile(self, type:str) -> object: found=False if self.check(full=True): for elem in self.getTypes(type): file= '{0}/{1}'.format(self.dataDir, elem.get('path')) if os.path.exists(file): if not found: self.mai...
[ "def", "genTypeFile", "(", "self", ",", "type", ":", "str", ")", "->", "object", ":", "found", "=", "False", "if", "self", ".", "check", "(", "full", "=", "True", ")", ":", "for", "elem", "in", "self", ".", "getTypes", "(", "type", ")", ":", "fil...
Generator of ids of particular type present in settings.
[ "Generator", "of", "ids", "of", "particular", "type", "present", "in", "settings", "." ]
[ "\"\"\"Generator of ids of particular type present in settings.\n\n :param type:\n :return: File XML element from settings, if such file exists on disk.\n \"\"\"", "#добавляем контрольную сумму в настройки" ]
[ { "param": "self", "type": null }, { "param": "type", "type": "str" } ]
{ "returns": [ { "docstring": "File XML element from settings, if such file exists on disk.", "docstring_tokens": [ "File", "XML", "element", "from", "settings", "if", "such", "file", "exists", "on", "disk", ...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
substVersatileChannels
str
def substVersatileChannels(self, channel: str) -> str: """Substitutes related versatile channel names, which should be the name of the source file type channel in settings. :param channel: versatile channel name, like samples or gaze. :return: master channel name. """ #FIXME hot...
Substitutes related versatile channel names, which should be the name of the source file type channel in settings. :param channel: versatile channel name, like samples or gaze. :return: master channel name.
Substitutes related versatile channel names, which should be the name of the source file type channel in settings.
[ "Substitutes", "related", "versatile", "channel", "names", "which", "should", "be", "the", "name", "of", "the", "source", "file", "type", "channel", "in", "settings", "." ]
def substVersatileChannels(self, channel: str) -> str: if channel in self.main.SAMPLES_COMPONENTS_LIST and self.hasType('samples') and not self.hasType('saccade'): return 'samples' elif channel in self.main.GAZE_COMPONENTS_LIST and self.hasType('gaze') and not self.hasType('fixations'): ...
[ "def", "substVersatileChannels", "(", "self", ",", "channel", ":", "str", ")", "->", "str", ":", "if", "channel", "in", "self", ".", "main", ".", "SAMPLES_COMPONENTS_LIST", "and", "self", ".", "hasType", "(", "'samples'", ")", "and", "not", "self", ".", ...
Substitutes related versatile channel names, which should be the name of the source file type channel in settings.
[ "Substitutes", "related", "versatile", "channel", "names", "which", "should", "be", "the", "name", "of", "the", "source", "file", "type", "channel", "in", "settings", "." ]
[ "\"\"\"Substitutes related versatile channel names, which should be the name of the source file type channel in settings.\n\n :param channel: versatile channel name, like samples or gaze.\n :return: master channel name.\n \"\"\"", "#FIXME hotfix" ]
[ { "param": "self", "type": null }, { "param": "channel", "type": "str" } ]
{ "returns": [ { "docstring": "master channel name.", "docstring_tokens": [ "master", "channel", "name", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstr...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
unique
list
def unique(self, element:str='file', field:str='') -> list: """Filters all specified elements by field and returns unique. :param element: On what element of settings to filter on. :param field: For what field to search for. :return: List of unique fields in these elements. ...
Filters all specified elements by field and returns unique. :param element: On what element of settings to filter on. :param field: For what field to search for. :return: List of unique fields in these elements.
Filters all specified elements by field and returns unique.
[ "Filters", "all", "specified", "elements", "by", "field", "and", "returns", "unique", "." ]
def unique(self, element:str='file', field:str='') -> list: elements = self.settings.findall(element) l=[] for el in elements: l.append(el.get(field)) return np.unique(l)
[ "def", "unique", "(", "self", ",", "element", ":", "str", "=", "'file'", ",", "field", ":", "str", "=", "''", ")", "->", "list", ":", "elements", "=", "self", ".", "settings", ".", "findall", "(", "element", ")", "l", "=", "[", "]", "for", "el", ...
Filters all specified elements by field and returns unique.
[ "Filters", "all", "specified", "elements", "by", "field", "and", "returns", "unique", "." ]
[ "\"\"\"Filters all specified elements by field and returns unique.\n \n :param element: On what element of settings to filter on.\n :param field: For what field to search for.\n :return: List of unique fields in these elements.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "element", "type": "str" }, { "param": "field", "type": "str" } ]
{ "returns": [ { "docstring": "List of unique fields in these elements.", "docstring_tokens": [ "List", "of", "unique", "fields", "in", "these", "elements", "." ], "type": null } ], "raises": [], "params": [ { ...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
totalDuration
object
def totalDuration(self, block:str, parse:bool=True) -> object: """Returns total duration of all intervals. :param block: :param parse: bool whether to parse str to timedelta or not. :return: Duration of interval in timedelta or str format. """ dur = pd.DataFrame(...
Returns total duration of all intervals. :param block: :param parse: bool whether to parse str to timedelta or not. :return: Duration of interval in timedelta or str format.
Returns total duration of all intervals.
[ "Returns", "total", "duration", "of", "all", "intervals", "." ]
def totalDuration(self, block:str, parse:bool=True) -> object: dur = pd.DataFrame(self.getDurations(block=block, parse=True)).sum()[0] if parse: return dur else: return dur.strftime('%M:%S.%f')
[ "def", "totalDuration", "(", "self", ",", "block", ":", "str", ",", "parse", ":", "bool", "=", "True", ")", "->", "object", ":", "dur", "=", "pd", ".", "DataFrame", "(", "self", ".", "getDurations", "(", "block", "=", "block", ",", "parse", "=", "T...
Returns total duration of all intervals.
[ "Returns", "total", "duration", "of", "all", "intervals", "." ]
[ "\"\"\"Returns total duration of all intervals.\n \n :param block:\n :param parse: bool whether to parse str to timedelta or not.\n :return: Duration of interval in timedelta or str format.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "block", "type": "str" }, { "param": "parse", "type": "bool" } ]
{ "returns": [ { "docstring": "Duration of interval in timedelta or str format.", "docstring_tokens": [ "Duration", "of", "interval", "in", "timedelta", "or", "str", "format", "." ], "type": null } ], "raises":...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
hasType
bool
def hasType(self, type:str) -> bool: """Checks if such file type present. :param type: :return: """ if type in self.unique(field='type'): return True else: return False
Checks if such file type present. :param type: :return:
Checks if such file type present.
[ "Checks", "if", "such", "file", "type", "present", "." ]
def hasType(self, type:str) -> bool: if type in self.unique(field='type'): return True else: return False
[ "def", "hasType", "(", "self", ",", "type", ":", "str", ")", "->", "bool", ":", "if", "type", "in", "self", ".", "unique", "(", "field", "=", "'type'", ")", ":", "return", "True", "else", ":", "return", "False" ]
Checks if such file type present.
[ "Checks", "if", "such", "file", "type", "present", "." ]
[ "\"\"\"Checks if such file type present.\n\n :param type:\n :return:\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "type", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
check
bool
def check(self, full:bool=False) -> bool: """Returns True if settings are already selected, False otherwise. :param full: if to check settings actually read and parsed already. :return: A bool representing presence of settings file path. """ #self.main.logger.debug('check settin...
Returns True if settings are already selected, False otherwise. :param full: if to check settings actually read and parsed already. :return: A bool representing presence of settings file path.
Returns True if settings are already selected, False otherwise.
[ "Returns", "True", "if", "settings", "are", "already", "selected", "False", "otherwise", "." ]
def check(self, full:bool=False) -> bool: if not full: if self.settingsFile: return True else: self.main.printToOut('WARNING: Select settings first!') return False else: if self.settings: return True ...
[ "def", "check", "(", "self", ",", "full", ":", "bool", "=", "False", ")", "->", "bool", ":", "if", "not", "full", ":", "if", "self", ".", "settingsFile", ":", "return", "True", "else", ":", "self", ".", "main", ".", "printToOut", "(", "'WARNING: Sele...
Returns True if settings are already selected, False otherwise.
[ "Returns", "True", "if", "settings", "are", "already", "selected", "False", "otherwise", "." ]
[ "\"\"\"Returns True if settings are already selected, False otherwise.\n\n :param full: if to check settings actually read and parsed already.\n :return: A bool representing presence of settings file path.\n \"\"\"", "#self.main.logger.debug('check settings')" ]
[ { "param": "self", "type": null }, { "param": "full", "type": "bool" } ]
{ "returns": [ { "docstring": "A bool representing presence of settings file path.", "docstring_tokens": [ "A", "bool", "representing", "presence", "of", "settings", "file", "path", "." ], "type": null } ], "ra...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
save
None
def save(self, saveDir:str)->None: """Write current settings to file. :param saveDir: Path to write into. :return: """ self.main.logger.debug('writing settings...') self.settingsTree.write(saveDir + '/' + os.path.basename(self.settingsFile)) #TODO ...
Write current settings to file. :param saveDir: Path to write into. :return:
Write current settings to file.
[ "Write", "current", "settings", "to", "file", "." ]
def save(self, saveDir:str)->None: self.main.logger.debug('writing settings...') self.settingsTree.write(saveDir + '/' + os.path.basename(self.settingsFile))
[ "def", "save", "(", "self", ",", "saveDir", ":", "str", ")", "->", "None", ":", "self", ".", "main", ".", "logger", ".", "debug", "(", "'writing settings...'", ")", "self", ".", "settingsTree", ".", "write", "(", "saveDir", "+", "'/'", "+", "os", "."...
Write current settings to file.
[ "Write", "current", "settings", "to", "file", "." ]
[ "\"\"\"Write current settings to file.\n \n :param saveDir: Path to write into.\n :return: \n \"\"\"", "#TODO", "#bs = BeautifulSoup(self.settingsTree)", "#print(bs.prettify())" ]
[ { "param": "self", "type": null }, { "param": "saveDir", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
6d1af6423bdbc7cdc99894903b528dc66a147f41
ivan866/smoothPursuitClassification
utils/SettingsReader.py
[ "MIT" ]
Python
md5
str
def md5(self, fname:str)->str: """Calculates and returns MD5 hash checksum of a file. From https://stackoverflow.com/a/3431838/2795533 :param fname: file path. :return: md5 hex value. """ hash_md5 = hashlib.md5() with open(fname, "rb") as f: for chun...
Calculates and returns MD5 hash checksum of a file. From https://stackoverflow.com/a/3431838/2795533 :param fname: file path. :return: md5 hex value.
Calculates and returns MD5 hash checksum of a file.
[ "Calculates", "and", "returns", "MD5", "hash", "checksum", "of", "a", "file", "." ]
def md5(self, fname:str)->str: hash_md5 = hashlib.md5() with open(fname, "rb") as f: for chunk in iter(lambda: f.read(4096), b""): hash_md5.update(chunk) return hash_md5.hexdigest()
[ "def", "md5", "(", "self", ",", "fname", ":", "str", ")", "->", "str", ":", "hash_md5", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "fname", ",", "\"rb\"", ")", "as", "f", ":", "for", "chunk", "in", "iter", "(", "lambda", ":", "f...
Calculates and returns MD5 hash checksum of a file.
[ "Calculates", "and", "returns", "MD5", "hash", "checksum", "of", "a", "file", "." ]
[ "\"\"\"Calculates and returns MD5 hash checksum of a file.\n\n From https://stackoverflow.com/a/3431838/2795533\n\n :param fname: file path.\n :return: md5 hex value.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "fname", "type": "str" } ]
{ "returns": [ { "docstring": "md5 hex value.", "docstring_tokens": [ "md5", "hex", "value", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens":...
e6442a01314cad1c19c867a6a896489979174e57
ivan866/smoothPursuitClassification
algo/IBDT.py
[ "MIT" ]
Python
addPoint
None
def addPoint(self, entry:object) -> None: """Calculates velocity and classifies event type of the given sample, if already trained. Not a method for aggregating data samples. Method is for using the classifier. :param entry: IBDT_Data to classify event on. :return: """ ...
Calculates velocity and classifies event type of the given sample, if already trained. Not a method for aggregating data samples. Method is for using the classifier. :param entry: IBDT_Data to classify event on. :return:
Calculates velocity and classifies event type of the given sample, if already trained. Not a method for aggregating data samples. Method is for using the classifier.
[ "Calculates", "velocity", "and", "classifies", "event", "type", "of", "the", "given", "sample", "if", "already", "trained", ".", "Not", "a", "method", "for", "aggregating", "data", "samples", ".", "Method", "is", "for", "using", "the", "classifier", "." ]
def addPoint(self, entry:object) -> None: entry.base.classification = MOVEMENT['UNDEF'] if entry.base.confidence < self.minSampleConfidence: return None self.window.append( entry ) self.prev = self.cur self.cur = self.window[len(self.window)-1] while True: ...
[ "def", "addPoint", "(", "self", ",", "entry", ":", "object", ")", "->", "None", ":", "entry", ".", "base", ".", "classification", "=", "MOVEMENT", "[", "'UNDEF'", "]", "if", "entry", ".", "base", ".", "confidence", "<", "self", ".", "minSampleConfidence"...
Calculates velocity and classifies event type of the given sample, if already trained.
[ "Calculates", "velocity", "and", "classifies", "event", "type", "of", "the", "given", "sample", "if", "already", "trained", "." ]
[ "\"\"\"Calculates velocity and classifies event type of the given sample, if already trained.\n\n Not a method for aggregating data samples. Method is for using the classifier.\n\n :param entry: IBDT_Data to classify event on.\n :return:\n \"\"\"", "#Low confidence, ignore it", "#Add...
[ { "param": "self", "type": null }, { "param": "entry", "type": "object" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
e6442a01314cad1c19c867a6a896489979174e57
ivan866/smoothPursuitClassification
algo/IBDT.py
[ "MIT" ]
Python
train
None
def train(self, gaze:list) -> None: """Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters. :param gaze: list of IBDT_Data to train on. :return: """ samples = deque() #Find first valid sample for index in...
Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters. :param gaze: list of IBDT_Data to train on. :return:
Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters.
[ "Perform", "training", "on", "the", "data", "specified", "split", "velocity", "means", "on", "2", "clusters", "and", "update", "model", "hyperparameters", "." ]
def train(self, gaze:list) -> None: samples = deque() for index in range(0, len(gaze)): previous = gaze[index] if (previous != gaze[len(gaze)-1]) and (previous.base.confidence < self.minSampleConfidence): previous.base.v = np.nan continue ...
[ "def", "train", "(", "self", ",", "gaze", ":", "list", ")", "->", "None", ":", "samples", "=", "deque", "(", ")", "for", "index", "in", "range", "(", "0", ",", "len", "(", "gaze", ")", ")", ":", "previous", "=", "gaze", "[", "index", "]", "if",...
Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters.
[ "Perform", "training", "on", "the", "data", "specified", "split", "velocity", "means", "on", "2", "clusters", "and", "update", "model", "hyperparameters", "." ]
[ "\"\"\"Perform training on the data specified, split velocity means on 2 clusters and update model hyperparameters.\n\n :param gaze: list of IBDT_Data to train on.\n :return:\n \"\"\"", "#Find first valid sample", "#Estimate velocities for remaining training samples", "#TODO refactor to a...
[ { "param": "self", "type": null }, { "param": "gaze", "type": "list" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
e6442a01314cad1c19c867a6a896489979174e57
ivan866/smoothPursuitClassification
algo/IBDT.py
[ "MIT" ]
Python
estimateVelocity
float
def estimateVelocity(self, cur:object, prev:object) -> float: """Simple velocity, no smoothing, no angular speed. :param cur: :param prev: :return: velocity from trigonometric distance (incorrect) """ #TODO simple trigonometric distance, must be cosine law for spherical ...
Simple velocity, no smoothing, no angular speed. :param cur: :param prev: :return: velocity from trigonometric distance (incorrect)
Simple velocity, no smoothing, no angular speed.
[ "Simple", "velocity", "no", "smoothing", "no", "angular", "speed", "." ]
def estimateVelocity(self, cur:object, prev:object) -> float: dist = cv2.norm( np.array([cur.base.x, cur.base.y]), np.array([prev.base.x, prev.base.y]) ) dt = cur.base.ts - prev.base.ts return dist / dt
[ "def", "estimateVelocity", "(", "self", ",", "cur", ":", "object", ",", "prev", ":", "object", ")", "->", "float", ":", "dist", "=", "cv2", ".", "norm", "(", "np", ".", "array", "(", "[", "cur", ".", "base", ".", "x", ",", "cur", ".", "base", "...
Simple velocity, no smoothing, no angular speed.
[ "Simple", "velocity", "no", "smoothing", "no", "angular", "speed", "." ]
[ "\"\"\"Simple velocity, no smoothing, no angular speed.\n\n :param cur:\n :param prev:\n :return: velocity from trigonometric distance (incorrect)\n \"\"\"", "#TODO simple trigonometric distance, must be cosine law for spherical eye model" ]
[ { "param": "self", "type": null }, { "param": "cur", "type": "object" }, { "param": "prev", "type": "object" } ]
{ "returns": [ { "docstring": "velocity from trigonometric distance (incorrect)", "docstring_tokens": [ "velocity", "from", "trigonometric", "distance", "(", "incorrect", ")" ], "type": null } ], "raises": [], "params": [ ...
e6442a01314cad1c19c867a6a896489979174e57
ivan866/smoothPursuitClassification
algo/IBDT.py
[ "MIT" ]
Python
runJob
list
def runJob(self, data:DataFrame, maxSaccadeDurationMs:float, minSampleConfidence:float, classification:int) -> list: """Sets classifier parameters, runs classification and returns list of specified event type. :param data: pandas dataframe with 4 columns - time(ms), validity(higher is more valid), x(p...
Sets classifier parameters, runs classification and returns list of specified event type. :param data: pandas dataframe with 4 columns - time(ms), validity(higher is more valid), x(px or mm), y(px or mm). :param maxSaccadeDurationMs: saccades longer than this will not be classified as saccades. ...
Sets classifier parameters, runs classification and returns list of specified event type.
[ "Sets", "classifier", "parameters", "runs", "classification", "and", "returns", "list", "of", "specified", "event", "type", "." ]
def runJob(self, data:DataFrame, maxSaccadeDurationMs:float, minSampleConfidence:float, classification:int) -> list: self.maxSaccadeDurationMs = maxSaccadeDurationMs self.minSampleConfidence = minSampleConfidence self.classification = classification ibdtData = [] for index, row ...
[ "def", "runJob", "(", "self", ",", "data", ":", "DataFrame", ",", "maxSaccadeDurationMs", ":", "float", ",", "minSampleConfidence", ":", "float", ",", "classification", ":", "int", ")", "->", "list", ":", "self", ".", "maxSaccadeDurationMs", "=", "maxSaccadeDu...
Sets classifier parameters, runs classification and returns list of specified event type.
[ "Sets", "classifier", "parameters", "runs", "classification", "and", "returns", "list", "of", "specified", "event", "type", "." ]
[ "\"\"\"Sets classifier parameters, runs classification and returns list of specified event type.\n\n :param data: pandas dataframe with 4 columns - time(ms), validity(higher is more valid), x(px or mm), y(px or mm).\n :param maxSaccadeDurationMs: saccades longer than this will not be classified as sac...
[ { "param": "self", "type": null }, { "param": "data", "type": "DataFrame" }, { "param": "maxSaccadeDurationMs", "type": "float" }, { "param": "minSampleConfidence", "type": "float" }, { "param": "classification", "type": "int" } ]
{ "returns": [ { "docstring": "list of IBDT_Data with events classified.", "docstring_tokens": [ "list", "of", "IBDT_Data", "with", "events", "classified", "." ], "type": null } ], "raises": [], "params": [ { "iden...
e6442a01314cad1c19c867a6a896489979174e57
ivan866/smoothPursuitClassification
algo/IBDT.py
[ "MIT" ]
Python
updatePursuitPrior
None
def updatePursuitPrior(self) -> None: """Calculates mean of all ?but last window values. :return: """ #TODO refactor whole method to list comprehension previousLikelihoods = [] for index in range(0, len(self.window)-1): d = self.window[index] prev...
Calculates mean of all ?but last window values. :return:
Calculates mean of all ?but last window values.
[ "Calculates", "mean", "of", "all", "?but", "last", "window", "values", "." ]
def updatePursuitPrior(self) -> None: previousLikelihoods = [] for index in range(0, len(self.window)-1): d = self.window[index] previousLikelihoods.append(d.pursuit.likelihood) self.cur.pursuit.prior = np.mean(previousLikelihoods)
[ "def", "updatePursuitPrior", "(", "self", ")", "->", "None", ":", "previousLikelihoods", "=", "[", "]", "for", "index", "in", "range", "(", "0", ",", "len", "(", "self", ".", "window", ")", "-", "1", ")", ":", "d", "=", "self", ".", "window", "[", ...
Calculates mean of all ?but last window values.
[ "Calculates", "mean", "of", "all", "?but", "last", "window", "values", "." ]
[ "\"\"\"Calculates mean of all ?but last window values.\n\n :return:\n \"\"\"", "#TODO refactor whole method to list comprehension" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
e6442a01314cad1c19c867a6a896489979174e57
ivan866/smoothPursuitClassification
algo/IBDT.py
[ "MIT" ]
Python
updateFixationAndSaccadeLikelihood
None
def updateFixationAndSaccadeLikelihood(self) -> None: """Queries the model for predicted likelihoods, writes them to cur sample. :return: """ if self.cur.base.v < self.fMean: self.cur.fixation.likelihood = 1 self.cur.saccade.likelihood = 0 return None...
Queries the model for predicted likelihoods, writes them to cur sample. :return:
Queries the model for predicted likelihoods, writes them to cur sample.
[ "Queries", "the", "model", "for", "predicted", "likelihoods", "writes", "them", "to", "cur", "sample", "." ]
def updateFixationAndSaccadeLikelihood(self) -> None: if self.cur.base.v < self.fMean: self.cur.fixation.likelihood = 1 self.cur.saccade.likelihood = 0 return None if self.cur.base.v > self.sMean: self.cur.fixation.likelihood = 0 self.cur.sacca...
[ "def", "updateFixationAndSaccadeLikelihood", "(", "self", ")", "->", "None", ":", "if", "self", ".", "cur", ".", "base", ".", "v", "<", "self", ".", "fMean", ":", "self", ".", "cur", ".", "fixation", ".", "likelihood", "=", "1", "self", ".", "cur", "...
Queries the model for predicted likelihoods, writes them to cur sample.
[ "Queries", "the", "model", "for", "predicted", "likelihoods", "writes", "them", "to", "cur", "sample", "." ]
[ "\"\"\"Queries the model for predicted likelihoods, writes them to cur sample.\n\n :return:\n \"\"\"", "#all zeros in sample" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
e6442a01314cad1c19c867a6a896489979174e57
ivan866/smoothPursuitClassification
algo/IBDT.py
[ "MIT" ]
Python
binaryClassification
None
def binaryClassification(self) -> None: """Simple 2-class likelihood comparison. :return: """ if self.cur.fixation.likelihood > self.cur.saccade.likelihood: self.cur.classification = MOVEMENT['FIXATION'] else: self.cur.classification = MOVEMENT['SACCADE']
Simple 2-class likelihood comparison. :return:
Simple 2-class likelihood comparison.
[ "Simple", "2", "-", "class", "likelihood", "comparison", "." ]
def binaryClassification(self) -> None: if self.cur.fixation.likelihood > self.cur.saccade.likelihood: self.cur.classification = MOVEMENT['FIXATION'] else: self.cur.classification = MOVEMENT['SACCADE']
[ "def", "binaryClassification", "(", "self", ")", "->", "None", ":", "if", "self", ".", "cur", ".", "fixation", ".", "likelihood", ">", "self", ".", "cur", ".", "saccade", ".", "likelihood", ":", "self", ".", "cur", ".", "classification", "=", "MOVEMENT",...
Simple 2-class likelihood comparison.
[ "Simple", "2", "-", "class", "likelihood", "comparison", "." ]
[ "\"\"\"Simple 2-class likelihood comparison.\n\n :return:\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
e6442a01314cad1c19c867a6a896489979174e57
ivan866/smoothPursuitClassification
algo/IBDT.py
[ "MIT" ]
Python
ternaryClassification
None
def ternaryClassification(self) -> None: """3-class Bayesian posterior comparison. :return: """ #Class that maximizes posterior probability maxPosterior = self.cur.fixation.posterior self.cur.base.classification = MOVEMENT['FIXATION'] if self.cur.saccade.poster...
3-class Bayesian posterior comparison. :return:
3-class Bayesian posterior comparison.
[ "3", "-", "class", "Bayesian", "posterior", "comparison", "." ]
def ternaryClassification(self) -> None: maxPosterior = self.cur.fixation.posterior self.cur.base.classification = MOVEMENT['FIXATION'] if self.cur.saccade.posterior > maxPosterior: self.cur.base.classification = MOVEMENT['SACCADE'] maxPosterior = self.cur.saccade.posteri...
[ "def", "ternaryClassification", "(", "self", ")", "->", "None", ":", "maxPosterior", "=", "self", ".", "cur", ".", "fixation", ".", "posterior", "self", ".", "cur", ".", "base", ".", "classification", "=", "MOVEMENT", "[", "'FIXATION'", "]", "if", "self", ...
3-class Bayesian posterior comparison.
[ "3", "-", "class", "Bayesian", "posterior", "comparison", "." ]
[ "\"\"\"3-class Bayesian posterior comparison.\n\n :return:\n \"\"\"", "#Class that maximizes posterior probability", "#Catch up saccades as saccades" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
95a1dbcd7206b07712b8abcfd7db96c2bb07a806
ivan866/smoothPursuitClassification
parsers/DataReader.py
[ "MIT" ]
Python
read
None
def read(self, settingsReader:object, multiData:object) -> None: """Actual data parsing code. Depends on pandas module. :param settingsReader: SettingsReader object to get xml settings tree from. :param multiData: MultiData object to write into. :return: """ ...
Actual data parsing code. Depends on pandas module. :param settingsReader: SettingsReader object to get xml settings tree from. :param multiData: MultiData object to write into. :return:
Actual data parsing code. Depends on pandas module.
[ "Actual", "data", "parsing", "code", ".", "Depends", "on", "pandas", "module", "." ]
def read(self, settingsReader:object, multiData:object) -> None: if settingsReader.check(): settingsReader.read() else: return multiData.reset() try: self.readSMISamples(settingsReader, multiData) self.readTobiiGaze(settingsReader, multiDat...
[ "def", "read", "(", "self", ",", "settingsReader", ":", "object", ",", "multiData", ":", "object", ")", "->", "None", ":", "if", "settingsReader", ".", "check", "(", ")", ":", "settingsReader", ".", "read", "(", ")", "else", ":", "return", "multiData", ...
Actual data parsing code.
[ "Actual", "data", "parsing", "code", "." ]
[ "\"\"\"Actual data parsing code.\n \n Depends on pandas module.\n\n :param settingsReader: SettingsReader object to get xml settings tree from.\n :param multiData: MultiData object to write into.\n :return:\n \"\"\"", "#self.main.logger.debug('reading data...')" ]
[ { "param": "self", "type": null }, { "param": "settingsReader", "type": "object" }, { "param": "multiData", "type": "object" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
95a1dbcd7206b07712b8abcfd7db96c2bb07a806
ivan866/smoothPursuitClassification
parsers/DataReader.py
[ "MIT" ]
Python
readTobiiGaze
None
def readTobiiGaze(self, settingsReader:object, multiData:object) -> None: """Reads Tobii Glasses 2 gaze data from .tsv file. :param settingsReader: same as everywhere :param multiData: same :return: """ for fileElem in settingsReader.genTypeFile('gaze'): ...
Reads Tobii Glasses 2 gaze data from .tsv file. :param settingsReader: same as everywhere :param multiData: same :return:
Reads Tobii Glasses 2 gaze data from .tsv file.
[ "Reads", "Tobii", "Glasses", "2", "gaze", "data", "from", ".", "tsv", "file", "." ]
def readTobiiGaze(self, settingsReader:object, multiData:object) -> None: for fileElem in settingsReader.genTypeFile('gaze'): filePath = settingsReader.getPathAttrById('gaze', fileElem.get('id'), absolute=True) fileExt = os.path.splitext(filePath)[1] self.main.printToOut('Rea...
[ "def", "readTobiiGaze", "(", "self", ",", "settingsReader", ":", "object", ",", "multiData", ":", "object", ")", "->", "None", ":", "for", "fileElem", "in", "settingsReader", ".", "genTypeFile", "(", "'gaze'", ")", ":", "filePath", "=", "settingsReader", "."...
Reads Tobii Glasses 2 gaze data from .tsv file.
[ "Reads", "Tobii", "Glasses", "2", "gaze", "data", "from", ".", "tsv", "file", "." ]
[ "\"\"\"Reads Tobii Glasses 2 gaze data from .tsv file.\n \n :param settingsReader: same as everywhere\n :param multiData: same\n :return:\n \"\"\"", "# узнаем какие столбцы присутствуют", "# переводим в секунды", "#gazeData['Gaze event duration'] /= 1000", "# убираем пусты...
[ { "param": "self", "type": null }, { "param": "settingsReader", "type": "object" }, { "param": "multiData", "type": "object" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
6a88b9f26a8a20121162c5474c09f2e23fce6154
ivan866/smoothPursuitClassification
parsers/MultiData.py
[ "MIT" ]
Python
genChannelIds
tuple
def genChannelIds(self, channel:str) -> tuple: """Generator of ids present in multiData in particular channel (i.e. 'type' tag). :param channel: :return: Tuple with current channel and id, if such id present in multiData. """ if self.settingsReader.check() and self.check(): ...
Generator of ids present in multiData in particular channel (i.e. 'type' tag). :param channel: :return: Tuple with current channel and id, if such id present in multiData.
Generator of ids present in multiData in particular channel .
[ "Generator", "of", "ids", "present", "in", "multiData", "in", "particular", "channel", "." ]
def genChannelIds(self, channel:str) -> tuple: if self.settingsReader.check() and self.check(): channelZeroName = self.settingsReader.substVersatileChannels(channel) typeList = self.settingsReader.getTypes(channelZeroName) if not len(typeList): typeList = self...
[ "def", "genChannelIds", "(", "self", ",", "channel", ":", "str", ")", "->", "tuple", ":", "if", "self", ".", "settingsReader", ".", "check", "(", ")", "and", "self", ".", "check", "(", ")", ":", "channelZeroName", "=", "self", ".", "settingsReader", "....
Generator of ids present in multiData in particular channel (i.e.
[ "Generator", "of", "ids", "present", "in", "multiData", "in", "particular", "channel", "(", "i", ".", "e", "." ]
[ "\"\"\"Generator of ids present in multiData in particular channel (i.e. 'type' tag).\n\n :param channel:\n :return: Tuple with current channel and id, if such id present in multiData.\n \"\"\"", "#на случай если нет комбинированного типа в настройках" ]
[ { "param": "self", "type": null }, { "param": "channel", "type": "str" } ]
{ "returns": [ { "docstring": "Tuple with current channel and id, if such id present in multiData.", "docstring_tokens": [ "Tuple", "with", "current", "channel", "and", "id", "if", "such", "id", "present", "in", ...
6a88b9f26a8a20121162c5474c09f2e23fce6154
ivan866/smoothPursuitClassification
parsers/MultiData.py
[ "MIT" ]
Python
tagIntervals
DataFrame
def tagIntervals(self, chData:object, startFrom:object, block:str, ignoreEmpty:bool=True) -> DataFrame: """Tags given data by intervals, then returns a single dataframe. :param chData: data to stack intervals from, usually after getChannelById method. :param startFrom: zeroTime to start...
Tags given data by intervals, then returns a single dataframe. :param chData: data to stack intervals from, usually after getChannelById method. :param startFrom: zeroTime to start from. :param block: which type of block to tag by. :param ignoreEmpty: Whether to cut off the empt...
Tags given data by intervals, then returns a single dataframe.
[ "Tags", "given", "data", "by", "intervals", "then", "returns", "a", "single", "dataframe", "." ]
def tagIntervals(self, chData:object, startFrom:object, block:str, ignoreEmpty:bool=True) -> DataFrame: data = [] ints = self.settingsReader.getIntervals(block=block, ignoreEmpty=ignoreEmpty) for interval in ints: intData = self.getDataInterval(chData, startFrom, interval.get('id'), ...
[ "def", "tagIntervals", "(", "self", ",", "chData", ":", "object", ",", "startFrom", ":", "object", ",", "block", ":", "str", ",", "ignoreEmpty", ":", "bool", "=", "True", ")", "->", "DataFrame", ":", "data", "=", "[", "]", "ints", "=", "self", ".", ...
Tags given data by intervals, then returns a single dataframe.
[ "Tags", "given", "data", "by", "intervals", "then", "returns", "a", "single", "dataframe", "." ]
[ "\"\"\"Tags given data by intervals, then returns a single dataframe.\n \n :param chData: data to stack intervals from, usually after getChannelById method.\n :param startFrom: zeroTime to start from.\n :param block: which type of block to tag by.\n :param ignoreEmpty: Whether to ...
[ { "param": "self", "type": null }, { "param": "chData", "type": "object" }, { "param": "startFrom", "type": "object" }, { "param": "block", "type": "str" }, { "param": "ignoreEmpty", "type": "bool" } ]
{ "returns": [ { "docstring": "DataFrame object ready to group by intervals.", "docstring_tokens": [ "DataFrame", "object", "ready", "to", "group", "by", "intervals", "." ], "type": null } ], "raises": [], "params": ...
6a88b9f26a8a20121162c5474c09f2e23fce6154
ivan866/smoothPursuitClassification
parsers/MultiData.py
[ "MIT" ]
Python
hasColumn
bool
def hasColumn(self, column:str, id:str) -> bool: """Checks if multiData contains such column in its gaze channel. :param column: Column name from Tobii gaze data. :param id: string of channel id from settings. :return: True if column present, False otherwise. """ ...
Checks if multiData contains such column in its gaze channel. :param column: Column name from Tobii gaze data. :param id: string of channel id from settings. :return: True if column present, False otherwise.
Checks if multiData contains such column in its gaze channel.
[ "Checks", "if", "multiData", "contains", "such", "column", "in", "its", "gaze", "channel", "." ]
def hasColumn(self, column:str, id:str) -> bool: return column in self.multiData['availColumns'][id]
[ "def", "hasColumn", "(", "self", ",", "column", ":", "str", ",", "id", ":", "str", ")", "->", "bool", ":", "return", "column", "in", "self", ".", "multiData", "[", "'availColumns'", "]", "[", "id", "]" ]
Checks if multiData contains such column in its gaze channel.
[ "Checks", "if", "multiData", "contains", "such", "column", "in", "its", "gaze", "channel", "." ]
[ "\"\"\"Checks if multiData contains such column in its gaze channel.\n \n :param column: Column name from Tobii gaze data.\n :param id: string of channel id from settings.\n :return: True if column present, False otherwise.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "column", "type": "str" }, { "param": "id", "type": "str" } ]
{ "returns": [ { "docstring": "True if column present, False otherwise.", "docstring_tokens": [ "True", "if", "column", "present", "False", "otherwise", "." ], "type": null } ], "raises": [], "params": [ { "identif...
6a88b9f26a8a20121162c5474c09f2e23fce6154
ivan866/smoothPursuitClassification
parsers/MultiData.py
[ "MIT" ]
Python
hasAllColumns
bool
def hasAllColumns(self, columns:list, id:str) -> bool: """Checks if multiData contains ALL these columns passed in list. :param columns: List of strings with column names. :param id: string of channel id from settings. :return: True if all columns present, False otherwise. ...
Checks if multiData contains ALL these columns passed in list. :param columns: List of strings with column names. :param id: string of channel id from settings. :return: True if all columns present, False otherwise.
Checks if multiData contains ALL these columns passed in list.
[ "Checks", "if", "multiData", "contains", "ALL", "these", "columns", "passed", "in", "list", "." ]
def hasAllColumns(self, columns:list, id:str) -> bool: for col in columns: if col not in self.multiData['availColumns'][id]: return False return True
[ "def", "hasAllColumns", "(", "self", ",", "columns", ":", "list", ",", "id", ":", "str", ")", "->", "bool", ":", "for", "col", "in", "columns", ":", "if", "col", "not", "in", "self", ".", "multiData", "[", "'availColumns'", "]", "[", "id", "]", ":"...
Checks if multiData contains ALL these columns passed in list.
[ "Checks", "if", "multiData", "contains", "ALL", "these", "columns", "passed", "in", "list", "." ]
[ "\"\"\"Checks if multiData contains ALL these columns passed in list.\n \n :param columns: List of strings with column names.\n :param id: string of channel id from settings.\n :return: True if all columns present, False otherwise.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "columns", "type": "list" }, { "param": "id", "type": "str" } ]
{ "returns": [ { "docstring": "True if all columns present, False otherwise.", "docstring_tokens": [ "True", "if", "all", "columns", "present", "False", "otherwise", "." ], "type": null } ], "raises": [], "params": [...
6a88b9f26a8a20121162c5474c09f2e23fce6154
ivan866/smoothPursuitClassification
parsers/MultiData.py
[ "MIT" ]
Python
hasChannelById
bool
def hasChannelById(self, channel:str, id:str) -> bool: """Checks if multiData contains this channel.id node in its hierarchy. :param channel: string of type from settings. :param id: string of channel id from settings. :return: True if such id in such channel present, False othe...
Checks if multiData contains this channel.id node in its hierarchy. :param channel: string of type from settings. :param id: string of channel id from settings. :return: True if such id in such channel present, False otherwise.
Checks if multiData contains this channel.id node in its hierarchy.
[ "Checks", "if", "multiData", "contains", "this", "channel", ".", "id", "node", "in", "its", "hierarchy", "." ]
def hasChannelById(self, channel:str, id:str) -> bool: try: self.multiData[channel][id] return True except KeyError: return False
[ "def", "hasChannelById", "(", "self", ",", "channel", ":", "str", ",", "id", ":", "str", ")", "->", "bool", ":", "try", ":", "self", ".", "multiData", "[", "channel", "]", "[", "id", "]", "return", "True", "except", "KeyError", ":", "return", "False"...
Checks if multiData contains this channel.id node in its hierarchy.
[ "Checks", "if", "multiData", "contains", "this", "channel", ".", "id", "node", "in", "its", "hierarchy", "." ]
[ "\"\"\"Checks if multiData contains this channel.id node in its hierarchy.\n \n :param channel: string of type from settings.\n :param id: string of channel id from settings.\n :return: True if such id in such channel present, False otherwise.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "channel", "type": "str" }, { "param": "id", "type": "str" } ]
{ "returns": [ { "docstring": "True if such id in such channel present, False otherwise.", "docstring_tokens": [ "True", "if", "such", "id", "in", "such", "channel", "present", "False", "otherwise", "." ], ...