Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Using the snippet: <|code_start|># You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either...
data = named_data.get_named_ground_truth_data(dataset_name)
Given snippet: <|code_start|> def visualize_dataset(dataset_name, output_path, num_animations=5, num_frames=20, fps=10): """Visualizes the data set by saving images to output_path. For each latent factor, outputs 16 images where only that latent factor is varied while all others are kept c...
visualize_util.grid_save_images(
Given the code snippet: <|code_start|># coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www....
visualize_dataset.visualize_dataset("dummy_data",
Predict the next line for this snippet: <|code_start|># coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #...
ground_truth_data = dummy_data.DummyData()
Using the snippet: <|code_start|># coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apach...
dataset = util.tf_data_set_from_ground_truth_data(ground_truth_data, 0)
Continue the code snippet: <|code_start|># Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
new_dict = results.namespaced_dict(base_dict, numbers=numbers, chars=chars)
Using the snippet: <|code_start|># # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for...
ground_truth_data = dummy_data.IdentityObservationsData()
Given the following code snippet before the placeholder: <|code_start|># Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific l...
scores = unified_scores.compute_unified_scores(
Based on the snippet: <|code_start|># coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.ap...
ground_truth_data = dummy_data.IdentityObservationsData()
Using the snippet: <|code_start|># coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apach...
scores = sap_score.compute_sap(
Predict the next line for this snippet: <|code_start|> "loss": loss, "reconstruction_loss": reconstruction_loss, "elbo": -elbo }, every_n_iter=100) return contrib_tpu.TPUEstimatorSpec( mode=mode, loss=loss, ...
return architectures.make_gaussian_encoder(
Continue the code snippet: <|code_start|># # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the Lic...
per_sample_loss = losses.make_reconstruction_loss(features, reconstructions)
Given the code snippet: <|code_start|># limitations under the License. """Library of losses for disentanglement learning. Implementation of VAE based models for unsupervised learning of disentangled representations. """ from __future__ import absolute_import from __future__ import division from __future__ import prin...
optimizer = optimizers.make_vae_optimizer()
Predict the next line after this snippet: <|code_start|># coding=utf-8 # Copyright 2018 The DisentanglementLib Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at #...
class BaseVAE(gaussian_encoder_model.GaussianEncoderModel):
Based on the snippet: <|code_start|> else: elt = self.f(self.buf) if isinstance(elt, t): return elt else: return t._make(elt) def build_reducer(reducer): if hasattr(reducer, "begin_group"): return reducer else: return Reducer(reducer) ...
stream = sort(stream, key)
Using the snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestBlockEntropy(unittest.TestCase): def test_block_entropy_empty(self): with self.assertRaises(ValueError): ...
with self.assertRaises(InformError):
Given the code snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestBlockEntropy(unittest.TestCase): def test_block_entropy_empty(self): with self.assertRaises(ValueErro...
block_entropy([], 1)
Given the code snippet: <|code_start|># license that can be found in the LICENSE file. class TestConditionalEntropy(unittest.TestCase): def test_conditional_entropy_empty(self): with self.assertRaises(ValueError): conditional_entropy([], []) with self.assertRaises(ValueError): ...
with self.assertRaises(InformError):
Using the snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestConditionalEntropy(unittest.TestCase): def test_conditional_entropy_empty(self): with self.assertRaises(V...
conditional_entropy([], [])
Based on the snippet: <|code_start|> elif isinf(x) or isinf(y): self.fail("unequal infinite values") else: self.assertAlmostEqual(x, y, places=places) def test_relative_entropy_empty(self): with self.assertRaises(ValueError): relative_entropy([], []) ...
with self.assertRaises(InformError):
Predict the next line for this snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestRelativeEntropy(unittest.TestCase): def assertQuasiEqual(self, x, y, places=7): if i...
relative_entropy([], [])
Given snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestEntropyRate(unittest.TestCase): def test_entropy_rate_empty(self): with self.assertRaises(ValueError): ...
with self.assertRaises(InformError):
Next line prediction: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestEntropyRate(unittest.TestCase): def test_entropy_rate_empty(self): with self.assertRaises(ValueError): ...
entropy_rate([], 1)
Using the snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestActiveInfo(unittest.TestCase): def test_active_info_empty(self): with self.assertRaises(ValueError): ...
with self.assertRaises(InformError):
Here is a snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestActiveInfo(unittest.TestCase): def test_active_info_empty(self): with self.assertRaises(ValueError): <|cod...
active_info([], 1)
Given snippet: <|code_start|># Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestMutualInfo(unittest.TestCase): def test_mutual_info_empty(self): with self.assertRaises(ValueError): mutual_info([], []) with self.assertRaises(ValueE...
with self.assertRaises(InformError):
Here is a snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestMutualInfo(unittest.TestCase): def test_mutual_info_empty(self): with self.assertRaises(ValueError): <|cod...
mutual_info([], [])
Given snippet: <|code_start|># Copyright 2016-2019 Douglas G. Moore. All rights reserved. # Use of this source code is governed by a MIT # license that can be found in the LICENSE file. class TestTransferEntropy(unittest.TestCase): def test_transfer_entropy_empty(self): with self.assertRaises(ValueError):...
transfer_entropy([], [], 1)
Predict the next line after this snippet: <|code_start|> def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), 'ip_address': get_ip_address(), 'distro': get_distro(), } return system_info_dict def system(self): system_dat...
return processes_data_collector.collect()
Based on the snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), 'ip_address': get_ip_address(), 'distro': get_distro(), } return system_info...
'uptime': get_uptime(),
Given snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), 'ip_address': get_ip_address(), 'distro': get_distro(), } return system_info_dict ...
'memory': get_memory_info(),
Based on the snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), 'ip_address': get_ip_address(), 'distro': get_distro(), } return system_info...
'cpu': get_cpu_utilization(),
Using the snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), 'ip_address': get_ip_address(), 'distro': get_distro(), } return system_info_di...
'loadavg': get_load_average(),
Given the code snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), 'ip_address': get_ip_address(), 'distro': get_distro(), } return system_in...
'disk': disk_check.check(),
Given the code snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), 'ip_address': get_ip_address(), 'distro': get_distro(), } return system_in...
'network': get_network_traffic(),
Given snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), <|code_end|> , continue by predicting the next line. Consider current file imports: from amona...
'ip_address': get_ip_address(),
Given the following code snippet before the placeholder: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { <|code_end|> , predict the next line using imports from the current file: from amona...
'processor': get_cpu_info(),
Given snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): self.plugins_list = discover_plugins() def info(self): system_info_dict = { 'processor': get_cpu_info(), 'ip_address': get_ip_address(), <|code_end|> , continue by predicting the next line. Conside...
'distro': get_distro(),
Given the code snippet: <|code_start|> log = logging.getLogger(__name__) class Runner(object): def __init__(self): <|code_end|> , generate the next line using the imports in this file: from amonagent.modules.processes import processes_data_collector from amonagent.modules.core import ( get_uptime, get_memory_inf...
self.plugins_list = discover_plugins()
Using the snippet: <|code_start|> log = logging.getLogger(__name__) def get_cpu_info(): processor_dict = {} with open('/proc/cpuinfo', 'r') as l: lines = l.readlines() for line in lines: <|code_end|> , determine the next line of code. You have imports: import subprocess import re import logging from amonag...
parsed_line = split_and_slugify(line)
Predict the next line for this snippet: <|code_start|> def check(self): data = {} try: df = subprocess.Popen(['df','-m'], stdout=subprocess.PIPE, close_fds=True).communicate()[0] dfi = subprocess.Popen(['df','-i'], stdout=subprocess.PIPE, close_fds=True).communicate()[0] except: log.exception('Unabl...
v['percent'] = to_float(v['percent'].replace("%",'')) # Delete the % sign for easier calculation later
Given the code snippet: <|code_start|> ### UTILS ### Used in PostgreSQL, Mysql, Mongo def normalize_row_value(self, value): if type(value) is Decimal: value = round(value, 2) elif type(value) is timedelta: value = value.total_seconds() elif type(value) is datetime: value = str(value) elif type(valu...
default_location = "{0}/{1}".format(settings.DEFAULT_PLUGINS_PATH, plugin_name)
Given the following code snippet before the placeholder: <|code_start|> class SystemPackages(object): def __init__(self): distro = get_distro() # apt or yum self.distro_type = distro.get('type') <|code_end|> , predict the next line using imports from the current file: import re import subprocess from amonag...
self.next_run = unix_utc_now()
Continue the code snippet: <|code_start|> log = logging.getLogger(__name__) class ProcessesDataCollector(object): def __init__(self): <|code_end|> . Use current file imports: import subprocess import re import logging from amonagent.modules.core import get_memory_info and context (classes, functions, or code) fro...
memory = get_memory_info()
Here is a snippet: <|code_start|> message = 'Fail' color = FAIL print "Distro collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) info = get_cpu_info() if len(info) > 0: message = 'OK' color = OKGREEN else: message = 'Fail' color =...
info = get_uptime()
Continue the code snippet: <|code_start|> else: message = 'Fail' color = FAIL print "CPU Info collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) info = get_ip_address() if len(info) > 0: message = 'OK' color = OKGREEN else: message = ...
info = get_memory_info()
Using the snippet: <|code_start|> else: message = 'Fail' color = FAIL print "Disk usage collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) info = get_network_traffic() if len(info) > 0: message = 'OK' color = OKGREEN else: message = ...
info = get_cpu_utilization()
Predict the next line after this snippet: <|code_start|> message = 'Fail' color = FAIL print "Memory collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) info = disk_check.check() if len(info) > 0: message = 'OK' color = OKGREEN else: m...
info = get_load_average()
Given the following code snippet before the placeholder: <|code_start|> message = 'Fail' color = FAIL print "IP address collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) info = get_uptime() if len(info) > 0: message = 'OK' color = OKGREE...
info = disk_check.check()
Using the snippet: <|code_start|> color = FAIL print "Uptime collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) info = get_memory_info() if len(info) > 0: message = 'OK' color = OKGREEN else: message = 'Fail' color = FAIL print "Mem...
info = get_network_traffic()
Here is a snippet: <|code_start|> print info print SEPARATOR def test_checks(): # Distro information info = get_distro() if len(info) > 0: message = 'OK' color = OKGREEN else: message = 'Fail' color = FAIL print "Distro collector: {color}{message}{end}".format(color=color, message=message, end=ENDC)...
info = get_ip_address()
Here is a snippet: <|code_start|> OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' SEPARATOR = "\n{color}---------{end}\n".format(color=OKGREEN,end=ENDC) def print_data(info=None, message=None): if message == 'OK': print info print SEPARATOR def test_checks(): # ...
info = get_cpu_info()
Based on the snippet: <|code_start|> color = OKGREEN else: message = 'Fail' color = FAIL print "Network traffic collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) info = get_load_average() if len(info) > 0: message = 'OK' color = OKGRE...
info = processes_data_collector.collect()
Given the following code snippet before the placeholder: <|code_start|> OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' SEPARATOR = "\n{color}---------{end}\n".format(color=OKGREEN,end=ENDC) def print_data(info=None, message=None): if message == 'OK': print info ...
info = get_distro()
Continue the code snippet: <|code_start|> message = 'OK' color = OKGREEN else: message = 'Fail' color = FAIL print "Process collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) url = "{0}/api/test/{1}".format(settings.HOST, settings.SERVE...
enabled_plugins = discover_plugins()
Here is a snippet: <|code_start|> message = 'Fail' color = FAIL print "Load collector: {color}{message}{end}".format(color=color, message=message, end=ENDC) print_data(info=info, message=message) info = get_cpu_utilization() if len(info) > 0: message = 'OK' color = OKGREEN else: message = 'Fail' color...
url = "{0}/api/test/{1}".format(settings.HOST, settings.SERVER_KEY)
Given the code snippet: <|code_start|>try: except ImportError: log = logging.getLogger(__name__) class ConnectionException(Exception): " Raised when the Amon Web interface is not responding" class Remote(object): def __init__(self): <|code_end|> , generate the next line using the imports in this file: import...
self.server_key = settings.SERVER_KEY
Based on the snippet: <|code_start|> def get_log_date_format(): return "%Y-%m-%d %H:%M:%S %Z" def get_log_format(logger_name): return '%%(asctime)s | %%(levelname)s | %s | %%(name)s(%%(filename)s:%%(lineno)s) | %%(message)s' % logger_name def initialize_logging(logger_name): <|code_end|> , predict the immediate...
log_file = settings.LOGFILE
Given snippet: <|code_start|> try: except ImportError: try: config_file = file('/etc/amon-agent.conf').read() config = json.loads(config_file) except Exception, e: print "There was an error in your configuration file (/etc/amon-agent.conf)" raise e class Settings(object): def __init__(self): # update this...
for setting in dir(defaults):
Continue the code snippet: <|code_start|> class TestSystemCheck(object): def test_uptime(self): uptime = get_uptime() assert isinstance(uptime, str) def test_ip_address(self): ip_address = get_ip_address() valid_ip = False try: socket.inet_pton(socket.AF_INET, ip_address) valid_ip = True exce...
memory_dict = get_memory_info()
Given the following code snippet before the placeholder: <|code_start|> assert 'swap_used_percent' in memory_dict assert 'swap_total_mb' in memory_dict assert 'used_percent' > 0 for v in memory_dict.values(): assert isinstance(v, int) def test_cpu_info(self): cpu_info = get_cpu_info() assert isinst...
cpu = get_cpu_utilization()
Given the following code snippet before the placeholder: <|code_start|> def test_disk(self): disk = disk_check.check() for k in disk: _dict = disk[k] assert 'used' in _dict assert 'percent' in _dict assert 'free' in _dict assert 'volume' in _dict assert 'total' in _dict def test_cpu(self): ...
loadavg = get_load_average()
Based on the snippet: <|code_start|> for v in cpu.values(): # Could be 1.10 - 4, 10.10 - 5, 100.00 - 6 assert len(v) == 4 or len(v) == 5 or len(v) == 6 value_regex = re.compile(r'\d+[\.]\d+') assert re.match(value_regex, v) def test_loadavg(self): loadavg = get_load_average() assert 'minute' in l...
network_data = get_network_traffic()
Based on the snippet: <|code_start|> class TestSystemCheck(object): def test_uptime(self): uptime = get_uptime() assert isinstance(uptime, str) def test_ip_address(self): <|code_end|> , predict the immediate next line with the help of imports: import sys import re import socket from amonagent.modules.core...
ip_address = get_ip_address()
Given the code snippet: <|code_start|> except socket.error: pass except socket.error: # not a valid address pass assert valid_ip def test_memory(self): memory_dict = get_memory_info() assert 'free_mb' in memory_dict assert 'total_mb' in memory_dict assert 'used_mb' in memory_dict assert...
cpu_info = get_cpu_info()
Next line prediction: <|code_start|> def test_memory(self): memory_dict = get_memory_info() assert 'free_mb' in memory_dict assert 'total_mb' in memory_dict assert 'used_mb' in memory_dict assert 'used_percent' in memory_dict assert 'swap_free_mb' in memory_dict assert 'swap_used_mb' in memory_dict...
disk = disk_check.check()
Here is a snippet: <|code_start|># # CommandModule # Subclass of HalModule that does the heavy lifting of commands for you # # Decorator for converting the string stripped of the command to an argument list def AsArgs(func): def wrapper(self, string, msg=None): args = string.split(" ") func(self, args, msg=msg...
class CommandModule(HalModule):
Given snippet: <|code_start|> def hasPermission(perm, reply=False, argnum=None, key="msg"): def real_dec(func): def wrapper(self, *args, **kwargs): if argnum != None and argnum < len(args): msg = args[argnum] else: msg = kwargs[key] # Origin must be set for this to be a valid permission check if...
raise MalformedMsgException("Bad or missing origin attribute")
Given snippet: <|code_start|> r[name] = to.sync_replies.pop(msg.uuid) return r async def _receive(self, msg): try: fname = 'receive_' + msg.type if hasattr(self, fname) and callable(getattr(self, fname)): # Type specific receive function getattr(self, fname)(msg) else: # Generic receive fu...
class Configurer(HalConfigurer):
Continue the code snippet: <|code_start|> self.shutdown() def _queue_msg(self, msg): fut = asyncio.run_coroutine_threadsafe(self._receive(msg), self.eventloop) return fut def init(self): pass def shutdown(self): pass def apply_filter(self, dest): fl = self._hal.config.get("filters") if not fl: r...
raise MalformedMsgException("raw_send given empty target")
Predict the next line for this snippet: <|code_start|># # HelpModule # class Help(CommandModule): def init(self): self.commands = { 'help' : self.command } def general_help(self, target): <|code_end|> with the help of current file imports: from halibot import CommandModule, Message and context from other...
hmsg = Message(body=[], type='help', origin=self.name)
Using the snippet: <|code_start|> class MalformedMsgException(Exception): 'Bad message object' class Message(): def __init__(self, **kwargs): self.log = logging.getLogger(self.__class__.__name__) self.uuid = uuid.uuid4() self.sync = False self.body = kwargs.get('body', None) self.type = kwargs.get('type',...
self.misc = kwargs.get('misc', jsdict())
Continue the code snippet: <|code_start|># # Main bot class # Handles routing, config, agent/module loading # # Avoid appending "." if it i if "." not in sys.path: sys.path.append(".") HALDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) class ObjectDict(dict): @property def modules(self): ...
return dict(filter(lambda x: isinstance(x[1], HalModule), self.items()))
Continue the code snippet: <|code_start|># # Main bot class # Handles routing, config, agent/module loading # # Avoid appending "." if it i if "." not in sys.path: sys.path.append(".") HALDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) class ObjectDict(dict): @property def modules(self): ...
return dict(filter(lambda x: isinstance(x[1], HalAgent), self.items()))
Given snippet: <|code_start|> return self.system[key] def __setitem__(self, key, value): self.local[key] = value def __delitem__(self, key): del self.local[value] def __iter__(self): return iter(self.local.keys() + self.system.keys()) def __len__(self): return len(set(self.local.keys()) + set(self.syst...
self.auth = HalAuth()
Continue the code snippet: <|code_start|> class TestBackend(unittest.TestCase): def test_auto_client(self): with self.subTest('No arguments are provided'): expected = { 'server_ip_address': '', 'vni': 0, } <|code_end|> . Use current file imports: im...
self.assertDictEqual(VxlanWireguard.auto_client(), expected)
Given snippet: <|code_start|> class OpenWisp(OpenWrt): """ OpenWISP 1.x Firmware (legacy) Configuration Backend """ schema = schema <|code_end|> , continue by predicting the next line. Consider current file imports: import re from jinja2 import Environment, PackageLoader from ..openwrt.openwrt impo...
renderer = OpenWrtRenderer
Continue the code snippet: <|code_start|> class Switch(OpenWrtConverter): netjson_key = 'switch' intermediate_key = 'network' _uci_types = ['switch', 'switch_vlan'] <|code_end|> . Use current file imports: from ..schema import schema from .base import OpenWrtConverter and context (classes, functions, or ...
_switch_schema = schema['properties']['switch']['items']
Here is a snippet: <|code_start|> class TestBackend(unittest.TestCase, _TabsMixin): maxDiff = None def test_config_copy(self): config = {'interfaces': []} <|code_end|> . Write the next line using the current file imports: import json import os import tarfile import unittest from hashlib import md5 f...
o = OpenWrt(config)
Based on the snippet: <|code_start|> class TestRadio(unittest.TestCase, _TabsMixin): maxDiff = None def test_render_radio(self): <|code_end|> , predict the immediate next line with the help of imports: import unittest from netjsonconfig import OpenWrt from netjsonconfig.utils import _TabsMixin and context ...
o = OpenWrt(
Continue the code snippet: <|code_start|> option enabled '1' option engine 'rsax' option fast_io '1' option fragment '0' option group 'nogroup' option keepalive '20 60' option key 'key.pem' option log '/var/log/openvpn.log' option mode 'server' option mssfix '1450' option mtu_...
c = OpenWrt(self._server_netjson)
Here is a snippet: <|code_start|> class Led(OpenWrtConverter): netjson_key = 'led' intermediate_key = 'system' _uci_types = ['led'] <|code_end|> . Write the next line using the current file imports: from ..schema import schema from .base import OpenWrtConverter and context from other files: # Path: netj...
_schema = schema['properties']['led']['items']
Continue the code snippet: <|code_start|> "apn": "apn.vodafone.com", "pin": "1234", "device": "/sys/devices/platform/ahb/1b000000.usb/usb1/1-1", "username": "user123", "password": "pwd123456", "metric": 50, "i...
result = OpenWrt(self._modemmanager_interface_netjson).render()
Given the following code snippet before the placeholder: <|code_start|> class TestInterfaces(unittest.TestCase, _TabsMixin): maxDiff = None def test_render_loopback(self): <|code_end|> , predict the next line using imports from the current file: import unittest from copy import deepcopy from netjsonconfig i...
o = OpenWrt(
Predict the next line for this snippet: <|code_start|> return self._add_netjson_addresses(interface, proto) def _add_netjson_addresses(self, interface, proto): addresses = [] ipv4 = interface.pop('ipaddr', []) ipv6 = interface.pop('ip6addr', []) if not isinstance(ipv4, list):...
_modem_manager_schema = schema['definitions']['modemmanager_interface']['allOf'][0]
Based on the snippet: <|code_start|># ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.viewcode', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # sour...
version = '{0}.{1}'.format(VERSION[0], VERSION[1])
Continue the code snippet: <|code_start|> 'sphinx.ext.autodoc', 'sphinx.ext.viewcode', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst...
release = get_version()
Here is a snippet: <|code_start|> vpn_pattern = re.compile('^# wireguard config:\s', flags=re.MULTILINE) config_pattern = re.compile('^([^\s]*) ?(.*)$') config_suffix = '.conf' <|code_end|> . Write the next line using the current file imports: import re from ..base.parser import BaseParser and context from other f...
class WireguardParser(BaseParser):
Next line prediction: <|code_start|> class TestNetwork(unittest.TestCase, _TabsMixin): maxDiff = None _ula_netjson = {"general": {"ula_prefix": "fd8e:f40a:6701::/48"}} _ula_uci = """package network config globals 'globals' option ula_prefix 'fd8e:f40a:6701::/48' """ _ula_netjson_id = { "g...
o = OpenWrt(self._ula_netjson)
Predict the next line after this snippet: <|code_start|> "mode": "access_point", "ssid": "wpa2-personal", "encryption": { "protocol": "wpa2_personal", "cipher": "tkip+ccmp", "key": "passphr...
o = OpenWrt(self._wpa2_personal_netjson)
Next line prediction: <|code_start|> ) command = ( "netjsonconfig --config '{0}' -b openwrt -m render -a files=False".format( config ) ) output = subprocess.check_output(command, shell=True).decode() self.assertNotIn('test.txt', output) ...
o = OpenWrt(
Given the code snippet: <|code_start|> }, "country": { "type": "string", "maxLength": 2, "default": "00", "enum": list(countries.values()), "options": {"enum_titles": list(countries.keys())...
"enum": channels_2and5,
Here is a snippet: <|code_start|> "phy": {"type": "string", "propertyOrder": 3}, "channel": {"type": "integer", "propertyOrder": 4}, "channel_width": { "type": "integer", "title": "channel width (mhz)", "propertyO...
"channel": {"enum": channels_2ghz, "options": {"enum_titles": ['auto']}}
Based on the snippet: <|code_start|> "propertyOrder": 5, }, "tx_power": { "type": "integer", "title": "transmit power (dbm)", "propertyOrder": 6, }, "country": { ...
"channel": {"enum": channels_5ghz, "options": {"enum_titles": ['auto']}}
Given the following code snippet before the placeholder: <|code_start|> } }, {"$ref": "#/definitions/base_wireless_settings"}, {"$ref": "#/definitions/mesh_id_wireless_property"}, {"$ref": "#/definitions/encryption_wireless_property_mesh...
"enum": list(countries.values()),
Given the following code snippet before the placeholder: <|code_start|>""" OpenWrt specific JSON-Schema definition """ default_radio_driver = "mac80211" wireguard = base_wireguard_schema["properties"]["wireguard"]["items"]["properties"] wireguard_peers = wireguard["peers"]["items"]["properties"] <|code_end|> , predic...
interface_settings = default_schema["definitions"]["interface_settings"]["properties"]
Given the following code snippet before the placeholder: <|code_start|>""" OpenWrt specific JSON-Schema definition """ default_radio_driver = "mac80211" wireguard = base_wireguard_schema["properties"]["wireguard"]["items"]["properties"] wireguard_peers = wireguard["peers"]["items"]["properties"] interface_settings = ...
schema = merge_config(
Here is a snippet: <|code_start|> "preshared_key": wireguard_peers["preshared_key"], "persistent_keepalive": { "type": "integer", "title": "keep alive", "description": ( ...
schema = merge_config(schema, base_openvpn_schema)
Based on the snippet: <|code_start|> "properties": { "hwmode": { "type": "string", "title": "hardware mode", "readOnly": True, "propertyOrder": 8, "default": "11a", ...
"timezone": {"enum": list(timezones.keys()), "default": "UTC"}
Next line prediction: <|code_start|> class TestFormats(unittest.TestCase, _TabsMixin): maxDiff = None def test_general_hostname(self): <|code_end|> . Use current file imports: (import unittest from netjsonconfig import OpenWrt from netjsonconfig.exceptions import ValidationError from netjsonconfig.utils imp...
o = OpenWrt({"general": {"hostname": "invalid hostname"}})