query stringlengths 9 9.05k | document stringlengths 10 222k | negatives listlengths 19 20 | metadata dict |
|---|---|---|---|
Returns the name of the trust file for the current user. | def trust_file(self):
return base_dir + "store/trust/" + self.user | [
"def pkcs11_get_trust_store_uri(): # real signature unknown; restored from __doc__\n return \"\"",
"def file_share_witness_username(self) -> str:\n return pulumi.get(self, \"file_share_witness_username\")",
"def trust_bundle(self) -> str:\n return typing.cast(\n str,\n sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Asserts that a user trusts this trust_root. Removes the trust entry if trust is TrustDB.APPROVED_ONCE . | def is_trusted(trust_root, by=None):
if by == None: by = web.session.user
trust_db = TrustDB(by)
approval = trust_db[trust_root]
if approval == TrustDB.APPROVED_ONCE:
del trust_db[trust_root]
return approval | [
"def trust(self, trust):\n\n self._trust = trust",
"def test_trust_init_pw(self):\r\n\r\n self._stubs_v2(method='trust')\r\n self.m.ReplayAll()\r\n\r\n self.ctx.auth_token = None\r\n self.ctx.trust_id = 'atrust123'\r\n self.ctx.trustor_user_id = 'trustor_user_id'\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract the username from an identity. | def username_from_identity(identity):
match = username_re.match(identity)
if match != None:
return match.groups()[0]
return None | [
"def get_username_from_openid(self, identity_url):\n try:\n return self._openid[identity_url]\n except KeyError:\n raise KeyError, \"no openID identity '%s'\" % identity_url",
"def _get_username(payload):\n if payload and \"User\" in payload and payload[\"User\"]:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Cleans up sessions every 5 minutes. | def cleanup_sessions():
web.env['com.saddi.service.session']._store.periodic()
threading.Timer(300.0, cleanup_sessions) | [
"def clearExpiredSessions():\n\t# djfacetlog(\"---UTILS/ClearExpiredSessions(): starting\")\n\tfrom django.contrib.sessions.models import Session\n\ttot = Session.objects.count()\n\tif tot > 50:\n\t\tdjfacetlog(\"---UTILS/ClearExpiredSessions(): cleaning table with expired sessions...\")\n\t\timport datetime\n\t\tS... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor. The notification method on the interested object should take one parameter of type C{INotification} | def __init__(self, notifyMethod, notifyContext):
self.notify = None
self.context = None
self.setNotifyMethod(notifyMethod)
self.setNotifyContext(notifyContext) | [
"def _init_notification(self):\n self.notification = notify.Notification(\n 'remind_bedtime bug!', icon='appointment')\n self.notification.set_timeout(notify.EXPIRES_NEVER)\n self.notification.set_urgency(notify.URGENCY_CRITICAL)\n self.notification.set_hint('transient', False... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the notification method. The notification method should take one parameter of type C{INotification}. | def setNotifyMethod(self, notifyMethod):
self.notify = notifyMethod | [
"def getNotifyMethod(self):\n return self.notify",
"def notify(self, **kwargs):\n self.notifiers.notify(**kwargs)",
"def __init__(self, notifyMethod, notifyContext):\n self.notify = None\n self.context = None\n\n self.setNotifyMethod(notifyMethod)\n self.setNotifyContex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the notification context. | def setNotifyContext(self, notifyContext):
self.context = notifyContext | [
"def set_msg_context(self, context):\n self._context = context",
"def set_context(self, context):",
"def set_context(self, context):\n success = win32.SetThreadContext(self.handle, win32.byref(context))\n if not success:\n raise win32.Win32Exception()",
"def set(contextIn):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the notification method. | def getNotifyMethod(self):
return self.notify | [
"def get_method(self, ):\n return self.attrs.get(self.AttributeNames.METHOD, None)",
"def method_name(self) -> str:\n return self.__data[\"method\"]",
"def _get_request_method(self):\n return self._request_method",
"def get_method(self):\n\n if self.is_metric_present():\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the notification context. | def getNotifyContext(self):
return self.context | [
"def context(self):\n return self.__service.context()",
"def get():\n global context\n return context",
"def ctx(self) -> typing.Any:\n id_ = connection_id.get()\n if id_ is ContextNotSet:\n raise RuntimeError(\n \"The .context property is only valid in a con... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compare an object to the notification context. | def compareNotifyContext(self, obj):
return (obj is self.context) | [
"def compare_mlag_object_03_and_object_01(context) -> None:\n\n assert context.object_03 == context.object_01",
"def getNotifyContext(self):\n return self.context",
"def __eq__(self, other: object) -> bool:\n return (\n isinstance(other, PipetteContext) and self._pipette_id == other.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialise the C{INotifier} instance with an empty multiton key | def __init__(self, *args, **kwds):
self.multitonKey = None | [
"def __init__(self, unique_keys_tracker):\n self._unique_keys_tracker = unique_keys_tracker",
"def __init__(self, first_id=1):\n\n self._key_base = first_id\n self._last_id = None",
"def __init__(self):\n self.uid = -1\n self.cid = {}",
"def _initialize_key(model_class, name):\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialize this INotifier instance. This is how a Notifier gets its multitonKey. Calls to sendNotification or to access the facade will fail until after this method has been called. Mediators, Commands or Proxies may override this method in order to send notifications or access the Multiton Facade instance as soon as p... | def initializeNotifier(self, key):
self.multitonKey = key | [
"def __init__(self, *args, **kwds):\n self.multitonKey = None",
"def __init__(self, notifyMethod, notifyContext):\n self.notify = None\n self.context = None\n\n self.setNotifyMethod(notifyMethod)\n self.setNotifyContext(notifyContext)",
"def __init__(self, *args, **kwargs):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the Multiton Facade instance | def facade(self):
key = self.multitonKey
if key is None:
raise MultitonError(self.MULTITON_MSG)
return puremvc.patterns.facade.Facade.getInstance(key) | [
"def shared_muse_instance():\n global _shared_muse_instance\n if not _shared_muse_instance:\n _shared_muse_instance = dct.muse()\n return _shared_muse_instance",
"def getInstance(cls):\r\n if cls._INSTANCE == None:\r\n cls._INSTANCE = cls._FM()\r\n \r\n return cls._INSTANCE"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the string representation of the C{Notification} instance. | def __repr__(self):
bd = "None" if self.body is None else repr(self.body)
ty = "None" if self.type is None else repr(self.type)
msg = "Notification Name: " + self.name
msg += "\nBody:"+bd
msg += "\nType:"+ty
return msg | [
"def message(self): \n if self.content != '':\n return self.content\n else:\n return self.get_notification_type_display()",
"def to_str(self):\n import json\n from JsonEncoder import JSONEncoder\n\n self._add_meta()\n return json.dumps(self.events, c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the body of the C{Notification} instance. | def setBody(self, body):
self.body = body | [
"def setBody(self, body):\n self._body = body",
"def update(self, body):\n self.body = body",
"def setBody(self, body, title='', is_error=False, lock=None):\n # allow locking of the body in the same way as the status\n if self._locked_body:\n return\n elif lock:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the body of the C{Notification} instance. | def getBody(self):
return self.body | [
"def body(self):\n return self.message.get_data()",
"def body(self) -> str:\n return str(self._email.Body)",
"def get_message_body(self):\n body = loader.render_to_string(self.body_template, self.get_rendering_context())\n return body",
"def message(self): \n if self.content... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the type of the C{Notification} instance. | def setType(self, notificationType):
self.type = notificationType | [
"def set_type(self, type):\n return _raw_util.raw_message_set_type(self, type)",
"def set_type(self, type):\n return _raw_util.raw_message_sptr_set_type(self, type)",
"def priority_type(self, priority_type):\n\n self._priority_type = priority_type",
"def notification_time(self, notificati... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use request.config.getoption('ansible_inventory') to the get list of inventory files. The 'ansible_inventory' option could have already been converted to a list by enchance_inventory fixture. | def get_inventory_files(request):
if isinstance(request.config.getoption("ansible_inventory"), list):
# enhance_inventory fixture changes ansible_inventory to a list.
inv_files = request.config.getoption("ansible_inventory")
else:
inv_files = [inv_file.strip() for inv_file in request.con... | [
"def ansible_playbook_options():\n ansible_options = [\n \"--ask-become-pass\", \"--ask-pass\", \"--ask-su-pass\", \"--ask-sudo-pass\",\n \"--ask-vault-pass\", \"--become\", \"--become-method\", \"--become-user\",\n \"--check\", \"--connection\", \"--diff\", \"--extra-vars\", \"--flush-cache... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the parameter passed as argname to function. | def _get_parameter(function, func_args, func_kargs, argname):
args_binding = inspect.getcallargs(function, *func_args, **func_kargs)
return args_binding.get(argname) or args_binding.get("kargs").get(argname) | [
"def getparam(self, parname):\n self.log.warn('GetParam is Decrecated - use GetArg')\n return self.getarg(parname)",
"def getarg(self, arg_name: str) -> Optional[str]:\n return next((val for arg, val in self._args.items() if arg == arg_name), None)",
"def get_arg_name(self, param):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create zone getter function used to retrieve parameter as zone. | def zone_getter_factory(argname):
def _zone_getter(function, func_args, func_kargs):
param = _get_parameter(function, func_args, func_kargs, argname)
if param is None:
raise ValueError("Failed to get parameter '%s' from function %s as zone." % (argname, function))
return param
... | [
"def ex_get_zone(self, name):\r\n if name.startswith('https://'):\r\n short_name = self._get_components_from_path(name)['name']\r\n request = name\r\n else:\r\n short_name = name\r\n request = '/zones/%s' % (name)\r\n # Check zone cache first\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if inventory file matches after read host variable from cached files. | def _check_inv_files_after_read(facts, function, func_args, func_kargs):
if facts is not FactsCache.NOTEXIST:
inv_files = _get_parameter(function, func_args, func_kargs, "inv_files")
if inv_files == facts["inv_files"]:
return facts["vars"]
# no facts cached or facts not in the same i... | [
"def contents_match(self, path):\n checksum = file_hash(path)\n\n kv = unitdata.kv()\n stored_checksum = kv.get('hardening:%s' % path)\n if not stored_checksum:\n # If the checksum hasn't been generated, return False to ensure\n # the file is written and the checksu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use ansible's InventoryManager to get value of variables defined for the specified host in the specified inventory files. | def get_host_vars(inv_files, hostname):
im = get_inventory_manager(inv_files)
host = im.get_host(hostname)
if not host:
logger.error("Unable to find host {} in {}".format(hostname, str(inv_files)))
return None
return host.vars.copy() | [
"def get_host_visible_vars(inv_files, hostname):\n vm = get_variable_manager(inv_files)\n im = vm._inventory\n host = im.get_host(hostname)\n if not host:\n logger.error(\"Unable to find host {} in {}\".format(hostname, str(inv_files)))\n return None\n return vm.get_vars(host=host)",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use ansible's VariableManager and InventoryManager to get value of variables visible to the specified host. The variable could be defined in host_vars or in group_vars that the host belongs to. | def get_host_visible_vars(inv_files, hostname):
vm = get_variable_manager(inv_files)
im = vm._inventory
host = im.get_host(hostname)
if not host:
logger.error("Unable to find host {} in {}".format(hostname, str(inv_files)))
return None
return vm.get_vars(host=host) | [
"def get_host_vars(inv_files, hostname):\n im = get_inventory_manager(inv_files)\n host = im.get_host(hostname)\n if not host:\n logger.error(\"Unable to find host {} in {}\".format(hostname, str(inv_files)))\n return None\n return host.vars.copy()",
"def get_group_visible_vars(inv_files... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use ansible's VariableManager and InventoryManager to get value of variables visible to the first host belongs to the specified group. The variable could be defined in host_vars of the first host or in group_vars that the host belongs to. | def get_group_visible_vars(inv_files, group_name):
vm = get_variable_manager(inv_files)
im = vm._inventory
group = im.groups.get(group_name, None)
if not group:
logger.error("Unable to find group {} in {}".format(group_name, str(inv_files)))
return None
group_hosts = group.get_hosts(... | [
"def get_containers_for_group(inventory, group):\n if 'hosts' in inventory[group]:\n containers = inventory[group]['hosts']\n else:\n containers = None\n return containers",
"def get_variable(self, varname):\n return next((v for v in self.config.data_spec if v['name'] == varname))",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get test server ansible host from the 'server' column in testbed file. | def get_test_server_host(inv_files, server):
vm = get_variable_manager(inv_files)
im = vm._inventory
group = im.groups.get(server, None)
if not group:
logger.error("Unable to find group {} in {}".format(server, str(inv_files)))
return None
for host in group.get_hosts():
if no... | [
"def server_host(self):\n return self.server['host']",
"def get_test_server_vars(inv_files, server):\n host = get_test_server_host(inv_files, server)\n if not host:\n logger.error(\"Unable to find test server host under group {}\".format(server))\n return None\n return host.vars.copy... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use ansible's VariableManager and InventoryManager to get value of variables of test server belong to specified server group. In testbed.csv file, we can get the server name of each test setup under the 'server' column. For example 'server_1', 'server_2', etc. This server name is indeed a group name in used ansible inv... | def get_test_server_vars(inv_files, server):
host = get_test_server_host(inv_files, server)
if not host:
logger.error("Unable to find test server host under group {}".format(server))
return None
return host.vars.copy() | [
"def get_test_server_host(inv_files, server):\n vm = get_variable_manager(inv_files)\n im = vm._inventory\n group = im.groups.get(server, None)\n if not group:\n logger.error(\"Unable to find group {} in {}\".format(server, str(inv_files)))\n return None\n for host in group.get_hosts():... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dump packet show output to string. | def dump_scapy_packet_show_output(packet):
_stdout, sys.stdout = sys.stdout, StringIO()
try:
if six.PY2:
packet.show()
else:
packet.show2()
return sys.stdout.getvalue()
finally:
sys.stdout = _stdout | [
"def inspect_packet(pkt):\n out = None\n backup = sys.stdout\n try:\n tmp = StringIO()\n sys.stdout = tmp\n pkt.show2()\n out = tmp.getvalue()\n tmp.close()\n finally:\n sys.stdout = backup\n return out",
"def op_print(self):\n zstr_address = self._o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deduce interface from sub interface by striping vlan id, if vlan id is not passed, will automatically strip vlan id by finding '.', | def get_intf_by_sub_intf(sub_intf, vlan_id=None):
if type(sub_intf) != str:
sub_intf = str(sub_intf)
if not vlan_id:
idx_of_sub_int_indicator = sub_intf.find(constants.VLAN_SUB_INTERFACE_SEPARATOR)
if idx_of_sub_int_indicator > -1:
return sub_intf[:idx_of_sub_int_indicator]
... | [
"def network_interface(ifname, sysifdir=\"/sys/class/net/\"):\n # only physical and virtual devices are in /sys/class/net/, no aliases\n ifs = [name for name in os.listdir(sysifdir)]\n if ifname not in ifs:\n err = ((\"'%s' isn't a network interface; \"\n \"you probably meant one of: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Replace illegal characters in the original filename with "_" or other specified characters. | def safe_filename(filename, replacement_char='_'):
illegal_chars_pattern = re.compile(r"[#%&{}\\<>\*\?/ \$!'\":@\+`|=]")
return re.sub(illegal_chars_pattern, replacement_char, filename) | [
"def clean_filename(filename, replace='', acceptable_chars=('.', '_')):\n return \"\".join([c if c.isalpha() or c.isdigit() or c in acceptable_chars else replace for c in filename])",
"def regularize_filename(f):\n invalids = r'< > : \" / \\ | ? *'.split(\" \")\n # invalids = r'<>:\"/\\\\\\|\\?\\*'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get the SONiC image type It might be public/microsoft/...or any other type. Different vendors can define their different types by checking the specific information from the build image. | def get_image_type(duthost):
return "public" | [
"def str_type(self):\n return self.IMAGE_TYPES[int(self.type)]",
"def short_type(self):\n return self.SHORT_IMAGE_TYPES[self.str_type]",
"async def get_image_type(self, **kwargs: Any) -> ImageType:\n return self._image_type",
"def determine_format(self):\n extension = self.image.na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert scapy packet to bytes for python2 and python3 compatibility | def convert_scapy_packet_to_bytes(packet):
if six.PY2:
return str(packet)
else:
return bytes(packet) | [
"def get_packet(self) -> bytes:\n return self.header + self.payload",
"def serialize(self, packet):\n\t\tbuffer = bytearray()\n\t\tscratch = 0\n\t\tscratch_bits = 0\n\t\tfor index, data in enumerate(packet._raw):\n\t\t\tfield = packet.FIELDS[index]\n\t\t\tbits_remaining = field.size\n\n\t\t\twhile True:\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set default_pfcwd_status in the specified file with parameter default_pfcwd_value | def update_pfcwd_default_state(duthost, filepath, default_pfcwd_value):
output = duthost.shell("cat {} | grep default_pfcwd_status".format(filepath))['stdout']
matched = re.search('"default_pfcwd_status": "(.*)"', output)
if matched:
original_value = matched.group(1)
else:
pytest.fail("T... | [
"def set_default(self, param, defval):\n if param not in self._rpars:\n raise ClineError(\n 'set_default: parameter = \"' + param +\n '\" has not been registered.'\n )\n\n if self._rpars[param]['g_or_l'] == Cline.GLOBAL:\n self._gpars[para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get ipv4 loopback ip address | def get_ipv4_loopback_ip(duthost):
config_facts = duthost.get_running_config_facts()
los = config_facts.get("LOOPBACK_INTERFACE", {})
loopback_ip = None
for key, _ in los.items():
if "Loopback" in key:
loopback_ips = los[key]
for ip_str, _ in loopback_ips.items():
... | [
"def is_loopback_addr(ipv4_addr):\n return addr_in_network(addr=ipv4_addr, **IPV4_LOOPBACK_NETWORK)",
"def ipv4():\n\n try:\n # to not take into account loopback addresses (no interest here)\n addresses = []\n for interface in interfaces():\n config = ifaddresses(interface)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a DSCP value, and the DSCP to TC map and TC to queue map, return the corresponding queue value. | def get_dscp_to_queue_value(dscp_value, dscp_to_tc_map, tc_to_queue_map):
if str(dscp_value) not in dscp_to_tc_map:
return None
tc_value = dscp_to_tc_map[str(dscp_value)]
if tc_value not in tc_to_queue_map:
return None
return int(tc_to_queue_map[tc_value]) | [
"def set_value(ipc_queue, value):\n ipc_queue.put((_VALUE, os.getpid(), value))",
"def get_queue_by_collection(self, collection):\n for k, v in self.mapping.items():\n if v == collection:\n return k\n raise KeyError",
"def peek(queue):\n return queue['Data'][_FRONT]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check if request AJAX | def is_xhr(self):
return self.request.headers.get('X-requested-with', '').lower() == 'xmlhttprequest' | [
"def is_ajax():\r\n return request.headers.get('x-akamatsu-partial', 'false') == 'true'",
"def test_request_ajax_view_if_ajax_request(self):\n self.client.get(reverse('hello:home'))\n response = self.client.get(reverse('hello:requests_ajax'),\n HTTP_X_REQUESTED_W... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if the given domain name is valid. | def is_valid_domain(domain):
return validators.domain(domain) == True | [
"def is_correct_domain(domain=None):\n if domain is None:\n return False\n else:\n return True if is_correct_domain_pattern.match(domain) else False",
"def is_valid_fqdn(fqdn: str) -> bool:\n # Regex friendly stealed from\n # https://github.com/johno/domain-regex/blob/8a6984c8fa1fe8481a4... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run the validation on all vector issuer icons. | def main():
try:
vectors = glob.glob('./vectors/*/*.svg')
except:
vectors = []
print('Running validation on {} icons.'.format(len(vectors)))
# Generic validations
guard(len(vectors) >= 450, 'It looks like many vectors were deleted. There are only {} left while there should be more... | [
"def _check_valid_icon(res):\n if \"convalidated\" in res['rows'][0] and res['rows'][0][\"convalidated\"]:\n icon = \"icon-check_constraint_bad\"\n valid = False\n else:\n icon = \"icon-check_constraint\"\n valid = True\n\n return icon, valid",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method converts input string to dictionary | def convert_to_dictionary(self, string):
return json.loads(string) | [
"def get_dict(string: str) -> Dict[str, int]:\n splited = string[1:-1].split(\", \")\n my_dict = {}\n for i in splited:\n key, value = i.split(\":\")\n if key[0] == \"'\" and key[-1] == \"'\":\n key = key[1:-1]\n if value[0] == \"'\" and value[-1] == \"'\":\n valu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method converts input dictionary to json | def convert_to_json(self, dictionary):
return json.dumps(dictionary) | [
"def convert_dictionary_to_json(dictionary):\n return json.dumps(dictionary, sort_keys=True, indent=4,\n separators=(',', ': '))",
"def test_dictionary_json(self):\n base = Square(1)\n self.assertEqual(base.to_json_string(None), \"[]\")\n my_dict = {}\n self.ass... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set variable by name, dynamically set variable | def set_varibale_by_name(source:dict, name_of_variable_to_set:str, value):
source[name_of_variable_to_set] = value
# globals()[name_of_variable_to_set] = value | [
"def set_variable(self, name: str, index=None):\n name_sh = name.strip(\".\").lower()\n l_name = name_sh.split(\".\")\n name_1 = l_name[0]\n for item in self.items:\n if name_1 == item.get_name(): \n if len(l_name) == 1:\n attr_refs = []\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Accepts the tokenized rows and a list of allowed patterns and returns a list of booleans where True is match not found (anomaly) whereas False is match found (not anomaly) | def mismatches(self, tokenized_column, patterns):
if not isinstance(patterns, list):
patterns = [patterns]
predicates = dict()
for pattern in patterns:
if pattern.pattern() not in predicates:
predicates[pattern.pattern()] = list()
for row in ... | [
"def _token_pattern_matches(tokens, search_tokens, match_type, ignore_case, glob_method):\n\n # search tokens may be of any type (e.g. bool when matching against token meta data)\n if not isinstance(search_tokens, (list, tuple, set)):\n search_tokens = [search_tokens]\n elif isinstance(search_tokens... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
op for downsampling, will use conv2d probably. | def downsample(inputs): | [
"def downsampling(self):\n temp = (self.img + 1024) / 4\n temp[temp > 254] = 254\n temp[temp < 0] = 0\n self.temp_img = temp",
"def downsample_rate(self) -> int:",
"def downsample2d(x, f, down=2, padding=0, flip_filter=False, gain=1, impl='cuda'):\n downx, downy = _parse_scaling(d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Number of rows with salary > 150000 | def n_salary_over_150000():
return 2384 | [
"def get(sal):\r\n cr.execute(f\"select * from emp where {sal}<=salary\")\r\n k = cr.fetchall()\r\n if len(k)!=0:\r\n print(f\"the employees who have more than {sal} in salary are:\")\r\n print(k)\r\n else:\r\n print(f\"there is no employee who has this {sal} or more than it\")\r\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Path of a parquet dataset for testing | def sample_data_path(request):
return Path(__file__).parent / "data" / "parquet" / request.param | [
"def test_ParticleDataset_from_path():\n pass",
"def path_to_example(dataset):\n abcclassroom_path = os.path.split(__file__)[0]\n data_dir = os.path.join(abcclassroom_path, \"example-data\")\n data_files = os.listdir(data_dir)\n if dataset not in data_files:\n raise KeyError(dataset + \" not... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read the sample dataframe to pandas and return a cached copy | def read_sample_dataframe():
if not hasattr(read_sample_dataframe, "df"):
parquet_file = Path(__file__).parent / "data" / "parquet" / "singlefile.parquet"
backend = dframeio.ParquetBackend(str(parquet_file.parent))
read_sample_dataframe.df = backend.read_to_pandas(parquet_file.name)
retu... | [
"def sample_dataframe():\n return read_sample_dataframe()",
"def _load_full_dataframe_cached(self):\n return self.memory_cache.cached_dataframe(\n csv_path=self.data_subset_path(),\n compute_fn=self._load_full_dataframe_from_gtf)",
"def get_dataframe(self) -> pd.DataFrame:\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provide the sample dataframe | def sample_dataframe():
return read_sample_dataframe() | [
"def read_sample_dataframe():\n if not hasattr(read_sample_dataframe, \"df\"):\n parquet_file = Path(__file__).parent / \"data\" / \"parquet\" / \"singlefile.parquet\"\n backend = dframeio.ParquetBackend(str(parquet_file.parent))\n read_sample_dataframe.df = backend.read_to_pandas(parquet_fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read a sample dataset into a pandas dataframe, selecting some columns | def test_read_to_pandas_some_columns(sample_data_path):
backend = dframeio.ParquetBackend(str(sample_data_path.parent))
df = backend.read_to_pandas(sample_data_path.name, columns=["id", "first_name"])
SampleDataSchema.to_schema().select_columns(["id", "first_name"]).validate(df)
assert len(df) == Sample... | [
"def sample_dataframe():\n return read_sample_dataframe()",
"def read_sample_dataframe():\n if not hasattr(read_sample_dataframe, \"df\"):\n parquet_file = Path(__file__).parent / \"data\" / \"parquet\" / \"singlefile.parquet\"\n backend = dframeio.ParquetBackend(str(parquet_file.parent))\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read a sample dataset into a pandas dataframe, filtering some rows | def test_read_to_pandas_some_rows(sample_data_path):
backend = dframeio.ParquetBackend(str(sample_data_path.parent))
df = backend.read_to_pandas(sample_data_path.name, row_filter="salary > 150000")
SampleDataSchema.to_schema().validate(df)
assert len(df) == SampleDataSchema.n_salary_over_150000() | [
"def filter(self, df):\n pass",
"def read_data(datapath):\n data = pd.read_csv(datapath, index_col='ID')\n ####Deleting cols. with only 0 or only 1 values: \n df = (data.sum (axis = 0) != 0) & (data.sum (axis = 0) != len(data)) \n data = data[df[df].index]\n return data",
"def get_training... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read a sample dataset into a dictionary, filtering some rows | def test_read_to_dict_some_rows(sample_data_path):
backend = dframeio.ParquetBackend(str(sample_data_path.parent))
df = backend.read_to_dict(sample_data_path.name, row_filter="salary > 150000")
assert isinstance(df, dict)
assert set(df.keys()) == SampleDataSchema.to_schema().columns.keys()
df = pd.D... | [
"def test_filter_rows_empty_dict():\n rows = query_csv.iter_csv_rows(_PATH, delim=' ')\n filtered = query_csv.filter_rows(rows, {})\n assert list(filtered) == [\n {'s': 'a', 'i': 1, 'f': 1.0},\n {'s': 'b', 'i': 2, 'f': 2.0},\n {'s': 'c', 'i': 3, 'f': 3.0},\n ]",
"def _read_data(se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Partially or fully evaluate and simplify an object There are two ways of passing in the value of variables. The first way is using `kwargs`, which should be a dictionary from variable names to values. For example, evaluate(f, x=2, y=3). The other way is to use `args`. For example, evaluate(f, 2, 3). This way is only ap... | def evaluate(obj, *args, **kwargs):
if is_const(obj):
return obj
elif type(obj) == Function:
return obj._evaluate(*args, **kwargs)
else:
assert not args, ValueError(
"Cannot pass in `vals_list` for non-Functions")
return obj._evaluate(**kwargs) | [
"def evaluate(expr, locals):",
"def evaluate(self, variables,functions):\r\n pass",
"def evaluator(*, requires):\n def wrapper(function):\n return EvaluatorMeta(function.__name__, (Evaluator,), {'evaluate': staticmethod(function), 'requires': requires})\n return wrapper",
"def eval(self):\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the gradient of an expression that is the function of `vars` `vals` should be a list of variables in the order in which the | def gradient(obj, *vars):
if type(obj) == Function:
assert not vars, ValueError("`vars` unnecessary for gradients of Functions")
vars = obj.vars
return [diff(obj, var) for var in vars] | [
"def value_and_gradient(f, xs, watch_accessed_variables=True, name=None):\n with tf.name_scope(name, 'value_and_gradient', [xs]):\n is_xs_list_like = isinstance(xs, (tuple, list))\n if not is_xs_list_like:\n xs = [xs]\n xs = [tf.convert_to_tensor(value=x, name='x{}'.format(i))\n for i, x in ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compare equality, guarding against numpy matrices Numpy arrays raise an error on being compared to a constant, necessitating this method. | def _equal(a, b):
return type(a) != np.ndarray and a == b | [
"def test_matrix_equality(self):\n\n m1 = matrices.Matrix(2, 2)\n m1.set_row(0, [1, 2])\n m1.set_row(1, [1, 4])\n\n m2 = matrices.Matrix(2, 2)\n m2.set_row(0, [1, 2])\n m2.set_row(1, [1, 4])\n\n self.assertTrue(m1 == m2)\n\n m2.set(1, 1, 50)\n self.asse... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make an Azure Storage account URL from an account name. | def make_account_url(account_name: str) -> str:
return f'https://{account_name}.blob.core.windows.net' | [
"def prepare_account_name_for_jwt(self, raw_account: str) -> str:\n account = raw_account\n if \".global\" not in account:\n # Handle the general case.\n idx = account.find(\".\")\n if idx > 0:\n account = account[0:idx]\n else:\n # Han... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create an Azure Storage blob. | def create_blob(account_name: str, account_key: str, container_name: str, blob_name: str, blob_data: Any) -> BlobClient:
account_url = make_account_url(account_name)
client: BlobServiceClient = BlobServiceClient(account_url, account_key)
blob_client: BlobClient = client.get_blob_client(container=container_... | [
"def _create_blob_container(self, connection):\r\n connection.create_container(self._container)",
"def create_one_time_azure_transfer(\n project_id: str,\n description: str,\n azure_storage_account: str,\n azure_sas_token: str,\n source_container: str,\n sink_bucket: str,\n):\n\n # Ini... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List the blobs in an Azure Storage Blob Container. | def list_blobs(account_name: str, account_key: str, container_name: str) -> List[BlobProperties]:
account_url = make_account_url(account_name)
client: ContainerClient = ContainerClient(account_url, container_name, credential=account_key)
blobs = client.list_blobs()
return [b for b in blobs] | [
"def list_container_blobs(storage_account_conn_str, container_name):\n try:\n # Create the container object\n container_client = ContainerClient.from_connection_string(conn_str=storage_account_conn_str,\n container_name=container_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copy the blobs from one Azure Storage Blob Container to another. | def copy_container(account_name: str, account_key: str, source_container: str, target_container: str,
target_folder: str) -> None:
blobs = list_blobs(account_name, account_key, source_container)
# Create copy jobs
targets = []
account_url = make_account_url(account_name)
client:... | [
"def copy_blob(self, storage_client, group_name_copy_to, storage_name_copy_to, container_name_copy_to,\n blob_name_copy_to, source_copy_from, group_name_copy_from, cancellation_context, logger):\n ulr_model_copy_from = self.parse_blob_url(source_copy_from)\n copied_blob_key = (storage... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Graph from adjacency matrix. | def graph_from_adjacency_matrix(
adjacency_matrix: Union[np.ndarray, List[List[int]]],
aprops: Optional[Union[np.ndarray, List[Any]]] = None,
):
# Get upper triangular adjacency matrix
adj = np.triu(adjacency_matrix)
assert adj.shape[0] == adj.shape[1]
num_vertices = adj.shape[0]
G = gt.G... | [
"def adjacency_matrix_to_graph(adjacency_matrix, labels=None):\n # Only consider edges have absolute edge weight > 0.01\n idx = np.abs(adjacency_matrix) > 0.01\n dirs = np.where(idx)\n import graphviz\n\n d = graphviz.Digraph(engine=\"dot\")\n names = labels if labels else [f\"x{i}\" for i in rang... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get vertex (node) property from graph | def vertex_property(G, vproperty: str, idx: int) -> Any:
return G.vertex_properties[vproperty][idx] | [
"def get_vertex(self, id_num):",
"def vertices(graph):\n return graph.keys()",
"def vertices(self):\n return list(self._graphDict.keys())",
"def get_vertex(self, v_id):\n pass",
"def get_out_vertex(self):",
"def get_vertex_value(self, x):\n if x in self.vertices:\n return se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build 2D lattice graph | def lattice(n1: int, n2: int):
return generation.lattice((n1, n2)) | [
"def lattice_builder(edges):\n\n\n topEdge, bottomEdge, leftEdge, rightEdge = edges \n # initializes the lattice\n latticeList = Lattice(np.zeros((containerSize, containerSize, 6), np.int8))\n\n # top left corner and top right corner positions are set, they won't vary\n # if the container size is od... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate random brush and stroke mask. Return a mask of (1, 1, W, H) partially fork from Jiahui Yu's Codes | def brush_stroke_mask(W, H):
min_num_vertex = 4
max_num_vertex = 12
mean_angle = 2*math.pi / 5
angle_range = 2*math.pi / 15
min_width = 12
max_width = 40
def generate_mask(W, H):
average_radius = math.sqrt(H*H+W*W) / 8
mask = Image.new('L', (W, H), 0)
for _ in range(... | [
"def _generate_mask(self):\r\n\r\n img = np.zeros((self.height, self.width, self.channels), np.uint8)\r\n\r\n # Set size scale\r\n size = int((self.width + self.height) * 0.03)\r\n if self.width < 64 or self.height < 64:\r\n raise Exception(\"Width and Height of mask must be a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the list of possible moves, ask the player controller for a selection, and move the player actor. Return the space the player moved to, or None if the player ended the move early. | def handle_player_move(self, player: HunterController, num_moves_remaining: int) -> Optional[MapSpace]:
possible_moves = self.get_player_moves(player)
player_move = player.select_move(possible_moves, num_moves_remaining)
if player_move.type == ActionType.MOVE:
destination_space =... | [
"def make_move(self):\n player_opts, opp_opts = self.generate_possibilities()\n move_choice = self.optimal_move(player_opts, opp_opts)\n return move_choice",
"def move(self, Game, ** keyword_parameters):\n whichPlayer = keyword_parameters['whichPlayer']\n if sum(Game) == 0: # I... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a new set of encoded keypair for VAPID | def generate_vapid_keypair():
pk = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p)
vk = pk.get_verifying_key()
return {
'private_key': base64.urlsafe_b64encode(pk.to_string()).decode('utf-8').strip("="),
'public_key': base64.urlsafe_b64encode(b"\x04" + vk.to_string()).decode('utf-8').strip("... | [
"def generateKeyPair(cls):",
"def generate_keypair(self) -> str:\n # create an NaClDSEncoder object\n nacl_enc = NaClDSEncoder()\n # generate new keys\n nacl_enc.generate()\n\n self.keypair = nacl_enc.keypair\n self.public_key = nacl_enc.public_key\n self.private_k... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Increment the current version number for the variable name given as ref. | def inc_version(self, ref: str) -> int:
if ref in self.varcounts:
self.varcounts[ref] += 1
return self.varcounts[ref]
else:
self.varcounts[ref] = 1
return 1 | [
"def inc_packageversion(self):\n match = re.compile(r\"^(\\d*)\\.?((\\d*)|(corr\\d*corr))$\")\n m = match.search(self.packageversion)\n #print(m.group(0))\n #print(m.group(1)[4:-4])\n #print(m.group(2))\n if m:\n if \"corr\" in m.group(2):\n pre_in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a unique Symbol with the given name. If one or more Symbols with the same name exists, the new Symbol will have a higher version number than any of them. | def sym(self, name: str, version: int = None) -> Symbol:
return Symbol(
name,
namespace=self.namespace,
version=version or self.inc_version(name),
relation=None
) | [
"def newClass(self, name = None):\n logger.debug(\"Creating new class: %s\" % (name))\n symCls = SymbolClass(self.featureSet, name = name)\n self.symbolClasses[symCls.name] = symCls\n\n #self.count += 1;\n #self.features.append([])\n #if name == None:\n #name = s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new Symbol that relates to the orig Symbol with the given relation. The new Symbol is guaranteed not to already exist. | def rel(self, orig: Symbol, relation: str, version: int = None) -> Symbol:
# Note: str(a) == str(b) if a == b, but it is possible (I think?)
# that str(a) == str(b) if a != b. This is okay, it just means that
# some symbols may have a higher version than strictly
# necessary (note tha... | [
"def dup(self, orig: Symbol) -> Symbol:\n return self(orig.label, orig.relation or None)",
"def swap(self, source, symbol, new): # pylint: disable=invalid-name\n if source not in self._originals:\n self._originals[source] = {}\n if not self._originals[source].get(symbol, None):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make a new Symbol that has the same name/relation/etc. as the original, but a new version. | def dup(self, orig: Symbol) -> Symbol:
return self(orig.label, orig.relation or None) | [
"def rel(self, orig: Symbol, relation: str, version: int = None) -> Symbol:\n # Note: str(a) == str(b) if a == b, but it is possible (I think?)\n # that str(a) == str(b) if a != b. This is okay, it just means that\n # some symbols may have a higher version than strictly\n # necessary ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a builtin symbol. A builtin symbol points to a function for internal use which is not meant to be referred to by name by the user. Accordingly, it will not be present in the user namespace. It is the case that ``bsym(x) == bsym(x)``, because builtins are indexed by name only. | def bsym(name: str) -> Symbol:
return Symbol(name, namespace='global::builtin') | [
"def _make_symbol_function(handle, name, func_name):\n code, doc_str = _generate_symbol_function_code(handle, name, func_name)\n\n local = {}\n exec(code, None, local) # pylint: disable=exec-used\n symbol_function = local[func_name]\n symbol_function.__name__ = func_name\n symbol_function.__doc__... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a null symbol. Use as a placeholder in destructuring assignments for irrelevant elements. It is not the case that ``nsym() == nsym()``. Each null symbol is different. That might be something to fix. | def nsym() -> Symbol:
return _ngen(NULLSYM) | [
"def get_empty_symbol():\n return Symbol.EMPTY_SYMBOL",
"def isSymbol(x):\n return type(x) == type(__empty_symbol)",
"def init_builtin_symbols():\n Symbol.EMPTY_SYMBOL = Terminal(Symbol.EMPTY_SYMBOL_NAME)\n Symbol.END_SYMBOL = Terminal(Symbol.END_SYMBOL_NAME)\n Symbol.ROOT_SYMBOL ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return whether the given variable name is a free variable or not, and the Symbol associated to the variable. A variable is free if it is found in this Tracker's parent, or grandparent, etc. It is not free if it is found in ``self.bindings``. Raise NameError if the variable was not declared. | def get_free(self, name: str, preserve_about: bool = True) \
-> TupleT[bool, 'Symbol']:
if name in self.bindings:
return (False, self.bindings[name].copy(preserve_about))
elif self.parent is None:
raise NameError("Undeclared variable: {}".format(name))
else:
... | [
"def freevar(self, var, expr):\n parsed = logic.Parser().parse(expr)\n variable = logic.Variable(var)\n return variable in parsed.free()",
"def _hasVarBeenDeclared(self, var_name, group=None):\n\n has_been_declared = False\n\n if isinstance(var_name, list) is not True:\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Associate the given symbol to the given node (typically a LambdaNode) in this universe. The LambdaNode's `ref` field will be set to the symbol. | def associate(self, sym, node):
if isinstance(node, LambdaNode):
node.ref = sym
self.cache[sym] = node | [
"def addref( self, symbol ):\n\t\t#log.debug( \" adding rule reference to %s by %s\" % (self.debugstr(), symbol.debugstr()) )\n\t\tself.refs.add( symbol )",
"def add_symbol(self, symbol: Symbol):\n\n # TODO: Check that another symbol with the same identifier is not already in this scope.\n self._s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a LambdaNode named according to the `ref` Symbol and return it. If `commit` is `True`, `ref` will be associated to the `LambdaNode` in `python_universe`. | def create_lambda(ref, args, body, gen=None, *,
commit=True, **kw):
lbda = LambdaNode(args, body, gen, **kw)
if commit:
python_universe.associate(ref, lbda)
return lbda | [
"def AS_newreference(self, ref):\n\t\tif isinstance(ref, GenericReference):\n\t\t\treturn ref.AS_resolve(Reference, self.AS_appdata)\n\t\telif isinstance(ref, aem.Query):\n\t\t\treturn Reference(self.AS_appdata, ref)\n\t\telif ref is None:\n\t\t\treturn Reference(self.AS_appdata, aem.app)\n\t\telse:\n\t\t\treturn R... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Indicates whether the disk will be autodeleted when the instance is deleted (but not when the disk is detached from the instance). | def auto_delete(self) -> bool:
return pulumi.get(self, "auto_delete") | [
"def AutoDeleteMustBeChanged(self, args, disk_resource):\n if args.keep_disks == 'boot':\n return disk_resource.autoDelete and disk_resource.boot\n elif args.keep_disks == 'data':\n return disk_resource.autoDelete and not disk_resource.boot\n elif args.keep_disks == 'all':\n return disk_reso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Indicates a list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options. | def guest_os_features(self) -> Sequence['outputs.GuestOsFeatureResponse']:
return pulumi.get(self, "guest_os_features") | [
"def guest_os_features(self) -> pulumi.Output[Sequence['outputs.ImageGuestOsFeature']]:\n return pulumi.get(self, \"guest_os_features\")",
"def guest_os_features(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ImageGuestOsFeatureArgs']]]]:\n return pulumi.get(self, \"guest_os_features\")",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A list of publicly visible licenses. Reserved for Google's use. A License represents billing and aggregate usage data for public and marketplace images. | def licenses(self) -> Sequence[str]:
return pulumi.get(self, "licenses") | [
"def list(self):\n response = self.client._request(url='/api/v2/hpelicense', http_method='get', description='license/get_license')\n return response.json()",
"def fetch_license_data():\n api_links = {\n \"MIT\": \"https://api.github.com/licenses/mit\",\n \"GPL\": \"https://api.githu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The URI of the external job used to execute the notebook. | def job_uri(self) -> str:
return pulumi.get(self, "job_uri") | [
"def job_path(self, job: str) -> str:\n return f'{self.project_path}/{self.location_path}/jobs/{job}'",
"def get_notebook_url(self, relative_path):\n return \"http://{}:{}/notebooks/{}\".format(\n self._notebook_server_ip,\n self._notebook_server_port,\n relative_path)",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Output notebook file generated by this execution | def output_notebook_file(self) -> str:
return pulumi.get(self, "output_notebook_file") | [
"def generate_outprint():\n s = 'Switched to IPython ... defined variables:\\n\\n\\t'\n s += 'corpus, results, concordance, edited ...\\n\\n\\tType \"quit\" to return to corpkit environment'\n return s",
"def test_export_notebook(self):\n (output, resources) = HTMLExporter(template_nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The type of Job to be used on this execution. | def job_type(self) -> str:
return pulumi.get(self, "job_type") | [
"def _get_job_type(test_job):\n job_type = None\n\n if 'pgo test' in test_job or 'pgo talos' in test_job:\n job_type = 'pgo'\n elif 'opt' in test_job or 'talos' in test_job:\n job_type = 'opt'\n elif 'debug' in test_job:\n job_type = 'debug'\n return job_type",
"def _get_jobtyp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Name of the kernel spec to use. This must be specified if the kernel spec name on the execution target does not match the name in the input notebook file. | def kernel_spec(self) -> str:
return pulumi.get(self, "kernel_spec") | [
"def normalize_kernel_name(nb, notebook):\n\n # normalize kernel name\n kernelspec = nb.metadata.kernelspec\n\n if \"[conda env:\" in kernelspec.display_name:\n if kernelspec.language == 'python':\n if nb.metadata.language_info.version.startswith('3.'):\n kernelspec.name = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Scale tier of the hardware used for notebook execution. DEPRECATED Will be discontinued. As right now only CUSTOM is supported. | def scale_tier(self) -> str:
warnings.warn("""Required. Scale tier of the hardware used for notebook execution. DEPRECATED Will be discontinued. As right now only CUSTOM is supported.""", DeprecationWarning)
pulumi.log.warn("""scale_tier is deprecated: Required. Scale tier of the hardware used for noteb... | [
"def storage_tier(self) -> str:\n return pulumi.get(self, \"storage_tier\")",
"def change_tier(self):\n input_tier = input('Change tier to: ')\n self.tier = input_tier",
"def PaperScale(self) -> float:",
"def ikHandleDisplayScale():\n pass",
"def setScaleFactor(self, factor):\n\t\tpa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Input only. Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new runtime. This property is mutually exclusive with the source property; you can only define one or the other, but not both. | def __init__(__self__, *,
description: str,
disk_name: str,
disk_size_gb: str,
disk_type: str,
labels: Mapping[str, str]):
pulumi.set(__self__, "description", description)
pulumi.set(__self__, "disk_name", disk_name)
... | [
"def creation_parameters(self) -> pulumi.Input['ApplicationScopedVolumeCreationParametersServiceFabricVolumeDiskArgs']:\n return pulumi.get(self, \"creation_parameters\")",
"def _create_disk(self, parameters):\n return disk_fcp.DiskFcp(parameters, self._mock_host_conn)",
"def __init__(self,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optional. Type of reservation to consume | def consume_reservation_type(self) -> str:
return pulumi.get(self, "consume_reservation_type") | [
"def io_reservation(self) -> Optional[int]:\n return pulumi.get(self, \"io_reservation\")",
"def reservation_conversion(self):\n \n if(self.order_type == OrderType.PURCHASE_ORDER):\n # this is already a purchase, nothing else to do\n return\n \n if(self.ord... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The proxy endpoint that is used to access the runtime. | def proxy_uri(self) -> str:
return pulumi.get(self, "proxy_uri") | [
"def proxy_service(self):\n return self.data.get(\"http_proxy\")",
"def get_proxy (self):\n return self.proxy",
"def proxyEndpoint(wrappedEndpoint):\n return _WrapperServerEndpoint(wrappedEndpoint, HAProxyWrappingFactory)",
"def proxy_url(self) -> str:\n return pulumi.get(self, \"proxy_url... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Defines whether the instance has integrity monitoring enabled. Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. Enabled by ... | def enable_integrity_monitoring(self) -> bool:
return pulumi.get(self, "enable_integrity_monitoring") | [
"def enable_monitoring(self) -> bool:\n return pulumi.get(self, \"enable_monitoring\")",
"def hw_virt_ex_enabled(self):\n ret = self._get_attr(\"HWVirtExEnabled\")\n return ret",
"def _firmware_is_upgrading(self):\r\n return self._debug_console_listener != None",
"def hibernation_e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Defines whether the instance has Secure Boot enabled. Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. Disabled by default. | def enable_secure_boot(self) -> bool:
return pulumi.get(self, "enable_secure_boot") | [
"def is_iscsi_boot_supported(self):\n return utils.is_operation_allowed(\n 'PATCH', self,\n ['@Redfish.Settings', 'SettingsObject'])",
"def _disable_secure_boot(task):\n cur_sec_state = False\n try:\n cur_sec_state = sdflex_common.get_secure_boot_mode(task)\n except ex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Defines whether the instance has the vTPM enabled. Enabled by default. | def enable_vtpm(self) -> bool:
return pulumi.get(self, "enable_vtpm") | [
"def hw_virt_ex_vpid_enabled(self):\n ret = self._get_attr(\"HWVirtExVPIDEnabled\")\n return ret",
"def r_is_vf_enabled(self):\r\n v = self.r_get(brcdapi_util.bp_vf_enabled)\r\n return False if v is None else v",
"def hw_virt_ex_enabled(self):\n ret = self._get_attr(\"HWVirtEx... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Specify a custom Cloud Storage path where the GPU driver is stored. If not specified, we'll automatically choose from official GPU drivers. | def custom_gpu_driver_path(self) -> str:
return pulumi.get(self, "custom_gpu_driver_path") | [
"def device(use_gpu=False):\n if use_gpu:\n return ops.device(\"/gpu:0\")\n return ops.device(\"/cpu:0\")",
"def _autodetect_backend(storage_path):\n if storage_path == '::inmem::':\n return 'inmem'\n elif storage_path.endswith('.npz'):\n return 'npz'\n elif storage_path.endswith(('.h5... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optional. Use a list of container images to use as Kernels in the notebook instance. | def kernels(self) -> Sequence['outputs.ContainerImageResponse']:
return pulumi.get(self, "kernels") | [
"def docker_images(repotag_name=None):\n raise NotImplementedError",
"def docker_images_list(self):\n images = Images.objects()\n if len(images) == 0:\n print(\"No images exist\")\n return\n\n for image in images:\n print(image.imageName)",
"def kerne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The container image before this instance upgrade. | def container_image(self) -> str:
return pulumi.get(self, "container_image") | [
"def get_xcom_sidecar_container_image(self):\n return self._get_field(\"xcom_sidecar_container_image\")",
"def docker_image_reference(self):\n return self._docker_image_reference",
"def image_reference(self) -> 'outputs.LabVirtualMachineImageReference':\n return pulumi.get(self, \"image_ref... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Target VM Version, like m63. | def target_version(self) -> str:
return pulumi.get(self, "target_version") | [
"def myst_version():\n return 0.13",
"def version(self):\n if not self.current_compiler:\n return None\n\n from platform import python_compiler\n\n version_str = python_compiler()\n\n if not version_str.startswith(\"MSC v.\"):\n return None\n\n version_s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The VM image before this instance upgrade. | def vm_image(self) -> str:
return pulumi.get(self, "vm_image") | [
"def image_reference(self) -> 'outputs.LabVirtualMachineImageReference':\n return pulumi.get(self, \"image_reference\")",
"def node_image_version(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"node_image_version\")",
"def boot_image(self) -> 'outputs.BootImageResponse':\n return p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optional. The Compute Engine accelerator configuration for this runtime. | def accelerator_config(self) -> 'outputs.RuntimeAcceleratorConfigResponse':
return pulumi.get(self, "accelerator_config") | [
"def elastic_inference_accelerator(self) -> Optional[pulumi.Input['LaunchTemplateElasticInferenceAcceleratorArgs']]:\n return pulumi.get(self, \"elastic_inference_accelerator\")",
"def elastic_inference_accelerator(self) -> pulumi.Output[Optional['outputs.LaunchTemplateElasticInferenceAccelerator']]:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optional. Boot image metadata used for runtime upgradeability. | def boot_image(self) -> 'outputs.BootImageResponse':
return pulumi.get(self, "boot_image") | [
"def bootinfok_params(self):\n BIK = {}\n if self.GENERAL_SNAP:\n BIK.update({'bootinfo_k' : self.__snap_stanza_read(self.GENERAL_SNAP, 'bootinfo -K')[0] })\n else:\n return None\n return BIK",
"def docker_image_manifest(self):\n return self._docker_image_m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optional. If true, runtime will only have internal IP addresses. By default, runtimes are not restricted to internal IP addresses, and will have ephemeral external IP addresses assigned to each vm. This `internal_ip_only` restriction can only be enabled for subnetwork enabled networks, and all dependencies must be conf... | def internal_ip_only(self) -> bool:
return pulumi.get(self, "internal_ip_only") | [
"def disable_public_ip_addresses(self) -> bool:\n return pulumi.get(self, \"disable_public_ip_addresses\")",
"def private_ip_enabled(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"private_ip_enabled\")",
"def is_internal(self, is_internal):\n if self.local_vars_configura... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optional. The type of vNIC to be used on this interface. This may be gVNIC or VirtioNet. | def nic_type(self) -> str:
return pulumi.get(self, "nic_type") | [
"def test_nic_type(self):\n self.cls.validate_nic_type(\"vmxnet3\")\n self.cls.validate_nic_type(\"VMXNET3\")\n self.cls.validate_nic_type(\"e1000\")\n self.cls.validate_nic_type(\"E1000\")\n self.cls.validate_nic_type(\"virtio\")\n self.cls.validate_nic_type(\"VirtIO\")",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optional. Shielded VM Instance configuration settings. | def shielded_instance_config(self) -> 'outputs.RuntimeShieldedInstanceConfigResponse':
return pulumi.get(self, "shielded_instance_config") | [
"def shielded_instance_config(self) -> Optional[pulumi.Input['OceanLaunchSpecShieldedInstanceConfigArgs']]:\n return pulumi.get(self, \"shielded_instance_config\")",
"def shielded_instance_config(self) -> pulumi.Output['outputs.OceanLaunchSpecShieldedInstanceConfig']:\n return pulumi.get(self, \"shi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Virtual Machine configuration settings. | def virtual_machine_config(self) -> 'outputs.VirtualMachineConfigResponse':
return pulumi.get(self, "virtual_machine_config") | [
"def vm_read_config(self):\n\n self.cfg_details['displayName'] = self.vmx_info['displayName']\n self.cfg_details['memsize'] = self.vmx_info['memsize']\n self.cfg_details['virtualHW.version'] = \\\n self.vmx_info['virtualHW']['version']\n\n # ToDo:Check for the following ke... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetch a product with a given identifier. | def fetch_product(identifier): | [
"def get_product_by_id(self, prod_id):\n if self.cursor:\n self.prod_id = prod_id\n self.cursor.execute(\n \"Select * from products where prod_id = %s\",\n (self.prod_id,)\n )\n product = self.cursor.fetchone()\n return prod... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse the given product object. | def parse_product(obj): | [
"def __parseProductInformation(self):\n searchTerms = [\n [ 'Product Dimensions', -1 ],\n [ 'Item Weight', -1 ], \n [ 'Shipping Weight', -1 ],\n [ 'ASIN', -1 ],\n [ 'Item model number', -1 ],\n [ 'Best Sellers Rank', -1 ],\n [ 'Date... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Charge the given amount for the transaction | def charge(token, amount, description, email): | [
"def charge(self, amount):\n if self.balance + amount > self.credit_limit:\n raise ValueError(\"Transaction declined, credit limit would be breached\")\n self._balance += amount\n return self._balance",
"def credit(self, amount):\n if self._is_asset_or_expenses:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This program fetches data from itunes and create media, song, and movie objects accordingly Other types of fecthed results will be ignored The count of all fetched results and the created objects will be returned | def fetchData(params):
resp = json.loads(requests.get(baseurl,params).text)
print(requests.get(baseurl,params).url)
res = resp["results"]
other_medias = []
songs = []
movies = []
urls = [[],[],[]]
for data in res:
if "kind" in data and data["kind"] == "song":
songs.ap... | [
"def create_movies():\n global movies\n for movie_id in MOVIE_ID_LIST:\n movie = media.Movie(movie_id)\n movies.append(movie)",
"def populate_list(movies, debug_on=False):\n global KEY\n movie_objects = []\n\n # Go through each title to find and generate each movie instance.\n for ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |