repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
edx/edx-val | edxval/api.py | get_transcript_preferences | def get_transcript_preferences(course_id):
"""
Retrieves course wide transcript preferences
Arguments:
course_id (str): course id
"""
try:
transcript_preference = TranscriptPreference.objects.get(course_id=course_id)
except TranscriptPreference.DoesNotExist:
return
... | python | def get_transcript_preferences(course_id):
"""
Retrieves course wide transcript preferences
Arguments:
course_id (str): course id
"""
try:
transcript_preference = TranscriptPreference.objects.get(course_id=course_id)
except TranscriptPreference.DoesNotExist:
return
... | [
"def",
"get_transcript_preferences",
"(",
"course_id",
")",
":",
"try",
":",
"transcript_preference",
"=",
"TranscriptPreference",
".",
"objects",
".",
"get",
"(",
"course_id",
"=",
"course_id",
")",
"except",
"TranscriptPreference",
".",
"DoesNotExist",
":",
"retur... | Retrieves course wide transcript preferences
Arguments:
course_id (str): course id | [
"Retrieves",
"course",
"wide",
"transcript",
"preferences"
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L419-L431 |
edx/edx-val | edxval/api.py | create_or_update_transcript_preferences | def create_or_update_transcript_preferences(course_id, **preferences):
"""
Creates or updates course-wide transcript preferences
Arguments:
course_id(str): course id
Keyword Arguments:
preferences(dict): keyword arguments
"""
transcript_preference, __ = TranscriptPreference.obj... | python | def create_or_update_transcript_preferences(course_id, **preferences):
"""
Creates or updates course-wide transcript preferences
Arguments:
course_id(str): course id
Keyword Arguments:
preferences(dict): keyword arguments
"""
transcript_preference, __ = TranscriptPreference.obj... | [
"def",
"create_or_update_transcript_preferences",
"(",
"course_id",
",",
"*",
"*",
"preferences",
")",
":",
"transcript_preference",
",",
"__",
"=",
"TranscriptPreference",
".",
"objects",
".",
"update_or_create",
"(",
"course_id",
"=",
"course_id",
",",
"defaults",
... | Creates or updates course-wide transcript preferences
Arguments:
course_id(str): course id
Keyword Arguments:
preferences(dict): keyword arguments | [
"Creates",
"or",
"updates",
"course",
"-",
"wide",
"transcript",
"preferences"
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L434-L447 |
edx/edx-val | edxval/api.py | remove_transcript_preferences | def remove_transcript_preferences(course_id):
"""
Deletes course-wide transcript preferences.
Arguments:
course_id(str): course id
"""
try:
transcript_preference = TranscriptPreference.objects.get(course_id=course_id)
transcript_preference.delete()
except TranscriptPrefe... | python | def remove_transcript_preferences(course_id):
"""
Deletes course-wide transcript preferences.
Arguments:
course_id(str): course id
"""
try:
transcript_preference = TranscriptPreference.objects.get(course_id=course_id)
transcript_preference.delete()
except TranscriptPrefe... | [
"def",
"remove_transcript_preferences",
"(",
"course_id",
")",
":",
"try",
":",
"transcript_preference",
"=",
"TranscriptPreference",
".",
"objects",
".",
"get",
"(",
"course_id",
"=",
"course_id",
")",
"transcript_preference",
".",
"delete",
"(",
")",
"except",
"... | Deletes course-wide transcript preferences.
Arguments:
course_id(str): course id | [
"Deletes",
"course",
"-",
"wide",
"transcript",
"preferences",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L450-L461 |
edx/edx-val | edxval/api.py | get_course_video_image_url | def get_course_video_image_url(course_id, edx_video_id):
"""
Returns course video image url or None if no image found
"""
try:
video_image = CourseVideo.objects.select_related('video_image').get(
course_id=course_id, video__edx_video_id=edx_video_id
).video_image
retu... | python | def get_course_video_image_url(course_id, edx_video_id):
"""
Returns course video image url or None if no image found
"""
try:
video_image = CourseVideo.objects.select_related('video_image').get(
course_id=course_id, video__edx_video_id=edx_video_id
).video_image
retu... | [
"def",
"get_course_video_image_url",
"(",
"course_id",
",",
"edx_video_id",
")",
":",
"try",
":",
"video_image",
"=",
"CourseVideo",
".",
"objects",
".",
"select_related",
"(",
"'video_image'",
")",
".",
"get",
"(",
"course_id",
"=",
"course_id",
",",
"video__ed... | Returns course video image url or None if no image found | [
"Returns",
"course",
"video",
"image",
"url",
"or",
"None",
"if",
"no",
"image",
"found"
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L464-L474 |
edx/edx-val | edxval/api.py | update_video_image | def update_video_image(edx_video_id, course_id, image_data, file_name):
"""
Update video image for an existing video.
NOTE: If `image_data` is None then `file_name` value will be used as it is, otherwise
a new file name is constructed based on uuid and extension from `file_name` value.
`image_data`... | python | def update_video_image(edx_video_id, course_id, image_data, file_name):
"""
Update video image for an existing video.
NOTE: If `image_data` is None then `file_name` value will be used as it is, otherwise
a new file name is constructed based on uuid and extension from `file_name` value.
`image_data`... | [
"def",
"update_video_image",
"(",
"edx_video_id",
",",
"course_id",
",",
"image_data",
",",
"file_name",
")",
":",
"try",
":",
"course_video",
"=",
"CourseVideo",
".",
"objects",
".",
"select_related",
"(",
"'video'",
")",
".",
"get",
"(",
"course_id",
"=",
... | Update video image for an existing video.
NOTE: If `image_data` is None then `file_name` value will be used as it is, otherwise
a new file name is constructed based on uuid and extension from `file_name` value.
`image_data` will be None in case of course re-run and export.
Arguments:
image_dat... | [
"Update",
"video",
"image",
"for",
"an",
"existing",
"video",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L477-L506 |
edx/edx-val | edxval/api.py | create_profile | def create_profile(profile_name):
"""
Used to create Profile objects in the database
A profile needs to exists before an EncodedVideo object can be created.
Args:
profile_name (str): ID of the profile
Raises:
ValCannotCreateError: Raised if the profile name is invalid or exists
... | python | def create_profile(profile_name):
"""
Used to create Profile objects in the database
A profile needs to exists before an EncodedVideo object can be created.
Args:
profile_name (str): ID of the profile
Raises:
ValCannotCreateError: Raised if the profile name is invalid or exists
... | [
"def",
"create_profile",
"(",
"profile_name",
")",
":",
"try",
":",
"profile",
"=",
"Profile",
"(",
"profile_name",
"=",
"profile_name",
")",
"profile",
".",
"full_clean",
"(",
")",
"profile",
".",
"save",
"(",
")",
"except",
"ValidationError",
"as",
"err",
... | Used to create Profile objects in the database
A profile needs to exists before an EncodedVideo object can be created.
Args:
profile_name (str): ID of the profile
Raises:
ValCannotCreateError: Raised if the profile name is invalid or exists | [
"Used",
"to",
"create",
"Profile",
"objects",
"in",
"the",
"database"
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L509-L526 |
edx/edx-val | edxval/api.py | _get_video | def _get_video(edx_video_id):
"""
Get a Video instance, prefetching encoded video and course information.
Raises ValVideoNotFoundError if the video cannot be retrieved.
"""
try:
return Video.objects.prefetch_related("encoded_videos", "courses").get(edx_video_id=edx_video_id)
except Vide... | python | def _get_video(edx_video_id):
"""
Get a Video instance, prefetching encoded video and course information.
Raises ValVideoNotFoundError if the video cannot be retrieved.
"""
try:
return Video.objects.prefetch_related("encoded_videos", "courses").get(edx_video_id=edx_video_id)
except Vide... | [
"def",
"_get_video",
"(",
"edx_video_id",
")",
":",
"try",
":",
"return",
"Video",
".",
"objects",
".",
"prefetch_related",
"(",
"\"encoded_videos\"",
",",
"\"courses\"",
")",
".",
"get",
"(",
"edx_video_id",
"=",
"edx_video_id",
")",
"except",
"Video",
".",
... | Get a Video instance, prefetching encoded video and course information.
Raises ValVideoNotFoundError if the video cannot be retrieved. | [
"Get",
"a",
"Video",
"instance",
"prefetching",
"encoded",
"video",
"and",
"course",
"information",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L529-L543 |
edx/edx-val | edxval/api.py | get_urls_for_profiles | def get_urls_for_profiles(edx_video_id, profiles):
"""
Returns a dict mapping profiles to URLs.
If the profiles or video is not found, urls will be blank.
Args:
edx_video_id (str): id of the video
profiles (list): list of profiles we want to search for
Returns:
(dict): A d... | python | def get_urls_for_profiles(edx_video_id, profiles):
"""
Returns a dict mapping profiles to URLs.
If the profiles or video is not found, urls will be blank.
Args:
edx_video_id (str): id of the video
profiles (list): list of profiles we want to search for
Returns:
(dict): A d... | [
"def",
"get_urls_for_profiles",
"(",
"edx_video_id",
",",
"profiles",
")",
":",
"profiles_to_urls",
"=",
"{",
"profile",
":",
"None",
"for",
"profile",
"in",
"profiles",
"}",
"try",
":",
"video_info",
"=",
"get_video_info",
"(",
"edx_video_id",
")",
"except",
... | Returns a dict mapping profiles to URLs.
If the profiles or video is not found, urls will be blank.
Args:
edx_video_id (str): id of the video
profiles (list): list of profiles we want to search for
Returns:
(dict): A dict containing the profile to url pair | [
"Returns",
"a",
"dict",
"mapping",
"profiles",
"to",
"URLs",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L595-L618 |
edx/edx-val | edxval/api.py | _get_videos_for_filter | def _get_videos_for_filter(video_filter, sort_field=None, sort_dir=SortDirection.asc, pagination_conf=None):
"""
Returns a generator expression that contains the videos found, sorted by
the given field and direction, with ties broken by edx_video_id to ensure a
total order.
"""
videos = Video.ob... | python | def _get_videos_for_filter(video_filter, sort_field=None, sort_dir=SortDirection.asc, pagination_conf=None):
"""
Returns a generator expression that contains the videos found, sorted by
the given field and direction, with ties broken by edx_video_id to ensure a
total order.
"""
videos = Video.ob... | [
"def",
"_get_videos_for_filter",
"(",
"video_filter",
",",
"sort_field",
"=",
"None",
",",
"sort_dir",
"=",
"SortDirection",
".",
"asc",
",",
"pagination_conf",
"=",
"None",
")",
":",
"videos",
"=",
"Video",
".",
"objects",
".",
"filter",
"(",
"*",
"*",
"v... | Returns a generator expression that contains the videos found, sorted by
the given field and direction, with ties broken by edx_video_id to ensure a
total order. | [
"Returns",
"a",
"generator",
"expression",
"that",
"contains",
"the",
"videos",
"found",
"sorted",
"by",
"the",
"given",
"field",
"and",
"direction",
"with",
"ties",
"broken",
"by",
"edx_video_id",
"to",
"ensure",
"a",
"total",
"order",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L636-L661 |
edx/edx-val | edxval/api.py | get_course_video_ids_with_youtube_profile | def get_course_video_ids_with_youtube_profile(course_ids=None, offset=None, limit=None):
"""
Returns a list that contains all the course ids and video ids with the youtube profile
Args:
course_ids (list): valid course ids
limit (int): batch records limit
offset (int): an offset f... | python | def get_course_video_ids_with_youtube_profile(course_ids=None, offset=None, limit=None):
"""
Returns a list that contains all the course ids and video ids with the youtube profile
Args:
course_ids (list): valid course ids
limit (int): batch records limit
offset (int): an offset f... | [
"def",
"get_course_video_ids_with_youtube_profile",
"(",
"course_ids",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"course_videos",
"=",
"(",
"CourseVideo",
".",
"objects",
".",
"select_related",
"(",
"'video'",
")",
".",
"pre... | Returns a list that contains all the course ids and video ids with the youtube profile
Args:
course_ids (list): valid course ids
limit (int): batch records limit
offset (int): an offset for selecting a batch
Returns:
(list): Tuples of course_id, edx_video_id and youtube vide... | [
"Returns",
"a",
"list",
"that",
"contains",
"all",
"the",
"course",
"ids",
"and",
"video",
"ids",
"with",
"the",
"youtube",
"profile"
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L664-L700 |
edx/edx-val | edxval/api.py | get_videos_for_course | def get_videos_for_course(course_id, sort_field=None, sort_dir=SortDirection.asc, pagination_conf=None):
"""
Returns an iterator of videos for the given course id.
Args:
course_id (String)
sort_field (VideoSortField)
sort_dir (SortDirection)
Returns:
A generator express... | python | def get_videos_for_course(course_id, sort_field=None, sort_dir=SortDirection.asc, pagination_conf=None):
"""
Returns an iterator of videos for the given course id.
Args:
course_id (String)
sort_field (VideoSortField)
sort_dir (SortDirection)
Returns:
A generator express... | [
"def",
"get_videos_for_course",
"(",
"course_id",
",",
"sort_field",
"=",
"None",
",",
"sort_dir",
"=",
"SortDirection",
".",
"asc",
",",
"pagination_conf",
"=",
"None",
")",
":",
"return",
"_get_videos_for_filter",
"(",
"{",
"'courses__course_id'",
":",
"six",
... | Returns an iterator of videos for the given course id.
Args:
course_id (String)
sort_field (VideoSortField)
sort_dir (SortDirection)
Returns:
A generator expression that contains the videos found, sorted by the
given field and direction, with ties broken by edx_video_id... | [
"Returns",
"an",
"iterator",
"of",
"videos",
"for",
"the",
"given",
"course",
"id",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L703-L722 |
edx/edx-val | edxval/api.py | remove_video_for_course | def remove_video_for_course(course_id, edx_video_id):
"""
Soft deletes video for particular course.
Arguments:
course_id (str): id of the course
edx_video_id (str): id of the video to be hidden
"""
course_video = CourseVideo.objects.get(course_id=course_id, video__edx_video_id=edx_v... | python | def remove_video_for_course(course_id, edx_video_id):
"""
Soft deletes video for particular course.
Arguments:
course_id (str): id of the course
edx_video_id (str): id of the video to be hidden
"""
course_video = CourseVideo.objects.get(course_id=course_id, video__edx_video_id=edx_v... | [
"def",
"remove_video_for_course",
"(",
"course_id",
",",
"edx_video_id",
")",
":",
"course_video",
"=",
"CourseVideo",
".",
"objects",
".",
"get",
"(",
"course_id",
"=",
"course_id",
",",
"video__edx_video_id",
"=",
"edx_video_id",
")",
"course_video",
".",
"is_hi... | Soft deletes video for particular course.
Arguments:
course_id (str): id of the course
edx_video_id (str): id of the video to be hidden | [
"Soft",
"deletes",
"video",
"for",
"particular",
"course",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L725-L735 |
edx/edx-val | edxval/api.py | get_videos_for_ids | def get_videos_for_ids(
edx_video_ids,
sort_field=None,
sort_dir=SortDirection.asc
):
"""
Returns an iterator of videos that match the given list of ids.
Args:
edx_video_ids (list)
sort_field (VideoSortField)
sort_dir (SortDirection)
Returns:
A g... | python | def get_videos_for_ids(
edx_video_ids,
sort_field=None,
sort_dir=SortDirection.asc
):
"""
Returns an iterator of videos that match the given list of ids.
Args:
edx_video_ids (list)
sort_field (VideoSortField)
sort_dir (SortDirection)
Returns:
A g... | [
"def",
"get_videos_for_ids",
"(",
"edx_video_ids",
",",
"sort_field",
"=",
"None",
",",
"sort_dir",
"=",
"SortDirection",
".",
"asc",
")",
":",
"videos",
",",
"__",
"=",
"_get_videos_for_filter",
"(",
"{",
"\"edx_video_id__in\"",
":",
"edx_video_ids",
"}",
",",
... | Returns an iterator of videos that match the given list of ids.
Args:
edx_video_ids (list)
sort_field (VideoSortField)
sort_dir (SortDirection)
Returns:
A generator expression that contains the videos found, sorted by the
given field and direction, with ties broken by e... | [
"Returns",
"an",
"iterator",
"of",
"videos",
"that",
"match",
"the",
"given",
"list",
"of",
"ids",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L738-L761 |
edx/edx-val | edxval/api.py | get_video_info_for_course_and_profiles | def get_video_info_for_course_and_profiles(course_id, profiles):
"""
Returns a dict of edx_video_ids with a dict of requested profiles.
Args:
course_id (str): id of the course
profiles (list): list of profile_names
Returns:
(dict): Returns all the profiles attached to a specific... | python | def get_video_info_for_course_and_profiles(course_id, profiles):
"""
Returns a dict of edx_video_ids with a dict of requested profiles.
Args:
course_id (str): id of the course
profiles (list): list of profile_names
Returns:
(dict): Returns all the profiles attached to a specific... | [
"def",
"get_video_info_for_course_and_profiles",
"(",
"course_id",
",",
"profiles",
")",
":",
"# In case someone passes in a key (VAL doesn't really understand opaque keys)",
"course_id",
"=",
"six",
".",
"text_type",
"(",
"course_id",
")",
"try",
":",
"encoded_videos",
"=",
... | Returns a dict of edx_video_ids with a dict of requested profiles.
Args:
course_id (str): id of the course
profiles (list): list of profile_names
Returns:
(dict): Returns all the profiles attached to a specific
edx_video_id
{
edx_video_id: {
'... | [
"Returns",
"a",
"dict",
"of",
"edx_video_ids",
"with",
"a",
"dict",
"of",
"requested",
"profiles",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L764-L844 |
edx/edx-val | edxval/api.py | copy_course_videos | def copy_course_videos(source_course_id, destination_course_id):
"""
Adds the destination_course_id to the videos taken from the source_course_id
Args:
source_course_id: The original course_id
destination_course_id: The new course_id where the videos will be copied
"""
if source_cou... | python | def copy_course_videos(source_course_id, destination_course_id):
"""
Adds the destination_course_id to the videos taken from the source_course_id
Args:
source_course_id: The original course_id
destination_course_id: The new course_id where the videos will be copied
"""
if source_cou... | [
"def",
"copy_course_videos",
"(",
"source_course_id",
",",
"destination_course_id",
")",
":",
"if",
"source_course_id",
"==",
"destination_course_id",
":",
"return",
"course_videos",
"=",
"CourseVideo",
".",
"objects",
".",
"select_related",
"(",
"'video'",
",",
"'vid... | Adds the destination_course_id to the videos taken from the source_course_id
Args:
source_course_id: The original course_id
destination_course_id: The new course_id where the videos will be copied | [
"Adds",
"the",
"destination_course_id",
"to",
"the",
"videos",
"taken",
"from",
"the",
"source_course_id"
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L847-L871 |
edx/edx-val | edxval/api.py | export_to_xml | def export_to_xml(video_id, resource_fs, static_dir, course_id=None):
"""
Exports data for a video into an xml object.
NOTE: For external video ids, only transcripts information will be added into xml.
If external=False, then edx_video_id is going to be on first index of the list.
Arguments:... | python | def export_to_xml(video_id, resource_fs, static_dir, course_id=None):
"""
Exports data for a video into an xml object.
NOTE: For external video ids, only transcripts information will be added into xml.
If external=False, then edx_video_id is going to be on first index of the list.
Arguments:... | [
"def",
"export_to_xml",
"(",
"video_id",
",",
"resource_fs",
",",
"static_dir",
",",
"course_id",
"=",
"None",
")",
":",
"video_image_name",
"=",
"''",
"video",
"=",
"_get_video",
"(",
"video_id",
")",
"try",
":",
"course_video",
"=",
"CourseVideo",
".",
"ob... | Exports data for a video into an xml object.
NOTE: For external video ids, only transcripts information will be added into xml.
If external=False, then edx_video_id is going to be on first index of the list.
Arguments:
video_id (str): Video id of the video to export transcripts.
cour... | [
"Exports",
"data",
"for",
"a",
"video",
"into",
"an",
"xml",
"object",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L874-L920 |
edx/edx-val | edxval/api.py | create_transcript_file | def create_transcript_file(video_id, language_code, file_format, resource_fs, static_dir):
"""
Writes transcript file to file system.
Arguments:
video_id (str): Video id of the video transcript file is attached.
language_code (str): Language code of the transcript.
file_format (str)... | python | def create_transcript_file(video_id, language_code, file_format, resource_fs, static_dir):
"""
Writes transcript file to file system.
Arguments:
video_id (str): Video id of the video transcript file is attached.
language_code (str): Language code of the transcript.
file_format (str)... | [
"def",
"create_transcript_file",
"(",
"video_id",
",",
"language_code",
",",
"file_format",
",",
"resource_fs",
",",
"static_dir",
")",
":",
"transcript_filename",
"=",
"'{video_id}-{language_code}.srt'",
".",
"format",
"(",
"video_id",
"=",
"video_id",
",",
"language... | Writes transcript file to file system.
Arguments:
video_id (str): Video id of the video transcript file is attached.
language_code (str): Language code of the transcript.
file_format (str): File format of the transcript file.
static_dir (str): The Directory to store transcript file.... | [
"Writes",
"transcript",
"file",
"to",
"file",
"system",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L923-L947 |
edx/edx-val | edxval/api.py | create_transcripts_xml | def create_transcripts_xml(video_id, video_el, resource_fs, static_dir):
"""
Creates xml for transcripts.
For each transcript element, an associated transcript file is also created in course OLX.
Arguments:
video_id (str): Video id of the video.
video_el (Element): lxml Element object
... | python | def create_transcripts_xml(video_id, video_el, resource_fs, static_dir):
"""
Creates xml for transcripts.
For each transcript element, an associated transcript file is also created in course OLX.
Arguments:
video_id (str): Video id of the video.
video_el (Element): lxml Element object
... | [
"def",
"create_transcripts_xml",
"(",
"video_id",
",",
"video_el",
",",
"resource_fs",
",",
"static_dir",
")",
":",
"video_transcripts",
"=",
"VideoTranscript",
".",
"objects",
".",
"filter",
"(",
"video__edx_video_id",
"=",
"video_id",
")",
".",
"order_by",
"(",
... | Creates xml for transcripts.
For each transcript element, an associated transcript file is also created in course OLX.
Arguments:
video_id (str): Video id of the video.
video_el (Element): lxml Element object
static_dir (str): The Directory to store transcript file.
resource_fs ... | [
"Creates",
"xml",
"for",
"transcripts",
".",
"For",
"each",
"transcript",
"element",
"an",
"associated",
"transcript",
"file",
"is",
"also",
"created",
"in",
"course",
"OLX",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L950-L998 |
edx/edx-val | edxval/api.py | import_from_xml | def import_from_xml(xml, edx_video_id, resource_fs, static_dir, external_transcripts=dict(), course_id=None):
"""
Imports data from a video_asset element about the given video_id.
If the edx_video_id already exists, then no changes are made. If an unknown
profile is referenced by an encoded video, that... | python | def import_from_xml(xml, edx_video_id, resource_fs, static_dir, external_transcripts=dict(), course_id=None):
"""
Imports data from a video_asset element about the given video_id.
If the edx_video_id already exists, then no changes are made. If an unknown
profile is referenced by an encoded video, that... | [
"def",
"import_from_xml",
"(",
"xml",
",",
"edx_video_id",
",",
"resource_fs",
",",
"static_dir",
",",
"external_transcripts",
"=",
"dict",
"(",
")",
",",
"course_id",
"=",
"None",
")",
":",
"if",
"xml",
".",
"tag",
"!=",
"'video_asset'",
":",
"raise",
"Va... | Imports data from a video_asset element about the given video_id.
If the edx_video_id already exists, then no changes are made. If an unknown
profile is referenced by an encoded video, that encoding will be ignored.
Arguments:
xml (Element): An lxml video_asset element containing import data
... | [
"Imports",
"data",
"from",
"a",
"video_asset",
"element",
"about",
"the",
"given",
"video_id",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L1001-L1103 |
edx/edx-val | edxval/api.py | import_transcript_from_fs | def import_transcript_from_fs(edx_video_id, language_code, file_name, provider, resource_fs, static_dir):
"""
Imports transcript file from file system and creates transcript record in DS.
Arguments:
edx_video_id (str): Video id of the video.
language_code (unicode): Language code of the req... | python | def import_transcript_from_fs(edx_video_id, language_code, file_name, provider, resource_fs, static_dir):
"""
Imports transcript file from file system and creates transcript record in DS.
Arguments:
edx_video_id (str): Video id of the video.
language_code (unicode): Language code of the req... | [
"def",
"import_transcript_from_fs",
"(",
"edx_video_id",
",",
"language_code",
",",
"file_name",
",",
"provider",
",",
"resource_fs",
",",
"static_dir",
")",
":",
"file_format",
"=",
"None",
"transcript_data",
"=",
"get_video_transcript_data",
"(",
"edx_video_id",
","... | Imports transcript file from file system and creates transcript record in DS.
Arguments:
edx_video_id (str): Video id of the video.
language_code (unicode): Language code of the requested transcript.
file_name (unicode): File name of the transcript file.
provider (unicode): Transcri... | [
"Imports",
"transcript",
"file",
"from",
"file",
"system",
"and",
"creates",
"transcript",
"record",
"in",
"DS",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L1106-L1167 |
edx/edx-val | edxval/api.py | create_transcript_objects | def create_transcript_objects(xml, edx_video_id, resource_fs, static_dir, external_transcripts):
"""
Create VideoTranscript objects.
Arguments:
xml (Element): lxml Element object.
edx_video_id (str): Video id of the video.
resource_fs (OSFS): Import file system.
static_dir (... | python | def create_transcript_objects(xml, edx_video_id, resource_fs, static_dir, external_transcripts):
"""
Create VideoTranscript objects.
Arguments:
xml (Element): lxml Element object.
edx_video_id (str): Video id of the video.
resource_fs (OSFS): Import file system.
static_dir (... | [
"def",
"create_transcript_objects",
"(",
"xml",
",",
"edx_video_id",
",",
"resource_fs",
",",
"static_dir",
",",
"external_transcripts",
")",
":",
"# File system should not start from /draft directory.",
"with",
"open_fs",
"(",
"resource_fs",
".",
"root_path",
".",
"split... | Create VideoTranscript objects.
Arguments:
xml (Element): lxml Element object.
edx_video_id (str): Video id of the video.
resource_fs (OSFS): Import file system.
static_dir (str): The Directory to retrieve transcript file.
external_transcripts (dict): A dict containing the l... | [
"Create",
"VideoTranscript",
"objects",
"."
] | train | https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L1170-L1220 |
bartTC/django-memcache-status | memcache_status/utils.py | get_cache_stats | def get_cache_stats():
"""
Returns a list of dictionaries of all cache servers and their stats,
if they provide stats.
"""
cache_stats = []
for name, _ in six.iteritems(settings.CACHES):
cache_backend = caches[name]
try:
cache_backend_stats = cache_backend._cache.get... | python | def get_cache_stats():
"""
Returns a list of dictionaries of all cache servers and their stats,
if they provide stats.
"""
cache_stats = []
for name, _ in six.iteritems(settings.CACHES):
cache_backend = caches[name]
try:
cache_backend_stats = cache_backend._cache.get... | [
"def",
"get_cache_stats",
"(",
")",
":",
"cache_stats",
"=",
"[",
"]",
"for",
"name",
",",
"_",
"in",
"six",
".",
"iteritems",
"(",
"settings",
".",
"CACHES",
")",
":",
"cache_backend",
"=",
"caches",
"[",
"name",
"]",
"try",
":",
"cache_backend_stats",
... | Returns a list of dictionaries of all cache servers and their stats,
if they provide stats. | [
"Returns",
"a",
"list",
"of",
"dictionaries",
"of",
"all",
"cache",
"servers",
"and",
"their",
"stats",
"if",
"they",
"provide",
"stats",
"."
] | train | https://github.com/bartTC/django-memcache-status/blob/991dd9f964d6e263cf1f5f3f655dcea11577547d/memcache_status/utils.py#L12-L34 |
MycroftAI/mycroft-skills-kit | msk/util.py | register_git_injector | def register_git_injector(username, password):
"""Generate a script that writes the password to the git command line tool"""
fd, tmp_path = mkstemp()
atexit.register(lambda: os.remove(tmp_path))
with os.fdopen(fd, 'w') as f:
f.write(ASKPASS.format(username=username, password=password or ''))
... | python | def register_git_injector(username, password):
"""Generate a script that writes the password to the git command line tool"""
fd, tmp_path = mkstemp()
atexit.register(lambda: os.remove(tmp_path))
with os.fdopen(fd, 'w') as f:
f.write(ASKPASS.format(username=username, password=password or ''))
... | [
"def",
"register_git_injector",
"(",
"username",
",",
"password",
")",
":",
"fd",
",",
"tmp_path",
"=",
"mkstemp",
"(",
")",
"atexit",
".",
"register",
"(",
"lambda",
":",
"os",
".",
"remove",
"(",
"tmp_path",
")",
")",
"with",
"os",
".",
"fdopen",
"("... | Generate a script that writes the password to the git command line tool | [
"Generate",
"a",
"script",
"that",
"writes",
"the",
"password",
"to",
"the",
"git",
"command",
"line",
"tool"
] | train | https://github.com/MycroftAI/mycroft-skills-kit/blob/4a8f5303fdd6d30082d3ba8f8c56457cdc1cecb7/msk/util.py#L53-L62 |
MycroftAI/mycroft-skills-kit | msk/util.py | to_snake | def to_snake(camel):
"""TimeSkill -> time_skill"""
if not camel:
return camel
return ''.join('_' + x if 'A' <= x <= 'Z' else x for x in camel).lower()[camel[0].isupper():] | python | def to_snake(camel):
"""TimeSkill -> time_skill"""
if not camel:
return camel
return ''.join('_' + x if 'A' <= x <= 'Z' else x for x in camel).lower()[camel[0].isupper():] | [
"def",
"to_snake",
"(",
"camel",
")",
":",
"if",
"not",
"camel",
":",
"return",
"camel",
"return",
"''",
".",
"join",
"(",
"'_'",
"+",
"x",
"if",
"'A'",
"<=",
"x",
"<=",
"'Z'",
"else",
"x",
"for",
"x",
"in",
"camel",
")",
".",
"lower",
"(",
")"... | TimeSkill -> time_skill | [
"TimeSkill",
"-",
">",
"time_skill"
] | train | https://github.com/MycroftAI/mycroft-skills-kit/blob/4a8f5303fdd6d30082d3ba8f8c56457cdc1cecb7/msk/util.py#L172-L176 |
MycroftAI/mycroft-skills-kit | msk/util.py | serialized | def serialized(func):
"""Write a serializer by yielding each line of output"""
@wraps(func)
def wrapper(*args, **kwargs):
return '\n'.join(
' '.join(parts) if isinstance(parts, tuple) else parts
for parts in func(*args, **kwargs)
)
return wrapper | python | def serialized(func):
"""Write a serializer by yielding each line of output"""
@wraps(func)
def wrapper(*args, **kwargs):
return '\n'.join(
' '.join(parts) if isinstance(parts, tuple) else parts
for parts in func(*args, **kwargs)
)
return wrapper | [
"def",
"serialized",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"' '",
".",
"join",
"(",
"parts",
")",
"if",
"isinstance",
"("... | Write a serializer by yielding each line of output | [
"Write",
"a",
"serializer",
"by",
"yielding",
"each",
"line",
"of",
"output"
] | train | https://github.com/MycroftAI/mycroft-skills-kit/blob/4a8f5303fdd6d30082d3ba8f8c56457cdc1cecb7/msk/util.py#L197-L207 |
MycroftAI/mycroft-skills-kit | msk/actions/upgrade.py | UpgradeAction.create_pr_message | def create_pr_message(self, skill_git: Git, skill_repo: Repository) -> tuple:
"""Reads git commits from skill repo to create a list of changes as the PR content"""
title = 'Upgrade ' + self.skill.name
body = body_template.format(
skill_name=self.skill.name,
commits='\n'.j... | python | def create_pr_message(self, skill_git: Git, skill_repo: Repository) -> tuple:
"""Reads git commits from skill repo to create a list of changes as the PR content"""
title = 'Upgrade ' + self.skill.name
body = body_template.format(
skill_name=self.skill.name,
commits='\n'.j... | [
"def",
"create_pr_message",
"(",
"self",
",",
"skill_git",
":",
"Git",
",",
"skill_repo",
":",
"Repository",
")",
"->",
"tuple",
":",
"title",
"=",
"'Upgrade '",
"+",
"self",
".",
"skill",
".",
"name",
"body",
"=",
"body_template",
".",
"format",
"(",
"s... | Reads git commits from skill repo to create a list of changes as the PR content | [
"Reads",
"git",
"commits",
"from",
"skill",
"repo",
"to",
"create",
"a",
"list",
"of",
"changes",
"as",
"the",
"PR",
"content"
] | train | https://github.com/MycroftAI/mycroft-skills-kit/blob/4a8f5303fdd6d30082d3ba8f8c56457cdc1cecb7/msk/actions/upgrade.py#L59-L74 |
click-contrib/click-didyoumean | examples/naval.py | ship_move | def ship_move(ship, x, y, speed):
"""Moves SHIP to the new location X,Y."""
click.echo('Moving ship %s to %s,%s with speed %s' % (ship, x, y, speed)) | python | def ship_move(ship, x, y, speed):
"""Moves SHIP to the new location X,Y."""
click.echo('Moving ship %s to %s,%s with speed %s' % (ship, x, y, speed)) | [
"def",
"ship_move",
"(",
"ship",
",",
"x",
",",
"y",
",",
"speed",
")",
":",
"click",
".",
"echo",
"(",
"'Moving ship %s to %s,%s with speed %s'",
"%",
"(",
"ship",
",",
"x",
",",
"y",
",",
"speed",
")",
")"
] | Moves SHIP to the new location X,Y. | [
"Moves",
"SHIP",
"to",
"the",
"new",
"location",
"X",
"Y",
"."
] | train | https://github.com/click-contrib/click-didyoumean/blob/7485cc7212a8f28e4f160dd02ebf044d1badda67/examples/naval.py#L33-L35 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | _check_status | def _check_status(sdp_state):
"""SDP Status check.
Do all the tests to determine, if the SDP state is
"broken", what could be the cause, and return a
suitable status message to be sent back by the calling
function.
"""
try:
errval = "error"
errdict = dict(state="unknown", re... | python | def _check_status(sdp_state):
"""SDP Status check.
Do all the tests to determine, if the SDP state is
"broken", what could be the cause, and return a
suitable status message to be sent back by the calling
function.
"""
try:
errval = "error"
errdict = dict(state="unknown", re... | [
"def",
"_check_status",
"(",
"sdp_state",
")",
":",
"try",
":",
"errval",
"=",
"\"error\"",
"errdict",
"=",
"dict",
"(",
"state",
"=",
"\"unknown\"",
",",
"reason",
"=",
"\"unknown\"",
")",
"if",
"sdp_state",
".",
"current_state",
"==",
"\"unknown\"",
":",
... | SDP Status check.
Do all the tests to determine, if the SDP state is
"broken", what could be the cause, and return a
suitable status message to be sent back by the calling
function. | [
"SDP",
"Status",
"check",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L27-L90 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | root | def root():
"""Home page."""
return {
"message": "Welcome to the SIP Master Controller (flask variant)",
"_links": {
"items": [
{
"Link": "Health",
"href": "{}health".format(request.url)
},
{
... | python | def root():
"""Home page."""
return {
"message": "Welcome to the SIP Master Controller (flask variant)",
"_links": {
"items": [
{
"Link": "Health",
"href": "{}health".format(request.url)
},
{
... | [
"def",
"root",
"(",
")",
":",
"return",
"{",
"\"message\"",
":",
"\"Welcome to the SIP Master Controller (flask variant)\"",
",",
"\"_links\"",
":",
"{",
"\"items\"",
":",
"[",
"{",
"\"Link\"",
":",
"\"Health\"",
",",
"\"href\"",
":",
"\"{}health\"",
".",
"format"... | Home page. | [
"Home",
"page",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L94-L146 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | health | def health():
"""Check the health of this service."""
up_time = time.time() - START_TIME
response = dict(service=__service_id__,
uptime='{:.2f}s'.format(up_time))
return response, HTTPStatus.OK | python | def health():
"""Check the health of this service."""
up_time = time.time() - START_TIME
response = dict(service=__service_id__,
uptime='{:.2f}s'.format(up_time))
return response, HTTPStatus.OK | [
"def",
"health",
"(",
")",
":",
"up_time",
"=",
"time",
".",
"time",
"(",
")",
"-",
"START_TIME",
"response",
"=",
"dict",
"(",
"service",
"=",
"__service_id__",
",",
"uptime",
"=",
"'{:.2f}s'",
".",
"format",
"(",
"up_time",
")",
")",
"return",
"respo... | Check the health of this service. | [
"Check",
"the",
"health",
"of",
"this",
"service",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L150-L155 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | allowed_transitions | def allowed_transitions():
"""Get target states allowed for the current state."""
try:
sdp_state = SDPState()
return sdp_state.allowed_target_states[sdp_state.current_state]
except KeyError:
LOG.error("Key Error")
return dict(state="KeyError", reason="KeyError") | python | def allowed_transitions():
"""Get target states allowed for the current state."""
try:
sdp_state = SDPState()
return sdp_state.allowed_target_states[sdp_state.current_state]
except KeyError:
LOG.error("Key Error")
return dict(state="KeyError", reason="KeyError") | [
"def",
"allowed_transitions",
"(",
")",
":",
"try",
":",
"sdp_state",
"=",
"SDPState",
"(",
")",
"return",
"sdp_state",
".",
"allowed_target_states",
"[",
"sdp_state",
".",
"current_state",
"]",
"except",
"KeyError",
":",
"LOG",
".",
"error",
"(",
"\"Key Error... | Get target states allowed for the current state. | [
"Get",
"target",
"states",
"allowed",
"for",
"the",
"current",
"state",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L167-L174 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | get_state | def get_state():
"""SDP State.
Return current state; target state and allowed
target states.
"""
sdp_state = SDPState()
errval, errdict = _check_status(sdp_state)
if errval == "error":
LOG.debug(errdict['reason'])
return dict(
current_state="unknown",
... | python | def get_state():
"""SDP State.
Return current state; target state and allowed
target states.
"""
sdp_state = SDPState()
errval, errdict = _check_status(sdp_state)
if errval == "error":
LOG.debug(errdict['reason'])
return dict(
current_state="unknown",
... | [
"def",
"get_state",
"(",
")",
":",
"sdp_state",
"=",
"SDPState",
"(",
")",
"errval",
",",
"errdict",
"=",
"_check_status",
"(",
"sdp_state",
")",
"if",
"errval",
"==",
"\"error\"",
":",
"LOG",
".",
"debug",
"(",
"errdict",
"[",
"'reason'",
"]",
")",
"r... | SDP State.
Return current state; target state and allowed
target states. | [
"SDP",
"State",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L178-L204 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | get_target_state | def get_target_state():
"""SDP target State.
Returns the target state; allowed target states and time updated
"""
sdp_state = SDPState()
errval, errdict = _check_status(sdp_state)
if errval == "error":
LOG.debug(errdict['reason'])
return dict(
current_target_state="u... | python | def get_target_state():
"""SDP target State.
Returns the target state; allowed target states and time updated
"""
sdp_state = SDPState()
errval, errdict = _check_status(sdp_state)
if errval == "error":
LOG.debug(errdict['reason'])
return dict(
current_target_state="u... | [
"def",
"get_target_state",
"(",
")",
":",
"sdp_state",
"=",
"SDPState",
"(",
")",
"errval",
",",
"errdict",
"=",
"_check_status",
"(",
"sdp_state",
")",
"if",
"errval",
"==",
"\"error\"",
":",
"LOG",
".",
"debug",
"(",
"errdict",
"[",
"'reason'",
"]",
")... | SDP target State.
Returns the target state; allowed target states and time updated | [
"SDP",
"target",
"State",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L209-L230 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | get_current_state | def get_current_state():
"""Return the SDP State and the timestamp for when it was updated."""
sdp_state = SDPState()
errval, errdict = _check_status(sdp_state)
if errval == "error":
LOG.debug(errdict['reason'])
return dict(
current_state="unknown",
last_updated="... | python | def get_current_state():
"""Return the SDP State and the timestamp for when it was updated."""
sdp_state = SDPState()
errval, errdict = _check_status(sdp_state)
if errval == "error":
LOG.debug(errdict['reason'])
return dict(
current_state="unknown",
last_updated="... | [
"def",
"get_current_state",
"(",
")",
":",
"sdp_state",
"=",
"SDPState",
"(",
")",
"errval",
",",
"errdict",
"=",
"_check_status",
"(",
"sdp_state",
")",
"if",
"errval",
"==",
"\"error\"",
":",
"LOG",
".",
"debug",
"(",
"errdict",
"[",
"'reason'",
"]",
"... | Return the SDP State and the timestamp for when it was updated. | [
"Return",
"the",
"SDP",
"State",
"and",
"the",
"timestamp",
"for",
"when",
"it",
"was",
"updated",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L234-L251 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | put_target_state | def put_target_state():
"""SDP target State.
Sets the target state
"""
sdp_state = SDPState()
errval, errdict = _check_status(sdp_state)
if errval == "error":
LOG.debug(errdict['reason'])
rdict = dict(
current_state="unknown",
last_updated="unknown",
... | python | def put_target_state():
"""SDP target State.
Sets the target state
"""
sdp_state = SDPState()
errval, errdict = _check_status(sdp_state)
if errval == "error":
LOG.debug(errdict['reason'])
rdict = dict(
current_state="unknown",
last_updated="unknown",
... | [
"def",
"put_target_state",
"(",
")",
":",
"sdp_state",
"=",
"SDPState",
"(",
")",
"errval",
",",
"errdict",
"=",
"_check_status",
"(",
"sdp_state",
")",
"if",
"errval",
"==",
"\"error\"",
":",
"LOG",
".",
"debug",
"(",
"errdict",
"[",
"'reason'",
"]",
")... | SDP target State.
Sets the target state | [
"SDP",
"target",
"State",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L256-L287 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | processing_block_list | def processing_block_list():
"""Return the list of processing blocks known to SDP."""
pb_list = ProcessingBlockList()
return dict(active=pb_list.active,
completed=pb_list.completed,
aborted=pb_list.aborted) | python | def processing_block_list():
"""Return the list of processing blocks known to SDP."""
pb_list = ProcessingBlockList()
return dict(active=pb_list.active,
completed=pb_list.completed,
aborted=pb_list.aborted) | [
"def",
"processing_block_list",
"(",
")",
":",
"pb_list",
"=",
"ProcessingBlockList",
"(",
")",
"return",
"dict",
"(",
"active",
"=",
"pb_list",
".",
"active",
",",
"completed",
"=",
"pb_list",
".",
"completed",
",",
"aborted",
"=",
"pb_list",
".",
"aborted"... | Return the list of processing blocks known to SDP. | [
"Return",
"the",
"list",
"of",
"processing",
"blocks",
"known",
"to",
"SDP",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L291-L296 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | scheduling_blocks | def scheduling_blocks():
"""Return list of Scheduling Block instances known to SDP."""
sbi_list = SchedulingBlockInstanceList()
return dict(active=sbi_list.active,
completed=sbi_list.completed,
aborted=sbi_list.aborted) | python | def scheduling_blocks():
"""Return list of Scheduling Block instances known to SDP."""
sbi_list = SchedulingBlockInstanceList()
return dict(active=sbi_list.active,
completed=sbi_list.completed,
aborted=sbi_list.aborted) | [
"def",
"scheduling_blocks",
"(",
")",
":",
"sbi_list",
"=",
"SchedulingBlockInstanceList",
"(",
")",
"return",
"dict",
"(",
"active",
"=",
"sbi_list",
".",
"active",
",",
"completed",
"=",
"sbi_list",
".",
"completed",
",",
"aborted",
"=",
"sbi_list",
".",
"... | Return list of Scheduling Block instances known to SDP. | [
"Return",
"list",
"of",
"Scheduling",
"Block",
"instances",
"known",
"to",
"SDP",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L300-L305 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/flask_master/app/app.py | configure_sbi | def configure_sbi():
"""Configure an SBI using POSTed configuration."""
# Need an ID for the subarray - guessing I just get
# the list of inactive subarrays and use the first
inactive_list = SubarrayList().inactive
request_data = request.data
LOG.debug('request is of type %s', type(request_data)... | python | def configure_sbi():
"""Configure an SBI using POSTed configuration."""
# Need an ID for the subarray - guessing I just get
# the list of inactive subarrays and use the first
inactive_list = SubarrayList().inactive
request_data = request.data
LOG.debug('request is of type %s', type(request_data)... | [
"def",
"configure_sbi",
"(",
")",
":",
"# Need an ID for the subarray - guessing I just get",
"# the list of inactive subarrays and use the first",
"inactive_list",
"=",
"SubarrayList",
"(",
")",
".",
"inactive",
"request_data",
"=",
"request",
".",
"data",
"LOG",
".",
"deb... | Configure an SBI using POSTed configuration. | [
"Configure",
"an",
"SBI",
"using",
"POSTed",
"configuration",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/flask_master/app/app.py#L322-L338 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/app.py | home | def home():
"""Temporary helper function to link to the API routes"""
return dict(links=dict(api='{}{}'.format(request.url, PREFIX[1:]))), \
HTTPStatus.OK | python | def home():
"""Temporary helper function to link to the API routes"""
return dict(links=dict(api='{}{}'.format(request.url, PREFIX[1:]))), \
HTTPStatus.OK | [
"def",
"home",
"(",
")",
":",
"return",
"dict",
"(",
"links",
"=",
"dict",
"(",
"api",
"=",
"'{}{}'",
".",
"format",
"(",
"request",
".",
"url",
",",
"PREFIX",
"[",
"1",
":",
"]",
")",
")",
")",
",",
"HTTPStatus",
".",
"OK"
] | Temporary helper function to link to the API routes | [
"Temporary",
"helper",
"function",
"to",
"link",
"to",
"the",
"API",
"routes"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/app.py#L45-L48 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/app.py | catch_all | def catch_all(path):
"""Catch all path - return a JSON 404 """
return (dict(error='Invalid URL: /{}'.format(path),
links=dict(root='{}{}'.format(request.url_root, PREFIX[1:]))),
HTTPStatus.NOT_FOUND) | python | def catch_all(path):
"""Catch all path - return a JSON 404 """
return (dict(error='Invalid URL: /{}'.format(path),
links=dict(root='{}{}'.format(request.url_root, PREFIX[1:]))),
HTTPStatus.NOT_FOUND) | [
"def",
"catch_all",
"(",
"path",
")",
":",
"return",
"(",
"dict",
"(",
"error",
"=",
"'Invalid URL: /{}'",
".",
"format",
"(",
"path",
")",
",",
"links",
"=",
"dict",
"(",
"root",
"=",
"'{}{}'",
".",
"format",
"(",
"request",
".",
"url_root",
",",
"P... | Catch all path - return a JSON 404 | [
"Catch",
"all",
"path",
"-",
"return",
"a",
"JSON",
"404"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/app.py#L52-L56 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/scheduling/subarray_list.py | SubarrayList.get_active | def get_active() -> List[str]:
"""Return the list of active subarrays."""
active = []
for i in range(__num_subarrays__):
key = Subarray.get_key(i)
if DB.get_hash_value(key, 'active').upper() == 'TRUE':
active.append(Subarray.get_id(i))
return activ... | python | def get_active() -> List[str]:
"""Return the list of active subarrays."""
active = []
for i in range(__num_subarrays__):
key = Subarray.get_key(i)
if DB.get_hash_value(key, 'active').upper() == 'TRUE':
active.append(Subarray.get_id(i))
return activ... | [
"def",
"get_active",
"(",
")",
"->",
"List",
"[",
"str",
"]",
":",
"active",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"__num_subarrays__",
")",
":",
"key",
"=",
"Subarray",
".",
"get_key",
"(",
"i",
")",
"if",
"DB",
".",
"get_hash_value",
"("... | Return the list of active subarrays. | [
"Return",
"the",
"list",
"of",
"active",
"subarrays",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/scheduling/subarray_list.py#L46-L53 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/scheduling/subarray_list.py | SubarrayList.get_inactive | def get_inactive() -> List[str]:
"""Return the list of inactive subarrays."""
inactive = []
for i in range(__num_subarrays__):
key = Subarray.get_key(i)
if DB.get_hash_value(key, 'active').upper() == 'FALSE':
inactive.append(Subarray.get_id(i))
ret... | python | def get_inactive() -> List[str]:
"""Return the list of inactive subarrays."""
inactive = []
for i in range(__num_subarrays__):
key = Subarray.get_key(i)
if DB.get_hash_value(key, 'active').upper() == 'FALSE':
inactive.append(Subarray.get_id(i))
ret... | [
"def",
"get_inactive",
"(",
")",
"->",
"List",
"[",
"str",
"]",
":",
"inactive",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"__num_subarrays__",
")",
":",
"key",
"=",
"Subarray",
".",
"get_key",
"(",
"i",
")",
"if",
"DB",
".",
"get_hash_value",
... | Return the list of inactive subarrays. | [
"Return",
"the",
"list",
"of",
"inactive",
"subarrays",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/scheduling/subarray_list.py#L56-L63 |
SKA-ScienceDataProcessor/integration-prototype | sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py | node_run | def node_run(input_file, coords_only, bc_settings, bc_grid_weights):
"""Main function to process visibility data on Spark cluster nodes.
Args:
input_file (str):
RDD element containing filename to process.
coords_only (boolean):
If true, read only baseline coordinates to ... | python | def node_run(input_file, coords_only, bc_settings, bc_grid_weights):
"""Main function to process visibility data on Spark cluster nodes.
Args:
input_file (str):
RDD element containing filename to process.
coords_only (boolean):
If true, read only baseline coordinates to ... | [
"def",
"node_run",
"(",
"input_file",
",",
"coords_only",
",",
"bc_settings",
",",
"bc_grid_weights",
")",
":",
"# Create a logger.",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'pyspark'",
")",
"log",
".",
"setLevel",
"(",
"logging",
".",
"INFO",
")",
"i... | Main function to process visibility data on Spark cluster nodes.
Args:
input_file (str):
RDD element containing filename to process.
coords_only (boolean):
If true, read only baseline coordinates to define the weights grid.
bc_settings (pyspark.broadcast.Broadcast):
... | [
"Main",
"function",
"to",
"process",
"visibility",
"data",
"on",
"Spark",
"cluster",
"nodes",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py#L43-L126 |
SKA-ScienceDataProcessor/integration-prototype | sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py | save_image | def save_image(imager, grid_data, grid_norm, output_file):
"""Makes an image from gridded visibilities and saves it to a FITS file.
Args:
imager (oskar.Imager): Handle to configured imager.
grid_data (numpy.ndarray): Final visibility grid.
grid_norm (float): G... | python | def save_image(imager, grid_data, grid_norm, output_file):
"""Makes an image from gridded visibilities and saves it to a FITS file.
Args:
imager (oskar.Imager): Handle to configured imager.
grid_data (numpy.ndarray): Final visibility grid.
grid_norm (float): G... | [
"def",
"save_image",
"(",
"imager",
",",
"grid_data",
",",
"grid_norm",
",",
"output_file",
")",
":",
"# Make the image (take the FFT, normalise, and apply grid correction).",
"imager",
".",
"finalise_plane",
"(",
"grid_data",
",",
"grid_norm",
")",
"grid_data",
"=",
"n... | Makes an image from gridded visibilities and saves it to a FITS file.
Args:
imager (oskar.Imager): Handle to configured imager.
grid_data (numpy.ndarray): Final visibility grid.
grid_norm (float): Grid normalisation to apply.
output_file (str): ... | [
"Makes",
"an",
"image",
"from",
"gridded",
"visibilities",
"and",
"saves",
"it",
"to",
"a",
"FITS",
"file",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py#L190-L211 |
SKA-ScienceDataProcessor/integration-prototype | sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py | reduce_sequences | def reduce_sequences(object_a, object_b):
"""Performs an element-wise addition of sequences into a new list.
Both sequences must have the same length, and the addition operator must be
defined for each element of the sequence.
"""
def is_seq(obj):
"""Returns true if the object passed is a s... | python | def reduce_sequences(object_a, object_b):
"""Performs an element-wise addition of sequences into a new list.
Both sequences must have the same length, and the addition operator must be
defined for each element of the sequence.
"""
def is_seq(obj):
"""Returns true if the object passed is a s... | [
"def",
"reduce_sequences",
"(",
"object_a",
",",
"object_b",
")",
":",
"def",
"is_seq",
"(",
"obj",
")",
":",
"\"\"\"Returns true if the object passed is a sequence.\"\"\"",
"return",
"hasattr",
"(",
"obj",
",",
"\"__getitem__\"",
")",
"or",
"hasattr",
"(",
"obj",
... | Performs an element-wise addition of sequences into a new list.
Both sequences must have the same length, and the addition operator must be
defined for each element of the sequence. | [
"Performs",
"an",
"element",
"-",
"wise",
"addition",
"of",
"sequences",
"into",
"a",
"new",
"list",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py#L214-L234 |
SKA-ScienceDataProcessor/integration-prototype | sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py | main | def main():
"""Runs test imaging pipeline using Spark."""
# Check command line arguments.
if len(sys.argv) < 3:
raise RuntimeError(
'Usage: spark-submit spark_imager_test.py <settings_file> <dir> '
'[partitions]')
# Create log object.
log = logging.getLogger('pyspark... | python | def main():
"""Runs test imaging pipeline using Spark."""
# Check command line arguments.
if len(sys.argv) < 3:
raise RuntimeError(
'Usage: spark-submit spark_imager_test.py <settings_file> <dir> '
'[partitions]')
# Create log object.
log = logging.getLogger('pyspark... | [
"def",
"main",
"(",
")",
":",
"# Check command line arguments.",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"<",
"3",
":",
"raise",
"RuntimeError",
"(",
"'Usage: spark-submit spark_imager_test.py <settings_file> <dir> '",
"'[partitions]'",
")",
"# Create log object.",
"... | Runs test imaging pipeline using Spark. | [
"Runs",
"test",
"imaging",
"pipeline",
"using",
"Spark",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/example_imager_spark/example_spark_imager.py#L237-L314 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | load_schema | def load_schema(path):
"""Loads a JSON schema file."""
with open(path) as json_data:
schema = json.load(json_data)
return schema | python | def load_schema(path):
"""Loads a JSON schema file."""
with open(path) as json_data:
schema = json.load(json_data)
return schema | [
"def",
"load_schema",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"json_data",
":",
"schema",
"=",
"json",
".",
"load",
"(",
"json_data",
")",
"return",
"schema"
] | Loads a JSON schema file. | [
"Loads",
"a",
"JSON",
"schema",
"file",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L25-L29 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | clear_db | def clear_db():
"""Clear the entire db."""
cursor = '0'
while cursor != 0:
cursor, keys = DB.scan(cursor, match='*', count=5000)
if keys:
DB.delete(*keys) | python | def clear_db():
"""Clear the entire db."""
cursor = '0'
while cursor != 0:
cursor, keys = DB.scan(cursor, match='*', count=5000)
if keys:
DB.delete(*keys) | [
"def",
"clear_db",
"(",
")",
":",
"cursor",
"=",
"'0'",
"while",
"cursor",
"!=",
"0",
":",
"cursor",
",",
"keys",
"=",
"DB",
".",
"scan",
"(",
"cursor",
",",
"match",
"=",
"'*'",
",",
"count",
"=",
"5000",
")",
"if",
"keys",
":",
"DB",
".",
"de... | Clear the entire db. | [
"Clear",
"the",
"entire",
"db",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L32-L38 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | get_scheduling_block_ids | def get_scheduling_block_ids():
"""Return list of scheduling block IDs"""
ids = [key.split('/')[-1]
for key in DB.keys(pattern='scheduling_block/*')]
return sorted(ids) | python | def get_scheduling_block_ids():
"""Return list of scheduling block IDs"""
ids = [key.split('/')[-1]
for key in DB.keys(pattern='scheduling_block/*')]
return sorted(ids) | [
"def",
"get_scheduling_block_ids",
"(",
")",
":",
"ids",
"=",
"[",
"key",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"for",
"key",
"in",
"DB",
".",
"keys",
"(",
"pattern",
"=",
"'scheduling_block/*'",
")",
"]",
"return",
"sorted",
"(",
"ids",... | Return list of scheduling block IDs | [
"Return",
"list",
"of",
"scheduling",
"block",
"IDs"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L46-L50 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | add_scheduling_block | def add_scheduling_block(config, schema_path=None):
"""Add a Scheduling Block to the Configuration Database.
The configuration dictionary must match the schema defined in
in the schema_path variable at the top of the function.
Args:
config (dict): Scheduling Block instance request configuratio... | python | def add_scheduling_block(config, schema_path=None):
"""Add a Scheduling Block to the Configuration Database.
The configuration dictionary must match the schema defined in
in the schema_path variable at the top of the function.
Args:
config (dict): Scheduling Block instance request configuratio... | [
"def",
"add_scheduling_block",
"(",
"config",
",",
"schema_path",
"=",
"None",
")",
":",
"if",
"schema_path",
"is",
"None",
":",
"schema_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'sb... | Add a Scheduling Block to the Configuration Database.
The configuration dictionary must match the schema defined in
in the schema_path variable at the top of the function.
Args:
config (dict): Scheduling Block instance request configuration.
schema_path (str): Path to schema file used to v... | [
"Add",
"a",
"Scheduling",
"Block",
"to",
"the",
"Configuration",
"Database",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L58-L84 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | delete_scheduling_block | def delete_scheduling_block(block_id):
"""Delete Scheduling Block with the specified ID"""
DB.delete('scheduling_block/{}'.format(block_id))
# Add a event to the scheduling block event list to notify
# of a deleting a scheduling block from the db
DB.rpush('scheduling_block_events',
jso... | python | def delete_scheduling_block(block_id):
"""Delete Scheduling Block with the specified ID"""
DB.delete('scheduling_block/{}'.format(block_id))
# Add a event to the scheduling block event list to notify
# of a deleting a scheduling block from the db
DB.rpush('scheduling_block_events',
jso... | [
"def",
"delete_scheduling_block",
"(",
"block_id",
")",
":",
"DB",
".",
"delete",
"(",
"'scheduling_block/{}'",
".",
"format",
"(",
"block_id",
")",
")",
"# Add a event to the scheduling block event list to notify",
"# of a deleting a scheduling block from the db",
"DB",
".",... | Delete Scheduling Block with the specified ID | [
"Delete",
"Scheduling",
"Block",
"with",
"the",
"specified",
"ID"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L87-L94 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | get_scheduling_block_event | def get_scheduling_block_event():
"""Return the latest Scheduling Block event"""
event = DB.rpoplpush('scheduling_block_events',
'scheduling_block_event_history')
if event:
event = json.loads(event.decode('utf-8'))
return event | python | def get_scheduling_block_event():
"""Return the latest Scheduling Block event"""
event = DB.rpoplpush('scheduling_block_events',
'scheduling_block_event_history')
if event:
event = json.loads(event.decode('utf-8'))
return event | [
"def",
"get_scheduling_block_event",
"(",
")",
":",
"event",
"=",
"DB",
".",
"rpoplpush",
"(",
"'scheduling_block_events'",
",",
"'scheduling_block_event_history'",
")",
"if",
"event",
":",
"event",
"=",
"json",
".",
"loads",
"(",
"event",
".",
"decode",
"(",
... | Return the latest Scheduling Block event | [
"Return",
"the",
"latest",
"Scheduling",
"Block",
"event"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L102-L108 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | get_sub_array_ids | def get_sub_array_ids():
"""Return list of sub-array Id's currently known to SDP"""
ids = set()
for key in sorted(DB.keys(pattern='scheduling_block/*')):
config = json.loads(DB.get(key))
ids.add(config['sub_array_id'])
return sorted(list(ids)) | python | def get_sub_array_ids():
"""Return list of sub-array Id's currently known to SDP"""
ids = set()
for key in sorted(DB.keys(pattern='scheduling_block/*')):
config = json.loads(DB.get(key))
ids.add(config['sub_array_id'])
return sorted(list(ids)) | [
"def",
"get_sub_array_ids",
"(",
")",
":",
"ids",
"=",
"set",
"(",
")",
"for",
"key",
"in",
"sorted",
"(",
"DB",
".",
"keys",
"(",
"pattern",
"=",
"'scheduling_block/*'",
")",
")",
":",
"config",
"=",
"json",
".",
"loads",
"(",
"DB",
".",
"get",
"(... | Return list of sub-array Id's currently known to SDP | [
"Return",
"list",
"of",
"sub",
"-",
"array",
"Id",
"s",
"currently",
"known",
"to",
"SDP"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L115-L121 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | get_subarray_sbi_ids | def get_subarray_sbi_ids(sub_array_id):
"""Return list of scheduling block Id's associated with the given
sub_array_id
"""
ids = []
for key in sorted(DB.keys(pattern='scheduling_block/*')):
config = json.loads(DB.get(key))
if config['sub_array_id'] == sub_array_id:
ids.ap... | python | def get_subarray_sbi_ids(sub_array_id):
"""Return list of scheduling block Id's associated with the given
sub_array_id
"""
ids = []
for key in sorted(DB.keys(pattern='scheduling_block/*')):
config = json.loads(DB.get(key))
if config['sub_array_id'] == sub_array_id:
ids.ap... | [
"def",
"get_subarray_sbi_ids",
"(",
"sub_array_id",
")",
":",
"ids",
"=",
"[",
"]",
"for",
"key",
"in",
"sorted",
"(",
"DB",
".",
"keys",
"(",
"pattern",
"=",
"'scheduling_block/*'",
")",
")",
":",
"config",
"=",
"json",
".",
"loads",
"(",
"DB",
".",
... | Return list of scheduling block Id's associated with the given
sub_array_id | [
"Return",
"list",
"of",
"scheduling",
"block",
"Id",
"s",
"associated",
"with",
"the",
"given",
"sub_array_id"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L124-L133 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | get_processing_block_ids | def get_processing_block_ids():
"""Return an array of Processing Block ids"""
ids = []
for key in sorted(DB.keys(pattern='scheduling_block/*')):
config = json.loads(DB.get(key))
for processing_block in config['processing_blocks']:
ids.append(processing_block['id'])
return ids | python | def get_processing_block_ids():
"""Return an array of Processing Block ids"""
ids = []
for key in sorted(DB.keys(pattern='scheduling_block/*')):
config = json.loads(DB.get(key))
for processing_block in config['processing_blocks']:
ids.append(processing_block['id'])
return ids | [
"def",
"get_processing_block_ids",
"(",
")",
":",
"ids",
"=",
"[",
"]",
"for",
"key",
"in",
"sorted",
"(",
"DB",
".",
"keys",
"(",
"pattern",
"=",
"'scheduling_block/*'",
")",
")",
":",
"config",
"=",
"json",
".",
"loads",
"(",
"DB",
".",
"get",
"(",... | Return an array of Processing Block ids | [
"Return",
"an",
"array",
"of",
"Processing",
"Block",
"ids"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L141-L148 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | get_processing_block | def get_processing_block(block_id):
"""Return the Processing Block Configuration for the specified ID"""
identifiers = block_id.split(':')
scheduling_block_id = identifiers[0]
scheduling_block_config = get_scheduling_block(scheduling_block_id)
for processing_block in scheduling_block_config['process... | python | def get_processing_block(block_id):
"""Return the Processing Block Configuration for the specified ID"""
identifiers = block_id.split(':')
scheduling_block_id = identifiers[0]
scheduling_block_config = get_scheduling_block(scheduling_block_id)
for processing_block in scheduling_block_config['process... | [
"def",
"get_processing_block",
"(",
"block_id",
")",
":",
"identifiers",
"=",
"block_id",
".",
"split",
"(",
"':'",
")",
"scheduling_block_id",
"=",
"identifiers",
"[",
"0",
"]",
"scheduling_block_config",
"=",
"get_scheduling_block",
"(",
"scheduling_block_id",
")"... | Return the Processing Block Configuration for the specified ID | [
"Return",
"the",
"Processing",
"Block",
"Configuration",
"for",
"the",
"specified",
"ID"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L151-L160 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | delete_processing_block | def delete_processing_block(processing_block_id):
"""Delete Processing Block with the specified ID"""
scheduling_block_id = processing_block_id.split(':')[0]
config = get_scheduling_block(scheduling_block_id)
processing_blocks = config.get('processing_blocks')
processing_block = list(filter(
... | python | def delete_processing_block(processing_block_id):
"""Delete Processing Block with the specified ID"""
scheduling_block_id = processing_block_id.split(':')[0]
config = get_scheduling_block(scheduling_block_id)
processing_blocks = config.get('processing_blocks')
processing_block = list(filter(
... | [
"def",
"delete_processing_block",
"(",
"processing_block_id",
")",
":",
"scheduling_block_id",
"=",
"processing_block_id",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
"config",
"=",
"get_scheduling_block",
"(",
"scheduling_block_id",
")",
"processing_blocks",
"=",
... | Delete Processing Block with the specified ID | [
"Delete",
"Processing",
"Block",
"with",
"the",
"specified",
"ID"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L163-L176 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/mock/client.py | get_processing_block_event | def get_processing_block_event():
"""Return the latest Processing Block event"""
event = DB.rpoplpush('processing_block_events',
'processing_block_event_history')
if event:
event = json.loads(event.decode('utf-8'))
return event | python | def get_processing_block_event():
"""Return the latest Processing Block event"""
event = DB.rpoplpush('processing_block_events',
'processing_block_event_history')
if event:
event = json.loads(event.decode('utf-8'))
return event | [
"def",
"get_processing_block_event",
"(",
")",
":",
"event",
"=",
"DB",
".",
"rpoplpush",
"(",
"'processing_block_events'",
",",
"'processing_block_event_history'",
")",
"if",
"event",
":",
"event",
"=",
"json",
".",
"loads",
"(",
"event",
".",
"decode",
"(",
... | Return the latest Processing Block event | [
"Return",
"the",
"latest",
"Processing",
"Block",
"event"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/mock/client.py#L179-L185 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | subscribe | def subscribe(object_type: str, subscriber: str,
callback_handler: Callable = None) -> EventQueue:
"""Subscribe to the specified object type.
Returns an EventQueue object which can be used to query events
associated with the object type for this subscriber.
Args:
object_type (str... | python | def subscribe(object_type: str, subscriber: str,
callback_handler: Callable = None) -> EventQueue:
"""Subscribe to the specified object type.
Returns an EventQueue object which can be used to query events
associated with the object type for this subscriber.
Args:
object_type (str... | [
"def",
"subscribe",
"(",
"object_type",
":",
"str",
",",
"subscriber",
":",
"str",
",",
"callback_handler",
":",
"Callable",
"=",
"None",
")",
"->",
"EventQueue",
":",
"key",
"=",
"_keys",
".",
"subscribers",
"(",
"object_type",
")",
"DB",
".",
"remove_fro... | Subscribe to the specified object type.
Returns an EventQueue object which can be used to query events
associated with the object type for this subscriber.
Args:
object_type (str): Object type
subscriber (str): Subscriber name
callback_handler (function, optional): Callback handler... | [
"Subscribe",
"to",
"the",
"specified",
"object",
"type",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L16-L35 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | get_subscribers | def get_subscribers(object_type: str) -> List[str]:
"""Get the list of subscribers to events of the object type.
Args:
object_type (str): Type of object.
Returns:
List[str], list of subscriber names.
"""
return DB.get_list(_keys.subscribers(object_type)) | python | def get_subscribers(object_type: str) -> List[str]:
"""Get the list of subscribers to events of the object type.
Args:
object_type (str): Type of object.
Returns:
List[str], list of subscriber names.
"""
return DB.get_list(_keys.subscribers(object_type)) | [
"def",
"get_subscribers",
"(",
"object_type",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"DB",
".",
"get_list",
"(",
"_keys",
".",
"subscribers",
"(",
"object_type",
")",
")"
] | Get the list of subscribers to events of the object type.
Args:
object_type (str): Type of object.
Returns:
List[str], list of subscriber names. | [
"Get",
"the",
"list",
"of",
"subscribers",
"to",
"events",
"of",
"the",
"object",
"type",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L38-L48 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | publish | def publish(event_type: str,
event_data: dict = None,
object_type: str = None,
object_id: str = None,
object_key: str = None,
origin: str = None):
"""Publish an event.
Published the event to all subscribers and stores the event with the
object.
... | python | def publish(event_type: str,
event_data: dict = None,
object_type: str = None,
object_id: str = None,
object_key: str = None,
origin: str = None):
"""Publish an event.
Published the event to all subscribers and stores the event with the
object.
... | [
"def",
"publish",
"(",
"event_type",
":",
"str",
",",
"event_data",
":",
"dict",
"=",
"None",
",",
"object_type",
":",
"str",
"=",
"None",
",",
"object_id",
":",
"str",
"=",
"None",
",",
"object_key",
":",
"str",
"=",
"None",
",",
"origin",
":",
"str... | Publish an event.
Published the event to all subscribers and stores the event with the
object.
Args:
event_type (str): The event type
event_data (dict, optional): Optional event data
object_type (str): Type of object.
object_id (str): Object ID
object_key (str, opti... | [
"Publish",
"an",
"event",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L51-L89 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | _get_events_list | def _get_events_list(object_key: str) -> List[str]:
"""Get list of event ids for the object with the specified key.
Args:
object_key (str): Key of an object in the database.
"""
return DB.get_list(_keys.events_list(object_key)) | python | def _get_events_list(object_key: str) -> List[str]:
"""Get list of event ids for the object with the specified key.
Args:
object_key (str): Key of an object in the database.
"""
return DB.get_list(_keys.events_list(object_key)) | [
"def",
"_get_events_list",
"(",
"object_key",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"DB",
".",
"get_list",
"(",
"_keys",
".",
"events_list",
"(",
"object_key",
")",
")"
] | Get list of event ids for the object with the specified key.
Args:
object_key (str): Key of an object in the database. | [
"Get",
"list",
"of",
"event",
"ids",
"for",
"the",
"object",
"with",
"the",
"specified",
"key",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L92-L99 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | _get_events_data | def _get_events_data(object_key: str) -> List[dict]:
"""Get the list of event data for the object with the specified key.
Args:
object_key (str): Key of an object in the database.
"""
events_data = []
key = _keys.events_data(object_key)
for event_id in _get_events_list(object_key):
... | python | def _get_events_data(object_key: str) -> List[dict]:
"""Get the list of event data for the object with the specified key.
Args:
object_key (str): Key of an object in the database.
"""
events_data = []
key = _keys.events_data(object_key)
for event_id in _get_events_list(object_key):
... | [
"def",
"_get_events_data",
"(",
"object_key",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"events_data",
"=",
"[",
"]",
"key",
"=",
"_keys",
".",
"events_data",
"(",
"object_key",
")",
"for",
"event_id",
"in",
"_get_events_list",
"(",
"object_key... | Get the list of event data for the object with the specified key.
Args:
object_key (str): Key of an object in the database. | [
"Get",
"the",
"list",
"of",
"event",
"data",
"for",
"the",
"object",
"with",
"the",
"specified",
"key",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L102-L114 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | get_events | def get_events(object_key: str) -> List[Event]:
"""Get list of events for the object with the specified key."""
events_data = _get_events_data(object_key)
return [Event.from_config(event_dict) for event_dict in events_data] | python | def get_events(object_key: str) -> List[Event]:
"""Get list of events for the object with the specified key."""
events_data = _get_events_data(object_key)
return [Event.from_config(event_dict) for event_dict in events_data] | [
"def",
"get_events",
"(",
"object_key",
":",
"str",
")",
"->",
"List",
"[",
"Event",
"]",
":",
"events_data",
"=",
"_get_events_data",
"(",
"object_key",
")",
"return",
"[",
"Event",
".",
"from_config",
"(",
"event_dict",
")",
"for",
"event_dict",
"in",
"e... | Get list of events for the object with the specified key. | [
"Get",
"list",
"of",
"events",
"for",
"the",
"object",
"with",
"the",
"specified",
"key",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L117-L120 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | _publish_to_subscribers | def _publish_to_subscribers(event: Event):
"""Publish and event to all subscribers.
- Adds the event id to the published event list for all subscribers.
- Adds the event data to the published event data for all subscribers.
- Publishes the event id notification to all subscribers.
Args:
ev... | python | def _publish_to_subscribers(event: Event):
"""Publish and event to all subscribers.
- Adds the event id to the published event list for all subscribers.
- Adds the event data to the published event data for all subscribers.
- Publishes the event id notification to all subscribers.
Args:
ev... | [
"def",
"_publish_to_subscribers",
"(",
"event",
":",
"Event",
")",
":",
"subscribers",
"=",
"get_subscribers",
"(",
"event",
".",
"object_type",
")",
"# Add the event to each subscribers published list",
"for",
"sub",
"in",
"subscribers",
":",
"DB",
".",
"prepend_to_l... | Publish and event to all subscribers.
- Adds the event id to the published event list for all subscribers.
- Adds the event data to the published event data for all subscribers.
- Publishes the event id notification to all subscribers.
Args:
event (Event): Event object to publish. | [
"Publish",
"and",
"event",
"to",
"all",
"subscribers",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L123-L144 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | _update_object | def _update_object(object_key: str, event: Event):
"""Update the events list and events data for the object.
- Adds the event Id to the list of events for the object.
- Adds the event data to the hash of object event data keyed by event
id.
Args:
object_key (str): Key of the object being... | python | def _update_object(object_key: str, event: Event):
"""Update the events list and events data for the object.
- Adds the event Id to the list of events for the object.
- Adds the event data to the hash of object event data keyed by event
id.
Args:
object_key (str): Key of the object being... | [
"def",
"_update_object",
"(",
"object_key",
":",
"str",
",",
"event",
":",
"Event",
")",
":",
"events_list_key",
"=",
"_keys",
".",
"events_list",
"(",
"object_key",
")",
"events_data_key",
"=",
"_keys",
".",
"events_data",
"(",
"object_key",
")",
"event_dict"... | Update the events list and events data for the object.
- Adds the event Id to the list of events for the object.
- Adds the event data to the hash of object event data keyed by event
id.
Args:
object_key (str): Key of the object being updated.
event (Event): Event object | [
"Update",
"the",
"events",
"list",
"and",
"events",
"data",
"for",
"the",
"object",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L147-L166 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py | _get_event_id | def _get_event_id(object_type: str) -> str:
"""Return an event key for the event on the object type.
This must be a unique event id for the object.
Args:
object_type (str): Type of object
Returns:
str, event id
"""
key = _keys.event_counter(object_type)
DB.watch(key, pipe... | python | def _get_event_id(object_type: str) -> str:
"""Return an event key for the event on the object type.
This must be a unique event id for the object.
Args:
object_type (str): Type of object
Returns:
str, event id
"""
key = _keys.event_counter(object_type)
DB.watch(key, pipe... | [
"def",
"_get_event_id",
"(",
"object_type",
":",
"str",
")",
"->",
"str",
":",
"key",
"=",
"_keys",
".",
"event_counter",
"(",
"object_type",
")",
"DB",
".",
"watch",
"(",
"key",
",",
"pipeline",
"=",
"True",
")",
"count",
"=",
"DB",
".",
"get_value",
... | Return an event key for the event on the object type.
This must be a unique event id for the object.
Args:
object_type (str): Type of object
Returns:
str, event id | [
"Return",
"an",
"event",
"key",
"for",
"the",
"event",
"on",
"the",
"object",
"type",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_events/pubsub.py#L169-L188 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/tango_processing_block/app/processing_block_device.py | ProcessingBlockDevice.init_device | def init_device(self):
"""Device constructor."""
start_time = time.time()
Device.init_device(self)
self._pb_id = ''
LOG.debug('init PB device %s, time taken %.6f s (total: %.2f s)',
self.get_name(), (time.time() - start_time),
(time.time() - se... | python | def init_device(self):
"""Device constructor."""
start_time = time.time()
Device.init_device(self)
self._pb_id = ''
LOG.debug('init PB device %s, time taken %.6f s (total: %.2f s)',
self.get_name(), (time.time() - start_time),
(time.time() - se... | [
"def",
"init_device",
"(",
"self",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"Device",
".",
"init_device",
"(",
"self",
")",
"self",
".",
"_pb_id",
"=",
"''",
"LOG",
".",
"debug",
"(",
"'init PB device %s, time taken %.6f s (total: %.2f s)'",... | Device constructor. | [
"Device",
"constructor",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/tango_processing_block/app/processing_block_device.py#L19-L27 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/tango_processing_block/app/processing_block_device.py | ProcessingBlockDevice.pb_id | def pb_id(self, pb_id: str):
"""Set the PB Id for this device."""
# FIXME(BMo) instead of creating the object to check if the PB exists
# use a method on PB List?
# ProcessingBlock(pb_id)
self.set_state(DevState.ON)
self._pb_id = pb_id | python | def pb_id(self, pb_id: str):
"""Set the PB Id for this device."""
# FIXME(BMo) instead of creating the object to check if the PB exists
# use a method on PB List?
# ProcessingBlock(pb_id)
self.set_state(DevState.ON)
self._pb_id = pb_id | [
"def",
"pb_id",
"(",
"self",
",",
"pb_id",
":",
"str",
")",
":",
"# FIXME(BMo) instead of creating the object to check if the PB exists",
"# use a method on PB List?",
"# ProcessingBlock(pb_id)",
"self",
".",
"set_state",
"(",
"DevState",
".",
"ON",
")",
"self",
... | Set the PB Id for this device. | [
"Set",
"the",
"PB",
"Id",
"for",
"this",
"device",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/tango_processing_block/app/processing_block_device.py#L48-L54 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/tango_processing_block/app/processing_block_device.py | ProcessingBlockDevice.pb_config | def pb_config(self):
"""Return the PB configuration."""
pb = ProcessingBlock(self._pb_id)
return json.dumps(pb.config) | python | def pb_config(self):
"""Return the PB configuration."""
pb = ProcessingBlock(self._pb_id)
return json.dumps(pb.config) | [
"def",
"pb_config",
"(",
"self",
")",
":",
"pb",
"=",
"ProcessingBlock",
"(",
"self",
".",
"_pb_id",
")",
"return",
"json",
".",
"dumps",
"(",
"pb",
".",
"config",
")"
] | Return the PB configuration. | [
"Return",
"the",
"PB",
"configuration",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/tango_processing_block/app/processing_block_device.py#L57-L60 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/states/_state_object.py | StateObject.current_timestamp | def current_timestamp(self) -> datetime:
"""Get the current state timestamp."""
timestamp = DB.get_hash_value(self._key, 'current_timestamp')
return datetime_from_isoformat(timestamp) | python | def current_timestamp(self) -> datetime:
"""Get the current state timestamp."""
timestamp = DB.get_hash_value(self._key, 'current_timestamp')
return datetime_from_isoformat(timestamp) | [
"def",
"current_timestamp",
"(",
"self",
")",
"->",
"datetime",
":",
"timestamp",
"=",
"DB",
".",
"get_hash_value",
"(",
"self",
".",
"_key",
",",
"'current_timestamp'",
")",
"return",
"datetime_from_isoformat",
"(",
"timestamp",
")"
] | Get the current state timestamp. | [
"Get",
"the",
"current",
"state",
"timestamp",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/states/_state_object.py#L93-L96 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/states/_state_object.py | StateObject.target_timestamp | def target_timestamp(self) -> datetime:
"""Get the target state timestamp."""
timestamp = DB.get_hash_value(self._key, 'target_timestamp')
return datetime_from_isoformat(timestamp) | python | def target_timestamp(self) -> datetime:
"""Get the target state timestamp."""
timestamp = DB.get_hash_value(self._key, 'target_timestamp')
return datetime_from_isoformat(timestamp) | [
"def",
"target_timestamp",
"(",
"self",
")",
"->",
"datetime",
":",
"timestamp",
"=",
"DB",
".",
"get_hash_value",
"(",
"self",
".",
"_key",
",",
"'target_timestamp'",
")",
"return",
"datetime_from_isoformat",
"(",
"timestamp",
")"
] | Get the target state timestamp. | [
"Get",
"the",
"target",
"state",
"timestamp",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/states/_state_object.py#L99-L102 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/states/_state_object.py | StateObject.update_target_state | def update_target_state(self, value: str, force: bool = True) -> datetime:
"""Set the target state.
Args:
value (str): New value for target state
force (bool): If true, ignore allowed transitions
Returns:
datetime, update timestamp
Raises:
... | python | def update_target_state(self, value: str, force: bool = True) -> datetime:
"""Set the target state.
Args:
value (str): New value for target state
force (bool): If true, ignore allowed transitions
Returns:
datetime, update timestamp
Raises:
... | [
"def",
"update_target_state",
"(",
"self",
",",
"value",
":",
"str",
",",
"force",
":",
"bool",
"=",
"True",
")",
"->",
"datetime",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
"if",
"not",
"force",
":",
"current_state",
"=",
"self",
".",
"cur... | Set the target state.
Args:
value (str): New value for target state
force (bool): If true, ignore allowed transitions
Returns:
datetime, update timestamp
Raises:
RuntimeError, if it is not possible to currently set the target
state.
... | [
"Set",
"the",
"target",
"state",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/states/_state_object.py#L104-L137 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/states/_state_object.py | StateObject.update_current_state | def update_current_state(self, value: str,
force: bool = False) -> datetime:
"""Update the current state.
Args:
value (str): New value for sdp state
force (bool): If true, ignore allowed transitions
Returns:
datetime, update time... | python | def update_current_state(self, value: str,
force: bool = False) -> datetime:
"""Update the current state.
Args:
value (str): New value for sdp state
force (bool): If true, ignore allowed transitions
Returns:
datetime, update time... | [
"def",
"update_current_state",
"(",
"self",
",",
"value",
":",
"str",
",",
"force",
":",
"bool",
"=",
"False",
")",
"->",
"datetime",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
"if",
"not",
"force",
":",
"current_state",
"=",
"self",
".",
"c... | Update the current state.
Args:
value (str): New value for sdp state
force (bool): If true, ignore allowed transitions
Returns:
datetime, update timestamp
Raises:
ValueError: If the specified current state is not allowed. | [
"Update",
"the",
"current",
"state",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/states/_state_object.py#L139-L173 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/states/_state_object.py | StateObject._initialise | def _initialise(self, initial_state: str = 'unknown') -> dict:
"""Return a dictionary used to initialise a state object.
This method is used to obtain a dictionary/hash describing the initial
state of SDP or a service in SDP.
Args:
initial_state (str): Initial state.
... | python | def _initialise(self, initial_state: str = 'unknown') -> dict:
"""Return a dictionary used to initialise a state object.
This method is used to obtain a dictionary/hash describing the initial
state of SDP or a service in SDP.
Args:
initial_state (str): Initial state.
... | [
"def",
"_initialise",
"(",
"self",
",",
"initial_state",
":",
"str",
"=",
"'unknown'",
")",
"->",
"dict",
":",
"initial_state",
"=",
"initial_state",
".",
"lower",
"(",
")",
"if",
"initial_state",
"!=",
"'unknown'",
"and",
"initial_state",
"not",
"in",
"self... | Return a dictionary used to initialise a state object.
This method is used to obtain a dictionary/hash describing the initial
state of SDP or a service in SDP.
Args:
initial_state (str): Initial state.
Returns:
dict, Initial state configuration | [
"Return",
"a",
"dictionary",
"used",
"to",
"initialise",
"a",
"state",
"object",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/states/_state_object.py#L228-L250 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/states/_state_object.py | StateObject._update_state | def _update_state(self, state_type: str, value: str) -> datetime:
"""Update the state of type specified (current or target).
Args:
state_type(str): Type of state to update, current or target.
value (str): New state value.
Returns:
timestamp, current time
... | python | def _update_state(self, state_type: str, value: str) -> datetime:
"""Update the state of type specified (current or target).
Args:
state_type(str): Type of state to update, current or target.
value (str): New state value.
Returns:
timestamp, current time
... | [
"def",
"_update_state",
"(",
"self",
",",
"state_type",
":",
"str",
",",
"value",
":",
"str",
")",
"->",
"datetime",
":",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"field",
"=",
"'{}_state'",
".",
"format",
"(",
"state_type",
")",
"old_state... | Update the state of type specified (current or target).
Args:
state_type(str): Type of state to update, current or target.
value (str): New state value.
Returns:
timestamp, current time | [
"Update",
"the",
"state",
"of",
"type",
"specified",
"(",
"current",
"or",
"target",
")",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/states/_state_object.py#L252-L275 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/states/_state_object.py | StateObject._dict_lower | def _dict_lower(dictionary: dict):
"""Convert allowed state transitions / target states to lowercase."""
return {key.lower(): [value.lower() for value in value]
for key, value in dictionary.items()} | python | def _dict_lower(dictionary: dict):
"""Convert allowed state transitions / target states to lowercase."""
return {key.lower(): [value.lower() for value in value]
for key, value in dictionary.items()} | [
"def",
"_dict_lower",
"(",
"dictionary",
":",
"dict",
")",
":",
"return",
"{",
"key",
".",
"lower",
"(",
")",
":",
"[",
"value",
".",
"lower",
"(",
")",
"for",
"value",
"in",
"value",
"]",
"for",
"key",
",",
"value",
"in",
"dictionary",
".",
"items... | Convert allowed state transitions / target states to lowercase. | [
"Convert",
"allowed",
"state",
"transitions",
"/",
"target",
"states",
"to",
"lowercase",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/states/_state_object.py#L278-L281 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.add_sched_block_instance | def add_sched_block_instance(self, config_dict):
"""Add Scheduling Block to the database.
Args:
config_dict (dict): SBI configuration
"""
# Get schema for validation
schema = self._get_schema()
LOG.debug('Adding SBI with config: %s', config_dict)
# ... | python | def add_sched_block_instance(self, config_dict):
"""Add Scheduling Block to the database.
Args:
config_dict (dict): SBI configuration
"""
# Get schema for validation
schema = self._get_schema()
LOG.debug('Adding SBI with config: %s', config_dict)
# ... | [
"def",
"add_sched_block_instance",
"(",
"self",
",",
"config_dict",
")",
":",
"# Get schema for validation",
"schema",
"=",
"self",
".",
"_get_schema",
"(",
")",
"LOG",
".",
"debug",
"(",
"'Adding SBI with config: %s'",
",",
"config_dict",
")",
"# Validates the schema... | Add Scheduling Block to the database.
Args:
config_dict (dict): SBI configuration | [
"Add",
"Scheduling",
"Block",
"to",
"the",
"database",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L31-L73 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.get_sched_block_instance_ids | def get_sched_block_instance_ids(self):
"""Get unordered list of scheduling block ids"""
# Initialise empty list
scheduling_block_ids = []
# Pattern used to search scheduling block ids
pattern = 'scheduling_block:*'
block_ids = self._db.get_ids(pattern)
for blo... | python | def get_sched_block_instance_ids(self):
"""Get unordered list of scheduling block ids"""
# Initialise empty list
scheduling_block_ids = []
# Pattern used to search scheduling block ids
pattern = 'scheduling_block:*'
block_ids = self._db.get_ids(pattern)
for blo... | [
"def",
"get_sched_block_instance_ids",
"(",
"self",
")",
":",
"# Initialise empty list",
"scheduling_block_ids",
"=",
"[",
"]",
"# Pattern used to search scheduling block ids",
"pattern",
"=",
"'scheduling_block:*'",
"block_ids",
"=",
"self",
".",
"_db",
".",
"get_ids",
"... | Get unordered list of scheduling block ids | [
"Get",
"unordered",
"list",
"of",
"scheduling",
"block",
"ids"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L79-L93 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.get_processing_block_ids | def get_processing_block_ids(self):
"""Get list of processing block ids using the processing block id"""
# Initialise empty list
_processing_block_ids = []
# Pattern used to search processing block ids
pattern = '*:processing_block:*'
block_ids = self._db.get_ids(patter... | python | def get_processing_block_ids(self):
"""Get list of processing block ids using the processing block id"""
# Initialise empty list
_processing_block_ids = []
# Pattern used to search processing block ids
pattern = '*:processing_block:*'
block_ids = self._db.get_ids(patter... | [
"def",
"get_processing_block_ids",
"(",
"self",
")",
":",
"# Initialise empty list",
"_processing_block_ids",
"=",
"[",
"]",
"# Pattern used to search processing block ids",
"pattern",
"=",
"'*:processing_block:*'",
"block_ids",
"=",
"self",
".",
"_db",
".",
"get_ids",
"(... | Get list of processing block ids using the processing block id | [
"Get",
"list",
"of",
"processing",
"block",
"ids",
"using",
"the",
"processing",
"block",
"id"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L95-L108 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.get_sub_array_ids | def get_sub_array_ids(self):
"""Get list of sub array ids"""
# Initialise empty list
_scheduling_block_ids = []
_sub_array_ids = []
for blocks_id in self.get_sched_block_instance_ids():
_scheduling_block_ids.append(blocks_id)
block_details = self.get_block_d... | python | def get_sub_array_ids(self):
"""Get list of sub array ids"""
# Initialise empty list
_scheduling_block_ids = []
_sub_array_ids = []
for blocks_id in self.get_sched_block_instance_ids():
_scheduling_block_ids.append(blocks_id)
block_details = self.get_block_d... | [
"def",
"get_sub_array_ids",
"(",
"self",
")",
":",
"# Initialise empty list",
"_scheduling_block_ids",
"=",
"[",
"]",
"_sub_array_ids",
"=",
"[",
"]",
"for",
"blocks_id",
"in",
"self",
".",
"get_sched_block_instance_ids",
"(",
")",
":",
"_scheduling_block_ids",
".",... | Get list of sub array ids | [
"Get",
"list",
"of",
"sub",
"array",
"ids"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L114-L127 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.get_sub_array_sbi_ids | def get_sub_array_sbi_ids(self, sub_array_id):
"""Get Scheduling Block Instance ID associated with sub array id"""
_ids = []
sbi_ids = self.get_sched_block_instance_ids()
for details in self.get_block_details(sbi_ids):
if details['sub_array_id'] == sub_array_id:
... | python | def get_sub_array_sbi_ids(self, sub_array_id):
"""Get Scheduling Block Instance ID associated with sub array id"""
_ids = []
sbi_ids = self.get_sched_block_instance_ids()
for details in self.get_block_details(sbi_ids):
if details['sub_array_id'] == sub_array_id:
... | [
"def",
"get_sub_array_sbi_ids",
"(",
"self",
",",
"sub_array_id",
")",
":",
"_ids",
"=",
"[",
"]",
"sbi_ids",
"=",
"self",
".",
"get_sched_block_instance_ids",
"(",
")",
"for",
"details",
"in",
"self",
".",
"get_block_details",
"(",
"sbi_ids",
")",
":",
"if"... | Get Scheduling Block Instance ID associated with sub array id | [
"Get",
"Scheduling",
"Block",
"Instance",
"ID",
"associated",
"with",
"sub",
"array",
"id"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L129-L136 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.get_block_details | def get_block_details(self, block_ids):
"""Get details of scheduling or processing block
Args:
block_ids (list): List of block IDs
"""
# Convert input to list if needed
if not hasattr(block_ids, "__iter__"):
block_ids = [block_ids]
for _id in blo... | python | def get_block_details(self, block_ids):
"""Get details of scheduling or processing block
Args:
block_ids (list): List of block IDs
"""
# Convert input to list if needed
if not hasattr(block_ids, "__iter__"):
block_ids = [block_ids]
for _id in blo... | [
"def",
"get_block_details",
"(",
"self",
",",
"block_ids",
")",
":",
"# Convert input to list if needed",
"if",
"not",
"hasattr",
"(",
"block_ids",
",",
"\"__iter__\"",
")",
":",
"block_ids",
"=",
"[",
"block_ids",
"]",
"for",
"_id",
"in",
"block_ids",
":",
"b... | Get details of scheduling or processing block
Args:
block_ids (list): List of block IDs | [
"Get",
"details",
"of",
"scheduling",
"or",
"processing",
"block"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L138-L159 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.update_value | def update_value(self, block_id, field, value):
""""Update the value of the given block id and field"""
block_name = self._db.get_block(block_id)
for name in block_name:
self._db.set_value(name, field, value) | python | def update_value(self, block_id, field, value):
""""Update the value of the given block id and field"""
block_name = self._db.get_block(block_id)
for name in block_name:
self._db.set_value(name, field, value) | [
"def",
"update_value",
"(",
"self",
",",
"block_id",
",",
"field",
",",
"value",
")",
":",
"block_name",
"=",
"self",
".",
"_db",
".",
"get_block",
"(",
"block_id",
")",
"for",
"name",
"in",
"block_name",
":",
"self",
".",
"_db",
".",
"set_value",
"(",... | Update the value of the given block id and field | [
"Update",
"the",
"value",
"of",
"the",
"given",
"block",
"id",
"and",
"field"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L172-L176 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.delete_sched_block_instance | def delete_sched_block_instance(self, block_id):
"""Delete the specified Scheduling Block Instance.
Removes the Scheduling Block Instance, and all Processing Blocks
that belong to it from the database"""
LOG.debug('Deleting SBI %s', block_id)
scheduling_blocks = self._db.get_al... | python | def delete_sched_block_instance(self, block_id):
"""Delete the specified Scheduling Block Instance.
Removes the Scheduling Block Instance, and all Processing Blocks
that belong to it from the database"""
LOG.debug('Deleting SBI %s', block_id)
scheduling_blocks = self._db.get_al... | [
"def",
"delete_sched_block_instance",
"(",
"self",
",",
"block_id",
")",
":",
"LOG",
".",
"debug",
"(",
"'Deleting SBI %s'",
",",
"block_id",
")",
"scheduling_blocks",
"=",
"self",
".",
"_db",
".",
"get_all_blocks",
"(",
"block_id",
")",
"if",
"not",
"scheduli... | Delete the specified Scheduling Block Instance.
Removes the Scheduling Block Instance, and all Processing Blocks
that belong to it from the database | [
"Delete",
"the",
"specified",
"Scheduling",
"Block",
"Instance",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L182-L210 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb.delete_processing_block | def delete_processing_block(self, processing_block_id):
"""Delete Processing Block(s).
Uses Processing Block IDs
"""
LOG.debug("Deleting Processing Block %s ...", processing_block_id)
processing_block = self._db.get_block(processing_block_id)
if not processing_block:
... | python | def delete_processing_block(self, processing_block_id):
"""Delete Processing Block(s).
Uses Processing Block IDs
"""
LOG.debug("Deleting Processing Block %s ...", processing_block_id)
processing_block = self._db.get_block(processing_block_id)
if not processing_block:
... | [
"def",
"delete_processing_block",
"(",
"self",
",",
"processing_block_id",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Deleting Processing Block %s ...\"",
",",
"processing_block_id",
")",
"processing_block",
"=",
"self",
".",
"_db",
".",
"get_block",
"(",
"processing_bloc... | Delete Processing Block(s).
Uses Processing Block IDs | [
"Delete",
"Processing",
"Block",
"(",
"s",
")",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L212-L241 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb._get_schema | def _get_schema():
"""Get the schema for validation"""
schema_path = os.path.join(os.path.dirname(__file__),
'schema', 'scheduling_block_schema.json')
with open(schema_path, 'r') as file:
schema_data = file.read()
schema = json.loads(schema_... | python | def _get_schema():
"""Get the schema for validation"""
schema_path = os.path.join(os.path.dirname(__file__),
'schema', 'scheduling_block_schema.json')
with open(schema_path, 'r') as file:
schema_data = file.read()
schema = json.loads(schema_... | [
"def",
"_get_schema",
"(",
")",
":",
"schema_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'schema'",
",",
"'scheduling_block_schema.json'",
")",
"with",
"open",
"(",
"schema_path",
",",
"... | Get the schema for validation | [
"Get",
"the",
"schema",
"for",
"validation"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L256-L263 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb._add_status | def _add_status(scheduling_block):
"""This function adds status fields to all the section
in the scheduling block instance"""
scheduling_block['status'] = "created"
for block in scheduling_block:
if isinstance(scheduling_block[block], list):
for field in sched... | python | def _add_status(scheduling_block):
"""This function adds status fields to all the section
in the scheduling block instance"""
scheduling_block['status'] = "created"
for block in scheduling_block:
if isinstance(scheduling_block[block], list):
for field in sched... | [
"def",
"_add_status",
"(",
"scheduling_block",
")",
":",
"scheduling_block",
"[",
"'status'",
"]",
"=",
"\"created\"",
"for",
"block",
"in",
"scheduling_block",
":",
"if",
"isinstance",
"(",
"scheduling_block",
"[",
"block",
"]",
",",
"list",
")",
":",
"for",
... | This function adds status fields to all the section
in the scheduling block instance | [
"This",
"function",
"adds",
"status",
"fields",
"to",
"all",
"the",
"section",
"in",
"the",
"scheduling",
"block",
"instance"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L266-L274 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | ConfigDb._split_sched_block_instance | def _split_sched_block_instance(self, scheduling_block):
"""Split the scheduling block data into multiple names
before adding to the configuration database"""
# Initialise empty list
_scheduling_block_data = {}
_processing_block_data = {}
_processing_block_id = []
... | python | def _split_sched_block_instance(self, scheduling_block):
"""Split the scheduling block data into multiple names
before adding to the configuration database"""
# Initialise empty list
_scheduling_block_data = {}
_processing_block_data = {}
_processing_block_id = []
... | [
"def",
"_split_sched_block_instance",
"(",
"self",
",",
"scheduling_block",
")",
":",
"# Initialise empty list",
"_scheduling_block_data",
"=",
"{",
"}",
"_processing_block_data",
"=",
"{",
"}",
"_processing_block_id",
"=",
"[",
"]",
"for",
"block",
"in",
"scheduling_... | Split the scheduling block data into multiple names
before adding to the configuration database | [
"Split",
"the",
"scheduling",
"block",
"data",
"into",
"multiple",
"names",
"before",
"adding",
"to",
"the",
"configuration",
"database"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L276-L307 |
SKA-ScienceDataProcessor/integration-prototype | sip/science_pipeline_workflows/ical_dask/pipelines/imaging_modeling.py | main | def main():
"""Workflow stage application."""
init_logging()
# Get Dask client
arlexecute.set_client(get_dask_Client())
arlexecute.run(init_logging)
LOG.info('Results dir = %s', RESULTS_DIR)
LOG.info("Starting imaging-modeling")
# Read parameters
PARFILE = 'parameters.json'
if... | python | def main():
"""Workflow stage application."""
init_logging()
# Get Dask client
arlexecute.set_client(get_dask_Client())
arlexecute.run(init_logging)
LOG.info('Results dir = %s', RESULTS_DIR)
LOG.info("Starting imaging-modeling")
# Read parameters
PARFILE = 'parameters.json'
if... | [
"def",
"main",
"(",
")",
":",
"init_logging",
"(",
")",
"# Get Dask client",
"arlexecute",
".",
"set_client",
"(",
"get_dask_Client",
"(",
")",
")",
"arlexecute",
".",
"run",
"(",
"init_logging",
")",
"LOG",
".",
"info",
"(",
"'Results dir = %s'",
",",
"RESU... | Workflow stage application. | [
"Workflow",
"stage",
"application",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/ical_dask/pipelines/imaging_modeling.py#L49-L169 |
SKA-ScienceDataProcessor/integration-prototype | sip/platform/logging/sip_logging/sip_logging.py | init_logger | def init_logger(logger_name='sip', log_level=None, p3_mode: bool = True,
show_thread: bool = False, propagate: bool = False,
show_log_origin=False):
"""Initialise the SIP logger.
Attaches a stdout stream handler to the 'sip' logger. This will
apply to all logger objects with... | python | def init_logger(logger_name='sip', log_level=None, p3_mode: bool = True,
show_thread: bool = False, propagate: bool = False,
show_log_origin=False):
"""Initialise the SIP logger.
Attaches a stdout stream handler to the 'sip' logger. This will
apply to all logger objects with... | [
"def",
"init_logger",
"(",
"logger_name",
"=",
"'sip'",
",",
"log_level",
"=",
"None",
",",
"p3_mode",
":",
"bool",
"=",
"True",
",",
"show_thread",
":",
"bool",
"=",
"False",
",",
"propagate",
":",
"bool",
"=",
"False",
",",
"show_log_origin",
"=",
"Fal... | Initialise the SIP logger.
Attaches a stdout stream handler to the 'sip' logger. This will
apply to all logger objects with a name prefixed by 'sip.'
This function respects the 'SIP_LOG_LEVEL' environment variable to
set the logging level.
Args:
logger_name (str, optional): Name of the lo... | [
"Initialise",
"the",
"SIP",
"logger",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/platform/logging/sip_logging/sip_logging.py#L46-L108 |
SKA-ScienceDataProcessor/integration-prototype | sip/platform/logging/sip_logging/sip_logging.py | disable_logger | def disable_logger(logger_name: str, propagate: bool = False):
"""Disable output for the logger of the specified name."""
log = logging.getLogger(logger_name)
log.propagate = propagate
for handler in log.handlers:
log.removeHandler(handler) | python | def disable_logger(logger_name: str, propagate: bool = False):
"""Disable output for the logger of the specified name."""
log = logging.getLogger(logger_name)
log.propagate = propagate
for handler in log.handlers:
log.removeHandler(handler) | [
"def",
"disable_logger",
"(",
"logger_name",
":",
"str",
",",
"propagate",
":",
"bool",
"=",
"False",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"logger_name",
")",
"log",
".",
"propagate",
"=",
"propagate",
"for",
"handler",
"in",
"log",
".... | Disable output for the logger of the specified name. | [
"Disable",
"output",
"for",
"the",
"logger",
"of",
"the",
"specified",
"name",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/platform/logging/sip_logging/sip_logging.py#L111-L116 |
SKA-ScienceDataProcessor/integration-prototype | sip/platform/logging/sip_logging/sip_logging.py | set_log_level | def set_log_level(logger_name: str, log_level: str, propagate: bool = False):
"""Set the log level of the specified logger."""
log = logging.getLogger(logger_name)
log.propagate = propagate
log.setLevel(log_level) | python | def set_log_level(logger_name: str, log_level: str, propagate: bool = False):
"""Set the log level of the specified logger."""
log = logging.getLogger(logger_name)
log.propagate = propagate
log.setLevel(log_level) | [
"def",
"set_log_level",
"(",
"logger_name",
":",
"str",
",",
"log_level",
":",
"str",
",",
"propagate",
":",
"bool",
"=",
"False",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"logger_name",
")",
"log",
".",
"propagate",
"=",
"propagate",
"log... | Set the log level of the specified logger. | [
"Set",
"the",
"log",
"level",
"of",
"the",
"specified",
"logger",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/platform/logging/sip_logging/sip_logging.py#L119-L123 |
SKA-ScienceDataProcessor/integration-prototype | sip/platform/logging/sip_logging/sip_logging.py | SIPFormatter.formatTime | def formatTime(self, record, datefmt=None):
"""Format the log timestamp."""
_seconds_fraction = record.created - int(record.created)
_datetime_utc = time.mktime(time.gmtime(record.created))
_datetime_utc += _seconds_fraction
_created = self.converter(_datetime_utc)
if da... | python | def formatTime(self, record, datefmt=None):
"""Format the log timestamp."""
_seconds_fraction = record.created - int(record.created)
_datetime_utc = time.mktime(time.gmtime(record.created))
_datetime_utc += _seconds_fraction
_created = self.converter(_datetime_utc)
if da... | [
"def",
"formatTime",
"(",
"self",
",",
"record",
",",
"datefmt",
"=",
"None",
")",
":",
"_seconds_fraction",
"=",
"record",
".",
"created",
"-",
"int",
"(",
"record",
".",
"created",
")",
"_datetime_utc",
"=",
"time",
".",
"mktime",
"(",
"time",
".",
"... | Format the log timestamp. | [
"Format",
"the",
"log",
"timestamp",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/platform/logging/sip_logging/sip_logging.py#L31-L43 |
SKA-ScienceDataProcessor/integration-prototype | demos/02_running_a_workflow/generate_sbi_config.py | generate_sbi | def generate_sbi(index: int = None):
"""Generate a SBI config JSON string."""
date = datetime.datetime.utcnow().strftime('%Y%m%d')
if index is None:
index = randint(0, 999)
sbi_id = 'SBI-{}-sip-demo-{:03d}'.format(date, index)
sb_id = 'SBI-{}-sip-demo-{:03d}'.format(date, index)
pb_id = ... | python | def generate_sbi(index: int = None):
"""Generate a SBI config JSON string."""
date = datetime.datetime.utcnow().strftime('%Y%m%d')
if index is None:
index = randint(0, 999)
sbi_id = 'SBI-{}-sip-demo-{:03d}'.format(date, index)
sb_id = 'SBI-{}-sip-demo-{:03d}'.format(date, index)
pb_id = ... | [
"def",
"generate_sbi",
"(",
"index",
":",
"int",
"=",
"None",
")",
":",
"date",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"strftime",
"(",
"'%Y%m%d'",
")",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"randint",
"(",
"0",
"... | Generate a SBI config JSON string. | [
"Generate",
"a",
"SBI",
"config",
"JSON",
"string",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/demos/02_running_a_workflow/generate_sbi_config.py#L9-L46 |
SKA-ScienceDataProcessor/integration-prototype | sip/science_pipeline_workflows/receive_pss/csp_pss_sender/app/pulsar_sender.py | PulsarSender.send | def send(self, config, log, obs_id, beam_id):
"""
Send the pulsar data to the ftp server
Args:
config (dict): Dictionary of settings
log (logging.Logger): Python logging object
obs_id: observation id
beam_id: beam id
"""
log.info('... | python | def send(self, config, log, obs_id, beam_id):
"""
Send the pulsar data to the ftp server
Args:
config (dict): Dictionary of settings
log (logging.Logger): Python logging object
obs_id: observation id
beam_id: beam id
"""
log.info('... | [
"def",
"send",
"(",
"self",
",",
"config",
",",
"log",
",",
"obs_id",
",",
"beam_id",
")",
":",
"log",
".",
"info",
"(",
"'Starting Pulsar Data Transfer...'",
")",
"socket",
"=",
"self",
".",
"_ftp",
".",
"transfercmd",
"(",
"'STOR {0}_{1}'",
".",
"format"... | Send the pulsar data to the ftp server
Args:
config (dict): Dictionary of settings
log (logging.Logger): Python logging object
obs_id: observation id
beam_id: beam id | [
"Send",
"the",
"pulsar",
"data",
"to",
"the",
"ftp",
"server"
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/receive_pss/csp_pss_sender/app/pulsar_sender.py#L33-L54 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/api/processing_block.py | get | def get(block_id):
"""Processing block detail resource."""
_url = get_root_url()
try:
block = DB.get_block_details([block_id]).__next__()
response = block
response['links'] = {
'self': '{}'.format(request.url),
'list': '{}/processing-blocks'.format(_url),
... | python | def get(block_id):
"""Processing block detail resource."""
_url = get_root_url()
try:
block = DB.get_block_details([block_id]).__next__()
response = block
response['links'] = {
'self': '{}'.format(request.url),
'list': '{}/processing-blocks'.format(_url),
... | [
"def",
"get",
"(",
"block_id",
")",
":",
"_url",
"=",
"get_root_url",
"(",
")",
"try",
":",
"block",
"=",
"DB",
".",
"get_block_details",
"(",
"[",
"block_id",
"]",
")",
".",
"__next__",
"(",
")",
"response",
"=",
"block",
"response",
"[",
"'links'",
... | Processing block detail resource. | [
"Processing",
"block",
"detail",
"resource",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/api/processing_block.py#L19-L40 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/api/processing_block.py | delete | def delete(block_id):
"""Processing block detail resource."""
_url = get_root_url()
try:
DB.delete_processing_block(block_id)
response = dict(message='Deleted block',
id='{}'.format(block_id),
links=dict(list='{}/processing-blocks'.format(_url)... | python | def delete(block_id):
"""Processing block detail resource."""
_url = get_root_url()
try:
DB.delete_processing_block(block_id)
response = dict(message='Deleted block',
id='{}'.format(block_id),
links=dict(list='{}/processing-blocks'.format(_url)... | [
"def",
"delete",
"(",
"block_id",
")",
":",
"_url",
"=",
"get_root_url",
"(",
")",
"try",
":",
"DB",
".",
"delete_processing_block",
"(",
"block_id",
")",
"response",
"=",
"dict",
"(",
"message",
"=",
"'Deleted block'",
",",
"id",
"=",
"'{}'",
".",
"form... | Processing block detail resource. | [
"Processing",
"block",
"detail",
"resource",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/api/processing_block.py#L45-L61 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/tango_subarray/app/subarray_device.py | SubarrayDevice.init_device | def init_device(self):
"""Initialise the device."""
Device.init_device(self)
time.sleep(0.1)
self.set_state(DevState.STANDBY) | python | def init_device(self):
"""Initialise the device."""
Device.init_device(self)
time.sleep(0.1)
self.set_state(DevState.STANDBY) | [
"def",
"init_device",
"(",
"self",
")",
":",
"Device",
".",
"init_device",
"(",
"self",
")",
"time",
".",
"sleep",
"(",
"0.1",
")",
"self",
".",
"set_state",
"(",
"DevState",
".",
"STANDBY",
")"
] | Initialise the device. | [
"Initialise",
"the",
"device",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/tango_subarray/app/subarray_device.py#L16-L20 |
SKA-ScienceDataProcessor/integration-prototype | sip/tango_control/tango_subarray/app/subarray_device.py | SubarrayDevice.configure | def configure(self, sbi_config: str):
"""Configure an SBI for this subarray.
Args:
sbi_config (str): SBI configuration JSON
Returns:
str,
"""
# print(sbi_config)
config_dict = json.loads(sbi_config)
self.debug_stream('SBI configuration:\... | python | def configure(self, sbi_config: str):
"""Configure an SBI for this subarray.
Args:
sbi_config (str): SBI configuration JSON
Returns:
str,
"""
# print(sbi_config)
config_dict = json.loads(sbi_config)
self.debug_stream('SBI configuration:\... | [
"def",
"configure",
"(",
"self",
",",
"sbi_config",
":",
"str",
")",
":",
"# print(sbi_config)",
"config_dict",
"=",
"json",
".",
"loads",
"(",
"sbi_config",
")",
"self",
".",
"debug_stream",
"(",
"'SBI configuration:\\n%s'",
",",
"json",
".",
"dumps",
"(",
... | Configure an SBI for this subarray.
Args:
sbi_config (str): SBI configuration JSON
Returns:
str, | [
"Configure",
"an",
"SBI",
"for",
"this",
"subarray",
"."
] | train | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/tango_subarray/app/subarray_device.py#L26-L48 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.