function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def set_app_version():
''' Declare the application version to juju '''
cmd = ['kubelet', '--version']
version = check_output(cmd)
hookenv.application_version_set(version.split(b' v')[-1].rstrip()) | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def notify_user_transient_status():
''' Notify to the user we are in a transient state and the application
is still converging. Potentially remotely, or we may be in a detached loop
wait state '''
# During deployment the worker has to start kubelet without cluster dns
# configured. If this is the f... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def charm_status(kube_control):
'''Update the status message with the current status of kubelet.'''
update_kubelet_status() | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def send_data(tls):
'''Send the data that is required to create a server certificate for
this server.'''
# Use the public ip of this unit as the Common Name for the certificate.
common_name = hookenv.unit_public_ip()
# Create SANs that the tls layer will add to the server cert.
sans = [
... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def watch_for_changes(kube_api, kube_control, cni):
''' Watch for configuration changes and signal if we need to restart the
worker services '''
servers = get_kube_api_servers(kube_api)
dns = kube_control.get_dns()
cluster_cidr = cni.get_config()['cidr']
if (data_changed('kube-api-servers', ser... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def start_worker(kube_api, kube_control, auth_control, cni):
''' Start kubelet using the provided API and DNS info.'''
servers = get_kube_api_servers(kube_api)
# Note that the DNS server doesn't necessarily exist at this point. We know
# what its IP will eventually be, though, so we can go ahead and con... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def configure_cni(cni):
''' Set worker configuration on the CNI relation. This lets the CNI
subordinate know that we're the worker so it can respond accordingly. '''
cni.set_config(is_master=False, kubeconfig_path=kubeconfig_path) | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def toggle_ingress_state():
''' Ingress is a toggled state. Remove ingress.available if set when
toggled '''
remove_state('kubernetes-worker.ingress.available') | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def sdn_changed():
'''The Software Defined Network changed on the container so restart the
kubernetes services.'''
restart_unit_services()
update_kubelet_status()
remove_state('docker.sdn.configured') | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def render_and_launch_ingress():
''' If configuration has ingress daemon set enabled, launch the ingress load
balancer and default http backend. Otherwise attempt deletion. '''
config = hookenv.config()
# If ingress is enabled, launch the ingress controller
if config.get('ingress'):
launch_d... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def apply_node_labels():
''' Parse the labels configuration option and apply the labels to the node.
'''
# scrub and try to format an array from the configuration option
config = hookenv.config()
user_labels = _parse_labels(config.get('labels'))
# For diffing sake, iterate the previous label se... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def extra_args_changed():
set_state('kubernetes-worker.restart-needed') | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def docker_logins_changed():
config = hookenv.config()
previous_logins = config.previous('docker-logins')
logins = config['docker-logins']
logins = json.loads(logins)
if previous_logins:
previous_logins = json.loads(previous_logins)
next_servers = {login['server'] for login in login... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def create_config(server, creds):
'''Create a kubernetes configuration for the worker unit.'''
# Get the options from the tls-client layer.
layer_options = layer.options('tls-client')
# Get all the paths to the tls information required for kubeconfig.
ca = layer_options.get('ca_certificate_path')
... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def configure_kubernetes_service(service, base_args, extra_args_key):
db = unitdata.kv()
prev_args_key = 'kubernetes-worker.prev_args.' + service
prev_args = db.get(prev_args_key) or {}
extra_args = parse_extra_args(extra_args_key)
args = {}
for arg in prev_args:
# remove previous arg... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def configure_kube_proxy(api_servers, cluster_cidr):
kube_proxy_opts = {}
kube_proxy_opts['cluster-cidr'] = cluster_cidr
kube_proxy_opts['kubeconfig'] = kubeproxyconfig_path
kube_proxy_opts['logtostderr'] = 'true'
kube_proxy_opts['v'] = '0'
kube_proxy_opts['master'] = random.choice(api_servers)
... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def launch_default_ingress_controller():
''' Launch the Kubernetes ingress controller & default backend (404) '''
context = {}
context['arch'] = arch()
addon_path = '/root/cdk/addons/{}'
context['defaultbackend_image'] = \
"gcr.io/google_containers/defaultbackend:1.4"
if arch() == 's390... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def get_kube_api_servers(kube_api):
'''Return the kubernetes api server address and port for this
relationship.'''
hosts = []
# Iterate over every service from the relation object.
for service in kube_api.services():
for unit in service['hosts']:
hosts.append('https://{0}:{1}'.fo... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def kubectl_success(*args):
''' Runs kubectl with the given args. Returns True if succesful, False if
not. '''
try:
kubectl(*args)
return True
except CalledProcessError:
return False | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def initial_nrpe_config(nagios=None):
set_state('nrpe-external-master.initial-config')
update_nrpe_config(nagios) | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def update_nrpe_config(unused=None):
services = ('snap.kubelet.daemon', 'snap.kube-proxy.daemon')
hostname = nrpe.get_nagios_hostname()
current_unit = nrpe.get_nagios_unit_name()
nrpe_setup = nrpe.NRPE(hostname=hostname)
nrpe.add_init_service_checks(nrpe_setup, services, current_unit)
nrpe_setup... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def remove_nrpe_config(nagios=None):
remove_state('nrpe-external-master.initial-config')
# List of systemd services for which the checks will be removed
services = ('snap.kubelet.daemon', 'snap.kube-proxy.daemon')
# The current nrpe-external-master interface doesn't handle a lot of logic,
# use th... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def on_config_allow_privileged_change():
"""React to changed 'allow-privileged' config value.
"""
set_state('kubernetes-worker.restart-needed')
remove_state('config.changed.allow-privileged') | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def enable_gpu():
"""Enable GPU usage on this node.
"""
config = hookenv.config()
if config['allow-privileged'] == "false":
hookenv.status_set(
'active',
'GPUs available. Set allow-privileged="auto" to enable.'
)
return
hookenv.log('Enabling gpu mode... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def disable_gpu():
"""Disable GPU usage on this node.
This handler fires when we're running in gpu mode, and then the operator
sets allow-privileged="false". Since we can no longer run privileged
containers, we need to disable gpu mode.
"""
hookenv.log('Disabling gpu mode')
# Remove node ... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def notify_master_gpu_enabled(kube_control):
"""Notify kubernetes-master that we're gpu-enabled.
"""
kube_control.set_gpu(True) | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def notify_master_gpu_not_enabled(kube_control):
"""Notify kubernetes-master that we're not gpu-enabled.
"""
kube_control.set_gpu(False) | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def request_kubelet_and_proxy_credentials(kube_control):
""" Request kubelet node authorization with a well formed kubelet user.
This also implies that we are requesting kube-proxy auth. """
# The kube-cotrol interface is created to support RBAC.
# At this point we might as well do the right thing and ... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def catch_change_in_creds(kube_control):
"""Request a service restart in case credential updates were detected."""
nodeuser = 'system:node:{}'.format(gethostname().lower())
creds = kube_control.get_auth_credentials(nodeuser)
if creds \
and data_changed('kube-control.creds', creds) \
... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def missing_kube_control():
"""Inform the operator they need to add the kube-control relation.
If deploying via bundle this won't happen, but if operator is upgrading a
a charm in a deployment that pre-dates the kube-control relation, it'll be
missing.
"""
hookenv.status_set(
'blocked'... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def fix_iptables_for_docker_1_13():
""" Fix iptables FORWARD policy for Docker >=1.13
https://github.com/kubernetes/kubernetes/issues/40182
https://github.com/kubernetes/kubernetes/issues/39823
"""
cmd = ['iptables', '-w', '300', '-P', 'FORWARD', 'ACCEPT']
check_call(cmd) | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def get_node_name():
# Get all the nodes in the cluster
cmd = 'kubectl --kubeconfig={} get no -o=json'.format(kubeconfig_path)
cmd = cmd.split()
deadline = time.time() + 60
while time.time() < deadline:
try:
raw = check_output(cmd)
break
except CalledProcessEr... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def _apply_node_label(label, delete=False, overwrite=False):
''' Invoke kubectl to apply node label changes '''
nodename = get_node_name()
# TODO: Make this part of the kubectl calls instead of a special string
cmd_base = 'kubectl --kubeconfig={0} label node {1} {2}'
if delete is True:
lab... | cncf/cross-cloud | [
164,
57,
164,
40,
1494451575
] |
def mm(self, barparam):
'''
@param barparam: this is barparam
''' | aptana/Pydev | [
239,
85,
239,
6,
1250792405
] |
def test_load_tsv_file(self):
self.assertEqual(self.TSV_CONTENTS, generator_utils.load_tsv_file(
os.path.join(SRC_DIR,
"tools/traffic_annotation/scripts/test_data/fake_annotations.tsv"),
False)) | chromium/chromium | [
14247,
5365,
14247,
62,
1517864132
] |
def test_xml_parser_build_placeholders(self):
xml_parser = generator_utils.XMLParser(
os.path.join(TESTS_DIR, "fake_grouping.xml"), self.ANNOTATIONS_MAPPING)
self.assertEqual(self.PLACEHOLDERS, xml_parser.build_placeholders()) | chromium/chromium | [
14247,
5365,
14247,
62,
1517864132
] |
def test_find_last_index(self):
last_index = generator_utils.find_last_index(self.DOC_JSON)
self.assertEqual(2066, last_index) | chromium/chromium | [
14247,
5365,
14247,
62,
1517864132
] |
def test_find_bold_ranges(self):
expected_bold_ranges = [(1843, 1855), (1859, 1867), (1871, 1876),
(1880, 1889), (1893, 1900), (1918, 1930),
(1934, 1942), (1968, 1975), (1946, 1951),
(1955, 1964), (2001, 2013), (2017, 2025),
... | chromium/chromium | [
14247,
5365,
14247,
62,
1517864132
] |
def get_current_request_hostname():
"""
This method will return the hostname that was used in the current Django request
"""
hostname = None
request = get_current_request()
if request:
hostname = request.META.get('HTTP_HOST')
return hostname | edx/edx-platform | [
6290,
3437,
6290,
280,
1369945238
] |
def syntax(self):
return "[-v]" | openhatch/oh-mainline | [
238,
323,
238,
203,
1321317235
] |
def add_options(self, parser):
ScrapyCommand.add_options(self, parser)
parser.add_option("--verbose", "-v", dest="verbose", action="store_true",
help="also display twisted/python/platform info (useful for bug reports)") | openhatch/oh-mainline | [
238,
323,
238,
203,
1321317235
] |
def regions():
"""
Get all available regions for the AWS CloudHSM service.
:rtype: list
:return: A list of :class:`boto.regioninfo.RegionInfo`
"""
from boto.cloudhsm.layer1 import CloudHSMConnection
return get_regions('cloudhsm', connection_cls=CloudHSMConnection) | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def __init__(self, name="", point=None, attributes=None, **kwargs):
self.name = name
if point is not None:
self.point = Point(point)
if attributes is None:
attributes = {}
self.attributes = dict(attributes, **kwargs) | golismero/golismero | [
814,
275,
814,
29,
1375181550
] |
def __getitem__(self, index):
"""Backwards compatibility with geopy 0.93 tuples."""
return (self.name, self.point)[index] | golismero/golismero | [
814,
275,
814,
29,
1375181550
] |
def __repr__(self):
return "Location(%r, %r)" % (self.name, self.point) | golismero/golismero | [
814,
275,
814,
29,
1375181550
] |
def __iter__(self):
return iter((self.name, self.point)) | golismero/golismero | [
814,
275,
814,
29,
1375181550
] |
def __eq__(self, other):
return (self.name, self.point) == (other.name, other.point) | golismero/golismero | [
814,
275,
814,
29,
1375181550
] |
def __ne__(self, other):
return (self.name, self.point) != (other.name, other.point) | golismero/golismero | [
814,
275,
814,
29,
1375181550
] |
def mknet(mkbn=lambda chan: df.BatchNormalization(chan, 0.95)):
kw = dict(mkbn=mkbn)
net = df.Sequential(
# -> 128x48
df.SpatialConvolutionCUDNN(3, 64, (7,7), border='same', bias=None),
dfext.resblock(64, **kw),
df.PoolingCUDNN((2,2)), # -> 64x24
dfext.resblock(64, **kw... | VisualComputingInstitute/towards-reid-tracking | [
82,
18,
82,
1,
1494600159
] |
def __init__(self, logdir):
self.PLUGIN_LOGDIR = logdir + '/plugins/' + PLUGIN_NAME
self.is_recording = False
self.video_writer = video_writing.VideoWriter(
self.PLUGIN_LOGDIR,
outputs=[video_writing.FFmpegVideoOutput, video_writing.PNGVideoOutput])
self.last_im... | lanpa/tensorboardX | [
7545,
867,
7545,
76,
1497362059
] |
def _write_summary(self, frame):
'''Writes the frame to disk as a tensor summary.'''
path = '{}/{}'.format(self.PLUGIN_LOGDIR, SUMMARY_FILENAME)
smd = SummaryMetadata()
tensor = TensorProto(
dtype='DT_FLOAT',
float_val=frame.reshape(-1).tolist(),
tenso... | lanpa/tensorboardX | [
7545,
867,
7545,
76,
1497362059
] |
def stats(tensor_and_name):
imgstats = []
for (img, name) in tensor_and_name:
immax = img.max()
immin = img.min()
imgstats.append(
{
'height': img.shape[0],
'max': str(immax),
'mean': str(img.... | lanpa/tensorboardX | [
7545,
867,
7545,
76,
1497362059
] |
def _enough_time_has_passed(self, FPS):
'''For limiting how often frames are computed.'''
if FPS == 0:
return False
else:
earliest_time = self.last_update_time + (1.0 / FPS)
return time.time() >= earliest_time | lanpa/tensorboardX | [
7545,
867,
7545,
76,
1497362059
] |
def _update_recording(self, frame, config):
'''Adds a frame to the current video output.'''
# pylint: disable=redefined-variable-type
should_record = config['is_recording']
if should_record:
if not self.is_recording:
self.is_recording = True
p... | lanpa/tensorboardX | [
7545,
867,
7545,
76,
1497362059
] |
def update(self, trainable=None, arrays=None, frame=None):
'''Creates a frame and writes it to disk.
Args:
trainable: a list of namedtuple (tensors, name).
arrays: a list of namedtuple (tensors, name).
frame: lalala
'''
new_config = self._get_config(... | lanpa/tensorboardX | [
7545,
867,
7545,
76,
1497362059
] |
def _compute_scheduled_date(self):
for rself in self:
if rself.interval_type not in [
"transferring_started",
"transferring_finished",
]:
return super(EventMailScheduler, rself)._compute_scheduled_date()
if rself.event_id.state... | it-projects-llc/website-addons | [
122,
304,
122,
13,
1431434015
] |
def findLadders(self, beginWord, endWord, wordlist):
"""
:type beginWord: str
:type endWord: str
:type wordlist: Set[str]
:rtype: List[List[int]]
""" | gavinfish/leetcode-share | [
181,
133,
181,
1,
1449815478
] |
def bfs(front_level, end_level, is_forward, word_set, path_dic):
if len(front_level) == 0:
return False
if len(front_level) > len(end_level):
return bfs(end_level, front_level, not is_forward, word_set, path_dic)
for word in (front_level | end_lev... | gavinfish/leetcode-share | [
181,
133,
181,
1,
1449815478
] |
def add_path(word, new_word, is_forward, path_dic):
if is_forward:
path_dic[word] = path_dic.get(word, []) + [new_word]
else:
path_dic[new_word] = path_dic.get(new_word, []) + [word] | gavinfish/leetcode-share | [
181,
133,
181,
1,
1449815478
] |
def construct_path(word, end_word, path_dic, path, paths):
if word == end_word:
paths.append(path)
return
if word in path_dic:
for item in path_dic[word]:
construct_path(item, end_word, path_dic, path + [item], paths) | gavinfish/leetcode-share | [
181,
133,
181,
1,
1449815478
] |
def _prepare_docstring(s, ignore=1):
# type: (unicode, int) -> List[unicode]
"""Convert a docstring into lines of parseable reST. Remove common leading
indentation, where the indentation of a given number of lines (usually just
one) is ignored.
Return the docstring as a list of lines usable for ins... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def __init__(self, docstring=None, what='', name='',
obj=None, options=None):
if not what:
if inspect.isclass(obj):
what = 'class'
elif inspect.ismodule(obj):
what = 'module'
elif isinstance(obj, collections.Callable): # type... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def result(self):
# type: () -> List[unicode]
"""Return the parsed lines of the docstring in reStructuredText format.
Returns
-------
list(str)
The lines of the docstring in a list.
"""
return {'sections': self._parsed_lines, **self._parsed_dicts} | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _consume_contiguous(self):
# type: () -> List[unicode]
lines = []
while (self._line_iter.has_next() and
self._line_iter.peek() and
not self._is_section_header()):
lines.append(next(self._line_iter)) # type: ignore
return lines | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _consume_field(self, parse_type=True, prefer_type=False):
# type: (bool, bool) -> Tuple[unicode, unicode, List[unicode]]
line = next(self._line_iter) # type: ignore
before, colon, after = self._partition_field_on_colon(line)
_name, _type, _desc = before, '', after # type: unicode,... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _consume_section_header(self):
# type: () -> unicode
section = next(self._line_iter) # type: ignore
stripped_section = section.strip(':')
if stripped_section.lower() in self._sections:
section = stripped_section
return section | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _consume_to_next_section(self):
# type: () -> List[unicode]
self._consume_empty()
lines = []
while not self._is_section_break():
lines.append(next(self._line_iter)) # type: ignore
return lines + self._consume_empty() | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _escape_args_and_kwargs(self, name):
# type: (unicode) -> unicode
if name[:2] == '**':
return r'\*\*' + name[2:]
elif name[:1] == '*':
return r'\*' + name[1:]
else:
return name | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _get_current_indent(self, peek_ahead=0):
# type: (int) -> int
line = self._line_iter.peek(peek_ahead + 1)[peek_ahead]
while line != self._line_iter.sentinel:
if line:
return self._get_indent(line)
peek_ahead += 1
line = self._line_iter.peek... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _get_initial_indent(self, lines):
# type: (List[unicode]) -> int
for line in lines:
if line:
return self._get_indent(line)
return 0 | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _indent(self, lines, n=4):
# type: (List[unicode], int) -> List[unicode]
return [(' ' * n) + line for line in lines] | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _is_list(self, lines):
# type: (List[unicode]) -> bool
if not lines:
return False
if _bullet_list_regex.match(lines[0]): # type: ignore
return True
if _enumerated_list_regex.match(lines[0]): # type: ignore
return True
if len(lines) < 2 or... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _is_section_break(self):
# type: () -> bool
line = self._line_iter.peek()
return (not self._line_iter.has_next() or
self._is_section_header() or
(self._is_in_section and
line and
not self._is_indented(line, self._section... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _parse_fields_section(self):
# type: (unicode) -> List[unicode]
fields = self._consume_fields()
# type: (List[Tuple[unicode, unicode, List[unicode]]], unicode, unicode) -> List[unicode] # NOQA
lines = []
for _name, _type, _desc in fields:
_desc = self._strip_emp... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def _partition_field_on_colon(self, line):
# type: (unicode) -> Tuple[unicode, unicode, unicode]
before_colon = []
after_colon = []
colon = ''
found_colon = False
for i, source in enumerate(_xref_regex.split(line)): # type: ignore
if found_colon:
... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def __init__(self):
self._client = MattermostClient(
bot_settings.BOT_URL, bot_settings.BOT_TEAM,
bot_settings.BOT_LOGIN, bot_settings.BOT_PASSWORD,
bot_settings.SSL_VERIFY
)
self._plugins = PluginsManager()
self._plugins.init_plugins()
sel... | seLain/mattermost_bot | [
5,
1,
5,
7,
1505455582
] |
def update(levels):
vis = np.zeros((cvImg.height, cvImg.width, 3), np.uint8)
levels = levels - 3
cv2.drawContours( vis, contours, (-1, 3)[levels <= 0], (128,255,255),
3, cv2.CV_AA, hierarchy, abs(levels) )
cv2.imshow('contours', vis) | hasadna/OpenPress | [
2,
8,
2,
21,
1383756546
] |
def init_app(app):
pass | miguelgrinberg/flasky | [
8080,
4112,
8080,
19,
1387863492
] |
def init_app(cls, app):
Config.init_app(app)
# email errors to the administrators
import logging
from logging.handlers import SMTPHandler
credentials = None
secure = None
if getattr(cls, 'MAIL_USERNAME', None) is not None:
credentials = (cls.MAIL_USER... | miguelgrinberg/flasky | [
8080,
4112,
8080,
19,
1387863492
] |
def init_app(cls, app):
ProductionConfig.init_app(app)
# handle reverse proxy server headers
try:
from werkzeug.middleware.proxy_fix import ProxyFix
except ImportError:
from werkzeug.contrib.fixers import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app)
... | miguelgrinberg/flasky | [
8080,
4112,
8080,
19,
1387863492
] |
def init_app(cls, app):
ProductionConfig.init_app(app)
# log to stderr
import logging
from logging import StreamHandler
file_handler = StreamHandler()
file_handler.setLevel(logging.INFO)
app.logger.addHandler(file_handler) | miguelgrinberg/flasky | [
8080,
4112,
8080,
19,
1387863492
] |
def init_app(cls, app):
ProductionConfig.init_app(app)
# log to syslog
import logging
from logging.handlers import SysLogHandler
syslog_handler = SysLogHandler()
syslog_handler.setLevel(logging.INFO)
app.logger.addHandler(syslog_handler) | miguelgrinberg/flasky | [
8080,
4112,
8080,
19,
1387863492
] |
def run_app(uri, type, parameter, **kwargs):
kwargs = {key: value for key, value in kwargs.items() if value is not None}
do = try_load(uri, type, parameters=parameter)
do = try_apply_sql(do, kwargs)
with qt_app():
from boadata.gui.qt import DataObjectWindow
window = DataObjectWindow(d... | janpipek/boadata | [
3,
1,
3,
10,
1410266406
] |
def higgs_signalstrength(wc_obj, par, name_prod, name_dec):
scale = flavio.config['renormalization scale']['hdecays']
C = wc_obj.get_wcxf(sector='all', scale=scale, par=par,
eft='SMEFT', basis='Warsaw')
f_prod = getattr(production, name_prod)
f_dec = getattr(decay, name_dec)
... | flav-io/flavio | [
66,
57,
66,
23,
1453802592
] |
def obs_fct(wc_obj, par):
return higgs_signalstrength(wc_obj, par, name_prod, name_dec) | flav-io/flavio | [
66,
57,
66,
23,
1453802592
] |
def __init__(
self, plotly_name="color", parent_name="surface.hoverlabel.font", **kwargs | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def clear(self) -> None:
raise NotImplementedError("implement in derived class") | ap--/python-seabreeze | [
172,
72,
172,
35,
1413502221
] |
def get_number_of_elements(self) -> int:
raise NotImplementedError("implement in derived class") | ap--/python-seabreeze | [
172,
72,
172,
35,
1413502221
] |
def set_buffer_capacity(self, capacity: int) -> None:
raise NotImplementedError("implement in derived class") | ap--/python-seabreeze | [
172,
72,
172,
35,
1413502221
] |
def __unicode__(self):
return self.name | bootcamptropa/django | [
7,
6,
7,
1,
1447057534
] |
def setUp(self):
# There will be a lot of warnings in the feature calculators.
# Just ignore all of them in these tests
warnings.simplefilter("ignore") | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def assertIsNaN(self, result):
self.assertTrue(np.isnan(result), msg="{} is not np.NaN") | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def assertTrueOnAllArrayTypes(self, f, input_to_f, *args, **kwargs):
self.assertTrue(f(input_to_f, *args, **kwargs), msg="Not true for lists")
self.assertTrue(
f(np.array(input_to_f), *args, **kwargs), msg="Not true for numpy.arrays"
)
self.assertTrue(
f(pd.Series... | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def assertFalseOnAllArrayTypes(self, f, input_to_f, *args, **kwargs):
self.assertFalse(f(input_to_f, *args, **kwargs), msg="Not false for lists")
self.assertFalse(
f(np.array(input_to_f), *args, **kwargs), msg="Not false for numpy.arrays"
)
self.assertFalse(
f(pd.... | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def assertAlmostEqualOnAllArrayTypes(self, f, input_to_f, result, *args, **kwargs):
expected_result = f(input_to_f, *args, **kwargs)
self.assertAlmostEqual(
expected_result,
result,
msg="Not almost equal for lists: {} != {}".format(expected_result, result),
)
... | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def assertEqualPandasSeriesWrapper(self, f, input_to_f, result, *args, **kwargs):
self.assertEqual(
f(pd.Series(input_to_f), *args, **kwargs),
result,
msg="Not equal for pandas.Series: {} != {}".format(
f(pd.Series(input_to_f), *args, **kwargs), result
... | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def test___get_length_sequences_where(self):
self.assertEqualOnAllArrayTypes(
_get_length_sequences_where,
[0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1],
[1, 3, 1, 2],
)
self.assertEqualOnAllArrayTypes(
_get_length_sequences_where,
[0, True, ... | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def test_variance_larger_than_standard_deviation(self):
self.assertFalseOnAllArrayTypes(
variance_larger_than_standard_deviation, [-1, -1, 1, 1, 1]
)
self.assertTrueOnAllArrayTypes(
variance_larger_than_standard_deviation, [-1, -1, 1, 1, 2]
) | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def test_symmetry_looking(self):
self.assertAllTrueOnAllArrayTypes(
symmetry_looking, [-1, -1, 1, 1], [dict(r=0.05), dict(r=0.75)]
)
self.assertAllFalseOnAllArrayTypes(
symmetry_looking, [-1, -1, 1, 1], [dict(r=0)]
)
self.assertAllFalseOnAllArrayTypes(
... | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
def test_has_duplicate_min(self):
self.assertTrueOnAllArrayTypes(has_duplicate_min, [-2.1, 0, 0, -2.1, 1.1])
self.assertFalseOnAllArrayTypes(has_duplicate_min, [2.1, 0, -1, 2, 1.1])
self.assertTrueOnAllArrayTypes(has_duplicate_min, np.array([1, 1, 1, 1]))
self.assertFalseOnAllArrayTypes(... | blue-yonder/tsfresh | [
7135,
1120,
7135,
61,
1477481357
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.