function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def _assert_sid_is_in_chain(sid, pid):
if not sid or not pid:
return
chain_model = _get_chain_by_pid(pid)
if not chain_model or not chain_model.sid:
return
if chain_model.sid.did != sid:
raise d1_common.types.exceptions.ServiceFailure(
0,
"Attempted to cre... | DataONEorg/d1_python | [
13,
6,
13,
17,
1464710460
] |
def _get_chain_by_pid(pid):
"""Find chain by pid.
Return None if not found.
"""
try:
return d1_gmn.app.models.ChainMember.objects.get(pid__did=pid).chain
except d1_gmn.app.models.ChainMember.DoesNotExist:
pass | DataONEorg/d1_python | [
13,
6,
13,
17,
1464710460
] |
def _update_sid_to_last_existing_pid_map(pid):
"""Set chain head PID to the last existing object in the chain to which ``pid``
belongs. If SID has been set for chain, it resolves to chain head PID.
Intended to be called in MNStorage.delete() and other chain manipulation.
Preconditions:
- ``pid`` m... | DataONEorg/d1_python | [
13,
6,
13,
17,
1464710460
] |
def _map_sid_to_pid(chain_model, sid, pid):
if sid is not None:
chain_model.sid = d1_gmn.app.did.get_or_create_did(sid)
chain_model.head_pid = d1_gmn.app.did.get_or_create_did(pid)
chain_model.save() | DataONEorg/d1_python | [
13,
6,
13,
17,
1464710460
] |
def _get_all_chain_member_queryset_by_chain(chain_model):
return d1_gmn.app.models.ChainMember.objects.filter(chain=chain_model) | DataONEorg/d1_python | [
13,
6,
13,
17,
1464710460
] |
def _cut_tail_from_chain(sciobj_model):
new_tail_model = d1_gmn.app.model_util.get_sci_model(sciobj_model.obsoleted_by.did)
new_tail_model.obsoletes = None
sciobj_model.obsoleted_by = None
sciobj_model.save()
new_tail_model.save() | DataONEorg/d1_python | [
13,
6,
13,
17,
1464710460
] |
def _is_head(sciobj_model):
return sciobj_model.obsoletes and not sciobj_model.obsoleted_by | DataONEorg/d1_python | [
13,
6,
13,
17,
1464710460
] |
def _set_revision_reverse(to_pid, from_pid, is_obsoletes):
try:
sciobj_model = d1_gmn.app.model_util.get_sci_model(from_pid)
except d1_gmn.app.models.ScienceObject.DoesNotExist:
return
if not d1_gmn.app.did.is_existing_object(to_pid):
return
did_model = d1_gmn.app.did.get_or_crea... | DataONEorg/d1_python | [
13,
6,
13,
17,
1464710460
] |
def snmp_version(self):
if self._values['snmp_version'] is None:
return None
return str(self._values['snmp_version']) | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def port(self):
if self._values['port'] is None:
return None
return int(self._values['port']) | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def api_params(self):
result = {}
for api_attribute in self.api_attributes:
if self.api_map is not None and api_attribute in self.api_map:
result[api_attribute] = getattr(self, self.api_map[api_attribute])
else:
result[api_attribute] = getattr(self... | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def network(self):
if self._values['network'] is None:
return None
network = str(self._values['network'])
if network == 'management':
return 'mgmt'
elif network == 'default':
return ''
else:
return network | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def network(self):
return None | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def __init__(self, client):
self.client = client | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def is_version_non_networked(self):
"""Checks to see if the TMOS version is less than 13
Anything less than BIG-IP 13.x does not support users
on different partitions.
:return: Bool
"""
version = self.client.api.tmos_version
if LooseVersion(version) < LooseVersi... | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def __init__(self, client):
self.client = client
self.have = None | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def exists(self):
result = self.client.api.tm.sys.snmp.traps_s.trap.exists(
name=self.want.name,
partition=self.want.partition
)
return result | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def create(self):
self._set_changed_options()
if self.client.check_mode:
return True
if all(getattr(self.want, v) is None for v in self.required_resources):
raise F5ModuleError(
"You must specify at least one of "
', '.join(self.required_re... | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def update(self):
self.have = self.read_current_from_device()
if not self.should_update():
return False
if self.client.check_mode:
return True
self.update_on_device()
return True | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def create_on_device(self):
params = self.want.api_params()
self.client.api.tm.sys.snmp.traps_s.trap.create(
name=self.want.name,
partition=self.want.partition,
**params
) | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def remove(self):
if self.client.check_mode:
return True
self.remove_from_device()
if self.exists():
raise F5ModuleError("Failed to delete the snmp trap")
return True | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def __init__(self, client):
super(NetworkedManager, self).__init__(client)
self.required_resources = [
'version', 'community', 'destination', 'port', 'network'
]
self.want = NetworkedParameters(self.client.module.params)
self.changes = NetworkedParameters() | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def _update_changed_options(self):
changed = {}
for key in NetworkedParameters.updatables:
if getattr(self.want, key) is not None:
attr1 = getattr(self.want, key)
attr2 = getattr(self.have, key)
if attr1 != attr2:
changed[ke... | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def _ensure_network(self, result):
# BIG-IP's value for "default" is that the key does not
# exist. This conflicts with our purpose of having a key
# not exist (which we equate to "i dont want to change that"
# therefore, if we load the information from BIG-IP and
# find that the... | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def __init__(self, client):
super(NonNetworkedManager, self).__init__(client)
self.required_resources = [
'version', 'community', 'destination', 'port'
]
self.want = NonNetworkedParameters(self.client.module.params)
self.changes = NonNetworkedParameters() | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def _update_changed_options(self):
changed = {}
for key in NonNetworkedParameters.updatables:
if getattr(self.want, key) is not None:
attr1 = getattr(self.want, key)
attr2 = getattr(self.have, key)
if attr1 != attr2:
changed... | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def __init__(self):
self.supports_check_mode = True
self.argument_spec = dict(
name=dict(
required=True
),
snmp_version=dict(
choices=['1', '2c']
),
community=dict(),
destination=dict(),
p... | mcgonagle/ansible_f5 | [
10,
27,
10,
1,
1478300759
] |
def test_enable_command_requires_a_password(self, t):
t.write("enable")
t.read("Password: ")
t.write_invisible(t.conf["extra"]["password"])
t.read("my_switch#") | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_wrong_password(self, t):
t.write("enable")
t.read("Password: ")
t.write_invisible("hello_world")
t.readln("% Access denied")
t.readln("")
t.read("my_switch>") | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_no_password_works_for_legacy_reasons(self, t):
t.write("enable")
t.read("Password: ")
t.write_invisible("")
t.read("my_switch#") | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_exiting_loses_the_connection(self, t):
t.write("enable")
t.read("Password: ")
t.write_invisible(t.conf["extra"]["password"])
t.read("my_switch#")
t.write("exit")
t.read_eof() | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_no_such_command_return_to_prompt(self, t):
enable(t)
t.write("shizzle")
t.readln("No such command : shizzle")
t.read("my_switch#") | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_command_copy_failing(self, t, read_tftp):
read_tftp.side_effect = Exception("Stuff")
enable(t)
t.write("copy tftp://1.2.3.4/my-file system:/running-config")
t.read("Destination filename [running-config]? ")
t.write("gneh")
t.readln("Accessing tftp://1.2.3.4/my-... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_command_copy_success(self, t, read_tftp):
enable(t)
t.write("copy tftp://1.2.3.4/my-file system:/running-config")
t.read("Destination filename [running-config]? ")
t.write_raw("\r")
t.wait_for("\r\n")
t.readln("Accessing tftp://1.2.3.4/my-file...")
t.rea... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_command_show_run_int_vlan_empty(self, t):
enable(t)
t.write("terminal length 0")
t.read("my_switch#")
t.write("show run vlan 120")
t.readln("Building configuration...")
t.readln("")
t.readln("Current configuration:")
t.readln("end")
t.rea... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_command_add_vlan(self, t):
enable(t)
t.write("conf t")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switch(config)#")
t.write("vlan 123")
t.read("my_switch(config-vlan)#")
t.write("name shizzle")
t.read("my... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_command_assign_access_vlan_to_port(self, t):
enable(t)
create_vlan(t, "123")
set_interface_on_vlan(t, "FastEthernet0/1", "123")
assert_interface_configuration(t, "Fa0/1", [
"interface FastEthernet0/1",
" switchport access vlan 123",
" switchp... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_show_vlan_brief(self, t):
enable(t)
create_vlan(t, "123")
create_vlan(t, "3333", "some-name")
create_vlan(t, "2222", "your-name-is-way-too-long-for-this-pretty-printed-interface-man")
set_interface_on_vlan(t, "FastEthernet0/1", "123")
t.write("show vlan brief")... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_show_vlan(self, t):
enable(t)
create_vlan(t, "123")
create_vlan(t, "3333", "some-name")
create_vlan(t, "2222", "your-name-is-way-too-long-for-this-pretty-printed-interface-man")
set_interface_on_vlan(t, "FastEthernet0/1", "123")
t.write("show vlan")
t.r... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_shutting_down(self, t):
enable(t)
configuring_interface(t, "FastEthernet 0/3", do="shutdown")
assert_interface_configuration(t, "FastEthernet0/3", [
"interface FastEthernet0/3",
" shutdown",
"end"])
configuring_interface(t, "FastEthernet 0/... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_configure_trunk_port(self, t):
enable(t)
configuring_interface(t, "Fa0/3", do="switchport mode trunk")
assert_interface_configuration(t, "FastEthernet0/3", [
"interface FastEthernet0/3",
" switchport mode trunk",
"end"])
# not really added ... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_configure_native_vlan(self, t):
enable(t)
configuring_interface(t, "FastEthernet0/2", do="switchport trunk native vlan 555")
assert_interface_configuration(t, "Fa0/2", [
"interface FastEthernet0/2",
" switchport trunk native vlan 555",
"end"])
... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_setup_an_interface(self, t):
enable(t)
create_vlan(t, "2999")
create_interface_vlan(t, "2999")
assert_interface_configuration(t, "Vlan2999", [
"interface Vlan2999",
" no ip address",
"end"])
configuring_interface_vlan(t, "2999", do="... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_partial_standby_properties(self, t):
enable(t)
create_vlan(t, "2999")
create_interface_vlan(t, "2999")
assert_interface_configuration(t, "Vlan2999", [
"interface Vlan2999",
" no ip address",
"end"])
configuring_interface_vlan(t, "299... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_partial_standby_ip_definition(self, t):
enable(t)
create_vlan(t, "2999")
create_interface_vlan(t, "2999")
configuring_interface_vlan(t, "2999", do='standby 1 ip')
assert_interface_configuration(t, "Vlan2999", [
"interface Vlan2999",
" no ip addr... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_creating_a_port_channel(self, t):
enable(t)
create_port_channel_interface(t, '1')
configuring_port_channel(t, '1', 'description HELLO')
configuring_port_channel(t, '1', 'switchport trunk encapsulation dot1q')
configuring_port_channel(t, '1', 'switchport trunk native vla... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_port_channel_is_automatically_created_when_adding_a_port_to_it(self, t):
enable(t)
t.write("configure terminal")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switch(config)#")
t.write("interface FastEthernet0/1")
t.read("m... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_port_channel_is_not_automatically_created_when_adding_a_port_to_it_if_its_already_created(self, t):
enable(t)
create_port_channel_interface(t, '14')
t.write("configure terminal")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switc... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_setting_secondary_ips(self, t):
enable(t)
create_interface_vlan(t, "2999")
configuring_interface_vlan(t, "2999", do="description hey ho")
configuring_interface_vlan(t, "2999", do="no ip redirects")
configuring_interface_vlan(t, "2999", do="ip address 1.1.1.1 255.255.255... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_setting_access_group(self, t):
enable(t)
create_interface_vlan(t, "2999")
configuring_interface_vlan(t, "2999", do="ip access-group SHNITZLE in")
configuring_interface_vlan(t, "2999", do="ip access-group WHIZZLE out")
assert_interface_configuration(t, "Vlan2999", [
... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_removing_ip_address(self, t):
enable(t)
t.write("configure terminal")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switch(config)#")
t.write("interface vlan2999")
t.read("my_switch(config-if)#")
t.write("ip address... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_show_ip_interface(self, t):
enable(t)
create_vlan(t, "1000")
create_interface_vlan(t, "1000")
create_vlan(t, "2000")
create_vlan(t, "3000")
create_interface_vlan(t, "3000")
configuring_interface_vlan(t, "3000", do="ip address 1.1.1.1 255.255.255.0")
... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_assigning_a_secondary_ip_as_the_primary_removes_it_from_secondary_and_removes_the_primary(self, t):
enable(t)
create_interface_vlan(t, "4000")
configuring_interface_vlan(t, "4000", do="ip address 2.2.2.2 255.255.255.0")
configuring_interface_vlan(t, "4000", do="ip address 4.2.2... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_overlapping_ips(self, t):
enable(t)
create_vlan(t, "1000")
create_interface_vlan(t, "1000")
create_vlan(t, "2000")
create_interface_vlan(t, "2000")
configuring_interface_vlan(t, "1000", do="ip address 2.2.2.2 255.255.255.0")
configuring_interface_vlan(t... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_unknown_ip_interface(self, t):
enable(t)
t.write("show ip interface Vlan2345")
t.readln(" ^")
t.readln("% Invalid input detected at '^' marker.")
t.readln("")
t.read("my_switch#") | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_removing_ip_needs_to_compare_objects_better(self, t):
enable(t)
create_vlan(t, "1000")
create_interface_vlan(t, "1000")
configuring_interface_vlan(t, "1000", do="ip address 1.1.1.1 255.255.255.0")
configuring_interface_vlan(t, "1000", do="ip address 1.1.1.2 255.255.255... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_extreme_vlan_range(self, t):
enable(t)
t.write("configure terminal")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switch(config)#")
t.write("vlan -1")
t.readln("Command rejected: Bad VLAN list - character #1 ('-') delimit... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_full_running_config_and_pipe_begin_support(self, t):
enable(t)
create_vlan(t, "1000", name="hello")
create_interface_vlan(t, "1000")
configuring_interface(t, "Fa0/2", do="switchport mode trunk")
configuring_interface(t, "Fa0/2", do="switchport trunk allowed vlan 125")
... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_pipe_inc_support(self, t):
enable(t)
create_vlan(t, "1000", name="hello")
t.write("show running | inc vlan")
t.readln("vlan 1")
t.readln("vlan 1000")
t.read("my_switch#")
remove_vlan(t, "1000") | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_ip_vrf(self, t):
enable(t)
t.write("conf t")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switch(config)#")
t.write("ip vrf SOME-LAN")
t.read("my_switch(config-vrf)#")
t.write("exit")
t.read("my_switch(conf... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_ip_vrf_forwarding(self, t):
enable(t)
t.write("conf t")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switch(config)#")
t.write("ip vrf SOME-LAN")
t.read("my_switch(config-vrf)#")
t.write("exit")
t.read("my_... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_ip_vrf_default_lan(self, t):
enable(t)
t.write("conf t")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switch(config)#")
t.write("interface Fa0/2")
t.read("my_switch(config-if)#")
t.write("ip vrf forwarding DEFAULT... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_ip_setting_vrf_forwarding_wipes_ip_addresses(self, t):
enable(t)
create_vlan(t, "4000")
create_interface_vlan(t, "4000")
configuring_interface_vlan(t, "4000", do="ip address 10.10.0.10 255.255.255.0")
configuring_interface_vlan(t, "4000", do="ip address 10.10.1.10 255.2... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_ip_helper(self, t):
enable(t)
create_interface_vlan(t, "4000")
assert_interface_configuration(t, "Vlan4000", [
"interface Vlan4000",
" no ip address",
"end"])
t.write("configure terminal")
t.readln("Enter configuration commands, one... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_ip_route(self, t):
enable(t)
configuring(t, do="ip route 1.1.1.0 255.255.255.0 2.2.2.2")
t.write("show ip route static | inc 2.2.2.2")
t.readln("S 1.1.1.0 [x/y] via 2.2.2.2")
t.read("my_switch#")
t.write("show running | inc 2.2.2.2")
t.readln("ip... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_write_memory(self, t):
enable(t)
t.write("write memory")
t.readln("Building configuration...")
t.readln("OK")
t.read("my_switch#") | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_show_version(self, t):
enable(t)
t.write("show version")
t.readln("Cisco IOS Software, C3750 Software (C3750-IPSERVICESK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)")
t.readln("Technical Support: http://www.cisco.com/techsupport")
t.readln("Copyright (c) 1986-2011 ... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_reset_port(self, t):
enable(t)
configuring_interface(t, "FastEthernet0/3", do="description shizzle the whizzle and drizzle with lizzle")
configuring_interface(t, "FastEthernet0/3", do="shutdown")
set_interface_on_vlan(t, "FastEthernet0/3", "123")
assert_interface_confi... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_reset_port_invalid_interface_fails(self, t):
enable(t)
configuring_interface(t, "FastEthernet0/3", do="description shizzle the whizzle and drizzle with lizzle")
t.write("conf t")
t.readln("Enter configuration commands, one per line. End with CNTL/Z.")
t.read("my_switc... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_standby_version(self, t):
enable(t)
create_vlan(t, "2999")
create_interface_vlan(t, "2999")
configuring_interface_vlan(t, "2999", do='standby version 2')
assert_interface_configuration(t, "Vlan2999", [
"interface Vlan2999",
" no ip address",
... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def test_disable_ntp(self, t):
enable(t)
configuring_interface(t, "FastEthernet 0/3", do="ntp disable")
assert_interface_configuration(t, "FastEthernet0/3", [
"interface FastEthernet0/3",
" ntp disable",
"end"])
configuring_interface(t, "FastEtherne... | internap/fake-switches | [
53,
37,
53,
11,
1440447597
] |
def init(self, buffer_id, reporting=None, *args, **kwargs):
self.db_name = buffer_id
self.db_path = os.path.join(os.path.abspath(os.path.curdir), self.db_name + ".sq3")
self.db = adbapi.ConnectionPool('sqlite3', self.db_path, check_same_thread=False)
self._pushed_values = 0
self.... | EricssonResearch/calvin-base | [
283,
93,
283,
15,
1432032106
] |
def write(self, value):
def error(e):
_log.warning("Error during write: {}".format(e))
done() # Call done to wake scheduler, not sure this is a good idea
def done(unused=None):
self._changed = True # Let can_read know there may be something new to read
se... | EricssonResearch/calvin-base | [
283,
93,
283,
15,
1432032106
] |
def error(e):
_log.warning("Error during read: {}".format(e))
done() | EricssonResearch/calvin-base | [
283,
93,
283,
15,
1432032106
] |
def pop(db):
limit = 2 # <- Not empirically/theoretically tested
db.execute("SELECT value FROM queue ORDER BY rowid LIMIT (?)", (limit,))
value = db.fetchall() # a list of (value, ) tuples, or None
if value:
# pop values (i.e. delete rows with len(value) l... | EricssonResearch/calvin-base | [
283,
93,
283,
15,
1432032106
] |
def read(self):
value = []
while self._value:
# get an item from list of replies
dbtuple = self._value.pop(0)
# the item is a tuple, get the first value
dbvalue = dbtuple[0]
# convert value from string and return it
try:
... | EricssonResearch/calvin-base | [
283,
93,
283,
15,
1432032106
] |
def done(response):
# A count response; [(cnt,)]
if response[0][0] == 0:
try:
os.remove(self.db_path)
except:
# Failed for some reason
_log.warning("Could not remove db file {}".format(self._dbpath)) | EricssonResearch/calvin-base | [
283,
93,
283,
15,
1432032106
] |
def batch_norm(inputs, training, data_format, name=''):
"""Performs a batch normalization using a standard set of parameters."""
# We set fused=True for a significant performance boost. See
# https://www.tensorflow.org/performance/performance_guide#common_fused_ops
return tf.compat.v1.layers.batch_normalization... | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def fixed_padding(inputs, kernel_size, data_format):
"""Pads the input along the spatial dimensions independently of input size.
Args:
inputs: A tensor of size [batch, channels, height_in, width_in] or [batch,
height_in, width_in, channels] depending on data_format.
kernel_size: The kernel to be used... | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def _building_block_v2(inputs, filters, training, projection_shortcut, strides,
data_format, name):
"""A single block for ResNet v2, without a bottleneck.
Batch normalization then ReLu then convolution as described by:
Identity Mappings in Deep Residual Networks
https://arxiv.org/pdf... | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def projection_shortcut(inputs, name):
return conv2d_fixed_padding(
inputs=inputs,
filters=filters_out,
kernel_size=1,
strides=strides,
data_format=data_format,
name=name) | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def __init__(self,
resnet_size,
bottleneck,
num_classes,
num_filters,
kernel_size,
conv_stride,
first_pool_size,
first_pool_stride,
block_sizes,
block_strides,
... | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def _model_variable_scope(self):
"""Returns a variable scope that the model should be created under.
If self.dtype is a castable type, model variable will be created in fp32
then cast to self.dtype before being used.
Returns:
A variable scope for the model.
"""
return tf.compat.v1.varia... | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def si_as_number(text):
"""Convert a string containing an SI value to an integer or return an
integer if that is what was passed in."""
if type(text) == int:
return text
if type(text) not in [str, unicode]:
raise ValueError("Source value must be string or integer")
matches = si_re... | mfeit-internet2/pscheduler-dev | [
45,
31,
45,
115,
1452259533
] |
def si_range(value, default_lower=0):
"""Convert a range of SI numbers to a range of integers.
The 'value' is a dict containing members 'lower' and 'upper', each
being an integer or string suitable for si_as_number(). If
'value' is not a dict, it will be passed directly to
si_as_number() and treat... | mfeit-internet2/pscheduler-dev | [
45,
31,
45,
115,
1452259533
] |
def get_cache() -> Dict:
return dict() | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def solve_ast_type_functions(path: str, lib_ast: globals.Globals) -> KeysView:
root = lib_ast
for path_element in path.split("."):
root = getattr(root, path_element)
return root.attrs.keys() | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def solve_real_type_functions(path: str) -> Set[str]:
parts = path.split(".")
klass_name = parts[-1]
# TODO: a better way. Loot at https://github.com/OpenMined/PySyft/issues/5249
# A way to walkaround the problem we can't `import torch.return_types` and
# get it from `sys.module... | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def create_union_ast(
lib_ast: globals.Globals, client: TypeAny = None | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def generate_func(target_method: str) -> Callable:
def func(self: TypeAny, *args: TypeAny, **kwargs: TypeAny) -> TypeAny:
func = getattr(self, target_method, None)
if func:
return func(*args, **kwargs)
else:
... | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def prop_get(self: TypeAny) -> TypeAny:
prop = getattr(self, target_attribute, None)
if prop is not None:
return prop
else:
ValueError(
f"Can't call {target_attribute} on {klass} with ... | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def protest (response, message):
response.send_response(200)
response.send_header('Content-type','application/json')
response.end_headers()
response.wfile.write(message) | Comcast/rulio | [
339,
58,
339,
28,
1447456380
] |
def do_GET(self):
protest(self, "You should POST with json.\n")
return | Comcast/rulio | [
339,
58,
339,
28,
1447456380
] |
def create_pipeline(
pipeline_name: str,
pipeline_root: str,
data_path: str,
preprocessing_fn: str,
run_fn: str,
train_args: tfx.proto.TrainArgs,
eval_args: tfx.proto.EvalArgs,
eval_accuracy_threshold: float,
serving_model_dir: str,
schema_path: Optional[str] = None,
metadata... | tensorflow/tfx | [
1905,
649,
1905,
157,
1549300476
] |
def test_execute_command(self):
self.assertEqual(execute_command(['exit', '2'], shell=True), 2)
self.assertEqual(execute_command('exit 3', shell=True), 3)
if os.name == 'nt':
self.assertEqual(execute_command(['cmd', '/C', 'exit 4'], shell=False), 4)
self.assertEqual(execu... | mogproject/mog-commons-python | [
2,
1,
2,
2,
1444292691
] |
def test_execute_command_with_pid(self):
pid_file = os.path.join(tempfile.gettempdir(), 'mog-commons-python-test.pid')
class RunSleep(threading.Thread):
def run(self):
execute_command_with_pid('python -c "import time;time.sleep(2)"', pid_file, shell=True)
th = RunSl... | mogproject/mog-commons-python | [
2,
1,
2,
2,
1444292691
] |
def __init__(self, name):
self._name = name | zentralopensource/zentral | [
671,
87,
671,
23,
1445349783
] |
def __init__(self, resolver, proxy_type, key):
if proxy_type == "file":
self._method = resolver.get_file_content
elif proxy_type == "param":
self._method = resolver.get_parameter_value
elif proxy_type == "secret":
self._method = resolver.get_secret_value
... | zentralopensource/zentral | [
671,
87,
671,
23,
1445349783
] |
def __init__(self, child_proxy):
self._child_proxy = child_proxy | zentralopensource/zentral | [
671,
87,
671,
23,
1445349783
] |
def __init__(self, child_proxy):
self._child_proxy = child_proxy | zentralopensource/zentral | [
671,
87,
671,
23,
1445349783
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.