repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
gabstopper/smc-python
smc/routing/bgp.py
BGPProfile.subnet_distance
def subnet_distance(self): """ Specific subnet administrative distances :return: list of tuple (subnet, distance) """ return [(Element.from_href(entry.get('subnet')), entry.get('distance')) for entry in self.data.get('distance_entry')]
python
def subnet_distance(self): """ Specific subnet administrative distances :return: list of tuple (subnet, distance) """ return [(Element.from_href(entry.get('subnet')), entry.get('distance')) for entry in self.data.get('distance_entry')]
[ "def", "subnet_distance", "(", "self", ")", ":", "return", "[", "(", "Element", ".", "from_href", "(", "entry", ".", "get", "(", "'subnet'", ")", ")", ",", "entry", ".", "get", "(", "'distance'", ")", ")", "for", "entry", "in", "self", ".", "data", ...
Specific subnet administrative distances :return: list of tuple (subnet, distance)
[ "Specific", "subnet", "administrative", "distances" ]
e027b8a5dcfaf884eada32d113d41c1e56b32457
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/routing/bgp.py#L463-L470
train
38,800
gabstopper/smc-python
smc/routing/bgp.py
ExternalBGPPeer.create
def create(cls, name, neighbor_as, neighbor_ip, neighbor_port=179, comment=None): """ Create an external BGP Peer. :param str name: name of peer :param str,AutonomousSystem neighbor_as_ref: AutonomousSystem element or href. :param str neighbor_ip: ip address of BGP peer :param int neighbor_port: port for BGP, default 179. :raises CreateElementFailed: failed creating :return: instance with meta :rtype: ExternalBGPPeer """ json = {'name': name, 'neighbor_ip': neighbor_ip, 'neighbor_port': neighbor_port, 'comment': comment} neighbor_as_ref = element_resolver(neighbor_as) json.update(neighbor_as=neighbor_as_ref) return ElementCreator(cls, json)
python
def create(cls, name, neighbor_as, neighbor_ip, neighbor_port=179, comment=None): """ Create an external BGP Peer. :param str name: name of peer :param str,AutonomousSystem neighbor_as_ref: AutonomousSystem element or href. :param str neighbor_ip: ip address of BGP peer :param int neighbor_port: port for BGP, default 179. :raises CreateElementFailed: failed creating :return: instance with meta :rtype: ExternalBGPPeer """ json = {'name': name, 'neighbor_ip': neighbor_ip, 'neighbor_port': neighbor_port, 'comment': comment} neighbor_as_ref = element_resolver(neighbor_as) json.update(neighbor_as=neighbor_as_ref) return ElementCreator(cls, json)
[ "def", "create", "(", "cls", ",", "name", ",", "neighbor_as", ",", "neighbor_ip", ",", "neighbor_port", "=", "179", ",", "comment", "=", "None", ")", ":", "json", "=", "{", "'name'", ":", "name", ",", "'neighbor_ip'", ":", "neighbor_ip", ",", "'neighbor_...
Create an external BGP Peer. :param str name: name of peer :param str,AutonomousSystem neighbor_as_ref: AutonomousSystem element or href. :param str neighbor_ip: ip address of BGP peer :param int neighbor_port: port for BGP, default 179. :raises CreateElementFailed: failed creating :return: instance with meta :rtype: ExternalBGPPeer
[ "Create", "an", "external", "BGP", "Peer", "." ]
e027b8a5dcfaf884eada32d113d41c1e56b32457
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/routing/bgp.py#L490-L512
train
38,801
gabstopper/smc-python
smc/routing/bgp.py
BGPPeering.create
def create(cls, name, connection_profile_ref=None, md5_password=None, local_as_option='not_set', max_prefix_option='not_enabled', send_community='no', connected_check='disabled', orf_option='disabled', next_hop_self=True, override_capability=False, dont_capability_negotiate=False, remote_private_as=False, route_reflector_client=False, soft_reconfiguration=True, ttl_option='disabled', comment=None): """ Create a new BGPPeering configuration. :param str name: name of peering :param str,BGPConnectionProfile connection_profile_ref: required BGP connection profile. System default used if not provided. :param str md5_password: optional md5_password :param str local_as_option: the local AS mode. Valid options are: 'not_set', 'prepend', 'no_prepend', 'replace_as' :param str max_prefix_option: The max prefix mode. Valid options are: 'not_enabled', 'enabled', 'warning_only' :param str send_community: the send community mode. Valid options are: 'no', 'standard', 'extended', 'standard_and_extended' :param str connected_check: the connected check mode. Valid options are: 'disabled', 'enabled', 'automatic' :param str orf_option: outbound route filtering mode. Valid options are: 'disabled', 'send', 'receive', 'both' :param bool next_hop_self: next hop self setting :param bool override_capability: is override received capabilities :param bool dont_capability_negotiate: do not send capabilities :param bool remote_private_as: is remote a private AS :param bool route_reflector_client: Route Reflector Client (iBGP only) :param bool soft_reconfiguration: do soft reconfiguration inbound :param str ttl_option: ttl check mode. Valid options are: 'disabled', 'ttl-security' :raises CreateElementFailed: failed creating profile :return: instance with meta :rtype: BGPPeering """ json = {'name': name, 'local_as_option': local_as_option, 'max_prefix_option': max_prefix_option, 'send_community': send_community, 'connected_check': connected_check, 'orf_option': orf_option, 'next_hop_self': next_hop_self, 'override_capability': override_capability, 'dont_capability_negotiate': dont_capability_negotiate, 'soft_reconfiguration': soft_reconfiguration, 'remove_private_as': remote_private_as, 'route_reflector_client': route_reflector_client, 'ttl_option': ttl_option, 'comment': comment} if md5_password: json.update(md5_password=md5_password) connection_profile_ref = element_resolver(connection_profile_ref) or \ BGPConnectionProfile('Default BGP Connection Profile').href json.update(connection_profile=connection_profile_ref) return ElementCreator(cls, json)
python
def create(cls, name, connection_profile_ref=None, md5_password=None, local_as_option='not_set', max_prefix_option='not_enabled', send_community='no', connected_check='disabled', orf_option='disabled', next_hop_self=True, override_capability=False, dont_capability_negotiate=False, remote_private_as=False, route_reflector_client=False, soft_reconfiguration=True, ttl_option='disabled', comment=None): """ Create a new BGPPeering configuration. :param str name: name of peering :param str,BGPConnectionProfile connection_profile_ref: required BGP connection profile. System default used if not provided. :param str md5_password: optional md5_password :param str local_as_option: the local AS mode. Valid options are: 'not_set', 'prepend', 'no_prepend', 'replace_as' :param str max_prefix_option: The max prefix mode. Valid options are: 'not_enabled', 'enabled', 'warning_only' :param str send_community: the send community mode. Valid options are: 'no', 'standard', 'extended', 'standard_and_extended' :param str connected_check: the connected check mode. Valid options are: 'disabled', 'enabled', 'automatic' :param str orf_option: outbound route filtering mode. Valid options are: 'disabled', 'send', 'receive', 'both' :param bool next_hop_self: next hop self setting :param bool override_capability: is override received capabilities :param bool dont_capability_negotiate: do not send capabilities :param bool remote_private_as: is remote a private AS :param bool route_reflector_client: Route Reflector Client (iBGP only) :param bool soft_reconfiguration: do soft reconfiguration inbound :param str ttl_option: ttl check mode. Valid options are: 'disabled', 'ttl-security' :raises CreateElementFailed: failed creating profile :return: instance with meta :rtype: BGPPeering """ json = {'name': name, 'local_as_option': local_as_option, 'max_prefix_option': max_prefix_option, 'send_community': send_community, 'connected_check': connected_check, 'orf_option': orf_option, 'next_hop_self': next_hop_self, 'override_capability': override_capability, 'dont_capability_negotiate': dont_capability_negotiate, 'soft_reconfiguration': soft_reconfiguration, 'remove_private_as': remote_private_as, 'route_reflector_client': route_reflector_client, 'ttl_option': ttl_option, 'comment': comment} if md5_password: json.update(md5_password=md5_password) connection_profile_ref = element_resolver(connection_profile_ref) or \ BGPConnectionProfile('Default BGP Connection Profile').href json.update(connection_profile=connection_profile_ref) return ElementCreator(cls, json)
[ "def", "create", "(", "cls", ",", "name", ",", "connection_profile_ref", "=", "None", ",", "md5_password", "=", "None", ",", "local_as_option", "=", "'not_set'", ",", "max_prefix_option", "=", "'not_enabled'", ",", "send_community", "=", "'no'", ",", "connected_...
Create a new BGPPeering configuration. :param str name: name of peering :param str,BGPConnectionProfile connection_profile_ref: required BGP connection profile. System default used if not provided. :param str md5_password: optional md5_password :param str local_as_option: the local AS mode. Valid options are: 'not_set', 'prepend', 'no_prepend', 'replace_as' :param str max_prefix_option: The max prefix mode. Valid options are: 'not_enabled', 'enabled', 'warning_only' :param str send_community: the send community mode. Valid options are: 'no', 'standard', 'extended', 'standard_and_extended' :param str connected_check: the connected check mode. Valid options are: 'disabled', 'enabled', 'automatic' :param str orf_option: outbound route filtering mode. Valid options are: 'disabled', 'send', 'receive', 'both' :param bool next_hop_self: next hop self setting :param bool override_capability: is override received capabilities :param bool dont_capability_negotiate: do not send capabilities :param bool remote_private_as: is remote a private AS :param bool route_reflector_client: Route Reflector Client (iBGP only) :param bool soft_reconfiguration: do soft reconfiguration inbound :param str ttl_option: ttl check mode. Valid options are: 'disabled', 'ttl-security' :raises CreateElementFailed: failed creating profile :return: instance with meta :rtype: BGPPeering
[ "Create", "a", "new", "BGPPeering", "configuration", "." ]
e027b8a5dcfaf884eada32d113d41c1e56b32457
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/routing/bgp.py#L554-L614
train
38,802
gabstopper/smc-python
smc/routing/bgp.py
BGPConnectionProfile.create
def create(cls, name, md5_password=None, connect_retry=120, session_hold_timer=180, session_keep_alive=60): """ Create a new BGP Connection Profile. :param str name: name of profile :param str md5_password: optional md5 password :param int connect_retry: The connect retry timer, in seconds :param int session_hold_timer: The session hold timer, in seconds :param int session_keep_alive: The session keep alive timer, in seconds :raises CreateElementFailed: failed creating profile :return: instance with meta :rtype: BGPConnectionProfile """ json = {'name': name, 'connect': connect_retry, 'session_hold_timer': session_hold_timer, 'session_keep_alive': session_keep_alive} if md5_password: json.update(md5_password=md5_password) return ElementCreator(cls, json)
python
def create(cls, name, md5_password=None, connect_retry=120, session_hold_timer=180, session_keep_alive=60): """ Create a new BGP Connection Profile. :param str name: name of profile :param str md5_password: optional md5 password :param int connect_retry: The connect retry timer, in seconds :param int session_hold_timer: The session hold timer, in seconds :param int session_keep_alive: The session keep alive timer, in seconds :raises CreateElementFailed: failed creating profile :return: instance with meta :rtype: BGPConnectionProfile """ json = {'name': name, 'connect': connect_retry, 'session_hold_timer': session_hold_timer, 'session_keep_alive': session_keep_alive} if md5_password: json.update(md5_password=md5_password) return ElementCreator(cls, json)
[ "def", "create", "(", "cls", ",", "name", ",", "md5_password", "=", "None", ",", "connect_retry", "=", "120", ",", "session_hold_timer", "=", "180", ",", "session_keep_alive", "=", "60", ")", ":", "json", "=", "{", "'name'", ":", "name", ",", "'connect'"...
Create a new BGP Connection Profile. :param str name: name of profile :param str md5_password: optional md5 password :param int connect_retry: The connect retry timer, in seconds :param int session_hold_timer: The session hold timer, in seconds :param int session_keep_alive: The session keep alive timer, in seconds :raises CreateElementFailed: failed creating profile :return: instance with meta :rtype: BGPConnectionProfile
[ "Create", "a", "new", "BGP", "Connection", "Profile", "." ]
e027b8a5dcfaf884eada32d113d41c1e56b32457
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/routing/bgp.py#L634-L656
train
38,803
gabstopper/smc-python
smc/policy/rule_nat.py
IPv4NATRule.create
def create(self, name, sources=None, destinations=None, services=None, dynamic_src_nat=None, dynamic_src_nat_ports=(1024, 65535), static_src_nat=None, static_dst_nat=None, static_dst_nat_ports=None, is_disabled=False, used_on=None, add_pos=None, after=None, before=None, comment=None): """ Create a NAT rule. When providing sources/destinations or services, you can provide the element href, network element or services from ``smc.elements``. You can also mix href strings with Element types in these fields. :param str name: name of NAT rule :param list sources: list of sources by href or Element :type sources: list(str,Element) :param list destinations: list of destinations by href or Element :type destinations: list(str,Element) :param list services: list of services by href or Element :type services: list(str,Element) :param dynamic_src_nat: str ip or Element for dest NAT :type dynamic_src_nat: str,Element :param tuple dynamic_src_nat_ports: starting and ending ports for PAT. Default: (1024, 65535) :param str static_src_nat: ip or element href of used for source NAT :param str static_dst_nat: destination NAT IP address or element href :param tuple static_dst_nat_ports: ports or port range used for original and destination ports (only needed if a different destination port is used and does not match the rules service port) :param bool is_disabled: whether to disable rule or not :param str,href used_on: Can be a str href of an Element or Element of type AddressRange('ANY'), AddressRange('NONE') or an engine element. :type used_on: str,Element :param int add_pos: position to insert the rule, starting with position 1. If the position value is greater than the number of rules, the rule is inserted at the bottom. If add_pos is not provided, rule is inserted in position 1. Mutually exclusive with ``after`` and ``before`` params. :param str after: Rule tag to add this rule after. Mutually exclusive with ``add_pos`` and ``before`` params. :param str before: Rule tag to add this rule before. Mutually exclusive with ``add_pos`` and ``after`` params. :param str comment: optional comment for the NAT rule :raises InvalidRuleValue: if rule requirements are not met :raises CreateRuleFailed: rule creation failure :return: newly created NAT rule :rtype: IPv4NATRule """ rule_values = self.update_targets(sources, destinations, services) rule_values.update(name=name, comment=comment) rule_values.update(is_disabled=is_disabled) rule_values.update(used_on=element_resolver(used_on) if used_on else used_on) #rule_values.update(used_on=element_resolver(AddressRange('ANY') if not \ # used_on else element_resolver(used_on))) if dynamic_src_nat: nat = DynamicSourceNAT() start_port, end_port = dynamic_src_nat_ports nat.update_field(dynamic_src_nat, start_port=start_port, end_port=end_port) rule_values.update(options=nat) elif static_src_nat: sources = rule_values['sources'] if 'any' in sources or 'none' in sources: raise InvalidRuleValue('Source field cannot be none or any for ' 'static source NAT.') nat = StaticSourceNAT() nat.update_field(static_src_nat, original_value=sources.get('src')[0]) rule_values.update(options=nat) if static_dst_nat: destinations = rule_values['destinations'] if 'any' in destinations or 'none' in destinations: raise InvalidRuleValue('Destination field cannot be none or any for ' 'destination NAT.') nat = StaticDestNAT() original_port, translated_port = None, None if static_dst_nat_ports: original_port, translated_port = static_dst_nat_ports nat.update_field(static_dst_nat, original_value=destinations.get('dst')[0], original_port=original_port, translated_port=translated_port) rule_values.setdefault('options', {}).update(nat) if 'options' not in rule_values: # No NAT rule_values.update(options=LogOptions()) params = None href = self.href if add_pos is not None: href = self.add_at_position(add_pos) elif before or after: params = self.add_before_after(before, after) return ElementCreator( self.__class__, exception=CreateRuleFailed, href=href, params=params, json=rule_values)
python
def create(self, name, sources=None, destinations=None, services=None, dynamic_src_nat=None, dynamic_src_nat_ports=(1024, 65535), static_src_nat=None, static_dst_nat=None, static_dst_nat_ports=None, is_disabled=False, used_on=None, add_pos=None, after=None, before=None, comment=None): """ Create a NAT rule. When providing sources/destinations or services, you can provide the element href, network element or services from ``smc.elements``. You can also mix href strings with Element types in these fields. :param str name: name of NAT rule :param list sources: list of sources by href or Element :type sources: list(str,Element) :param list destinations: list of destinations by href or Element :type destinations: list(str,Element) :param list services: list of services by href or Element :type services: list(str,Element) :param dynamic_src_nat: str ip or Element for dest NAT :type dynamic_src_nat: str,Element :param tuple dynamic_src_nat_ports: starting and ending ports for PAT. Default: (1024, 65535) :param str static_src_nat: ip or element href of used for source NAT :param str static_dst_nat: destination NAT IP address or element href :param tuple static_dst_nat_ports: ports or port range used for original and destination ports (only needed if a different destination port is used and does not match the rules service port) :param bool is_disabled: whether to disable rule or not :param str,href used_on: Can be a str href of an Element or Element of type AddressRange('ANY'), AddressRange('NONE') or an engine element. :type used_on: str,Element :param int add_pos: position to insert the rule, starting with position 1. If the position value is greater than the number of rules, the rule is inserted at the bottom. If add_pos is not provided, rule is inserted in position 1. Mutually exclusive with ``after`` and ``before`` params. :param str after: Rule tag to add this rule after. Mutually exclusive with ``add_pos`` and ``before`` params. :param str before: Rule tag to add this rule before. Mutually exclusive with ``add_pos`` and ``after`` params. :param str comment: optional comment for the NAT rule :raises InvalidRuleValue: if rule requirements are not met :raises CreateRuleFailed: rule creation failure :return: newly created NAT rule :rtype: IPv4NATRule """ rule_values = self.update_targets(sources, destinations, services) rule_values.update(name=name, comment=comment) rule_values.update(is_disabled=is_disabled) rule_values.update(used_on=element_resolver(used_on) if used_on else used_on) #rule_values.update(used_on=element_resolver(AddressRange('ANY') if not \ # used_on else element_resolver(used_on))) if dynamic_src_nat: nat = DynamicSourceNAT() start_port, end_port = dynamic_src_nat_ports nat.update_field(dynamic_src_nat, start_port=start_port, end_port=end_port) rule_values.update(options=nat) elif static_src_nat: sources = rule_values['sources'] if 'any' in sources or 'none' in sources: raise InvalidRuleValue('Source field cannot be none or any for ' 'static source NAT.') nat = StaticSourceNAT() nat.update_field(static_src_nat, original_value=sources.get('src')[0]) rule_values.update(options=nat) if static_dst_nat: destinations = rule_values['destinations'] if 'any' in destinations or 'none' in destinations: raise InvalidRuleValue('Destination field cannot be none or any for ' 'destination NAT.') nat = StaticDestNAT() original_port, translated_port = None, None if static_dst_nat_ports: original_port, translated_port = static_dst_nat_ports nat.update_field(static_dst_nat, original_value=destinations.get('dst')[0], original_port=original_port, translated_port=translated_port) rule_values.setdefault('options', {}).update(nat) if 'options' not in rule_values: # No NAT rule_values.update(options=LogOptions()) params = None href = self.href if add_pos is not None: href = self.add_at_position(add_pos) elif before or after: params = self.add_before_after(before, after) return ElementCreator( self.__class__, exception=CreateRuleFailed, href=href, params=params, json=rule_values)
[ "def", "create", "(", "self", ",", "name", ",", "sources", "=", "None", ",", "destinations", "=", "None", ",", "services", "=", "None", ",", "dynamic_src_nat", "=", "None", ",", "dynamic_src_nat_ports", "=", "(", "1024", ",", "65535", ")", ",", "static_s...
Create a NAT rule. When providing sources/destinations or services, you can provide the element href, network element or services from ``smc.elements``. You can also mix href strings with Element types in these fields. :param str name: name of NAT rule :param list sources: list of sources by href or Element :type sources: list(str,Element) :param list destinations: list of destinations by href or Element :type destinations: list(str,Element) :param list services: list of services by href or Element :type services: list(str,Element) :param dynamic_src_nat: str ip or Element for dest NAT :type dynamic_src_nat: str,Element :param tuple dynamic_src_nat_ports: starting and ending ports for PAT. Default: (1024, 65535) :param str static_src_nat: ip or element href of used for source NAT :param str static_dst_nat: destination NAT IP address or element href :param tuple static_dst_nat_ports: ports or port range used for original and destination ports (only needed if a different destination port is used and does not match the rules service port) :param bool is_disabled: whether to disable rule or not :param str,href used_on: Can be a str href of an Element or Element of type AddressRange('ANY'), AddressRange('NONE') or an engine element. :type used_on: str,Element :param int add_pos: position to insert the rule, starting with position 1. If the position value is greater than the number of rules, the rule is inserted at the bottom. If add_pos is not provided, rule is inserted in position 1. Mutually exclusive with ``after`` and ``before`` params. :param str after: Rule tag to add this rule after. Mutually exclusive with ``add_pos`` and ``before`` params. :param str before: Rule tag to add this rule before. Mutually exclusive with ``add_pos`` and ``after`` params. :param str comment: optional comment for the NAT rule :raises InvalidRuleValue: if rule requirements are not met :raises CreateRuleFailed: rule creation failure :return: newly created NAT rule :rtype: IPv4NATRule
[ "Create", "a", "NAT", "rule", "." ]
e027b8a5dcfaf884eada32d113d41c1e56b32457
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/policy/rule_nat.py#L535-L640
train
38,804
GoogleCloudPlatform/google-auth-library-python-httplib2
google_auth_httplib2.py
AuthorizedHttp.request
def request(self, uri, method='GET', body=None, headers=None, **kwargs): """Implementation of httplib2's Http.request.""" _credential_refresh_attempt = kwargs.pop( '_credential_refresh_attempt', 0) # Make a copy of the headers. They will be modified by the credentials # and we want to pass the original headers if we recurse. request_headers = headers.copy() if headers is not None else {} self.credentials.before_request( self._request, method, uri, request_headers) # Check if the body is a file-like stream, and if so, save the body # stream position so that it can be restored in case of refresh. body_stream_position = None if all(getattr(body, stream_prop, None) for stream_prop in _STREAM_PROPERTIES): body_stream_position = body.tell() # Make the request. response, content = self.http.request( uri, method, body=body, headers=request_headers, **kwargs) # If the response indicated that the credentials needed to be # refreshed, then refresh the credentials and re-attempt the # request. # A stored token may expire between the time it is retrieved and # the time the request is made, so we may need to try twice. if (response.status in self._refresh_status_codes and _credential_refresh_attempt < self._max_refresh_attempts): _LOGGER.info( 'Refreshing credentials due to a %s response. Attempt %s/%s.', response.status, _credential_refresh_attempt + 1, self._max_refresh_attempts) self.credentials.refresh(self._request) # Restore the body's stream position if needed. if body_stream_position is not None: body.seek(body_stream_position) # Recurse. Pass in the original headers, not our modified set. return self.request( uri, method, body=body, headers=headers, _credential_refresh_attempt=_credential_refresh_attempt + 1, **kwargs) return response, content
python
def request(self, uri, method='GET', body=None, headers=None, **kwargs): """Implementation of httplib2's Http.request.""" _credential_refresh_attempt = kwargs.pop( '_credential_refresh_attempt', 0) # Make a copy of the headers. They will be modified by the credentials # and we want to pass the original headers if we recurse. request_headers = headers.copy() if headers is not None else {} self.credentials.before_request( self._request, method, uri, request_headers) # Check if the body is a file-like stream, and if so, save the body # stream position so that it can be restored in case of refresh. body_stream_position = None if all(getattr(body, stream_prop, None) for stream_prop in _STREAM_PROPERTIES): body_stream_position = body.tell() # Make the request. response, content = self.http.request( uri, method, body=body, headers=request_headers, **kwargs) # If the response indicated that the credentials needed to be # refreshed, then refresh the credentials and re-attempt the # request. # A stored token may expire between the time it is retrieved and # the time the request is made, so we may need to try twice. if (response.status in self._refresh_status_codes and _credential_refresh_attempt < self._max_refresh_attempts): _LOGGER.info( 'Refreshing credentials due to a %s response. Attempt %s/%s.', response.status, _credential_refresh_attempt + 1, self._max_refresh_attempts) self.credentials.refresh(self._request) # Restore the body's stream position if needed. if body_stream_position is not None: body.seek(body_stream_position) # Recurse. Pass in the original headers, not our modified set. return self.request( uri, method, body=body, headers=headers, _credential_refresh_attempt=_credential_refresh_attempt + 1, **kwargs) return response, content
[ "def", "request", "(", "self", ",", "uri", ",", "method", "=", "'GET'", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_credential_refresh_attempt", "=", "kwargs", ".", "pop", "(", "'_credential_refresh_attempt'"...
Implementation of httplib2's Http.request.
[ "Implementation", "of", "httplib2", "s", "Http", ".", "request", "." ]
e7cd722281d1d897fa9ae6e3b6b78ae142778e6e
https://github.com/GoogleCloudPlatform/google-auth-library-python-httplib2/blob/e7cd722281d1d897fa9ae6e3b6b78ae142778e6e/google_auth_httplib2.py#L178-L228
train
38,805
randomsync/robotframework-mqttlibrary
src/MQTTLibrary/MQTTKeywords.py
MQTTKeywords.connect
def connect(self, broker, port=1883, client_id="", clean_session=True): """ Connect to an MQTT broker. This is a pre-requisite step for publish and subscribe keywords. `broker` MQTT broker host `port` broker port (default 1883) `client_id` if not specified, a random id is generated `clean_session` specifies the clean session flag for the connection Examples: Connect to a broker with default port and client id | Connect | 127.0.0.1 | Connect to a broker by specifying the port and client id explicitly | Connect | 127.0.0.1 | 1883 | test.client | Connect to a broker with clean session flag set to false | Connect | 127.0.0.1 | clean_session=${false} | """ logger.info('Connecting to %s at port %s' % (broker, port)) self._connected = False self._unexpected_disconnect = False self._mqttc = mqtt.Client(client_id, clean_session) # set callbacks self._mqttc.on_connect = self._on_connect self._mqttc.on_disconnect = self._on_disconnect if self._username: self._mqttc.username_pw_set(self._username, self._password) self._mqttc.connect(broker, int(port)) timer_start = time.time() while time.time() < timer_start + self._loop_timeout: if self._connected or self._unexpected_disconnect: break; self._mqttc.loop() if self._unexpected_disconnect: raise RuntimeError("The client disconnected unexpectedly") logger.debug('client_id: %s' % self._mqttc._client_id) return self._mqttc
python
def connect(self, broker, port=1883, client_id="", clean_session=True): """ Connect to an MQTT broker. This is a pre-requisite step for publish and subscribe keywords. `broker` MQTT broker host `port` broker port (default 1883) `client_id` if not specified, a random id is generated `clean_session` specifies the clean session flag for the connection Examples: Connect to a broker with default port and client id | Connect | 127.0.0.1 | Connect to a broker by specifying the port and client id explicitly | Connect | 127.0.0.1 | 1883 | test.client | Connect to a broker with clean session flag set to false | Connect | 127.0.0.1 | clean_session=${false} | """ logger.info('Connecting to %s at port %s' % (broker, port)) self._connected = False self._unexpected_disconnect = False self._mqttc = mqtt.Client(client_id, clean_session) # set callbacks self._mqttc.on_connect = self._on_connect self._mqttc.on_disconnect = self._on_disconnect if self._username: self._mqttc.username_pw_set(self._username, self._password) self._mqttc.connect(broker, int(port)) timer_start = time.time() while time.time() < timer_start + self._loop_timeout: if self._connected or self._unexpected_disconnect: break; self._mqttc.loop() if self._unexpected_disconnect: raise RuntimeError("The client disconnected unexpectedly") logger.debug('client_id: %s' % self._mqttc._client_id) return self._mqttc
[ "def", "connect", "(", "self", ",", "broker", ",", "port", "=", "1883", ",", "client_id", "=", "\"\"", ",", "clean_session", "=", "True", ")", ":", "logger", ".", "info", "(", "'Connecting to %s at port %s'", "%", "(", "broker", ",", "port", ")", ")", ...
Connect to an MQTT broker. This is a pre-requisite step for publish and subscribe keywords. `broker` MQTT broker host `port` broker port (default 1883) `client_id` if not specified, a random id is generated `clean_session` specifies the clean session flag for the connection Examples: Connect to a broker with default port and client id | Connect | 127.0.0.1 | Connect to a broker by specifying the port and client id explicitly | Connect | 127.0.0.1 | 1883 | test.client | Connect to a broker with clean session flag set to false | Connect | 127.0.0.1 | clean_session=${false} |
[ "Connect", "to", "an", "MQTT", "broker", ".", "This", "is", "a", "pre", "-", "requisite", "step", "for", "publish", "and", "subscribe", "keywords", "." ]
14f20038ccdbb576cc1057ec6736e3685138f59e
https://github.com/randomsync/robotframework-mqttlibrary/blob/14f20038ccdbb576cc1057ec6736e3685138f59e/src/MQTTLibrary/MQTTKeywords.py#L28-L75
train
38,806
randomsync/robotframework-mqttlibrary
src/MQTTLibrary/MQTTKeywords.py
MQTTKeywords.publish
def publish(self, topic, message=None, qos=0, retain=False): """ Publish a message to a topic with specified qos and retained flag. It is required that a connection has been established using `Connect` keyword before using this keyword. `topic` topic to which the message will be published `message` message payload to publish `qos` qos of the message `retain` retained flag Examples: | Publish | test/test | test message | 1 | ${false} | """ logger.info('Publish topic: %s, message: %s, qos: %s, retain: %s' % (topic, message, qos, retain)) self._mid = -1 self._mqttc.on_publish = self._on_publish result, mid = self._mqttc.publish(topic, message, int(qos), retain) if result != 0: raise RuntimeError('Error publishing: %s' % result) timer_start = time.time() while time.time() < timer_start + self._loop_timeout: if mid == self._mid: break; self._mqttc.loop() if mid != self._mid: logger.warn('mid wasn\'t matched: %s' % mid)
python
def publish(self, topic, message=None, qos=0, retain=False): """ Publish a message to a topic with specified qos and retained flag. It is required that a connection has been established using `Connect` keyword before using this keyword. `topic` topic to which the message will be published `message` message payload to publish `qos` qos of the message `retain` retained flag Examples: | Publish | test/test | test message | 1 | ${false} | """ logger.info('Publish topic: %s, message: %s, qos: %s, retain: %s' % (topic, message, qos, retain)) self._mid = -1 self._mqttc.on_publish = self._on_publish result, mid = self._mqttc.publish(topic, message, int(qos), retain) if result != 0: raise RuntimeError('Error publishing: %s' % result) timer_start = time.time() while time.time() < timer_start + self._loop_timeout: if mid == self._mid: break; self._mqttc.loop() if mid != self._mid: logger.warn('mid wasn\'t matched: %s' % mid)
[ "def", "publish", "(", "self", ",", "topic", ",", "message", "=", "None", ",", "qos", "=", "0", ",", "retain", "=", "False", ")", ":", "logger", ".", "info", "(", "'Publish topic: %s, message: %s, qos: %s, retain: %s'", "%", "(", "topic", ",", "message", "...
Publish a message to a topic with specified qos and retained flag. It is required that a connection has been established using `Connect` keyword before using this keyword. `topic` topic to which the message will be published `message` message payload to publish `qos` qos of the message `retain` retained flag Examples: | Publish | test/test | test message | 1 | ${false} |
[ "Publish", "a", "message", "to", "a", "topic", "with", "specified", "qos", "and", "retained", "flag", ".", "It", "is", "required", "that", "a", "connection", "has", "been", "established", "using", "Connect", "keyword", "before", "using", "this", "keyword", "...
14f20038ccdbb576cc1057ec6736e3685138f59e
https://github.com/randomsync/robotframework-mqttlibrary/blob/14f20038ccdbb576cc1057ec6736e3685138f59e/src/MQTTLibrary/MQTTKeywords.py#L77-L110
train
38,807
randomsync/robotframework-mqttlibrary
src/MQTTLibrary/MQTTKeywords.py
MQTTKeywords.subscribe
def subscribe(self, topic, qos, timeout=1, limit=1): """ Subscribe to a topic and return a list of message payloads received within the specified time. `topic` topic to subscribe to `qos` quality of service for the subscription `timeout` duration of subscription. Specify 0 to enable background looping (async) `limit` the max number of payloads that will be returned. Specify 0 for no limit Examples: Subscribe and get a list of all messages received within 5 seconds | ${messages}= | Subscribe | test/test | qos=1 | timeout=5 | limit=0 | Subscribe and get 1st message received within 60 seconds | @{messages}= | Subscribe | test/test | qos=1 | timeout=60 | limit=1 | | Length should be | ${messages} | 1 | """ seconds = convert_time(timeout) self._messages[topic] = [] limit = int(limit) self._subscribed = False logger.info('Subscribing to topic: %s' % topic) self._mqttc.on_subscribe = self._on_subscribe self._mqttc.subscribe(str(topic), int(qos)) self._mqttc.on_message = self._on_message_list if seconds == 0: logger.info('Starting background loop') self._background_mqttc = self._mqttc self._background_mqttc.loop_start() return self._messages[topic] timer_start = time.time() while time.time() < timer_start + seconds: if limit == 0 or len(self._messages[topic]) < limit: self._mqttc.loop() else: # workaround for client to ack the publish. Otherwise, # it seems that if client disconnects quickly, broker # will not get the ack and publish the message again on # next connect. time.sleep(1) break return self._messages[topic]
python
def subscribe(self, topic, qos, timeout=1, limit=1): """ Subscribe to a topic and return a list of message payloads received within the specified time. `topic` topic to subscribe to `qos` quality of service for the subscription `timeout` duration of subscription. Specify 0 to enable background looping (async) `limit` the max number of payloads that will be returned. Specify 0 for no limit Examples: Subscribe and get a list of all messages received within 5 seconds | ${messages}= | Subscribe | test/test | qos=1 | timeout=5 | limit=0 | Subscribe and get 1st message received within 60 seconds | @{messages}= | Subscribe | test/test | qos=1 | timeout=60 | limit=1 | | Length should be | ${messages} | 1 | """ seconds = convert_time(timeout) self._messages[topic] = [] limit = int(limit) self._subscribed = False logger.info('Subscribing to topic: %s' % topic) self._mqttc.on_subscribe = self._on_subscribe self._mqttc.subscribe(str(topic), int(qos)) self._mqttc.on_message = self._on_message_list if seconds == 0: logger.info('Starting background loop') self._background_mqttc = self._mqttc self._background_mqttc.loop_start() return self._messages[topic] timer_start = time.time() while time.time() < timer_start + seconds: if limit == 0 or len(self._messages[topic]) < limit: self._mqttc.loop() else: # workaround for client to ack the publish. Otherwise, # it seems that if client disconnects quickly, broker # will not get the ack and publish the message again on # next connect. time.sleep(1) break return self._messages[topic]
[ "def", "subscribe", "(", "self", ",", "topic", ",", "qos", ",", "timeout", "=", "1", ",", "limit", "=", "1", ")", ":", "seconds", "=", "convert_time", "(", "timeout", ")", "self", ".", "_messages", "[", "topic", "]", "=", "[", "]", "limit", "=", ...
Subscribe to a topic and return a list of message payloads received within the specified time. `topic` topic to subscribe to `qos` quality of service for the subscription `timeout` duration of subscription. Specify 0 to enable background looping (async) `limit` the max number of payloads that will be returned. Specify 0 for no limit Examples: Subscribe and get a list of all messages received within 5 seconds | ${messages}= | Subscribe | test/test | qos=1 | timeout=5 | limit=0 | Subscribe and get 1st message received within 60 seconds | @{messages}= | Subscribe | test/test | qos=1 | timeout=60 | limit=1 | | Length should be | ${messages} | 1 |
[ "Subscribe", "to", "a", "topic", "and", "return", "a", "list", "of", "message", "payloads", "received", "within", "the", "specified", "time", "." ]
14f20038ccdbb576cc1057ec6736e3685138f59e
https://github.com/randomsync/robotframework-mqttlibrary/blob/14f20038ccdbb576cc1057ec6736e3685138f59e/src/MQTTLibrary/MQTTKeywords.py#L112-L162
train
38,808
randomsync/robotframework-mqttlibrary
src/MQTTLibrary/MQTTKeywords.py
MQTTKeywords.listen
def listen(self, topic, timeout=1, limit=1): """ Listen to a topic and return a list of message payloads received within the specified time. Requires an async Subscribe to have been called previously. `topic` topic to listen to `timeout` duration to listen `limit` the max number of payloads that will be returned. Specify 0 for no limit Examples: Listen and get a list of all messages received within 5 seconds | ${messages}= | Listen | test/test | timeout=5 | limit=0 | Listen and get 1st message received within 60 seconds | @{messages}= | Listen | test/test | timeout=60 | limit=1 | | Length should be | ${messages} | 1 | """ if not self._subscribed: logger.warn('Cannot listen when not subscribed to a topic') return [] if topic not in self._messages: logger.warn('Cannot listen when not subscribed to topic: %s' % topic) return [] # If enough messages have already been gathered, return them if limit != 0 and len(self._messages[topic]) >= limit: messages = self._messages[topic][:] # Copy the list's contents self._messages[topic] = [] return messages[-limit:] seconds = convert_time(timeout) limit = int(limit) logger.info('Listening on topic: %s' % topic) timer_start = time.time() while time.time() < timer_start + seconds: if limit == 0 or len(self._messages[topic]) < limit: # If the loop is running in the background # merely sleep here for a second or so and continue # otherwise, do the loop ourselves if self._background_mqttc: time.sleep(1) else: self._mqttc.loop() else: # workaround for client to ack the publish. Otherwise, # it seems that if client disconnects quickly, broker # will not get the ack and publish the message again on # next connect. time.sleep(1) break messages = self._messages[topic][:] # Copy the list's contents self._messages[topic] = [] return messages[-limit:] if limit != 0 else messages
python
def listen(self, topic, timeout=1, limit=1): """ Listen to a topic and return a list of message payloads received within the specified time. Requires an async Subscribe to have been called previously. `topic` topic to listen to `timeout` duration to listen `limit` the max number of payloads that will be returned. Specify 0 for no limit Examples: Listen and get a list of all messages received within 5 seconds | ${messages}= | Listen | test/test | timeout=5 | limit=0 | Listen and get 1st message received within 60 seconds | @{messages}= | Listen | test/test | timeout=60 | limit=1 | | Length should be | ${messages} | 1 | """ if not self._subscribed: logger.warn('Cannot listen when not subscribed to a topic') return [] if topic not in self._messages: logger.warn('Cannot listen when not subscribed to topic: %s' % topic) return [] # If enough messages have already been gathered, return them if limit != 0 and len(self._messages[topic]) >= limit: messages = self._messages[topic][:] # Copy the list's contents self._messages[topic] = [] return messages[-limit:] seconds = convert_time(timeout) limit = int(limit) logger.info('Listening on topic: %s' % topic) timer_start = time.time() while time.time() < timer_start + seconds: if limit == 0 or len(self._messages[topic]) < limit: # If the loop is running in the background # merely sleep here for a second or so and continue # otherwise, do the loop ourselves if self._background_mqttc: time.sleep(1) else: self._mqttc.loop() else: # workaround for client to ack the publish. Otherwise, # it seems that if client disconnects quickly, broker # will not get the ack and publish the message again on # next connect. time.sleep(1) break messages = self._messages[topic][:] # Copy the list's contents self._messages[topic] = [] return messages[-limit:] if limit != 0 else messages
[ "def", "listen", "(", "self", ",", "topic", ",", "timeout", "=", "1", ",", "limit", "=", "1", ")", ":", "if", "not", "self", ".", "_subscribed", ":", "logger", ".", "warn", "(", "'Cannot listen when not subscribed to a topic'", ")", "return", "[", "]", "...
Listen to a topic and return a list of message payloads received within the specified time. Requires an async Subscribe to have been called previously. `topic` topic to listen to `timeout` duration to listen `limit` the max number of payloads that will be returned. Specify 0 for no limit Examples: Listen and get a list of all messages received within 5 seconds | ${messages}= | Listen | test/test | timeout=5 | limit=0 | Listen and get 1st message received within 60 seconds | @{messages}= | Listen | test/test | timeout=60 | limit=1 | | Length should be | ${messages} | 1 |
[ "Listen", "to", "a", "topic", "and", "return", "a", "list", "of", "message", "payloads", "received", "within", "the", "specified", "time", ".", "Requires", "an", "async", "Subscribe", "to", "have", "been", "called", "previously", "." ]
14f20038ccdbb576cc1057ec6736e3685138f59e
https://github.com/randomsync/robotframework-mqttlibrary/blob/14f20038ccdbb576cc1057ec6736e3685138f59e/src/MQTTLibrary/MQTTKeywords.py#L164-L223
train
38,809
randomsync/robotframework-mqttlibrary
src/MQTTLibrary/MQTTKeywords.py
MQTTKeywords.subscribe_and_validate
def subscribe_and_validate(self, topic, qos, payload, timeout=1): """ Subscribe to a topic and validate that the specified payload is received within timeout. It is required that a connection has been established using `Connect` keyword. The payload can be specified as a python regular expression. If the specified payload is not received within timeout, an AssertionError is thrown. `topic` topic to subscribe to `qos` quality of service for the subscription `payload` payload (message) that is expected to arrive `timeout` time to wait for the payload to arrive Examples: | Subscribe And Validate | test/test | 1 | test message | """ seconds = convert_time(timeout) self._verified = False logger.info('Subscribing to topic: %s' % topic) self._mqttc.subscribe(str(topic), int(qos)) self._payload = str(payload) self._mqttc.on_message = self._on_message timer_start = time.time() while time.time() < timer_start + seconds: if self._verified: break self._mqttc.loop() if not self._verified: raise AssertionError("The expected payload didn't arrive in the topic")
python
def subscribe_and_validate(self, topic, qos, payload, timeout=1): """ Subscribe to a topic and validate that the specified payload is received within timeout. It is required that a connection has been established using `Connect` keyword. The payload can be specified as a python regular expression. If the specified payload is not received within timeout, an AssertionError is thrown. `topic` topic to subscribe to `qos` quality of service for the subscription `payload` payload (message) that is expected to arrive `timeout` time to wait for the payload to arrive Examples: | Subscribe And Validate | test/test | 1 | test message | """ seconds = convert_time(timeout) self._verified = False logger.info('Subscribing to topic: %s' % topic) self._mqttc.subscribe(str(topic), int(qos)) self._payload = str(payload) self._mqttc.on_message = self._on_message timer_start = time.time() while time.time() < timer_start + seconds: if self._verified: break self._mqttc.loop() if not self._verified: raise AssertionError("The expected payload didn't arrive in the topic")
[ "def", "subscribe_and_validate", "(", "self", ",", "topic", ",", "qos", ",", "payload", ",", "timeout", "=", "1", ")", ":", "seconds", "=", "convert_time", "(", "timeout", ")", "self", ".", "_verified", "=", "False", "logger", ".", "info", "(", "'Subscri...
Subscribe to a topic and validate that the specified payload is received within timeout. It is required that a connection has been established using `Connect` keyword. The payload can be specified as a python regular expression. If the specified payload is not received within timeout, an AssertionError is thrown. `topic` topic to subscribe to `qos` quality of service for the subscription `payload` payload (message) that is expected to arrive `timeout` time to wait for the payload to arrive Examples: | Subscribe And Validate | test/test | 1 | test message |
[ "Subscribe", "to", "a", "topic", "and", "validate", "that", "the", "specified", "payload", "is", "received", "within", "timeout", ".", "It", "is", "required", "that", "a", "connection", "has", "been", "established", "using", "Connect", "keyword", ".", "The", ...
14f20038ccdbb576cc1057ec6736e3685138f59e
https://github.com/randomsync/robotframework-mqttlibrary/blob/14f20038ccdbb576cc1057ec6736e3685138f59e/src/MQTTLibrary/MQTTKeywords.py#L225-L260
train
38,810
randomsync/robotframework-mqttlibrary
src/MQTTLibrary/MQTTKeywords.py
MQTTKeywords.unsubscribe
def unsubscribe(self, topic): """ Unsubscribe the client from the specified topic. `topic` topic to unsubscribe from Example: | Unsubscribe | test/mqtt_test | """ try: tmp = self._mqttc except AttributeError: logger.info('No MQTT Client instance found so nothing to unsubscribe from.') return if self._background_mqttc: logger.info('Closing background loop') self._background_mqttc.loop_stop() self._background_mqttc = None if topic in self._messages: del self._messages[topic] logger.info('Unsubscribing from topic: %s' % topic) self._unsubscribed = False self._mqttc.on_unsubscribe = self._on_unsubscribe self._mqttc.unsubscribe(str(topic)) timer_start = time.time() while (not self._unsubscribed and time.time() < timer_start + self._loop_timeout): self._mqttc.loop() if not self._unsubscribed: logger.warn('Client didn\'t receive an unsubscribe callback')
python
def unsubscribe(self, topic): """ Unsubscribe the client from the specified topic. `topic` topic to unsubscribe from Example: | Unsubscribe | test/mqtt_test | """ try: tmp = self._mqttc except AttributeError: logger.info('No MQTT Client instance found so nothing to unsubscribe from.') return if self._background_mqttc: logger.info('Closing background loop') self._background_mqttc.loop_stop() self._background_mqttc = None if topic in self._messages: del self._messages[topic] logger.info('Unsubscribing from topic: %s' % topic) self._unsubscribed = False self._mqttc.on_unsubscribe = self._on_unsubscribe self._mqttc.unsubscribe(str(topic)) timer_start = time.time() while (not self._unsubscribed and time.time() < timer_start + self._loop_timeout): self._mqttc.loop() if not self._unsubscribed: logger.warn('Client didn\'t receive an unsubscribe callback')
[ "def", "unsubscribe", "(", "self", ",", "topic", ")", ":", "try", ":", "tmp", "=", "self", ".", "_mqttc", "except", "AttributeError", ":", "logger", ".", "info", "(", "'No MQTT Client instance found so nothing to unsubscribe from.'", ")", "return", "if", "self", ...
Unsubscribe the client from the specified topic. `topic` topic to unsubscribe from Example: | Unsubscribe | test/mqtt_test |
[ "Unsubscribe", "the", "client", "from", "the", "specified", "topic", "." ]
14f20038ccdbb576cc1057ec6736e3685138f59e
https://github.com/randomsync/robotframework-mqttlibrary/blob/14f20038ccdbb576cc1057ec6736e3685138f59e/src/MQTTLibrary/MQTTKeywords.py#L262-L296
train
38,811
randomsync/robotframework-mqttlibrary
src/MQTTLibrary/MQTTKeywords.py
MQTTKeywords.disconnect
def disconnect(self): """ Disconnect from MQTT Broker. Example: | Disconnect | """ try: tmp = self._mqttc except AttributeError: logger.info('No MQTT Client instance found so nothing to disconnect from.') return self._disconnected = False self._unexpected_disconnect = False self._mqttc.on_disconnect = self._on_disconnect self._mqttc.disconnect() timer_start = time.time() while time.time() < timer_start + self._loop_timeout: if self._disconnected or self._unexpected_disconnect: break; self._mqttc.loop() if self._unexpected_disconnect: raise RuntimeError("The client disconnected unexpectedly")
python
def disconnect(self): """ Disconnect from MQTT Broker. Example: | Disconnect | """ try: tmp = self._mqttc except AttributeError: logger.info('No MQTT Client instance found so nothing to disconnect from.') return self._disconnected = False self._unexpected_disconnect = False self._mqttc.on_disconnect = self._on_disconnect self._mqttc.disconnect() timer_start = time.time() while time.time() < timer_start + self._loop_timeout: if self._disconnected or self._unexpected_disconnect: break; self._mqttc.loop() if self._unexpected_disconnect: raise RuntimeError("The client disconnected unexpectedly")
[ "def", "disconnect", "(", "self", ")", ":", "try", ":", "tmp", "=", "self", ".", "_mqttc", "except", "AttributeError", ":", "logger", ".", "info", "(", "'No MQTT Client instance found so nothing to disconnect from.'", ")", "return", "self", ".", "_disconnected", "...
Disconnect from MQTT Broker. Example: | Disconnect |
[ "Disconnect", "from", "MQTT", "Broker", "." ]
14f20038ccdbb576cc1057ec6736e3685138f59e
https://github.com/randomsync/robotframework-mqttlibrary/blob/14f20038ccdbb576cc1057ec6736e3685138f59e/src/MQTTLibrary/MQTTKeywords.py#L298-L323
train
38,812
imbolc/aiohttp-login
aiohttp_login/decorators.py
user_to_request
def user_to_request(handler): '''Add user to request if user logged in''' @wraps(handler) async def decorator(*args): request = _get_request(args) request[cfg.REQUEST_USER_KEY] = await get_cur_user(request) return await handler(*args) return decorator
python
def user_to_request(handler): '''Add user to request if user logged in''' @wraps(handler) async def decorator(*args): request = _get_request(args) request[cfg.REQUEST_USER_KEY] = await get_cur_user(request) return await handler(*args) return decorator
[ "def", "user_to_request", "(", "handler", ")", ":", "@", "wraps", "(", "handler", ")", "async", "def", "decorator", "(", "*", "args", ")", ":", "request", "=", "_get_request", "(", "args", ")", "request", "[", "cfg", ".", "REQUEST_USER_KEY", "]", "=", ...
Add user to request if user logged in
[ "Add", "user", "to", "request", "if", "user", "logged", "in" ]
43b30d8630ca5c14d4b75c398eb5f6a27ddf0a52
https://github.com/imbolc/aiohttp-login/blob/43b30d8630ca5c14d4b75c398eb5f6a27ddf0a52/aiohttp_login/decorators.py#L21-L28
train
38,813
brandon-rhodes/python-adventure
adventure/model.py
Word.add_synonym
def add_synonym(self, other): """Every word in a group of synonyms shares the same list.""" self.synonyms.extend(other.synonyms) other.synonyms = self.synonyms
python
def add_synonym(self, other): """Every word in a group of synonyms shares the same list.""" self.synonyms.extend(other.synonyms) other.synonyms = self.synonyms
[ "def", "add_synonym", "(", "self", ",", "other", ")", ":", "self", ".", "synonyms", ".", "extend", "(", "other", ".", "synonyms", ")", "other", ".", "synonyms", "=", "self", ".", "synonyms" ]
Every word in a group of synonyms shares the same list.
[ "Every", "word", "in", "a", "group", "of", "synonyms", "shares", "the", "same", "list", "." ]
e503b68e394fbccb05fe381901c7009fb1bda3d9
https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/model.py#L102-L105
train
38,814
imbolc/aiohttp-login
aiohttp_login/sql.py
_split_dict
def _split_dict(dic): '''Split dict into sorted keys and values >>> _split_dict({'b': 2, 'a': 1}) (['a', 'b'], [1, 2]) ''' keys = sorted(dic.keys()) return keys, [dic[k] for k in keys]
python
def _split_dict(dic): '''Split dict into sorted keys and values >>> _split_dict({'b': 2, 'a': 1}) (['a', 'b'], [1, 2]) ''' keys = sorted(dic.keys()) return keys, [dic[k] for k in keys]
[ "def", "_split_dict", "(", "dic", ")", ":", "keys", "=", "sorted", "(", "dic", ".", "keys", "(", ")", ")", "return", "keys", ",", "[", "dic", "[", "k", "]", "for", "k", "in", "keys", "]" ]
Split dict into sorted keys and values >>> _split_dict({'b': 2, 'a': 1}) (['a', 'b'], [1, 2])
[ "Split", "dict", "into", "sorted", "keys", "and", "values" ]
43b30d8630ca5c14d4b75c398eb5f6a27ddf0a52
https://github.com/imbolc/aiohttp-login/blob/43b30d8630ca5c14d4b75c398eb5f6a27ddf0a52/aiohttp_login/sql.py#L110-L117
train
38,815
brandon-rhodes/python-adventure
adventure/__init__.py
play
def play(seed=None): """Turn the Python prompt into an Adventure game. With optional the `seed` argument the caller can supply an integer to start the Python random number generator at a known state. """ global _game from .game import Game from .prompt import install_words _game = Game(seed) load_advent_dat(_game) install_words(_game) _game.start() print(_game.output[:-1])
python
def play(seed=None): """Turn the Python prompt into an Adventure game. With optional the `seed` argument the caller can supply an integer to start the Python random number generator at a known state. """ global _game from .game import Game from .prompt import install_words _game = Game(seed) load_advent_dat(_game) install_words(_game) _game.start() print(_game.output[:-1])
[ "def", "play", "(", "seed", "=", "None", ")", ":", "global", "_game", "from", ".", "game", "import", "Game", "from", ".", "prompt", "import", "install_words", "_game", "=", "Game", "(", "seed", ")", "load_advent_dat", "(", "_game", ")", "install_words", ...
Turn the Python prompt into an Adventure game. With optional the `seed` argument the caller can supply an integer to start the Python random number generator at a known state.
[ "Turn", "the", "Python", "prompt", "into", "an", "Adventure", "game", "." ]
e503b68e394fbccb05fe381901c7009fb1bda3d9
https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/__init__.py#L15-L31
train
38,816
brandon-rhodes/python-adventure
adventure/game.py
Game.write
def write(self, more): """Append the Unicode representation of `s` to our output.""" if more: self.output += str(more).upper() self.output += '\n'
python
def write(self, more): """Append the Unicode representation of `s` to our output.""" if more: self.output += str(more).upper() self.output += '\n'
[ "def", "write", "(", "self", ",", "more", ")", ":", "if", "more", ":", "self", ".", "output", "+=", "str", "(", "more", ")", ".", "upper", "(", ")", "self", ".", "output", "+=", "'\\n'" ]
Append the Unicode representation of `s` to our output.
[ "Append", "the", "Unicode", "representation", "of", "s", "to", "our", "output", "." ]
e503b68e394fbccb05fe381901c7009fb1bda3d9
https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/game.py#L67-L71
train
38,817
brandon-rhodes/python-adventure
adventure/game.py
Game.yesno
def yesno(self, s, yesno_callback, casual=False): """Ask a question and prepare to receive a yes-or-no answer.""" self.write(s) self.yesno_callback = yesno_callback self.yesno_casual = casual
python
def yesno(self, s, yesno_callback, casual=False): """Ask a question and prepare to receive a yes-or-no answer.""" self.write(s) self.yesno_callback = yesno_callback self.yesno_casual = casual
[ "def", "yesno", "(", "self", ",", "s", ",", "yesno_callback", ",", "casual", "=", "False", ")", ":", "self", ".", "write", "(", "s", ")", "self", ".", "yesno_callback", "=", "yesno_callback", "self", ".", "yesno_casual", "=", "casual" ]
Ask a question and prepare to receive a yes-or-no answer.
[ "Ask", "a", "question", "and", "prepare", "to", "receive", "a", "yes", "-", "or", "-", "no", "answer", "." ]
e503b68e394fbccb05fe381901c7009fb1bda3d9
https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/game.py#L76-L80
train
38,818
brandon-rhodes/python-adventure
adventure/game.py
Game.start2
def start2(self, yes): """Display instructions if the user wants them.""" if yes: self.write_message(1) self.hints[3].used = True self.lamp_turns = 1000 self.oldloc2 = self.oldloc = self.loc = self.rooms[1] self.dwarves = [ Dwarf(self.rooms[n]) for n in (19, 27, 33, 44, 64) ] self.pirate = Pirate(self.chest_room) treasures = self.treasures self.treasures_not_found = len(treasures) for treasure in treasures: treasure.prop = -1 self.describe_location()
python
def start2(self, yes): """Display instructions if the user wants them.""" if yes: self.write_message(1) self.hints[3].used = True self.lamp_turns = 1000 self.oldloc2 = self.oldloc = self.loc = self.rooms[1] self.dwarves = [ Dwarf(self.rooms[n]) for n in (19, 27, 33, 44, 64) ] self.pirate = Pirate(self.chest_room) treasures = self.treasures self.treasures_not_found = len(treasures) for treasure in treasures: treasure.prop = -1 self.describe_location()
[ "def", "start2", "(", "self", ",", "yes", ")", ":", "if", "yes", ":", "self", ".", "write_message", "(", "1", ")", "self", ".", "hints", "[", "3", "]", ".", "used", "=", "True", "self", ".", "lamp_turns", "=", "1000", "self", ".", "oldloc2", "=",...
Display instructions if the user wants them.
[ "Display", "instructions", "if", "the", "user", "wants", "them", "." ]
e503b68e394fbccb05fe381901c7009fb1bda3d9
https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/game.py#L134-L150
train
38,819
brandon-rhodes/python-adventure
adventure/game.py
Game.do_command
def do_command(self, words): """Parse and act upon the command in the list of strings `words`.""" self.output = '' self._do_command(words) return self.output
python
def do_command(self, words): """Parse and act upon the command in the list of strings `words`.""" self.output = '' self._do_command(words) return self.output
[ "def", "do_command", "(", "self", ",", "words", ")", ":", "self", ".", "output", "=", "''", "self", ".", "_do_command", "(", "words", ")", "return", "self", ".", "output" ]
Parse and act upon the command in the list of strings `words`.
[ "Parse", "and", "act", "upon", "the", "command", "in", "the", "list", "of", "strings", "words", "." ]
e503b68e394fbccb05fe381901c7009fb1bda3d9
https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/game.py#L434-L438
train
38,820
brandon-rhodes/python-adventure
adventure/game.py
Game.resume
def resume(self, obj): """Returns an Adventure game saved to the given file.""" if isinstance(obj, str): savefile = open(obj, 'rb') else: savefile = obj game = pickle.loads(zlib.decompress(savefile.read())) if savefile is not obj: savefile.close() # Reinstate the random number generator. game.random_generator = random.Random() game.random_generator.setstate(game.random_state) del game.random_state return game
python
def resume(self, obj): """Returns an Adventure game saved to the given file.""" if isinstance(obj, str): savefile = open(obj, 'rb') else: savefile = obj game = pickle.loads(zlib.decompress(savefile.read())) if savefile is not obj: savefile.close() # Reinstate the random number generator. game.random_generator = random.Random() game.random_generator.setstate(game.random_state) del game.random_state return game
[ "def", "resume", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "savefile", "=", "open", "(", "obj", ",", "'rb'", ")", "else", ":", "savefile", "=", "obj", "game", "=", "pickle", ".", "loads", "(", "zlib"...
Returns an Adventure game saved to the given file.
[ "Returns", "an", "Adventure", "game", "saved", "to", "the", "given", "file", "." ]
e503b68e394fbccb05fe381901c7009fb1bda3d9
https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/game.py#L1574-L1587
train
38,821
brandon-rhodes/python-adventure
adventure/data.py
parse
def parse(data, datafile): """Read the Adventure data file and return a ``Data`` object.""" data._last_travel = [0, [0]] # x and verbs used by section 3 while True: section_number = int(datafile.readline()) if not section_number: # no further sections break store = globals().get('section%d' % section_number) while True: fields = [ (int(field) if field.lstrip('-').isdigit() else field) for field in datafile.readline().strip().split('\t') ] if fields[0] == -1: # end-of-section marker break store(data, *fields) del data._last_travel # state used by section 3 del data._object # state used by section 5 data.object_list = sorted(set(data.objects.values()), key=attrgetter('n')) #data.room_list = sorted(set(data.rooms.values()), key=attrgetter('n')) for obj in data.object_list: name = obj.names[0] if hasattr(data, name): name = name + '2' # create identifiers like ROD2, PLANT2 setattr(data, name, obj) return data
python
def parse(data, datafile): """Read the Adventure data file and return a ``Data`` object.""" data._last_travel = [0, [0]] # x and verbs used by section 3 while True: section_number = int(datafile.readline()) if not section_number: # no further sections break store = globals().get('section%d' % section_number) while True: fields = [ (int(field) if field.lstrip('-').isdigit() else field) for field in datafile.readline().strip().split('\t') ] if fields[0] == -1: # end-of-section marker break store(data, *fields) del data._last_travel # state used by section 3 del data._object # state used by section 5 data.object_list = sorted(set(data.objects.values()), key=attrgetter('n')) #data.room_list = sorted(set(data.rooms.values()), key=attrgetter('n')) for obj in data.object_list: name = obj.names[0] if hasattr(data, name): name = name + '2' # create identifiers like ROD2, PLANT2 setattr(data, name, obj) return data
[ "def", "parse", "(", "data", ",", "datafile", ")", ":", "data", ".", "_last_travel", "=", "[", "0", ",", "[", "0", "]", "]", "# x and verbs used by section 3", "while", "True", ":", "section_number", "=", "int", "(", "datafile", ".", "readline", "(", ")"...
Read the Adventure data file and return a ``Data`` object.
[ "Read", "the", "Adventure", "data", "file", "and", "return", "a", "Data", "object", "." ]
e503b68e394fbccb05fe381901c7009fb1bda3d9
https://github.com/brandon-rhodes/python-adventure/blob/e503b68e394fbccb05fe381901c7009fb1bda3d9/adventure/data.py#L201-L228
train
38,822
BradWhittington/django-mailgun
django_mailgun.py
MailgunBackend._map_smtp_headers_to_api_parameters
def _map_smtp_headers_to_api_parameters(self, email_message): """ Map the values passed in SMTP headers to API-ready 2-item tuples present in HEADERS_MAP header values must be a single string or list or tuple of strings :return: 2-item tuples of the form (api_name, api_values) """ api_data = [] for smtp_key, api_transformer in six.iteritems(self._headers_map): data_to_transform = email_message.extra_headers.pop(smtp_key, None) if data_to_transform is not None: if isinstance(data_to_transform, (list, tuple)): # map each value in the tuple/list for data in data_to_transform: api_data.append((api_transformer[0], api_transformer[1](data))) elif isinstance(data_to_transform, dict): for data in six.iteritems(data_to_transform): api_data.append(api_transformer(data)) else: # we only have one value api_data.append((api_transformer[0], api_transformer[1](data_to_transform))) return api_data
python
def _map_smtp_headers_to_api_parameters(self, email_message): """ Map the values passed in SMTP headers to API-ready 2-item tuples present in HEADERS_MAP header values must be a single string or list or tuple of strings :return: 2-item tuples of the form (api_name, api_values) """ api_data = [] for smtp_key, api_transformer in six.iteritems(self._headers_map): data_to_transform = email_message.extra_headers.pop(smtp_key, None) if data_to_transform is not None: if isinstance(data_to_transform, (list, tuple)): # map each value in the tuple/list for data in data_to_transform: api_data.append((api_transformer[0], api_transformer[1](data))) elif isinstance(data_to_transform, dict): for data in six.iteritems(data_to_transform): api_data.append(api_transformer(data)) else: # we only have one value api_data.append((api_transformer[0], api_transformer[1](data_to_transform))) return api_data
[ "def", "_map_smtp_headers_to_api_parameters", "(", "self", ",", "email_message", ")", ":", "api_data", "=", "[", "]", "for", "smtp_key", ",", "api_transformer", "in", "six", ".", "iteritems", "(", "self", ".", "_headers_map", ")", ":", "data_to_transform", "=", ...
Map the values passed in SMTP headers to API-ready 2-item tuples present in HEADERS_MAP header values must be a single string or list or tuple of strings :return: 2-item tuples of the form (api_name, api_values)
[ "Map", "the", "values", "passed", "in", "SMTP", "headers", "to", "API", "-", "ready", "2", "-", "item", "tuples", "present", "in", "HEADERS_MAP" ]
c4bfb77fca1eb3d5c772294e3d065274bab9ddc6
https://github.com/BradWhittington/django-mailgun/blob/c4bfb77fca1eb3d5c772294e3d065274bab9ddc6/django_mailgun.py#L74-L97
train
38,823
Stanford-Online/xblock-image-modal
imagemodal/views.py
ImageModalViewMixin.student_view
def student_view(self, context=None): """ Build the fragment for the default student view """ context = context or {} context.update({ 'display_name': self.display_name, 'image_url': self.image_url, 'thumbnail_url': self.thumbnail_url or self.image_url, 'description': self.description, 'xblock_id': text_type(self.scope_ids.usage_id), 'alt_text': self.alt_text or self.display_name, }) fragment = self.build_fragment( template='view.html', context=context, css=[ 'view.less.css', URL_FONT_AWESOME_CSS, ], js=[ 'draggabilly.pkgd.js', 'view.js', ], js_init='ImageModalView', ) return fragment
python
def student_view(self, context=None): """ Build the fragment for the default student view """ context = context or {} context.update({ 'display_name': self.display_name, 'image_url': self.image_url, 'thumbnail_url': self.thumbnail_url or self.image_url, 'description': self.description, 'xblock_id': text_type(self.scope_ids.usage_id), 'alt_text': self.alt_text or self.display_name, }) fragment = self.build_fragment( template='view.html', context=context, css=[ 'view.less.css', URL_FONT_AWESOME_CSS, ], js=[ 'draggabilly.pkgd.js', 'view.js', ], js_init='ImageModalView', ) return fragment
[ "def", "student_view", "(", "self", ",", "context", "=", "None", ")", ":", "context", "=", "context", "or", "{", "}", "context", ".", "update", "(", "{", "'display_name'", ":", "self", ".", "display_name", ",", "'image_url'", ":", "self", ".", "image_url...
Build the fragment for the default student view
[ "Build", "the", "fragment", "for", "the", "default", "student", "view" ]
bd05f99a830a44f8d1a0e6e137e507b8ff8ff028
https://github.com/Stanford-Online/xblock-image-modal/blob/bd05f99a830a44f8d1a0e6e137e507b8ff8ff028/imagemodal/views.py#L27-L53
train
38,824
Stanford-Online/xblock-image-modal
imagemodal/mixins/fragment.py
XBlockFragmentBuilderMixin.build_fragment
def build_fragment( self, template='', context=None, css=None, js=None, js_init=None, ): """ Creates a fragment for display. """ template = 'templates/' + template context = context or {} css = css or [] js = js or [] rendered_template = '' if template: rendered_template = self.loader.render_django_template( template, context=Context(context), i18n_service=self.runtime.service(self, 'i18n'), ) fragment = Fragment(rendered_template) for item in css: if item.startswith('/'): url = item else: item = 'public/' + item url = self.runtime.local_resource_url(self, item) fragment.add_css_url(url) for item in js: item = 'public/' + item url = self.runtime.local_resource_url(self, item) fragment.add_javascript_url(url) if js_init: fragment.initialize_js(js_init) return fragment
python
def build_fragment( self, template='', context=None, css=None, js=None, js_init=None, ): """ Creates a fragment for display. """ template = 'templates/' + template context = context or {} css = css or [] js = js or [] rendered_template = '' if template: rendered_template = self.loader.render_django_template( template, context=Context(context), i18n_service=self.runtime.service(self, 'i18n'), ) fragment = Fragment(rendered_template) for item in css: if item.startswith('/'): url = item else: item = 'public/' + item url = self.runtime.local_resource_url(self, item) fragment.add_css_url(url) for item in js: item = 'public/' + item url = self.runtime.local_resource_url(self, item) fragment.add_javascript_url(url) if js_init: fragment.initialize_js(js_init) return fragment
[ "def", "build_fragment", "(", "self", ",", "template", "=", "''", ",", "context", "=", "None", ",", "css", "=", "None", ",", "js", "=", "None", ",", "js_init", "=", "None", ",", ")", ":", "template", "=", "'templates/'", "+", "template", "context", "...
Creates a fragment for display.
[ "Creates", "a", "fragment", "for", "display", "." ]
bd05f99a830a44f8d1a0e6e137e507b8ff8ff028
https://github.com/Stanford-Online/xblock-image-modal/blob/bd05f99a830a44f8d1a0e6e137e507b8ff8ff028/imagemodal/mixins/fragment.py#L14-L50
train
38,825
Stanford-Online/xblock-image-modal
imagemodal/mixins/scenario.py
_parse_title
def _parse_title(file_path): """ Parse a title from a file name """ title = file_path title = title.split('/')[-1] title = '.'.join(title.split('.')[:-1]) title = ' '.join(title.split('-')) title = ' '.join([ word.capitalize() for word in title.split(' ') ]) return title
python
def _parse_title(file_path): """ Parse a title from a file name """ title = file_path title = title.split('/')[-1] title = '.'.join(title.split('.')[:-1]) title = ' '.join(title.split('-')) title = ' '.join([ word.capitalize() for word in title.split(' ') ]) return title
[ "def", "_parse_title", "(", "file_path", ")", ":", "title", "=", "file_path", "title", "=", "title", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "title", "=", "'.'", ".", "join", "(", "title", ".", "split", "(", "'.'", ")", "[", ":", "-", ...
Parse a title from a file name
[ "Parse", "a", "title", "from", "a", "file", "name" ]
bd05f99a830a44f8d1a0e6e137e507b8ff8ff028
https://github.com/Stanford-Online/xblock-image-modal/blob/bd05f99a830a44f8d1a0e6e137e507b8ff8ff028/imagemodal/mixins/scenario.py#L17-L29
train
38,826
Stanford-Online/xblock-image-modal
imagemodal/mixins/scenario.py
_read_files
def _read_files(files): """ Read the contents of a list of files """ file_contents = [ ( _parse_title(file_path), _read_file(file_path), ) for file_path in files ] return file_contents
python
def _read_files(files): """ Read the contents of a list of files """ file_contents = [ ( _parse_title(file_path), _read_file(file_path), ) for file_path in files ] return file_contents
[ "def", "_read_files", "(", "files", ")", ":", "file_contents", "=", "[", "(", "_parse_title", "(", "file_path", ")", ",", "_read_file", "(", "file_path", ")", ",", ")", "for", "file_path", "in", "files", "]", "return", "file_contents" ]
Read the contents of a list of files
[ "Read", "the", "contents", "of", "a", "list", "of", "files" ]
bd05f99a830a44f8d1a0e6e137e507b8ff8ff028
https://github.com/Stanford-Online/xblock-image-modal/blob/bd05f99a830a44f8d1a0e6e137e507b8ff8ff028/imagemodal/mixins/scenario.py#L32-L43
train
38,827
Stanford-Online/xblock-image-modal
imagemodal/mixins/scenario.py
_find_files
def _find_files(directory): """ Find XML files in the directory """ pattern = "{directory}/*.xml".format( directory=directory, ) files = glob(pattern) return files
python
def _find_files(directory): """ Find XML files in the directory """ pattern = "{directory}/*.xml".format( directory=directory, ) files = glob(pattern) return files
[ "def", "_find_files", "(", "directory", ")", ":", "pattern", "=", "\"{directory}/*.xml\"", ".", "format", "(", "directory", "=", "directory", ",", ")", "files", "=", "glob", "(", "pattern", ")", "return", "files" ]
Find XML files in the directory
[ "Find", "XML", "files", "in", "the", "directory" ]
bd05f99a830a44f8d1a0e6e137e507b8ff8ff028
https://github.com/Stanford-Online/xblock-image-modal/blob/bd05f99a830a44f8d1a0e6e137e507b8ff8ff028/imagemodal/mixins/scenario.py#L46-L54
train
38,828
Stanford-Online/xblock-image-modal
imagemodal/mixins/scenario.py
XBlockWorkbenchMixin.workbench_scenarios
def workbench_scenarios(cls): """ Gather scenarios to be displayed in the workbench """ module = cls.__module__ module = module.split('.')[0] directory = pkg_resources.resource_filename(module, 'scenarios') files = _find_files(directory) scenarios = _read_files(files) return scenarios
python
def workbench_scenarios(cls): """ Gather scenarios to be displayed in the workbench """ module = cls.__module__ module = module.split('.')[0] directory = pkg_resources.resource_filename(module, 'scenarios') files = _find_files(directory) scenarios = _read_files(files) return scenarios
[ "def", "workbench_scenarios", "(", "cls", ")", ":", "module", "=", "cls", ".", "__module__", "module", "=", "module", ".", "split", "(", "'.'", ")", "[", "0", "]", "directory", "=", "pkg_resources", ".", "resource_filename", "(", "module", ",", "'scenarios...
Gather scenarios to be displayed in the workbench
[ "Gather", "scenarios", "to", "be", "displayed", "in", "the", "workbench" ]
bd05f99a830a44f8d1a0e6e137e507b8ff8ff028
https://github.com/Stanford-Online/xblock-image-modal/blob/bd05f99a830a44f8d1a0e6e137e507b8ff8ff028/imagemodal/mixins/scenario.py#L63-L72
train
38,829
broadinstitute/fiss
firecloud/api.py
_check_response_code
def _check_response_code(response, codes): """ Throws an exception if the http response is not expected. Can check single integer or list of valid responses. Example usage: >>> r = api.get_workspace("broad-firecloud-testing", "Fake-Bucket") >>> _check_response_code(r, 200) ... FireCloudServerError ... """ if type(codes) == int: codes = [codes] if response.status_code not in codes: raise FireCloudServerError(response.status_code, response.content)
python
def _check_response_code(response, codes): """ Throws an exception if the http response is not expected. Can check single integer or list of valid responses. Example usage: >>> r = api.get_workspace("broad-firecloud-testing", "Fake-Bucket") >>> _check_response_code(r, 200) ... FireCloudServerError ... """ if type(codes) == int: codes = [codes] if response.status_code not in codes: raise FireCloudServerError(response.status_code, response.content)
[ "def", "_check_response_code", "(", "response", ",", "codes", ")", ":", "if", "type", "(", "codes", ")", "==", "int", ":", "codes", "=", "[", "codes", "]", "if", "response", ".", "status_code", "not", "in", "codes", ":", "raise", "FireCloudServerError", ...
Throws an exception if the http response is not expected. Can check single integer or list of valid responses. Example usage: >>> r = api.get_workspace("broad-firecloud-testing", "Fake-Bucket") >>> _check_response_code(r, 200) ... FireCloudServerError ...
[ "Throws", "an", "exception", "if", "the", "http", "response", "is", "not", "expected", ".", "Can", "check", "single", "integer", "or", "list", "of", "valid", "responses", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L129-L142
train
38,830
broadinstitute/fiss
firecloud/api.py
list_entity_types
def list_entity_types(namespace, workspace): """List the entity types present in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Entities/getEntityTypes """ headers = _fiss_agent_header({"Content-type": "application/json"}) uri = "workspaces/{0}/{1}/entities".format(namespace, workspace) return __get(uri, headers=headers)
python
def list_entity_types(namespace, workspace): """List the entity types present in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Entities/getEntityTypes """ headers = _fiss_agent_header({"Content-type": "application/json"}) uri = "workspaces/{0}/{1}/entities".format(namespace, workspace) return __get(uri, headers=headers)
[ "def", "list_entity_types", "(", "namespace", ",", "workspace", ")", ":", "headers", "=", "_fiss_agent_header", "(", "{", "\"Content-type\"", ":", "\"application/json\"", "}", ")", "uri", "=", "\"workspaces/{0}/{1}/entities\"", ".", "format", "(", "namespace", ",", ...
List the entity types present in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Entities/getEntityTypes
[ "List", "the", "entity", "types", "present", "in", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L170-L182
train
38,831
broadinstitute/fiss
firecloud/api.py
upload_entities
def upload_entities(namespace, workspace, entity_data): """Upload entities from tab-delimited string. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name entity_data (str): TSV string describing entites Swagger: https://api.firecloud.org/#!/Entities/importEntities """ body = urlencode({"entities" : entity_data}) headers = _fiss_agent_header({ 'Content-type': "application/x-www-form-urlencoded" }) uri = "workspaces/{0}/{1}/importEntities".format(namespace, workspace) return __post(uri, headers=headers, data=body)
python
def upload_entities(namespace, workspace, entity_data): """Upload entities from tab-delimited string. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name entity_data (str): TSV string describing entites Swagger: https://api.firecloud.org/#!/Entities/importEntities """ body = urlencode({"entities" : entity_data}) headers = _fiss_agent_header({ 'Content-type': "application/x-www-form-urlencoded" }) uri = "workspaces/{0}/{1}/importEntities".format(namespace, workspace) return __post(uri, headers=headers, data=body)
[ "def", "upload_entities", "(", "namespace", ",", "workspace", ",", "entity_data", ")", ":", "body", "=", "urlencode", "(", "{", "\"entities\"", ":", "entity_data", "}", ")", "headers", "=", "_fiss_agent_header", "(", "{", "'Content-type'", ":", "\"application/x-...
Upload entities from tab-delimited string. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name entity_data (str): TSV string describing entites Swagger: https://api.firecloud.org/#!/Entities/importEntities
[ "Upload", "entities", "from", "tab", "-", "delimited", "string", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L184-L200
train
38,832
broadinstitute/fiss
firecloud/api.py
upload_entities_tsv
def upload_entities_tsv(namespace, workspace, entities_tsv): """Upload entities from a tsv loadfile. File-based wrapper for api.upload_entities(). A loadfile is a tab-separated text file with a header row describing entity type and attribute names, followed by rows of entities and their attribute values. Ex: entity:participant_id age alive participant_23 25 Y participant_27 35 N Args: namespace (str): project to which workspace belongs workspace (str): Workspace name entities_tsv (file): FireCloud loadfile, see format above """ if isinstance(entities_tsv, string_types): with open(entities_tsv, "r") as tsv: entity_data = tsv.read() elif isinstance(entities_tsv, io.StringIO): entity_data = entities_tsv.getvalue() else: raise ValueError('Unsupported input type.') return upload_entities(namespace, workspace, entity_data)
python
def upload_entities_tsv(namespace, workspace, entities_tsv): """Upload entities from a tsv loadfile. File-based wrapper for api.upload_entities(). A loadfile is a tab-separated text file with a header row describing entity type and attribute names, followed by rows of entities and their attribute values. Ex: entity:participant_id age alive participant_23 25 Y participant_27 35 N Args: namespace (str): project to which workspace belongs workspace (str): Workspace name entities_tsv (file): FireCloud loadfile, see format above """ if isinstance(entities_tsv, string_types): with open(entities_tsv, "r") as tsv: entity_data = tsv.read() elif isinstance(entities_tsv, io.StringIO): entity_data = entities_tsv.getvalue() else: raise ValueError('Unsupported input type.') return upload_entities(namespace, workspace, entity_data)
[ "def", "upload_entities_tsv", "(", "namespace", ",", "workspace", ",", "entities_tsv", ")", ":", "if", "isinstance", "(", "entities_tsv", ",", "string_types", ")", ":", "with", "open", "(", "entities_tsv", ",", "\"r\"", ")", "as", "tsv", ":", "entity_data", ...
Upload entities from a tsv loadfile. File-based wrapper for api.upload_entities(). A loadfile is a tab-separated text file with a header row describing entity type and attribute names, followed by rows of entities and their attribute values. Ex: entity:participant_id age alive participant_23 25 Y participant_27 35 N Args: namespace (str): project to which workspace belongs workspace (str): Workspace name entities_tsv (file): FireCloud loadfile, see format above
[ "Upload", "entities", "from", "a", "tsv", "loadfile", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L202-L227
train
38,833
broadinstitute/fiss
firecloud/api.py
copy_entities
def copy_entities(from_namespace, from_workspace, to_namespace, to_workspace, etype, enames, link_existing_entities=False): """Copy entities between workspaces Args: from_namespace (str): project (namespace) to which source workspace belongs from_workspace (str): Source workspace name to_namespace (str): project (namespace) to which target workspace belongs to_workspace (str): Target workspace name etype (str): Entity type enames (list(str)): List of entity names to copy link_existing_entities (boolean): Link all soft conflicts to the entities that already exist. Swagger: https://api.firecloud.org/#!/Entities/copyEntities """ uri = "workspaces/{0}/{1}/entities/copy".format(to_namespace, to_workspace) body = { "sourceWorkspace": { "namespace": from_namespace, "name": from_workspace }, "entityType": etype, "entityNames": enames } return __post(uri, json=body, params={'linkExistingEntities': str(link_existing_entities).lower()})
python
def copy_entities(from_namespace, from_workspace, to_namespace, to_workspace, etype, enames, link_existing_entities=False): """Copy entities between workspaces Args: from_namespace (str): project (namespace) to which source workspace belongs from_workspace (str): Source workspace name to_namespace (str): project (namespace) to which target workspace belongs to_workspace (str): Target workspace name etype (str): Entity type enames (list(str)): List of entity names to copy link_existing_entities (boolean): Link all soft conflicts to the entities that already exist. Swagger: https://api.firecloud.org/#!/Entities/copyEntities """ uri = "workspaces/{0}/{1}/entities/copy".format(to_namespace, to_workspace) body = { "sourceWorkspace": { "namespace": from_namespace, "name": from_workspace }, "entityType": etype, "entityNames": enames } return __post(uri, json=body, params={'linkExistingEntities': str(link_existing_entities).lower()})
[ "def", "copy_entities", "(", "from_namespace", ",", "from_workspace", ",", "to_namespace", ",", "to_workspace", ",", "etype", ",", "enames", ",", "link_existing_entities", "=", "False", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/entities/copy\"", ".", "format", "("...
Copy entities between workspaces Args: from_namespace (str): project (namespace) to which source workspace belongs from_workspace (str): Source workspace name to_namespace (str): project (namespace) to which target workspace belongs to_workspace (str): Target workspace name etype (str): Entity type enames (list(str)): List of entity names to copy link_existing_entities (boolean): Link all soft conflicts to the entities that already exist. Swagger: https://api.firecloud.org/#!/Entities/copyEntities
[ "Copy", "entities", "between", "workspaces" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L229-L257
train
38,834
broadinstitute/fiss
firecloud/api.py
get_entities
def get_entities(namespace, workspace, etype): """List entities of given type in a workspace. Response content will be in JSON format. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type Swagger: https://api.firecloud.org/#!/Entities/getEntities """ uri = "workspaces/{0}/{1}/entities/{2}".format(namespace, workspace, etype) return __get(uri)
python
def get_entities(namespace, workspace, etype): """List entities of given type in a workspace. Response content will be in JSON format. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type Swagger: https://api.firecloud.org/#!/Entities/getEntities """ uri = "workspaces/{0}/{1}/entities/{2}".format(namespace, workspace, etype) return __get(uri)
[ "def", "get_entities", "(", "namespace", ",", "workspace", ",", "etype", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/entities/{2}\"", ".", "format", "(", "namespace", ",", "workspace", ",", "etype", ")", "return", "__get", "(", "uri", ")" ]
List entities of given type in a workspace. Response content will be in JSON format. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type Swagger: https://api.firecloud.org/#!/Entities/getEntities
[ "List", "entities", "of", "given", "type", "in", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L259-L273
train
38,835
broadinstitute/fiss
firecloud/api.py
get_entities_tsv
def get_entities_tsv(namespace, workspace, etype): """List entities of given type in a workspace as a TSV. Identical to get_entities(), but the response is a TSV. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type Swagger: https://api.firecloud.org/#!/Entities/browserDownloadEntitiesTSV """ uri = "workspaces/{0}/{1}/entities/{2}/tsv".format(namespace, workspace, etype) return __get(uri)
python
def get_entities_tsv(namespace, workspace, etype): """List entities of given type in a workspace as a TSV. Identical to get_entities(), but the response is a TSV. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type Swagger: https://api.firecloud.org/#!/Entities/browserDownloadEntitiesTSV """ uri = "workspaces/{0}/{1}/entities/{2}/tsv".format(namespace, workspace, etype) return __get(uri)
[ "def", "get_entities_tsv", "(", "namespace", ",", "workspace", ",", "etype", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/entities/{2}/tsv\"", ".", "format", "(", "namespace", ",", "workspace", ",", "etype", ")", "return", "__get", "(", "uri", ")" ]
List entities of given type in a workspace as a TSV. Identical to get_entities(), but the response is a TSV. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type Swagger: https://api.firecloud.org/#!/Entities/browserDownloadEntitiesTSV
[ "List", "entities", "of", "given", "type", "in", "a", "workspace", "as", "a", "TSV", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L275-L290
train
38,836
broadinstitute/fiss
firecloud/api.py
get_entity
def get_entity(namespace, workspace, etype, ename): """Request entity information. Gets entity metadata and attributes. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type ename (str): The entity's unique id Swagger: https://api.firecloud.org/#!/Entities/getEntity """ uri = "workspaces/{0}/{1}/entities/{2}/{3}".format(namespace, workspace, etype, ename) return __get(uri)
python
def get_entity(namespace, workspace, etype, ename): """Request entity information. Gets entity metadata and attributes. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type ename (str): The entity's unique id Swagger: https://api.firecloud.org/#!/Entities/getEntity """ uri = "workspaces/{0}/{1}/entities/{2}/{3}".format(namespace, workspace, etype, ename) return __get(uri)
[ "def", "get_entity", "(", "namespace", ",", "workspace", ",", "etype", ",", "ename", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/entities/{2}/{3}\"", ".", "format", "(", "namespace", ",", "workspace", ",", "etype", ",", "ename", ")", "return", "__get", "(", ...
Request entity information. Gets entity metadata and attributes. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type ename (str): The entity's unique id Swagger: https://api.firecloud.org/#!/Entities/getEntity
[ "Request", "entity", "information", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L292-L308
train
38,837
broadinstitute/fiss
firecloud/api.py
get_entities_query
def get_entities_query(namespace, workspace, etype, page=1, page_size=100, sort_direction="asc", filter_terms=None): """Paginated version of get_entities_with_type. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Entities/entityQuery """ # Initial parameters for pagination params = { "page" : page, "pageSize" : page_size, "sortDirection" : sort_direction } if filter_terms: params['filterTerms'] = filter_terms uri = "workspaces/{0}/{1}/entityQuery/{2}".format(namespace,workspace,etype) return __get(uri, params=params)
python
def get_entities_query(namespace, workspace, etype, page=1, page_size=100, sort_direction="asc", filter_terms=None): """Paginated version of get_entities_with_type. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Entities/entityQuery """ # Initial parameters for pagination params = { "page" : page, "pageSize" : page_size, "sortDirection" : sort_direction } if filter_terms: params['filterTerms'] = filter_terms uri = "workspaces/{0}/{1}/entityQuery/{2}".format(namespace,workspace,etype) return __get(uri, params=params)
[ "def", "get_entities_query", "(", "namespace", ",", "workspace", ",", "etype", ",", "page", "=", "1", ",", "page_size", "=", "100", ",", "sort_direction", "=", "\"asc\"", ",", "filter_terms", "=", "None", ")", ":", "# Initial parameters for pagination", "params"...
Paginated version of get_entities_with_type. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Entities/entityQuery
[ "Paginated", "version", "of", "get_entities_with_type", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L434-L458
train
38,838
broadinstitute/fiss
firecloud/api.py
update_entity
def update_entity(namespace, workspace, etype, ename, updates): """ Update entity attributes in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type ename (str): Entity name updates (list(dict)): List of updates to entity from _attr_set, e.g. Swagger: https://api.firecloud.org/#!/Entities/update_entity """ headers = _fiss_agent_header({"Content-type": "application/json"}) uri = "{0}workspaces/{1}/{2}/entities/{3}/{4}".format(fcconfig.root_url, namespace, workspace, etype, ename) # FIXME: create __patch method, akin to __get, __delete etc return __SESSION.patch(uri, headers=headers, json=updates)
python
def update_entity(namespace, workspace, etype, ename, updates): """ Update entity attributes in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type ename (str): Entity name updates (list(dict)): List of updates to entity from _attr_set, e.g. Swagger: https://api.firecloud.org/#!/Entities/update_entity """ headers = _fiss_agent_header({"Content-type": "application/json"}) uri = "{0}workspaces/{1}/{2}/entities/{3}/{4}".format(fcconfig.root_url, namespace, workspace, etype, ename) # FIXME: create __patch method, akin to __get, __delete etc return __SESSION.patch(uri, headers=headers, json=updates)
[ "def", "update_entity", "(", "namespace", ",", "workspace", ",", "etype", ",", "ename", ",", "updates", ")", ":", "headers", "=", "_fiss_agent_header", "(", "{", "\"Content-type\"", ":", "\"application/json\"", "}", ")", "uri", "=", "\"{0}workspaces/{1}/{2}/entiti...
Update entity attributes in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name etype (str): Entity type ename (str): Entity name updates (list(dict)): List of updates to entity from _attr_set, e.g. Swagger: https://api.firecloud.org/#!/Entities/update_entity
[ "Update", "entity", "attributes", "in", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L460-L478
train
38,839
broadinstitute/fiss
firecloud/api.py
list_workspace_configs
def list_workspace_configs(namespace, workspace, allRepos=False): """List method configurations in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Method_Configurations/listWorkspaceMethodConfigs DUPLICATE: https://api.firecloud.org/#!/Workspaces/listWorkspaceMethodConfigs """ uri = "workspaces/{0}/{1}/methodconfigs".format(namespace, workspace) return __get(uri, params={'allRepos': allRepos})
python
def list_workspace_configs(namespace, workspace, allRepos=False): """List method configurations in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Method_Configurations/listWorkspaceMethodConfigs DUPLICATE: https://api.firecloud.org/#!/Workspaces/listWorkspaceMethodConfigs """ uri = "workspaces/{0}/{1}/methodconfigs".format(namespace, workspace) return __get(uri, params={'allRepos': allRepos})
[ "def", "list_workspace_configs", "(", "namespace", ",", "workspace", ",", "allRepos", "=", "False", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/methodconfigs\"", ".", "format", "(", "namespace", ",", "workspace", ")", "return", "__get", "(", "uri", ",", "params"...
List method configurations in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name Swagger: https://api.firecloud.org/#!/Method_Configurations/listWorkspaceMethodConfigs DUPLICATE: https://api.firecloud.org/#!/Workspaces/listWorkspaceMethodConfigs
[ "List", "method", "configurations", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L484-L496
train
38,840
broadinstitute/fiss
firecloud/api.py
create_workspace_config
def create_workspace_config(namespace, workspace, body): """Create method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name body (json) : a filled-in JSON object for the new method config (e.g. see return value of get_workspace_config) Swagger: https://api.firecloud.org/#!/Method_Configurations/postWorkspaceMethodConfig DUPLICATE: https://api.firecloud.org/#!/Workspaces/postWorkspaceMethodConfig """ #json_body = { # "namespace" : mnamespace, # "name" : method, # "rootEntityType" : root_etype, # "inputs" : {}, # "outputs" : {}, # "prerequisites" : {} #} uri = "workspaces/{0}/{1}/methodconfigs".format(namespace, workspace) return __post(uri, json=body)
python
def create_workspace_config(namespace, workspace, body): """Create method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name body (json) : a filled-in JSON object for the new method config (e.g. see return value of get_workspace_config) Swagger: https://api.firecloud.org/#!/Method_Configurations/postWorkspaceMethodConfig DUPLICATE: https://api.firecloud.org/#!/Workspaces/postWorkspaceMethodConfig """ #json_body = { # "namespace" : mnamespace, # "name" : method, # "rootEntityType" : root_etype, # "inputs" : {}, # "outputs" : {}, # "prerequisites" : {} #} uri = "workspaces/{0}/{1}/methodconfigs".format(namespace, workspace) return __post(uri, json=body)
[ "def", "create_workspace_config", "(", "namespace", ",", "workspace", ",", "body", ")", ":", "#json_body = {", "# \"namespace\" : mnamespace,", "# \"name\" : method,", "# \"rootEntityType\" : root_etype,", "# \"inputs\" : {},", "# \"outputs\" : {},", "# ...
Create method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name body (json) : a filled-in JSON object for the new method config (e.g. see return value of get_workspace_config) Swagger: https://api.firecloud.org/#!/Method_Configurations/postWorkspaceMethodConfig DUPLICATE: https://api.firecloud.org/#!/Workspaces/postWorkspaceMethodConfig
[ "Create", "method", "configuration", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L498-L521
train
38,841
broadinstitute/fiss
firecloud/api.py
delete_workspace_config
def delete_workspace_config(namespace, workspace, cnamespace, config): """Delete method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name mnamespace (str): Method namespace method (str): Method name Swagger: https://api.firecloud.org/#!/Method_Configurations/deleteWorkspaceMethodConfig """ uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace, workspace, cnamespace, config) return __delete(uri)
python
def delete_workspace_config(namespace, workspace, cnamespace, config): """Delete method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name mnamespace (str): Method namespace method (str): Method name Swagger: https://api.firecloud.org/#!/Method_Configurations/deleteWorkspaceMethodConfig """ uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace, workspace, cnamespace, config) return __delete(uri)
[ "def", "delete_workspace_config", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "config", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/method_configs/{2}/{3}\"", ".", "format", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "config", ")", ...
Delete method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name mnamespace (str): Method namespace method (str): Method name Swagger: https://api.firecloud.org/#!/Method_Configurations/deleteWorkspaceMethodConfig
[ "Delete", "method", "configuration", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L523-L537
train
38,842
broadinstitute/fiss
firecloud/api.py
get_workspace_config
def get_workspace_config(namespace, workspace, cnamespace, config): """Get method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Config namespace config (str): Config name Swagger: https://api.firecloud.org/#!/Method_Configurations/getWorkspaceMethodConfig """ uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace, workspace, cnamespace, config) return __get(uri)
python
def get_workspace_config(namespace, workspace, cnamespace, config): """Get method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Config namespace config (str): Config name Swagger: https://api.firecloud.org/#!/Method_Configurations/getWorkspaceMethodConfig """ uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace, workspace, cnamespace, config) return __get(uri)
[ "def", "get_workspace_config", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "config", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/method_configs/{2}/{3}\"", ".", "format", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "config", ")", "r...
Get method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Config namespace config (str): Config name Swagger: https://api.firecloud.org/#!/Method_Configurations/getWorkspaceMethodConfig
[ "Get", "method", "configuration", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L539-L554
train
38,843
broadinstitute/fiss
firecloud/api.py
overwrite_workspace_config
def overwrite_workspace_config(namespace, workspace, cnamespace, configname, body): """Add or overwrite method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace configname (str): Configuration name body (json): new body (definition) of the method config Swagger: https://api.firecloud.org/#!/Method_Configurations/overwriteWorkspaceMethodConfig """ headers = _fiss_agent_header({"Content-type": "application/json"}) uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace, workspace, cnamespace, configname) return __put(uri, headers=headers, json=body)
python
def overwrite_workspace_config(namespace, workspace, cnamespace, configname, body): """Add or overwrite method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace configname (str): Configuration name body (json): new body (definition) of the method config Swagger: https://api.firecloud.org/#!/Method_Configurations/overwriteWorkspaceMethodConfig """ headers = _fiss_agent_header({"Content-type": "application/json"}) uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace, workspace, cnamespace, configname) return __put(uri, headers=headers, json=body)
[ "def", "overwrite_workspace_config", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "configname", ",", "body", ")", ":", "headers", "=", "_fiss_agent_header", "(", "{", "\"Content-type\"", ":", "\"application/json\"", "}", ")", "uri", "=", "\"workspac...
Add or overwrite method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace configname (str): Configuration name body (json): new body (definition) of the method config Swagger: https://api.firecloud.org/#!/Method_Configurations/overwriteWorkspaceMethodConfig
[ "Add", "or", "overwrite", "method", "configuration", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L556-L572
train
38,844
broadinstitute/fiss
firecloud/api.py
update_workspace_config
def update_workspace_config(namespace, workspace, cnamespace, configname, body): """Update method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace configname (str): Configuration name body (json): new body (definition) of the method config Swagger: https://api.firecloud.org/#!/Method_Configurations/updateWorkspaceMethodConfig """ uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace, workspace, cnamespace, configname) return __post(uri, json=body)
python
def update_workspace_config(namespace, workspace, cnamespace, configname, body): """Update method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace configname (str): Configuration name body (json): new body (definition) of the method config Swagger: https://api.firecloud.org/#!/Method_Configurations/updateWorkspaceMethodConfig """ uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace, workspace, cnamespace, configname) return __post(uri, json=body)
[ "def", "update_workspace_config", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "configname", ",", "body", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/method_configs/{2}/{3}\"", ".", "format", "(", "namespace", ",", "workspace", ",", "cnamespace", ",",...
Update method configuration in workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace configname (str): Configuration name body (json): new body (definition) of the method config Swagger: https://api.firecloud.org/#!/Method_Configurations/updateWorkspaceMethodConfig
[ "Update", "method", "configuration", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L574-L589
train
38,845
broadinstitute/fiss
firecloud/api.py
validate_config
def validate_config(namespace, workspace, cnamespace, config): """Get syntax validation for a configuration. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace config (str): Configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/validate_method_configuration """ uri = "workspaces/{0}/{1}/method_configs/{2}/{3}/validate".format(namespace, workspace, cnamespace, config) return __get(uri)
python
def validate_config(namespace, workspace, cnamespace, config): """Get syntax validation for a configuration. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace config (str): Configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/validate_method_configuration """ uri = "workspaces/{0}/{1}/method_configs/{2}/{3}/validate".format(namespace, workspace, cnamespace, config) return __get(uri)
[ "def", "validate_config", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "config", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/method_configs/{2}/{3}/validate\"", ".", "format", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "config", ")", ...
Get syntax validation for a configuration. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Configuration namespace config (str): Configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/validate_method_configuration
[ "Get", "syntax", "validation", "for", "a", "configuration", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L591-L605
train
38,846
broadinstitute/fiss
firecloud/api.py
rename_workspace_config
def rename_workspace_config(namespace, workspace, cnamespace, config, new_namespace, new_name): """Rename a method configuration in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name mnamespace (str): Config namespace config (str): Config name new_namespace (str): Updated config namespace new_name (str): Updated method name Swagger: https://api.firecloud.org/#!/Method_Configurations/renameWorkspaceMethodConfig """ body = { "namespace" : new_namespace, "name" : new_name, # I have no idea why this is required by FC, but it is... "workspaceName" : { "namespace" : namespace, "name" : workspace } } uri = "workspaces/{0}/{1}/method_configs/{2}/{3}/rename".format(namespace, workspace, cnamespace, config) return __post(uri, json=body)
python
def rename_workspace_config(namespace, workspace, cnamespace, config, new_namespace, new_name): """Rename a method configuration in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name mnamespace (str): Config namespace config (str): Config name new_namespace (str): Updated config namespace new_name (str): Updated method name Swagger: https://api.firecloud.org/#!/Method_Configurations/renameWorkspaceMethodConfig """ body = { "namespace" : new_namespace, "name" : new_name, # I have no idea why this is required by FC, but it is... "workspaceName" : { "namespace" : namespace, "name" : workspace } } uri = "workspaces/{0}/{1}/method_configs/{2}/{3}/rename".format(namespace, workspace, cnamespace, config) return __post(uri, json=body)
[ "def", "rename_workspace_config", "(", "namespace", ",", "workspace", ",", "cnamespace", ",", "config", ",", "new_namespace", ",", "new_name", ")", ":", "body", "=", "{", "\"namespace\"", ":", "new_namespace", ",", "\"name\"", ":", "new_name", ",", "# I have no ...
Rename a method configuration in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name mnamespace (str): Config namespace config (str): Config name new_namespace (str): Updated config namespace new_name (str): Updated method name Swagger: https://api.firecloud.org/#!/Method_Configurations/renameWorkspaceMethodConfig
[ "Rename", "a", "method", "configuration", "in", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L607-L634
train
38,847
broadinstitute/fiss
firecloud/api.py
copy_config_from_repo
def copy_config_from_repo(namespace, workspace, from_cnamespace, from_config, from_snapshot_id, to_cnamespace, to_config): """Copy a method config from the methods repository to a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name from_cnamespace (str): Source configuration namespace from_config (str): Source configuration name from_snapshot_id (int): Source configuration snapshot_id to_cnamespace (str): Target configuration namespace to_config (str): Target configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/copyFromMethodRepo DUPLICATE: https://api.firecloud.org/#!/Method_Repository/copyFromMethodRepo """ body = { "configurationNamespace" : from_cnamespace, "configurationName" : from_config, "configurationSnapshotId" : from_snapshot_id, "destinationNamespace" : to_cnamespace, "destinationName" : to_config } uri = "workspaces/{0}/{1}/method_configs/copyFromMethodRepo".format( namespace, workspace) return __post(uri, json=body)
python
def copy_config_from_repo(namespace, workspace, from_cnamespace, from_config, from_snapshot_id, to_cnamespace, to_config): """Copy a method config from the methods repository to a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name from_cnamespace (str): Source configuration namespace from_config (str): Source configuration name from_snapshot_id (int): Source configuration snapshot_id to_cnamespace (str): Target configuration namespace to_config (str): Target configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/copyFromMethodRepo DUPLICATE: https://api.firecloud.org/#!/Method_Repository/copyFromMethodRepo """ body = { "configurationNamespace" : from_cnamespace, "configurationName" : from_config, "configurationSnapshotId" : from_snapshot_id, "destinationNamespace" : to_cnamespace, "destinationName" : to_config } uri = "workspaces/{0}/{1}/method_configs/copyFromMethodRepo".format( namespace, workspace) return __post(uri, json=body)
[ "def", "copy_config_from_repo", "(", "namespace", ",", "workspace", ",", "from_cnamespace", ",", "from_config", ",", "from_snapshot_id", ",", "to_cnamespace", ",", "to_config", ")", ":", "body", "=", "{", "\"configurationNamespace\"", ":", "from_cnamespace", ",", "\...
Copy a method config from the methods repository to a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name from_cnamespace (str): Source configuration namespace from_config (str): Source configuration name from_snapshot_id (int): Source configuration snapshot_id to_cnamespace (str): Target configuration namespace to_config (str): Target configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/copyFromMethodRepo DUPLICATE: https://api.firecloud.org/#!/Method_Repository/copyFromMethodRepo
[ "Copy", "a", "method", "config", "from", "the", "methods", "repository", "to", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L636-L664
train
38,848
broadinstitute/fiss
firecloud/api.py
copy_config_to_repo
def copy_config_to_repo(namespace, workspace, from_cnamespace, from_config, to_cnamespace, to_config): """Copy a method config from a workspace to the methods repository. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name from_cnamespace (str): Source configuration namespace from_config (str): Source configuration name to_cnamespace (str): Target configuration namespace to_config (str): Target configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/copyToMethodRepo DUPLICATE: https://api.firecloud.org/#!/Method_Repository/copyToMethodRepo """ body = { "configurationNamespace" : to_cnamespace, "configurationName" : to_config, "sourceNamespace" : from_cnamespace, "sourceName" : from_config } uri = "workspaces/{0}/{1}/method_configs/copyToMethodRepo".format( namespace, workspace) return __post(uri, json=body)
python
def copy_config_to_repo(namespace, workspace, from_cnamespace, from_config, to_cnamespace, to_config): """Copy a method config from a workspace to the methods repository. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name from_cnamespace (str): Source configuration namespace from_config (str): Source configuration name to_cnamespace (str): Target configuration namespace to_config (str): Target configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/copyToMethodRepo DUPLICATE: https://api.firecloud.org/#!/Method_Repository/copyToMethodRepo """ body = { "configurationNamespace" : to_cnamespace, "configurationName" : to_config, "sourceNamespace" : from_cnamespace, "sourceName" : from_config } uri = "workspaces/{0}/{1}/method_configs/copyToMethodRepo".format( namespace, workspace) return __post(uri, json=body)
[ "def", "copy_config_to_repo", "(", "namespace", ",", "workspace", ",", "from_cnamespace", ",", "from_config", ",", "to_cnamespace", ",", "to_config", ")", ":", "body", "=", "{", "\"configurationNamespace\"", ":", "to_cnamespace", ",", "\"configurationName\"", ":", "...
Copy a method config from a workspace to the methods repository. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name from_cnamespace (str): Source configuration namespace from_config (str): Source configuration name to_cnamespace (str): Target configuration namespace to_config (str): Target configuration name Swagger: https://api.firecloud.org/#!/Method_Configurations/copyToMethodRepo DUPLICATE: https://api.firecloud.org/#!/Method_Repository/copyToMethodRepo
[ "Copy", "a", "method", "config", "from", "a", "workspace", "to", "the", "methods", "repository", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L666-L691
train
38,849
broadinstitute/fiss
firecloud/api.py
get_config_template
def get_config_template(namespace, method, version): """Get the configuration template for a method. The method should exist in the methods repository. Args: namespace (str): Method's namespace method (str): method name version (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/createMethodTemplate """ body = { "methodNamespace" : namespace, "methodName" : method, "methodVersion" : int(version) } return __post("template", json=body)
python
def get_config_template(namespace, method, version): """Get the configuration template for a method. The method should exist in the methods repository. Args: namespace (str): Method's namespace method (str): method name version (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/createMethodTemplate """ body = { "methodNamespace" : namespace, "methodName" : method, "methodVersion" : int(version) } return __post("template", json=body)
[ "def", "get_config_template", "(", "namespace", ",", "method", ",", "version", ")", ":", "body", "=", "{", "\"methodNamespace\"", ":", "namespace", ",", "\"methodName\"", ":", "method", ",", "\"methodVersion\"", ":", "int", "(", "version", ")", "}", "return", ...
Get the configuration template for a method. The method should exist in the methods repository. Args: namespace (str): Method's namespace method (str): method name version (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/createMethodTemplate
[ "Get", "the", "configuration", "template", "for", "a", "method", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L725-L744
train
38,850
broadinstitute/fiss
firecloud/api.py
get_inputs_outputs
def get_inputs_outputs(namespace, method, snapshot_id): """Get a description of the inputs and outputs for a method. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodIO """ body = { "methodNamespace" : namespace, "methodName" : method, "methodVersion" : snapshot_id } return __post("inputsOutputs", json=body)
python
def get_inputs_outputs(namespace, method, snapshot_id): """Get a description of the inputs and outputs for a method. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodIO """ body = { "methodNamespace" : namespace, "methodName" : method, "methodVersion" : snapshot_id } return __post("inputsOutputs", json=body)
[ "def", "get_inputs_outputs", "(", "namespace", ",", "method", ",", "snapshot_id", ")", ":", "body", "=", "{", "\"methodNamespace\"", ":", "namespace", ",", "\"methodName\"", ":", "method", ",", "\"methodVersion\"", ":", "snapshot_id", "}", "return", "__post", "(...
Get a description of the inputs and outputs for a method. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodIO
[ "Get", "a", "description", "of", "the", "inputs", "and", "outputs", "for", "a", "method", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L746-L765
train
38,851
broadinstitute/fiss
firecloud/api.py
get_repository_config
def get_repository_config(namespace, config, snapshot_id): """Get a method configuration from the methods repository. Args: namespace (str): Methods namespace config (str): config name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodRepositoryConfiguration """ uri = "configurations/{0}/{1}/{2}".format(namespace, config, snapshot_id) return __get(uri)
python
def get_repository_config(namespace, config, snapshot_id): """Get a method configuration from the methods repository. Args: namespace (str): Methods namespace config (str): config name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodRepositoryConfiguration """ uri = "configurations/{0}/{1}/{2}".format(namespace, config, snapshot_id) return __get(uri)
[ "def", "get_repository_config", "(", "namespace", ",", "config", ",", "snapshot_id", ")", ":", "uri", "=", "\"configurations/{0}/{1}/{2}\"", ".", "format", "(", "namespace", ",", "config", ",", "snapshot_id", ")", "return", "__get", "(", "uri", ")" ]
Get a method configuration from the methods repository. Args: namespace (str): Methods namespace config (str): config name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodRepositoryConfiguration
[ "Get", "a", "method", "configuration", "from", "the", "methods", "repository", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L767-L779
train
38,852
broadinstitute/fiss
firecloud/api.py
get_repository_method
def get_repository_method(namespace, method, snapshot_id, wdl_only=False): """Get a method definition from the method repository. Args: namespace (str): Methods namespace method (str): method name version (int): snapshot_id of the method wdl_only (bool): Exclude metadata Swagger: https://api.firecloud.org/#!/Method_Repository/get_api_methods_namespace_name_snapshotId """ uri = "methods/{0}/{1}/{2}?onlyPayload={3}".format(namespace, method, snapshot_id, str(wdl_only).lower()) return __get(uri)
python
def get_repository_method(namespace, method, snapshot_id, wdl_only=False): """Get a method definition from the method repository. Args: namespace (str): Methods namespace method (str): method name version (int): snapshot_id of the method wdl_only (bool): Exclude metadata Swagger: https://api.firecloud.org/#!/Method_Repository/get_api_methods_namespace_name_snapshotId """ uri = "methods/{0}/{1}/{2}?onlyPayload={3}".format(namespace, method, snapshot_id, str(wdl_only).lower()) return __get(uri)
[ "def", "get_repository_method", "(", "namespace", ",", "method", ",", "snapshot_id", ",", "wdl_only", "=", "False", ")", ":", "uri", "=", "\"methods/{0}/{1}/{2}?onlyPayload={3}\"", ".", "format", "(", "namespace", ",", "method", ",", "snapshot_id", ",", "str", "...
Get a method definition from the method repository. Args: namespace (str): Methods namespace method (str): method name version (int): snapshot_id of the method wdl_only (bool): Exclude metadata Swagger: https://api.firecloud.org/#!/Method_Repository/get_api_methods_namespace_name_snapshotId
[ "Get", "a", "method", "definition", "from", "the", "method", "repository", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L781-L796
train
38,853
broadinstitute/fiss
firecloud/api.py
delete_repository_method
def delete_repository_method(namespace, name, snapshot_id): """Redacts a method and all of its associated configurations. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/delete_api_methods_namespace_name_snapshotId """ uri = "methods/{0}/{1}/{2}".format(namespace, name, snapshot_id) return __delete(uri)
python
def delete_repository_method(namespace, name, snapshot_id): """Redacts a method and all of its associated configurations. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/delete_api_methods_namespace_name_snapshotId """ uri = "methods/{0}/{1}/{2}".format(namespace, name, snapshot_id) return __delete(uri)
[ "def", "delete_repository_method", "(", "namespace", ",", "name", ",", "snapshot_id", ")", ":", "uri", "=", "\"methods/{0}/{1}/{2}\"", ".", "format", "(", "namespace", ",", "name", ",", "snapshot_id", ")", "return", "__delete", "(", "uri", ")" ]
Redacts a method and all of its associated configurations. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/delete_api_methods_namespace_name_snapshotId
[ "Redacts", "a", "method", "and", "all", "of", "its", "associated", "configurations", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L835-L849
train
38,854
broadinstitute/fiss
firecloud/api.py
delete_repository_config
def delete_repository_config(namespace, name, snapshot_id): """Redacts a configuration and all of its associated configurations. The configuration should exist in the methods repository. Args: namespace (str): configuration namespace configuration (str): configuration name snapshot_id (int): snapshot_id of the configuration Swagger: https://api.firecloud.org/#!/Method_Repository/delete_api_configurations_namespace_name_snapshotId """ uri = "configurations/{0}/{1}/{2}".format(namespace, name, snapshot_id) return __delete(uri)
python
def delete_repository_config(namespace, name, snapshot_id): """Redacts a configuration and all of its associated configurations. The configuration should exist in the methods repository. Args: namespace (str): configuration namespace configuration (str): configuration name snapshot_id (int): snapshot_id of the configuration Swagger: https://api.firecloud.org/#!/Method_Repository/delete_api_configurations_namespace_name_snapshotId """ uri = "configurations/{0}/{1}/{2}".format(namespace, name, snapshot_id) return __delete(uri)
[ "def", "delete_repository_config", "(", "namespace", ",", "name", ",", "snapshot_id", ")", ":", "uri", "=", "\"configurations/{0}/{1}/{2}\"", ".", "format", "(", "namespace", ",", "name", ",", "snapshot_id", ")", "return", "__delete", "(", "uri", ")" ]
Redacts a configuration and all of its associated configurations. The configuration should exist in the methods repository. Args: namespace (str): configuration namespace configuration (str): configuration name snapshot_id (int): snapshot_id of the configuration Swagger: https://api.firecloud.org/#!/Method_Repository/delete_api_configurations_namespace_name_snapshotId
[ "Redacts", "a", "configuration", "and", "all", "of", "its", "associated", "configurations", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L851-L865
train
38,855
broadinstitute/fiss
firecloud/api.py
get_repository_method_acl
def get_repository_method_acl(namespace, method, snapshot_id): """Get permissions for a method. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name version (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodACL """ uri = "methods/{0}/{1}/{2}/permissions".format(namespace,method,snapshot_id) return __get(uri)
python
def get_repository_method_acl(namespace, method, snapshot_id): """Get permissions for a method. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name version (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodACL """ uri = "methods/{0}/{1}/{2}/permissions".format(namespace,method,snapshot_id) return __get(uri)
[ "def", "get_repository_method_acl", "(", "namespace", ",", "method", ",", "snapshot_id", ")", ":", "uri", "=", "\"methods/{0}/{1}/{2}/permissions\"", ".", "format", "(", "namespace", ",", "method", ",", "snapshot_id", ")", "return", "__get", "(", "uri", ")" ]
Get permissions for a method. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name version (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getMethodACL
[ "Get", "permissions", "for", "a", "method", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L867-L881
train
38,856
broadinstitute/fiss
firecloud/api.py
update_repository_method_acl
def update_repository_method_acl(namespace, method, snapshot_id, acl_updates): """Set method permissions. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method acl_updates (list(dict)): List of access control updates Swagger: https://api.firecloud.org/#!/Method_Repository/setMethodACL """ uri = "methods/{0}/{1}/{2}/permissions".format(namespace,method,snapshot_id) return __post(uri, json=acl_updates)
python
def update_repository_method_acl(namespace, method, snapshot_id, acl_updates): """Set method permissions. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method acl_updates (list(dict)): List of access control updates Swagger: https://api.firecloud.org/#!/Method_Repository/setMethodACL """ uri = "methods/{0}/{1}/{2}/permissions".format(namespace,method,snapshot_id) return __post(uri, json=acl_updates)
[ "def", "update_repository_method_acl", "(", "namespace", ",", "method", ",", "snapshot_id", ",", "acl_updates", ")", ":", "uri", "=", "\"methods/{0}/{1}/{2}/permissions\"", ".", "format", "(", "namespace", ",", "method", ",", "snapshot_id", ")", "return", "__post", ...
Set method permissions. The method should exist in the methods repository. Args: namespace (str): Methods namespace method (str): method name snapshot_id (int): snapshot_id of the method acl_updates (list(dict)): List of access control updates Swagger: https://api.firecloud.org/#!/Method_Repository/setMethodACL
[ "Set", "method", "permissions", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L883-L899
train
38,857
broadinstitute/fiss
firecloud/api.py
get_repository_config_acl
def get_repository_config_acl(namespace, config, snapshot_id): """Get configuration permissions. The configuration should exist in the methods repository. Args: namespace (str): Configuration namespace config (str): Configuration name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getConfigACL """ uri = "configurations/{0}/{1}/{2}/permissions".format(namespace, config, snapshot_id) return __get(uri)
python
def get_repository_config_acl(namespace, config, snapshot_id): """Get configuration permissions. The configuration should exist in the methods repository. Args: namespace (str): Configuration namespace config (str): Configuration name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getConfigACL """ uri = "configurations/{0}/{1}/{2}/permissions".format(namespace, config, snapshot_id) return __get(uri)
[ "def", "get_repository_config_acl", "(", "namespace", ",", "config", ",", "snapshot_id", ")", ":", "uri", "=", "\"configurations/{0}/{1}/{2}/permissions\"", ".", "format", "(", "namespace", ",", "config", ",", "snapshot_id", ")", "return", "__get", "(", "uri", ")"...
Get configuration permissions. The configuration should exist in the methods repository. Args: namespace (str): Configuration namespace config (str): Configuration name snapshot_id (int): snapshot_id of the method Swagger: https://api.firecloud.org/#!/Method_Repository/getConfigACL
[ "Get", "configuration", "permissions", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L901-L916
train
38,858
broadinstitute/fiss
firecloud/api.py
update_repository_config_acl
def update_repository_config_acl(namespace, config, snapshot_id, acl_updates): """Set configuration permissions. The configuration should exist in the methods repository. Args: namespace (str): Configuration namespace config (str): Configuration name snapshot_id (int): snapshot_id of the method acl_updates (list(dict)): List of access control updates Swagger: https://api.firecloud.org/#!/Method_Repository/setConfigACL """ uri = "configurations/{0}/{1}/{2}/permissions".format(namespace, config, snapshot_id) return __post(uri, json=acl_updates)
python
def update_repository_config_acl(namespace, config, snapshot_id, acl_updates): """Set configuration permissions. The configuration should exist in the methods repository. Args: namespace (str): Configuration namespace config (str): Configuration name snapshot_id (int): snapshot_id of the method acl_updates (list(dict)): List of access control updates Swagger: https://api.firecloud.org/#!/Method_Repository/setConfigACL """ uri = "configurations/{0}/{1}/{2}/permissions".format(namespace, config, snapshot_id) return __post(uri, json=acl_updates)
[ "def", "update_repository_config_acl", "(", "namespace", ",", "config", ",", "snapshot_id", ",", "acl_updates", ")", ":", "uri", "=", "\"configurations/{0}/{1}/{2}/permissions\"", ".", "format", "(", "namespace", ",", "config", ",", "snapshot_id", ")", "return", "__...
Set configuration permissions. The configuration should exist in the methods repository. Args: namespace (str): Configuration namespace config (str): Configuration name snapshot_id (int): snapshot_id of the method acl_updates (list(dict)): List of access control updates Swagger: https://api.firecloud.org/#!/Method_Repository/setConfigACL
[ "Set", "configuration", "permissions", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L918-L935
train
38,859
broadinstitute/fiss
firecloud/api.py
create_submission
def create_submission(wnamespace, workspace, cnamespace, config, entity, etype, expression=None, use_callcache=True): """Submit job in FireCloud workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Method configuration namespace config (str): Method configuration name entity (str): Entity to submit job on. Should be the same type as the root entity type of the method config, unless an expression is used etype (str): Entity type of root_entity expression (str): Instead of using entity as the root entity, evaluate the root entity from this expression. use_callcache (bool): use call cache if applicable (default: true) Swagger: https://api.firecloud.org/#!/Submissions/createSubmission """ uri = "workspaces/{0}/{1}/submissions".format(wnamespace, workspace) body = { "methodConfigurationNamespace" : cnamespace, "methodConfigurationName" : config, "entityType" : etype, "entityName" : entity, "useCallCache" : use_callcache } if expression: body['expression'] = expression return __post(uri, json=body)
python
def create_submission(wnamespace, workspace, cnamespace, config, entity, etype, expression=None, use_callcache=True): """Submit job in FireCloud workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Method configuration namespace config (str): Method configuration name entity (str): Entity to submit job on. Should be the same type as the root entity type of the method config, unless an expression is used etype (str): Entity type of root_entity expression (str): Instead of using entity as the root entity, evaluate the root entity from this expression. use_callcache (bool): use call cache if applicable (default: true) Swagger: https://api.firecloud.org/#!/Submissions/createSubmission """ uri = "workspaces/{0}/{1}/submissions".format(wnamespace, workspace) body = { "methodConfigurationNamespace" : cnamespace, "methodConfigurationName" : config, "entityType" : etype, "entityName" : entity, "useCallCache" : use_callcache } if expression: body['expression'] = expression return __post(uri, json=body)
[ "def", "create_submission", "(", "wnamespace", ",", "workspace", ",", "cnamespace", ",", "config", ",", "entity", ",", "etype", ",", "expression", "=", "None", ",", "use_callcache", "=", "True", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/submissions\"", ".", ...
Submit job in FireCloud workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Method configuration namespace config (str): Method configuration name entity (str): Entity to submit job on. Should be the same type as the root entity type of the method config, unless an expression is used etype (str): Entity type of root_entity expression (str): Instead of using entity as the root entity, evaluate the root entity from this expression. use_callcache (bool): use call cache if applicable (default: true) Swagger: https://api.firecloud.org/#!/Submissions/createSubmission
[ "Submit", "job", "in", "FireCloud", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1023-L1056
train
38,860
broadinstitute/fiss
firecloud/api.py
abort_submission
def abort_submission(namespace, workspace, submission_id): """Abort running job in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier Swagger: https://api.firecloud.org/#!/Submissions/deleteSubmission """ uri = "workspaces/{0}/{1}/submissions/{2}".format(namespace, workspace, submission_id) return __delete(uri)
python
def abort_submission(namespace, workspace, submission_id): """Abort running job in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier Swagger: https://api.firecloud.org/#!/Submissions/deleteSubmission """ uri = "workspaces/{0}/{1}/submissions/{2}".format(namespace, workspace, submission_id) return __delete(uri)
[ "def", "abort_submission", "(", "namespace", ",", "workspace", ",", "submission_id", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/submissions/{2}\"", ".", "format", "(", "namespace", ",", "workspace", ",", "submission_id", ")", "return", "__delete", "(", "uri", ")"...
Abort running job in a workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier Swagger: https://api.firecloud.org/#!/Submissions/deleteSubmission
[ "Abort", "running", "job", "in", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1058-L1071
train
38,861
broadinstitute/fiss
firecloud/api.py
get_submission
def get_submission(namespace, workspace, submission_id): """Request submission information. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier Swagger: https://api.firecloud.org/#!/Submissions/monitorSubmission """ uri = "workspaces/{0}/{1}/submissions/{2}".format(namespace, workspace, submission_id) return __get(uri)
python
def get_submission(namespace, workspace, submission_id): """Request submission information. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier Swagger: https://api.firecloud.org/#!/Submissions/monitorSubmission """ uri = "workspaces/{0}/{1}/submissions/{2}".format(namespace, workspace, submission_id) return __get(uri)
[ "def", "get_submission", "(", "namespace", ",", "workspace", ",", "submission_id", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/submissions/{2}\"", ".", "format", "(", "namespace", ",", "workspace", ",", "submission_id", ")", "return", "__get", "(", "uri", ")" ]
Request submission information. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier Swagger: https://api.firecloud.org/#!/Submissions/monitorSubmission
[ "Request", "submission", "information", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1073-L1086
train
38,862
broadinstitute/fiss
firecloud/api.py
get_workflow_metadata
def get_workflow_metadata(namespace, workspace, submission_id, workflow_id): """Request the metadata for a workflow in a submission. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier workflow_id (str): Workflow's unique identifier. Swagger: https://api.firecloud.org/#!/Submissions/workflowMetadata """ uri = "workspaces/{0}/{1}/submissions/{2}/workflows/{3}".format(namespace, workspace, submission_id, workflow_id) return __get(uri)
python
def get_workflow_metadata(namespace, workspace, submission_id, workflow_id): """Request the metadata for a workflow in a submission. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier workflow_id (str): Workflow's unique identifier. Swagger: https://api.firecloud.org/#!/Submissions/workflowMetadata """ uri = "workspaces/{0}/{1}/submissions/{2}/workflows/{3}".format(namespace, workspace, submission_id, workflow_id) return __get(uri)
[ "def", "get_workflow_metadata", "(", "namespace", ",", "workspace", ",", "submission_id", ",", "workflow_id", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/submissions/{2}/workflows/{3}\"", ".", "format", "(", "namespace", ",", "workspace", ",", "submission_id", ",", "w...
Request the metadata for a workflow in a submission. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier workflow_id (str): Workflow's unique identifier. Swagger: https://api.firecloud.org/#!/Submissions/workflowMetadata
[ "Request", "the", "metadata", "for", "a", "workflow", "in", "a", "submission", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1088-L1102
train
38,863
broadinstitute/fiss
firecloud/api.py
get_workflow_outputs
def get_workflow_outputs(namespace, workspace, submission_id, workflow_id): """Request the outputs for a workflow in a submission. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier workflow_id (str): Workflow's unique identifier. Swagger: https://api.firecloud.org/#!/Submissions/workflowOutputsInSubmission """ uri = "workspaces/{0}/{1}/".format(namespace, workspace) uri += "submissions/{0}/workflows/{1}/outputs".format(submission_id, workflow_id) return __get(uri)
python
def get_workflow_outputs(namespace, workspace, submission_id, workflow_id): """Request the outputs for a workflow in a submission. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier workflow_id (str): Workflow's unique identifier. Swagger: https://api.firecloud.org/#!/Submissions/workflowOutputsInSubmission """ uri = "workspaces/{0}/{1}/".format(namespace, workspace) uri += "submissions/{0}/workflows/{1}/outputs".format(submission_id, workflow_id) return __get(uri)
[ "def", "get_workflow_outputs", "(", "namespace", ",", "workspace", ",", "submission_id", ",", "workflow_id", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/\"", ".", "format", "(", "namespace", ",", "workspace", ")", "uri", "+=", "\"submissions/{0}/workflows/{1}/outputs\...
Request the outputs for a workflow in a submission. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier workflow_id (str): Workflow's unique identifier. Swagger: https://api.firecloud.org/#!/Submissions/workflowOutputsInSubmission
[ "Request", "the", "outputs", "for", "a", "workflow", "in", "a", "submission", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1104-L1119
train
38,864
broadinstitute/fiss
firecloud/api.py
create_workspace
def create_workspace(namespace, name, authorizationDomain="", attributes=None): """Create a new FireCloud Workspace. Args: namespace (str): project to which workspace belongs name (str): Workspace name protected (bool): If True, this workspace is protected by dbGaP credentials. This option is only available if your FireCloud account is linked to your NIH account. attributes (dict): Workspace attributes as key value pairs Swagger: https://api.firecloud.org/#!/Workspaces/createWorkspace """ if not attributes: attributes = dict() body = { "namespace": namespace, "name": name, "attributes": attributes } if authorizationDomain: authDomain = [{"membersGroupName": authorizationDomain}] else: authDomain = [] body["authorizationDomain"] = authDomain return __post("workspaces", json=body)
python
def create_workspace(namespace, name, authorizationDomain="", attributes=None): """Create a new FireCloud Workspace. Args: namespace (str): project to which workspace belongs name (str): Workspace name protected (bool): If True, this workspace is protected by dbGaP credentials. This option is only available if your FireCloud account is linked to your NIH account. attributes (dict): Workspace attributes as key value pairs Swagger: https://api.firecloud.org/#!/Workspaces/createWorkspace """ if not attributes: attributes = dict() body = { "namespace": namespace, "name": name, "attributes": attributes } if authorizationDomain: authDomain = [{"membersGroupName": authorizationDomain}] else: authDomain = [] body["authorizationDomain"] = authDomain return __post("workspaces", json=body)
[ "def", "create_workspace", "(", "namespace", ",", "name", ",", "authorizationDomain", "=", "\"\"", ",", "attributes", "=", "None", ")", ":", "if", "not", "attributes", ":", "attributes", "=", "dict", "(", ")", "body", "=", "{", "\"namespace\"", ":", "names...
Create a new FireCloud Workspace. Args: namespace (str): project to which workspace belongs name (str): Workspace name protected (bool): If True, this workspace is protected by dbGaP credentials. This option is only available if your FireCloud account is linked to your NIH account. attributes (dict): Workspace attributes as key value pairs Swagger: https://api.firecloud.org/#!/Workspaces/createWorkspace
[ "Create", "a", "new", "FireCloud", "Workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1141-L1171
train
38,865
broadinstitute/fiss
firecloud/api.py
update_workspace_acl
def update_workspace_acl(namespace, workspace, acl_updates, invite_users_not_found=False): """Update workspace access control list. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name acl_updates (list(dict)): Acl updates as dicts with two keys: "email" - Firecloud user email "accessLevel" - one of "OWNER", "READER", "WRITER", "NO ACCESS" Example: {"email":"user1@mail.com", "accessLevel":"WRITER"} invite_users_not_found (bool): true to invite unregistered users, false to ignore Swagger: https://api.firecloud.org/#!/Workspaces/updateWorkspaceACL """ uri = "{0}workspaces/{1}/{2}/acl?inviteUsersNotFound={3}".format(fcconfig.root_url, namespace, workspace, str(invite_users_not_found).lower()) headers = _fiss_agent_header({"Content-type": "application/json"}) # FIXME: create __patch method, akin to __get, __delete etc return __SESSION.patch(uri, headers=headers, data=json.dumps(acl_updates))
python
def update_workspace_acl(namespace, workspace, acl_updates, invite_users_not_found=False): """Update workspace access control list. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name acl_updates (list(dict)): Acl updates as dicts with two keys: "email" - Firecloud user email "accessLevel" - one of "OWNER", "READER", "WRITER", "NO ACCESS" Example: {"email":"user1@mail.com", "accessLevel":"WRITER"} invite_users_not_found (bool): true to invite unregistered users, false to ignore Swagger: https://api.firecloud.org/#!/Workspaces/updateWorkspaceACL """ uri = "{0}workspaces/{1}/{2}/acl?inviteUsersNotFound={3}".format(fcconfig.root_url, namespace, workspace, str(invite_users_not_found).lower()) headers = _fiss_agent_header({"Content-type": "application/json"}) # FIXME: create __patch method, akin to __get, __delete etc return __SESSION.patch(uri, headers=headers, data=json.dumps(acl_updates))
[ "def", "update_workspace_acl", "(", "namespace", ",", "workspace", ",", "acl_updates", ",", "invite_users_not_found", "=", "False", ")", ":", "uri", "=", "\"{0}workspaces/{1}/{2}/acl?inviteUsersNotFound={3}\"", ".", "format", "(", "fcconfig", ".", "root_url", ",", "na...
Update workspace access control list. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name acl_updates (list(dict)): Acl updates as dicts with two keys: "email" - Firecloud user email "accessLevel" - one of "OWNER", "READER", "WRITER", "NO ACCESS" Example: {"email":"user1@mail.com", "accessLevel":"WRITER"} invite_users_not_found (bool): true to invite unregistered users, false to ignore Swagger: https://api.firecloud.org/#!/Workspaces/updateWorkspaceACL
[ "Update", "workspace", "access", "control", "list", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1214-L1233
train
38,866
broadinstitute/fiss
firecloud/api.py
clone_workspace
def clone_workspace(from_namespace, from_workspace, to_namespace, to_workspace, authorizationDomain=""): """Clone a FireCloud workspace. A clone is a shallow copy of a FireCloud workspace, enabling easy sharing of data, such as TCGA data, without duplication. Args: from_namespace (str): project (namespace) to which source workspace belongs from_workspace (str): Source workspace's name to_namespace (str): project to which target workspace belongs to_workspace (str): Target workspace's name authorizationDomain: (str) required authorization domains Swagger: https://api.firecloud.org/#!/Workspaces/cloneWorkspace """ if authorizationDomain: if isinstance(authorizationDomain, string_types): authDomain = [{"membersGroupName": authorizationDomain}] else: authDomain = [{"membersGroupName": authDomain} for authDomain in authorizationDomain] else: authDomain = [] body = { "namespace": to_namespace, "name": to_workspace, "attributes": dict(), "authorizationDomain": authDomain, } uri = "workspaces/{0}/{1}/clone".format(from_namespace, from_workspace) return __post(uri, json=body)
python
def clone_workspace(from_namespace, from_workspace, to_namespace, to_workspace, authorizationDomain=""): """Clone a FireCloud workspace. A clone is a shallow copy of a FireCloud workspace, enabling easy sharing of data, such as TCGA data, without duplication. Args: from_namespace (str): project (namespace) to which source workspace belongs from_workspace (str): Source workspace's name to_namespace (str): project to which target workspace belongs to_workspace (str): Target workspace's name authorizationDomain: (str) required authorization domains Swagger: https://api.firecloud.org/#!/Workspaces/cloneWorkspace """ if authorizationDomain: if isinstance(authorizationDomain, string_types): authDomain = [{"membersGroupName": authorizationDomain}] else: authDomain = [{"membersGroupName": authDomain} for authDomain in authorizationDomain] else: authDomain = [] body = { "namespace": to_namespace, "name": to_workspace, "attributes": dict(), "authorizationDomain": authDomain, } uri = "workspaces/{0}/{1}/clone".format(from_namespace, from_workspace) return __post(uri, json=body)
[ "def", "clone_workspace", "(", "from_namespace", ",", "from_workspace", ",", "to_namespace", ",", "to_workspace", ",", "authorizationDomain", "=", "\"\"", ")", ":", "if", "authorizationDomain", ":", "if", "isinstance", "(", "authorizationDomain", ",", "string_types", ...
Clone a FireCloud workspace. A clone is a shallow copy of a FireCloud workspace, enabling easy sharing of data, such as TCGA data, without duplication. Args: from_namespace (str): project (namespace) to which source workspace belongs from_workspace (str): Source workspace's name to_namespace (str): project to which target workspace belongs to_workspace (str): Target workspace's name authorizationDomain: (str) required authorization domains Swagger: https://api.firecloud.org/#!/Workspaces/cloneWorkspace
[ "Clone", "a", "FireCloud", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1235-L1269
train
38,867
broadinstitute/fiss
firecloud/api.py
update_workspace_attributes
def update_workspace_attributes(namespace, workspace, attrs): """Update or remove workspace attributes. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name attrs (list(dict)): List of update operations for workspace attributes. Use the helper dictionary construction functions to create these: _attr_set() : Set/Update attribute _attr_rem() : Remove attribute _attr_ladd() : Add list member to attribute _attr_lrem() : Remove list member from attribute Swagger: https://api.firecloud.org/#!/Workspaces/updateAttributes """ headers = _fiss_agent_header({"Content-type": "application/json"}) uri = "{0}workspaces/{1}/{2}/updateAttributes".format(fcconfig.root_url, namespace, workspace) body = json.dumps(attrs) # FIXME: create __patch method, akin to __get, __delete etc return __SESSION.patch(uri, headers=headers, data=body)
python
def update_workspace_attributes(namespace, workspace, attrs): """Update or remove workspace attributes. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name attrs (list(dict)): List of update operations for workspace attributes. Use the helper dictionary construction functions to create these: _attr_set() : Set/Update attribute _attr_rem() : Remove attribute _attr_ladd() : Add list member to attribute _attr_lrem() : Remove list member from attribute Swagger: https://api.firecloud.org/#!/Workspaces/updateAttributes """ headers = _fiss_agent_header({"Content-type": "application/json"}) uri = "{0}workspaces/{1}/{2}/updateAttributes".format(fcconfig.root_url, namespace, workspace) body = json.dumps(attrs) # FIXME: create __patch method, akin to __get, __delete etc return __SESSION.patch(uri, headers=headers, data=body)
[ "def", "update_workspace_attributes", "(", "namespace", ",", "workspace", ",", "attrs", ")", ":", "headers", "=", "_fiss_agent_header", "(", "{", "\"Content-type\"", ":", "\"application/json\"", "}", ")", "uri", "=", "\"{0}workspaces/{1}/{2}/updateAttributes\"", ".", ...
Update or remove workspace attributes. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name attrs (list(dict)): List of update operations for workspace attributes. Use the helper dictionary construction functions to create these: _attr_set() : Set/Update attribute _attr_rem() : Remove attribute _attr_ladd() : Add list member to attribute _attr_lrem() : Remove list member from attribute Swagger: https://api.firecloud.org/#!/Workspaces/updateAttributes
[ "Update", "or", "remove", "workspace", "attributes", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1302-L1325
train
38,868
broadinstitute/fiss
firecloud/api.py
add_user_to_group
def add_user_to_group(group, role, email): """Add a user to a group the caller owns Args: group (str): Group name role (str) : Role of user for group; either 'member' or 'admin' email (str): Email of user or group to add Swagger: https://api.firecloud.org/#!/Groups/addUserToGroup """ uri = "groups/{0}/{1}/{2}".format(group, role, email) return __put(uri)
python
def add_user_to_group(group, role, email): """Add a user to a group the caller owns Args: group (str): Group name role (str) : Role of user for group; either 'member' or 'admin' email (str): Email of user or group to add Swagger: https://api.firecloud.org/#!/Groups/addUserToGroup """ uri = "groups/{0}/{1}/{2}".format(group, role, email) return __put(uri)
[ "def", "add_user_to_group", "(", "group", ",", "role", ",", "email", ")", ":", "uri", "=", "\"groups/{0}/{1}/{2}\"", ".", "format", "(", "group", ",", "role", ",", "email", ")", "return", "__put", "(", "uri", ")" ]
Add a user to a group the caller owns Args: group (str): Group name role (str) : Role of user for group; either 'member' or 'admin' email (str): Email of user or group to add Swagger: https://api.firecloud.org/#!/Groups/addUserToGroup
[ "Add", "a", "user", "to", "a", "group", "the", "caller", "owns" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1408-L1420
train
38,869
broadinstitute/fiss
firecloud/api.py
remove_user_from_group
def remove_user_from_group(group, role, email): """Remove a user from a group the caller owns Args: group (str): Group name role (str) : Role of user for group; either 'member' or 'admin' email (str): Email of user or group to remove Swagger: https://api.firecloud.org/#!/Groups/removeUserFromGroup """ uri = "groups/{0}/{1}/{2}".format(group, role, email) return __delete(uri)
python
def remove_user_from_group(group, role, email): """Remove a user from a group the caller owns Args: group (str): Group name role (str) : Role of user for group; either 'member' or 'admin' email (str): Email of user or group to remove Swagger: https://api.firecloud.org/#!/Groups/removeUserFromGroup """ uri = "groups/{0}/{1}/{2}".format(group, role, email) return __delete(uri)
[ "def", "remove_user_from_group", "(", "group", ",", "role", ",", "email", ")", ":", "uri", "=", "\"groups/{0}/{1}/{2}\"", ".", "format", "(", "group", ",", "role", ",", "email", ")", "return", "__delete", "(", "uri", ")" ]
Remove a user from a group the caller owns Args: group (str): Group name role (str) : Role of user for group; either 'member' or 'admin' email (str): Email of user or group to remove Swagger: https://api.firecloud.org/#!/Groups/removeUserFromGroup
[ "Remove", "a", "user", "from", "a", "group", "the", "caller", "owns" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1422-L1434
train
38,870
broadinstitute/fiss
plugins/dev_plugin.py
GDACFissfcPlugin.register_commands
def register_commands(self, subparsers): """ Add commands to a list of subparsers. This will be called by Fissfc to add additional command targets from this plugin. Each command added should follow the pattern: parser = subparsers.add_parser('cmd', ...) parser.add_argument(...) ... parser.set_defaults(func=do_my_cmd) where do_my_cmd is a function that takes one argument "args": def do_my_cmd(args): pass """ #print_("DEV PLUGIN: Loaded commands") prsr = subparsers.add_parser( 'upload', description='Copy the file or directory into the given') prsr.add_argument('workspace', help='Workspace name') prsr.add_argument('source', help='File or directory to upload') prsr.add_argument('-s', '--show', action='store_true', help="Show the gsutil command, but don't run it") dest_help = 'Destination relative to the bucket root. ' dest_help += 'If omitted the file will be placed in the root directory' prsr.add_argument('-d', '--destination', help=dest_help) prsr.set_defaults(func=upload)
python
def register_commands(self, subparsers): """ Add commands to a list of subparsers. This will be called by Fissfc to add additional command targets from this plugin. Each command added should follow the pattern: parser = subparsers.add_parser('cmd', ...) parser.add_argument(...) ... parser.set_defaults(func=do_my_cmd) where do_my_cmd is a function that takes one argument "args": def do_my_cmd(args): pass """ #print_("DEV PLUGIN: Loaded commands") prsr = subparsers.add_parser( 'upload', description='Copy the file or directory into the given') prsr.add_argument('workspace', help='Workspace name') prsr.add_argument('source', help='File or directory to upload') prsr.add_argument('-s', '--show', action='store_true', help="Show the gsutil command, but don't run it") dest_help = 'Destination relative to the bucket root. ' dest_help += 'If omitted the file will be placed in the root directory' prsr.add_argument('-d', '--destination', help=dest_help) prsr.set_defaults(func=upload)
[ "def", "register_commands", "(", "self", ",", "subparsers", ")", ":", "#print_(\"DEV PLUGIN: Loaded commands\")", "prsr", "=", "subparsers", ".", "add_parser", "(", "'upload'", ",", "description", "=", "'Copy the file or directory into the given'", ")", "prsr", ".", "ad...
Add commands to a list of subparsers. This will be called by Fissfc to add additional command targets from this plugin. Each command added should follow the pattern: parser = subparsers.add_parser('cmd', ...) parser.add_argument(...) ... parser.set_defaults(func=do_my_cmd) where do_my_cmd is a function that takes one argument "args": def do_my_cmd(args): pass
[ "Add", "commands", "to", "a", "list", "of", "subparsers", ".", "This", "will", "be", "called", "by", "Fissfc", "to", "add", "additional", "command", "targets", "from", "this", "plugin", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/plugins/dev_plugin.py#L21-L52
train
38,871
broadinstitute/fiss
firecloud/method.py
Method.new
def new(namespace, name, wdl, synopsis, documentation=None, api_url=fapi.PROD_API_ROOT): """Create new FireCloud method. If the namespace + name already exists, a new snapshot is created. Args: namespace (str): Method namespace for this method name (str): Method name wdl (file): WDL description synopsis (str): Short description of task documentation (file): Extra documentation for method """ r = fapi.update_workflow(namespace, name, synopsis, wdl, documentation, api_url) fapi._check_response_code(r, 201) d = r.json() return Method(namespace, name, d["snapshotId"])
python
def new(namespace, name, wdl, synopsis, documentation=None, api_url=fapi.PROD_API_ROOT): """Create new FireCloud method. If the namespace + name already exists, a new snapshot is created. Args: namespace (str): Method namespace for this method name (str): Method name wdl (file): WDL description synopsis (str): Short description of task documentation (file): Extra documentation for method """ r = fapi.update_workflow(namespace, name, synopsis, wdl, documentation, api_url) fapi._check_response_code(r, 201) d = r.json() return Method(namespace, name, d["snapshotId"])
[ "def", "new", "(", "namespace", ",", "name", ",", "wdl", ",", "synopsis", ",", "documentation", "=", "None", ",", "api_url", "=", "fapi", ".", "PROD_API_ROOT", ")", ":", "r", "=", "fapi", ".", "update_workflow", "(", "namespace", ",", "name", ",", "syn...
Create new FireCloud method. If the namespace + name already exists, a new snapshot is created. Args: namespace (str): Method namespace for this method name (str): Method name wdl (file): WDL description synopsis (str): Short description of task documentation (file): Extra documentation for method
[ "Create", "new", "FireCloud", "method", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/method.py#L36-L53
train
38,872
broadinstitute/fiss
firecloud/method.py
Method.template
def template(self): """Return a method template for this method.""" r = fapi.get_config_template(self.namespace, self.name, self.snapshot_id, self.api_url) fapi._check_response_code(r, 200) return r.json()
python
def template(self): """Return a method template for this method.""" r = fapi.get_config_template(self.namespace, self.name, self.snapshot_id, self.api_url) fapi._check_response_code(r, 200) return r.json()
[ "def", "template", "(", "self", ")", ":", "r", "=", "fapi", ".", "get_config_template", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "snapshot_id", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", ...
Return a method template for this method.
[ "Return", "a", "method", "template", "for", "this", "method", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/method.py#L55-L60
train
38,873
broadinstitute/fiss
firecloud/method.py
Method.inputs_outputs
def inputs_outputs(self): """Get information on method inputs & outputs.""" r = fapi.get_inputs_outputs(self.namespace, self.name, self.snapshot_id, self.api_url) fapi._check_response_code(r, 200) return r.json()
python
def inputs_outputs(self): """Get information on method inputs & outputs.""" r = fapi.get_inputs_outputs(self.namespace, self.name, self.snapshot_id, self.api_url) fapi._check_response_code(r, 200) return r.json()
[ "def", "inputs_outputs", "(", "self", ")", ":", "r", "=", "fapi", ".", "get_inputs_outputs", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "snapshot_id", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", ...
Get information on method inputs & outputs.
[ "Get", "information", "on", "method", "inputs", "&", "outputs", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/method.py#L62-L67
train
38,874
broadinstitute/fiss
firecloud/method.py
Method.acl
def acl(self): """Get the access control list for this method.""" r = fapi.get_repository_method_acl( self.namespace, self.name, self.snapshot_id, self.api_url) fapi._check_response_code(r, 200) return r.json()
python
def acl(self): """Get the access control list for this method.""" r = fapi.get_repository_method_acl( self.namespace, self.name, self.snapshot_id, self.api_url) fapi._check_response_code(r, 200) return r.json()
[ "def", "acl", "(", "self", ")", ":", "r", "=", "fapi", ".", "get_repository_method_acl", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "snapshot_id", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(",...
Get the access control list for this method.
[ "Get", "the", "access", "control", "list", "for", "this", "method", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/method.py#L69-L74
train
38,875
broadinstitute/fiss
firecloud/method.py
Method.set_acl
def set_acl(self, role, users): """Set permissions for this method. Args: role (str): Access level one of {one of "OWNER", "READER", "WRITER", "NO ACCESS"} users (list(str)): List of users to give role to """ acl_updates = [{"user": user, "role": role} for user in users] r = fapi.update_repository_method_acl( self.namespace, self.name, self.snapshot_id, acl_updates, self.api_url ) fapi._check_response_code(r, 200)
python
def set_acl(self, role, users): """Set permissions for this method. Args: role (str): Access level one of {one of "OWNER", "READER", "WRITER", "NO ACCESS"} users (list(str)): List of users to give role to """ acl_updates = [{"user": user, "role": role} for user in users] r = fapi.update_repository_method_acl( self.namespace, self.name, self.snapshot_id, acl_updates, self.api_url ) fapi._check_response_code(r, 200)
[ "def", "set_acl", "(", "self", ",", "role", ",", "users", ")", ":", "acl_updates", "=", "[", "{", "\"user\"", ":", "user", ",", "\"role\"", ":", "role", "}", "for", "user", "in", "users", "]", "r", "=", "fapi", ".", "update_repository_method_acl", "(",...
Set permissions for this method. Args: role (str): Access level one of {one of "OWNER", "READER", "WRITER", "NO ACCESS"} users (list(str)): List of users to give role to
[ "Set", "permissions", "for", "this", "method", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/method.py#L76-L89
train
38,876
broadinstitute/fiss
firecloud/workspace.py
Workspace.new
def new(namespace, name, protected=False, attributes=dict(), api_url=fapi.PROD_API_ROOT): """Create a new FireCloud workspace. Returns: Workspace: A new FireCloud workspace Raises: FireCloudServerError: API call failed. """ r = fapi.create_workspace(namespace, name, protected, attributes, api_url) fapi._check_response_code(r, 201) return Workspace(namespace, name, api_url)
python
def new(namespace, name, protected=False, attributes=dict(), api_url=fapi.PROD_API_ROOT): """Create a new FireCloud workspace. Returns: Workspace: A new FireCloud workspace Raises: FireCloudServerError: API call failed. """ r = fapi.create_workspace(namespace, name, protected, attributes, api_url) fapi._check_response_code(r, 201) return Workspace(namespace, name, api_url)
[ "def", "new", "(", "namespace", ",", "name", ",", "protected", "=", "False", ",", "attributes", "=", "dict", "(", ")", ",", "api_url", "=", "fapi", ".", "PROD_API_ROOT", ")", ":", "r", "=", "fapi", ".", "create_workspace", "(", "namespace", ",", "name"...
Create a new FireCloud workspace. Returns: Workspace: A new FireCloud workspace Raises: FireCloudServerError: API call failed.
[ "Create", "a", "new", "FireCloud", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L42-L54
train
38,877
broadinstitute/fiss
firecloud/workspace.py
Workspace.refresh
def refresh(self): """Reload workspace metadata from firecloud. Workspace metadata is cached in the data attribute of a Workspace, and may become stale, requiring a refresh(). """ r = fapi.get_workspace(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) self.data = r.json() return self
python
def refresh(self): """Reload workspace metadata from firecloud. Workspace metadata is cached in the data attribute of a Workspace, and may become stale, requiring a refresh(). """ r = fapi.get_workspace(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) self.data = r.json() return self
[ "def", "refresh", "(", "self", ")", ":", "r", "=", "fapi", ".", "get_workspace", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "self", ".", ...
Reload workspace metadata from firecloud. Workspace metadata is cached in the data attribute of a Workspace, and may become stale, requiring a refresh().
[ "Reload", "workspace", "metadata", "from", "firecloud", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L56-L65
train
38,878
broadinstitute/fiss
firecloud/workspace.py
Workspace.delete
def delete(self): """Delete the workspace from FireCloud. Note: This action cannot be undone. Be careful! """ r = fapi.delete_workspace(self.namespace, self.name) fapi._check_response_code(r, 202)
python
def delete(self): """Delete the workspace from FireCloud. Note: This action cannot be undone. Be careful! """ r = fapi.delete_workspace(self.namespace, self.name) fapi._check_response_code(r, 202)
[ "def", "delete", "(", "self", ")", ":", "r", "=", "fapi", ".", "delete_workspace", "(", "self", ".", "namespace", ",", "self", ".", "name", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "202", ")" ]
Delete the workspace from FireCloud. Note: This action cannot be undone. Be careful!
[ "Delete", "the", "workspace", "from", "FireCloud", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L67-L74
train
38,879
broadinstitute/fiss
firecloud/workspace.py
Workspace.lock
def lock(self): """Lock this Workspace. This causes the workspace to behave in a read-only way, regardless of access permissions. """ r = fapi.lock_workspace(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 204) self.data['workspace']['isLocked'] = True return self
python
def lock(self): """Lock this Workspace. This causes the workspace to behave in a read-only way, regardless of access permissions. """ r = fapi.lock_workspace(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 204) self.data['workspace']['isLocked'] = True return self
[ "def", "lock", "(", "self", ")", ":", "r", "=", "fapi", ".", "lock_workspace", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "204", ")", "self", ".", "...
Lock this Workspace. This causes the workspace to behave in a read-only way, regardless of access permissions.
[ "Lock", "this", "Workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L85-L94
train
38,880
broadinstitute/fiss
firecloud/workspace.py
Workspace.unlock
def unlock(self): """Unlock this Workspace.""" r = fapi.unlock_workspace(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 204) self.data['workspace']['isLocked'] = False return self
python
def unlock(self): """Unlock this Workspace.""" r = fapi.unlock_workspace(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 204) self.data['workspace']['isLocked'] = False return self
[ "def", "unlock", "(", "self", ")", ":", "r", "=", "fapi", ".", "unlock_workspace", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "204", ")", "self", ".",...
Unlock this Workspace.
[ "Unlock", "this", "Workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L96-L101
train
38,881
broadinstitute/fiss
firecloud/workspace.py
Workspace.update_attribute
def update_attribute(self, attr, value): """Set the value of a workspace attribute.""" update = [fapi._attr_up(attr, value)] r = fapi.update_workspace_attributes(self.namespace, self.name, update, self.api_url) fapi._check_response_code(r, 200)
python
def update_attribute(self, attr, value): """Set the value of a workspace attribute.""" update = [fapi._attr_up(attr, value)] r = fapi.update_workspace_attributes(self.namespace, self.name, update, self.api_url) fapi._check_response_code(r, 200)
[ "def", "update_attribute", "(", "self", ",", "attr", ",", "value", ")", ":", "update", "=", "[", "fapi", ".", "_attr_up", "(", "attr", ",", "value", ")", "]", "r", "=", "fapi", ".", "update_workspace_attributes", "(", "self", ".", "namespace", ",", "se...
Set the value of a workspace attribute.
[ "Set", "the", "value", "of", "a", "workspace", "attribute", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L114-L119
train
38,882
broadinstitute/fiss
firecloud/workspace.py
Workspace.remove_attribute
def remove_attribute(self, attr): """Remove attribute from a workspace. Args: attr (str): attribute name """ update = [fapi._attr_rem(attr)] r = fapi.update_workspace_attributes(self.namespace, self.name, update, self.api_url) self.data["workspace"]["attributes"].pop(attr, None) fapi._check_response_code(r, 200)
python
def remove_attribute(self, attr): """Remove attribute from a workspace. Args: attr (str): attribute name """ update = [fapi._attr_rem(attr)] r = fapi.update_workspace_attributes(self.namespace, self.name, update, self.api_url) self.data["workspace"]["attributes"].pop(attr, None) fapi._check_response_code(r, 200)
[ "def", "remove_attribute", "(", "self", ",", "attr", ")", ":", "update", "=", "[", "fapi", ".", "_attr_rem", "(", "attr", ")", "]", "r", "=", "fapi", ".", "update_workspace_attributes", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "upd...
Remove attribute from a workspace. Args: attr (str): attribute name
[ "Remove", "attribute", "from", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L121-L131
train
38,883
broadinstitute/fiss
firecloud/workspace.py
Workspace.import_tsv
def import_tsv(self, tsv_file): """Upload entity data to workspace from tsv loadfile. Args: tsv_file (file): Tab-delimited file of entity data """ r = fapi.upload_entities_tsv(self.namespace, self.name, self.tsv_file, self.api_url) fapi._check_response_code(r, 201)
python
def import_tsv(self, tsv_file): """Upload entity data to workspace from tsv loadfile. Args: tsv_file (file): Tab-delimited file of entity data """ r = fapi.upload_entities_tsv(self.namespace, self.name, self.tsv_file, self.api_url) fapi._check_response_code(r, 201)
[ "def", "import_tsv", "(", "self", ",", "tsv_file", ")", ":", "r", "=", "fapi", ".", "upload_entities_tsv", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "tsv_file", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_res...
Upload entity data to workspace from tsv loadfile. Args: tsv_file (file): Tab-delimited file of entity data
[ "Upload", "entity", "data", "to", "workspace", "from", "tsv", "loadfile", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L133-L141
train
38,884
broadinstitute/fiss
firecloud/workspace.py
Workspace.get_entity
def get_entity(self, etype, entity_id): """Return entity in this workspace. Args: etype (str): Entity type entity_id (str): Entity name/unique id """ r = fapi.get_entity(self.namespace, self.name, etype, entity_id, self.api_url) fapi._check_response_code(r, 200) dresp = r.json() return Entity(etype, entity_id, dresp['attributes'])
python
def get_entity(self, etype, entity_id): """Return entity in this workspace. Args: etype (str): Entity type entity_id (str): Entity name/unique id """ r = fapi.get_entity(self.namespace, self.name, etype, entity_id, self.api_url) fapi._check_response_code(r, 200) dresp = r.json() return Entity(etype, entity_id, dresp['attributes'])
[ "def", "get_entity", "(", "self", ",", "etype", ",", "entity_id", ")", ":", "r", "=", "fapi", ".", "get_entity", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "etype", ",", "entity_id", ",", "self", ".", "api_url", ")", "fapi", ".", ...
Return entity in this workspace. Args: etype (str): Entity type entity_id (str): Entity name/unique id
[ "Return", "entity", "in", "this", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L143-L154
train
38,885
broadinstitute/fiss
firecloud/workspace.py
Workspace.delete_entity
def delete_entity(self, etype, entity_id): """Delete an entity in this workspace. Args: etype (str): Entity type entity_id (str): Entity name/unique id """ r = fapi.delete_entity(self.namespace, self.name, etype, entity_id, self.api_url) fapi._check_response_code(r, 202)
python
def delete_entity(self, etype, entity_id): """Delete an entity in this workspace. Args: etype (str): Entity type entity_id (str): Entity name/unique id """ r = fapi.delete_entity(self.namespace, self.name, etype, entity_id, self.api_url) fapi._check_response_code(r, 202)
[ "def", "delete_entity", "(", "self", ",", "etype", ",", "entity_id", ")", ":", "r", "=", "fapi", ".", "delete_entity", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "etype", ",", "entity_id", ",", "self", ".", "api_url", ")", "fapi", ...
Delete an entity in this workspace. Args: etype (str): Entity type entity_id (str): Entity name/unique id
[ "Delete", "an", "entity", "in", "this", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L156-L165
train
38,886
broadinstitute/fiss
firecloud/workspace.py
Workspace.import_entities
def import_entities(self, entities): """Upload entity objects. Args: entities: iterable of firecloud.Entity objects. """ edata = Entity.create_payload(entities) r = fapi.upload_entities(self.namespace, self.name, edata, self.api_url) fapi._check_response_code(r, 201)
python
def import_entities(self, entities): """Upload entity objects. Args: entities: iterable of firecloud.Entity objects. """ edata = Entity.create_payload(entities) r = fapi.upload_entities(self.namespace, self.name, edata, self.api_url) fapi._check_response_code(r, 201)
[ "def", "import_entities", "(", "self", ",", "entities", ")", ":", "edata", "=", "Entity", ".", "create_payload", "(", "entities", ")", "r", "=", "fapi", ".", "upload_entities", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "edata", ",", ...
Upload entity objects. Args: entities: iterable of firecloud.Entity objects.
[ "Upload", "entity", "objects", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L167-L176
train
38,887
broadinstitute/fiss
firecloud/workspace.py
Workspace.create_set
def create_set(self, set_id, etype, entities): """Create a set of entities and upload to FireCloud. Args etype (str): one of {"sample, "pair", "participant"} entities: iterable of firecloud.Entity objects. """ if etype not in {"sample", "pair", "participant"}: raise ValueError("Unsupported entity type:" + str(etype)) payload = "membership:" + etype + "_set_id\t" + etype + "_id\n" for e in entities: if e.etype != etype: msg = "Entity type '" + e.etype + "' does not match " msg += "set type '" + etype + "'" raise ValueError(msg) payload += set_id + '\t' + e.entity_id + '\n' r = fapi.upload_entities(self.namespace, self.name, payload, self.api_url) fapi._check_response_code(r, 201)
python
def create_set(self, set_id, etype, entities): """Create a set of entities and upload to FireCloud. Args etype (str): one of {"sample, "pair", "participant"} entities: iterable of firecloud.Entity objects. """ if etype not in {"sample", "pair", "participant"}: raise ValueError("Unsupported entity type:" + str(etype)) payload = "membership:" + etype + "_set_id\t" + etype + "_id\n" for e in entities: if e.etype != etype: msg = "Entity type '" + e.etype + "' does not match " msg += "set type '" + etype + "'" raise ValueError(msg) payload += set_id + '\t' + e.entity_id + '\n' r = fapi.upload_entities(self.namespace, self.name, payload, self.api_url) fapi._check_response_code(r, 201)
[ "def", "create_set", "(", "self", ",", "set_id", ",", "etype", ",", "entities", ")", ":", "if", "etype", "not", "in", "{", "\"sample\"", ",", "\"pair\"", ",", "\"participant\"", "}", ":", "raise", "ValueError", "(", "\"Unsupported entity type:\"", "+", "str"...
Create a set of entities and upload to FireCloud. Args etype (str): one of {"sample, "pair", "participant"} entities: iterable of firecloud.Entity objects.
[ "Create", "a", "set", "of", "entities", "and", "upload", "to", "FireCloud", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L178-L200
train
38,888
broadinstitute/fiss
firecloud/workspace.py
Workspace.submissions
def submissions(self): """List job submissions in workspace.""" r = fapi.get_submissions(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) return r.json()
python
def submissions(self): """List job submissions in workspace.""" r = fapi.get_submissions(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) return r.json()
[ "def", "submissions", "(", "self", ")", ":", "r", "=", "fapi", ".", "get_submissions", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "return", ...
List job submissions in workspace.
[ "List", "job", "submissions", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L214-L218
train
38,889
broadinstitute/fiss
firecloud/workspace.py
Workspace.entity_types
def entity_types(self): """List entity types in workspace.""" r = fapi.get_entity_types(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) return r.json().keys()
python
def entity_types(self): """List entity types in workspace.""" r = fapi.get_entity_types(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) return r.json().keys()
[ "def", "entity_types", "(", "self", ")", ":", "r", "=", "fapi", ".", "get_entity_types", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "return"...
List entity types in workspace.
[ "List", "entity", "types", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L220-L224
train
38,890
broadinstitute/fiss
firecloud/workspace.py
Workspace.entities
def entities(self): """List all entities in workspace.""" r = fapi.get_entities_with_type(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) edicts = r.json() return [Entity(e['entityType'], e['name'], e['attributes']) for e in edicts]
python
def entities(self): """List all entities in workspace.""" r = fapi.get_entities_with_type(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) edicts = r.json() return [Entity(e['entityType'], e['name'], e['attributes']) for e in edicts]
[ "def", "entities", "(", "self", ")", ":", "r", "=", "fapi", ".", "get_entities_with_type", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "edict...
List all entities in workspace.
[ "List", "all", "entities", "in", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L226-L233
train
38,891
broadinstitute/fiss
firecloud/workspace.py
Workspace.__get_entities
def __get_entities(self, etype): """Helper to get entities for a given type.""" r = fapi.get_entities(self.namespace, self.name, etype, self.api_url) fapi._check_response_code(r, 200) return [Entity(e['entityType'], e['name'], e['attributes']) for e in r.json()]
python
def __get_entities(self, etype): """Helper to get entities for a given type.""" r = fapi.get_entities(self.namespace, self.name, etype, self.api_url) fapi._check_response_code(r, 200) return [Entity(e['entityType'], e['name'], e['attributes']) for e in r.json()]
[ "def", "__get_entities", "(", "self", ",", "etype", ")", ":", "r", "=", "fapi", ".", "get_entities", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "etype", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r",...
Helper to get entities for a given type.
[ "Helper", "to", "get", "entities", "for", "a", "given", "type", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L235-L241
train
38,892
broadinstitute/fiss
firecloud/workspace.py
Workspace.copy_entities
def copy_entities(self, from_namespace, from_workspace, etype, enames): """Copy entities from another workspace. Args: from_namespace (str): Source workspace namespace from_workspace (str): Source workspace name etype (str): Entity type enames (list(str)): List of entity names to copy """ r = fapi.copy_entities(from_namespace, from_workspace, self.namespace, self.name, etype, enames, self.api_url) fapi._check_response_code(r, 201)
python
def copy_entities(self, from_namespace, from_workspace, etype, enames): """Copy entities from another workspace. Args: from_namespace (str): Source workspace namespace from_workspace (str): Source workspace name etype (str): Entity type enames (list(str)): List of entity names to copy """ r = fapi.copy_entities(from_namespace, from_workspace, self.namespace, self.name, etype, enames, self.api_url) fapi._check_response_code(r, 201)
[ "def", "copy_entities", "(", "self", ",", "from_namespace", ",", "from_workspace", ",", "etype", ",", "enames", ")", ":", "r", "=", "fapi", ".", "copy_entities", "(", "from_namespace", ",", "from_workspace", ",", "self", ".", "namespace", ",", "self", ".", ...
Copy entities from another workspace. Args: from_namespace (str): Source workspace namespace from_workspace (str): Source workspace name etype (str): Entity type enames (list(str)): List of entity names to copy
[ "Copy", "entities", "from", "another", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L267-L279
train
38,893
broadinstitute/fiss
firecloud/workspace.py
Workspace.configs
def configs(self): """Get method configurations in a workspace.""" raise NotImplementedError r = fapi.get_configs(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) cdata = r.json() configs = [] for c in cdata: cnamespace = c['namespace'] cname = c['name'] root_etype = c['rootEntityType'] method_namespace = c['methodRepoMethod']['methodNamespace'] method_name = c['methodRepoMethod']['methodName'] method_version = c['methodRepoMethod']['methodVersion']
python
def configs(self): """Get method configurations in a workspace.""" raise NotImplementedError r = fapi.get_configs(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) cdata = r.json() configs = [] for c in cdata: cnamespace = c['namespace'] cname = c['name'] root_etype = c['rootEntityType'] method_namespace = c['methodRepoMethod']['methodNamespace'] method_name = c['methodRepoMethod']['methodName'] method_version = c['methodRepoMethod']['methodVersion']
[ "def", "configs", "(", "self", ")", ":", "raise", "NotImplementedError", "r", "=", "fapi", ".", "get_configs", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r", ",", ...
Get method configurations in a workspace.
[ "Get", "method", "configurations", "in", "a", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L281-L294
train
38,894
broadinstitute/fiss
firecloud/workspace.py
Workspace.acl
def acl(self): """Get the access control list for this workspace.""" r = fapi.get_workspace_acl(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) return r.json()
python
def acl(self): """Get the access control list for this workspace.""" r = fapi.get_workspace_acl(self.namespace, self.name, self.api_url) fapi._check_response_code(r, 200) return r.json()
[ "def", "acl", "(", "self", ")", ":", "r", "=", "fapi", ".", "get_workspace_acl", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "self", ".", "api_url", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "return", "r",...
Get the access control list for this workspace.
[ "Get", "the", "access", "control", "list", "for", "this", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L296-L300
train
38,895
broadinstitute/fiss
firecloud/workspace.py
Workspace.clone
def clone(self, to_namespace, to_name): """Clone this workspace. Args: to_namespace (str): Target workspace namespace to_name (str): Target workspace name """ r = fapi.clone_workspace(self.namespace, self.name, to_namespace, to_name, self.api_url) fapi._check_response_code(r, 201) return Workspace(to_namespace, to_name, self.api_url)
python
def clone(self, to_namespace, to_name): """Clone this workspace. Args: to_namespace (str): Target workspace namespace to_name (str): Target workspace name """ r = fapi.clone_workspace(self.namespace, self.name, to_namespace, to_name, self.api_url) fapi._check_response_code(r, 201) return Workspace(to_namespace, to_name, self.api_url)
[ "def", "clone", "(", "self", ",", "to_namespace", ",", "to_name", ")", ":", "r", "=", "fapi", ".", "clone_workspace", "(", "self", ".", "namespace", ",", "self", ".", "name", ",", "to_namespace", ",", "to_name", ",", "self", ".", "api_url", ")", "fapi"...
Clone this workspace. Args: to_namespace (str): Target workspace namespace to_name (str): Target workspace name
[ "Clone", "this", "workspace", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L315-L325
train
38,896
broadinstitute/fiss
firecloud/supervisor.py
supervise
def supervise(project, workspace, namespace, workflow, sample_sets, recovery_file): """ Supervise submission of jobs from a Firehose-style workflow of workflows""" # Get arguments logging.info("Initializing FireCloud Supervisor...") logging.info("Saving recovery checkpoints to " + recovery_file) # Parse workflow description # these three objects must be saved in order to recover the supervisor args = { 'project' : project, 'workspace': workspace, 'namespace': namespace, 'workflow' : workflow, 'sample_sets': sample_sets } monitor_data, dependencies = init_supervisor_data(workflow, sample_sets) recovery_data = { 'args' : args, 'monitor_data' : monitor_data, 'dependencies' : dependencies } # Monitor loop. Keep going until all nodes have been evaluated supervise_until_complete(monitor_data, dependencies, args, recovery_file)
python
def supervise(project, workspace, namespace, workflow, sample_sets, recovery_file): """ Supervise submission of jobs from a Firehose-style workflow of workflows""" # Get arguments logging.info("Initializing FireCloud Supervisor...") logging.info("Saving recovery checkpoints to " + recovery_file) # Parse workflow description # these three objects must be saved in order to recover the supervisor args = { 'project' : project, 'workspace': workspace, 'namespace': namespace, 'workflow' : workflow, 'sample_sets': sample_sets } monitor_data, dependencies = init_supervisor_data(workflow, sample_sets) recovery_data = { 'args' : args, 'monitor_data' : monitor_data, 'dependencies' : dependencies } # Monitor loop. Keep going until all nodes have been evaluated supervise_until_complete(monitor_data, dependencies, args, recovery_file)
[ "def", "supervise", "(", "project", ",", "workspace", ",", "namespace", ",", "workflow", ",", "sample_sets", ",", "recovery_file", ")", ":", "# Get arguments", "logging", ".", "info", "(", "\"Initializing FireCloud Supervisor...\"", ")", "logging", ".", "info", "(...
Supervise submission of jobs from a Firehose-style workflow of workflows
[ "Supervise", "submission", "of", "jobs", "from", "a", "Firehose", "-", "style", "workflow", "of", "workflows" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/supervisor.py#L12-L39
train
38,897
broadinstitute/fiss
firecloud/supervisor.py
validate_monitor_tasks
def validate_monitor_tasks(dependencies, args): """ Validate that all entries in the supervisor are valid task configurations and that all permissions requirements are satisfied. """ # Make a list of all task configurations needed to supervise sup_configs = sorted(dependencies.keys()) try: logging.info("Validating supervisor data...") # Make an api call to list task configurations in the workspace r = fapi.list_workspace_configs(args['project'], args['workspace']) fapi._check_response_code(r, 200) space_configs = r.json() # Make a dict for easy lookup later space_configs = { c["name"]: c for c in space_configs} # Also make an api call to list methods you have view permissions for r = fapi.list_repository_methods() fapi._check_response_code(r, 200) repo_methods = r.json() ## Put in a form that is more easily searchable: namespace/name:snapshot repo_methods = {m['namespace'] + '/' + m['name'] + ':' + str(m['snapshotId']) for m in repo_methods if m['entityType'] == 'Workflow'} valid = True for config in sup_configs: # ensure config exists in the workspace if config not in space_configs: logging.error("No task configuration for " + config + " found in " + args['project'] + "/" + args['workspace']) valid = False else: # Check access permissions for the referenced method m = space_configs[config]['methodRepoMethod'] ref_method = m['methodNamespace'] + "/" + m['methodName'] + ":" + str(m['methodVersion']) if ref_method not in repo_methods: logging.error(config+ " -- You don't have permisson to run the referenced method: " + ref_method) valid = False except Exception as e: logging.error("Exception occurred while validating supervisor: " + str(e)) raise return False return valid
python
def validate_monitor_tasks(dependencies, args): """ Validate that all entries in the supervisor are valid task configurations and that all permissions requirements are satisfied. """ # Make a list of all task configurations needed to supervise sup_configs = sorted(dependencies.keys()) try: logging.info("Validating supervisor data...") # Make an api call to list task configurations in the workspace r = fapi.list_workspace_configs(args['project'], args['workspace']) fapi._check_response_code(r, 200) space_configs = r.json() # Make a dict for easy lookup later space_configs = { c["name"]: c for c in space_configs} # Also make an api call to list methods you have view permissions for r = fapi.list_repository_methods() fapi._check_response_code(r, 200) repo_methods = r.json() ## Put in a form that is more easily searchable: namespace/name:snapshot repo_methods = {m['namespace'] + '/' + m['name'] + ':' + str(m['snapshotId']) for m in repo_methods if m['entityType'] == 'Workflow'} valid = True for config in sup_configs: # ensure config exists in the workspace if config not in space_configs: logging.error("No task configuration for " + config + " found in " + args['project'] + "/" + args['workspace']) valid = False else: # Check access permissions for the referenced method m = space_configs[config]['methodRepoMethod'] ref_method = m['methodNamespace'] + "/" + m['methodName'] + ":" + str(m['methodVersion']) if ref_method not in repo_methods: logging.error(config+ " -- You don't have permisson to run the referenced method: " + ref_method) valid = False except Exception as e: logging.error("Exception occurred while validating supervisor: " + str(e)) raise return False return valid
[ "def", "validate_monitor_tasks", "(", "dependencies", ",", "args", ")", ":", "# Make a list of all task configurations needed to supervise", "sup_configs", "=", "sorted", "(", "dependencies", ".", "keys", "(", ")", ")", "try", ":", "logging", ".", "info", "(", "\"Va...
Validate that all entries in the supervisor are valid task configurations and that all permissions requirements are satisfied.
[ "Validate", "that", "all", "entries", "in", "the", "supervisor", "are", "valid", "task", "configurations", "and", "that", "all", "permissions", "requirements", "are", "satisfied", "." ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/supervisor.py#L78-L128
train
38,898
broadinstitute/fiss
firecloud/supervisor.py
recover_and_supervise
def recover_and_supervise(recovery_file): """ Retrieve monitor data from recovery_file and resume monitoring """ try: logging.info("Attempting to recover Supervisor data from " + recovery_file) with open(recovery_file) as rf: recovery_data = json.load(rf) monitor_data = recovery_data['monitor_data'] dependencies = recovery_data['dependencies'] args = recovery_data['args'] except: logging.error("Could not recover monitor data, exiting...") return 1 logging.info("Data successfully loaded, resuming Supervisor") supervise_until_complete(monitor_data, dependencies, args, recovery_file)
python
def recover_and_supervise(recovery_file): """ Retrieve monitor data from recovery_file and resume monitoring """ try: logging.info("Attempting to recover Supervisor data from " + recovery_file) with open(recovery_file) as rf: recovery_data = json.load(rf) monitor_data = recovery_data['monitor_data'] dependencies = recovery_data['dependencies'] args = recovery_data['args'] except: logging.error("Could not recover monitor data, exiting...") return 1 logging.info("Data successfully loaded, resuming Supervisor") supervise_until_complete(monitor_data, dependencies, args, recovery_file)
[ "def", "recover_and_supervise", "(", "recovery_file", ")", ":", "try", ":", "logging", ".", "info", "(", "\"Attempting to recover Supervisor data from \"", "+", "recovery_file", ")", "with", "open", "(", "recovery_file", ")", "as", "rf", ":", "recovery_data", "=", ...
Retrieve monitor data from recovery_file and resume monitoring
[ "Retrieve", "monitor", "data", "from", "recovery_file", "and", "resume", "monitoring" ]
dddf91547479506dbbafb69ec84d44dcc4a94ab4
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/supervisor.py#L130-L145
train
38,899