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_documentation_string
stringlengths
1
47.2k
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 ...
Retrieves course wide transcript preferences Arguments: course_id (str): course id
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...
Creates or updates course-wide transcript preferences Arguments: course_id(str): course id Keyword Arguments: preferences(dict): keyword arguments
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...
Deletes course-wide transcript preferences. Arguments: course_id(str): course id
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...
Returns course video image url or None if no image found
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`...
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...
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 ...
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
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...
Get a Video instance, prefetching encoded video and course information. Raises ValVideoNotFoundError if the video cannot be retrieved.
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...
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
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...
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.
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...
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...
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...
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...
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...
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
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...
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...
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...
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: { '...
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...
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
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:...
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...
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)...
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....
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 ...
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 ...
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...
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 ...
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...
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...
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 (...
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...
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...
Returns a list of dictionaries of all cache servers and their stats, if they provide stats.
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 '')) ...
Generate a script that writes the password to the git command line tool
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():]
TimeSkill -> time_skill
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
Write a serializer by yielding each line of output
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...
Reads git commits from skill repo to create a list of changes as the PR content
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))
Moves SHIP to the new location X,Y.
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...
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.
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) }, { ...
Home page.
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
Check the health of this service.
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")
Get target states allowed for the current state.
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", ...
SDP State. Return current state; target state and allowed target states.
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...
SDP target State. Returns the target state; allowed target states and time updated
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="...
Return the SDP State and the timestamp for when it was updated.
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", ...
SDP target State. Sets the target state
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)
Return the list of processing blocks known to SDP.
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)
Return list of Scheduling Block instances known to SDP.
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)...
Configure an SBI using POSTed configuration.
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
Temporary helper function to link to the API routes
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)
Catch all path - return a JSON 404
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...
Return the list of active subarrays.
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...
Return the list of inactive subarrays.
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 ...
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): ...
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...
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): ...
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...
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.
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...
Runs test imaging pipeline using Spark.
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
Loads a JSON schema file.
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)
Clear the entire db.
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)
Return list of scheduling block IDs
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...
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...
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...
Delete Scheduling Block with the specified ID
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
Return the latest Scheduling Block event
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))
Return list of sub-array Id's currently known to SDP
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...
Return list of scheduling block Id's associated with the given sub_array_id
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
Return an array of Processing Block ids
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...
Return the Processing Block Configuration for the specified ID
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( ...
Delete Processing Block with the specified ID
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
Return the latest Processing Block event
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...
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...
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))
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.
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. ...
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...
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))
Get list of event ids for the object with the specified key. Args: object_key (str): Key of an object in the database.
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): ...
Get the list of event data for the object with the specified key. Args: object_key (str): Key of an object in the database.
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]
Get list of events for the object with the specified key.
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...
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.
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...
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
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...
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
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...
Device constructor.
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
Set the PB Id for this device.
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)
Return the PB configuration.
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)
Get the current state timestamp.
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)
Get the target state timestamp.
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: ...
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. ...
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...
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.
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. ...
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
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 ...
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
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()}
Convert allowed state transitions / target states to lowercase.
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) # ...
Add Scheduling Block to the database. Args: config_dict (dict): SBI configuration
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...
Get unordered list of scheduling block ids
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...
Get list of processing block ids using the processing block id
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...
Get list of sub array ids
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: ...
Get Scheduling Block Instance ID associated with sub array id
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...
Get details of scheduling or processing block Args: block_ids (list): List of block IDs
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)
Update the value of the given block id and field
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...
Delete the specified Scheduling Block Instance. Removes the Scheduling Block Instance, and all Processing Blocks that belong to it from the database
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: ...
Delete Processing Block(s). Uses Processing Block IDs
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_...
Get the schema for validation
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...
This function adds status fields to all the section in the scheduling block instance
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 = [] ...
Split the scheduling block data into multiple names before adding to the configuration database
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...
Workflow stage application.
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...
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...
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)
Disable output for the logger of the specified name.
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)
Set the log level of the specified logger.
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...
Format the log timestamp.
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 = ...
Generate a SBI config JSON string.
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('...
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
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), ...
Processing block detail resource.
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)...
Processing block detail resource.
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)
Initialise the device.
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:\...
Configure an SBI for this subarray. Args: sbi_config (str): SBI configuration JSON Returns: str,
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/tango_control/tango_subarray/app/subarray_device.py#L26-L48