Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Predict the next line after this snippet: <|code_start|> logger = logging.getLogger(__name__) logging.basicConfig(format='%(levelname)s : %(message)s', level=logging.INFO) logger.setLevel(logging.DEBUG) logging.getLogger('inputgeneration').setLevel(logging.DEBUG) if __name__ == '__main__': parser = argparse.Argu...
p = Perspective('', pos_topic_words(), pos_opinion_words())
Based on the snippet: <|code_start|> logger = logging.getLogger(__name__) logging.basicConfig(format='%(levelname)s : %(message)s', level=logging.INFO) logger.setLevel(logging.DEBUG) logging.getLogger('inputgeneration').setLevel(logging.DEBUG) if __name__ == '__main__': parser = argparse.ArgumentParser() par...
p = Perspective('', pos_topic_words(), pos_opinion_words())
Continue the code snippet: <|code_start|>logging.getLogger('inputgeneration').setLevel(logging.DEBUG) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('dir_in', help='directory containing the data ' '(manifesto project csv files)') parser.add_argume...
if pos in word_types():
Here is a snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- """Create input files in cptm format from manifesto project csv files. Usage: python manifestoproject2cptm_input.py <input dir> <output dir> """ logger = logging.getLogger(__name__) logging.basicConfig(format='%(levelname)s : %(message)s', le...
frogclient = get_frogclient()
Using the snippet: <|code_start|>logger.setLevel(logging.DEBUG) logging.getLogger('inputgeneration').setLevel(logging.DEBUG) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('dir_in', help='directory containing the data ' '(manifesto project csv files)'...
for pos, lemma in pos_and_lemmas(text, frogclient):
Based on the snippet: <|code_start|> print '{},{}'.format(year, len(data_files)) years.sort() min_year = years[0] print 'min year', min_year max_year = years[-1] print 'max year', max_year data_files = glob.glob('{}data_folia/*.xml.gz'.format(min_year)) for df in data_files: f = gzip.open(df) context = etr...
config = load_config(args.json)
Continue the code snippet: <|code_start|>Usage: python cptm/experiment_calculate_perplexity.py /path/to/experiment.json. """ def calculate_perplexity(config, corpus, nPerplexity, nTopics): sampler = get_sampler(config, corpus, nTopics, initialize=False) results = [] for s in nPerplexity: logger....
config = load_config(args.json)
Given snippet: <|code_start|>""" def calculate_perplexity(config, corpus, nPerplexity, nTopics): sampler = get_sampler(config, corpus, nTopics, initialize=False) results = [] for s in nPerplexity: logger.info('doing perplexity calculation ({}, {})'.format(nTopics, s)) tw_perp, ow_perp = ...
corpus = get_corpus(config)
Based on the snippet: <|code_start|>"""Calculate opinion perplexity for different numbers of topics Calclulate opinion perplexity for the test set as described in [Fang et al. 2012] section 5.1.1. This script should be run after experiment_number_of_topics.py. Usage: python cptm/experiment_calculate_perplexity.py /p...
sampler = get_sampler(config, corpus, nTopics, initialize=False)
Next line prediction: <|code_start|> def setup(): global jsonFile global config global nTopics jsonFile = 'config.json' # create cofig.json params = {} with open(jsonFile, 'wb') as f: dump(params, f, sort_keys=True, indent=4) <|code_end|> . Use current file imports: (from nose.t...
config = load_config(jsonFile)
Using the snippet: <|code_start|> def test_load_config_default_values(): params = {} params['inputData'] = None params['outDir'] = '/{}' params['testSplit'] = 20 params['minFreq'] = None params['removeTopTF'] = None params['removeTopDF'] = None params['nIter'] = 200 params['beta'] =...
add_parameter(pName, nTopics, jsonFile)
Based on the snippet: <|code_start|> params['removeTopTF'] = None params['removeTopDF'] = None params['nIter'] = 200 params['beta'] = 0.02 params['beta_o'] = 0.02 params['expNumTopics'] = range(20, 201, 20) params['nTopics'] = None params['nProcesses'] = None params['topicLines'] = [0...
fName = thetaFileName(config)
Continue the code snippet: <|code_start|> params['nTopics'] = None params['nProcesses'] = None params['topicLines'] = [0] params['opinionLines'] = [1] params['sampleEstimateStart'] = None params['sampleEstimateEnd'] = None for p, v in params.iteritems(): yield assert_equal, v, config...
fName = topicFileName(config)
Given the code snippet: <|code_start|> yield assert_equal, v, config[p] def test_add_parameter(): pName = 'nTopics' yield assert_false, hasattr(config, pName) add_parameter(pName, nTopics, jsonFile) config2 = load_config(jsonFile) yield assert_equal, config2[pName], nTopics def test_th...
fName = opinionFileName(config, p)
Continue the code snippet: <|code_start|> config['nTopics'] = nTopics fName = thetaFileName(config) assert_equal(fName, '/theta_{}.csv'.format(nTopics)) def test_topicFileName(): config['nTopics'] = nTopics fName = topicFileName(config) assert_equal(fName, '/topics_{}.csv'.format(nTopics)) de...
fName = tarFileName(config)
Next line prediction: <|code_start|> add_parameter(pName, nTopics, jsonFile) config2 = load_config(jsonFile) yield assert_equal, config2[pName], nTopics def test_thetaFileName(): config['nTopics'] = nTopics fName = thetaFileName(config) assert_equal(fName, '/theta_{}.csv'.format(nTopics)) d...
assert_equal('test', experimentName(config))
Continue the code snippet: <|code_start|>logging.basicConfig(format='%(levelname)s : %(message)s', level=logging.DEBUG) parser = argparse.ArgumentParser() parser.add_argument('json', help='json file containing experiment ' 'configuration.') parser.add_argument('data_dir', help='dir containing the i...
sampler = get_sampler(params, corpus, nTopics=nTopics,
Based on the snippet: <|code_start|>"""Script to extract a document/topic matrix for a set of text documents. The corpus is not divided in perspectives. Used to calculate theta for the CAP vragenuurtje data. Before this script can be run, a cptm corpus should be created. Use the tabular2cptm_input.py script to creat...
params = load_config(args.json)
Using the snippet: <|code_start|>"""Script to extract a document/topic matrix for a set of text documents. The corpus is not divided in perspectives. Used to calculate theta for the CAP vragenuurtje data. Before this script can be run, a cptm corpus should be created. Use the tabular2cptm_input.py script to create a...
phi_topic_file = topicFileName(params)
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- def test_remove_training_digits(): cases = {u'd66': u'd', u'f16': u'f', u'é33': u'é'} for i, o in cases.iteritems(): <|code_end|> using the current file's imports: from nose.tools im...
r = remove_trailing_digits(i)
Using the snippet: <|code_start|>"""Remove saved parameter samples for certain iterations Before, the Gibbs sampler saved estimates for all iterations. However, because this took to much disk space, now the sampler only saves every tenth estimate. This script removes samples for results generated with an old version o...
config = load_config(args.json)
Based on the snippet: <|code_start|>"""Remove saved parameter samples for certain iterations Before, the Gibbs sampler saved estimates for all iterations. However, because this took to much disk space, now the sampler only saves every tenth estimate. This script removes samples for results generated with an old versio...
corpus = get_corpus(config)
Here is a snippet: <|code_start|>Before, the Gibbs sampler saved estimates for all iterations. However, because this took to much disk space, now the sampler only saves every tenth estimate. This script removes samples for results generated with an old version of the sampler. Usage: python experiment_prune_samples.py ...
sampler = get_sampler(config, corpus, nTopics=nt, initialize=False)
Given the following code snippet before the placeholder: <|code_start|> @contextmanager def not_raises(exception): try: yield except exception: raise pytest.fail("Unexpected raise {0}".format(exception)) def kern32_script_test(scripts, specs=None): if specs is None: specs = Defaul...
SlowScripts = [dump_btree, extract_function_names]
Based on the snippet: <|code_start|> @contextmanager def not_raises(exception): try: yield except exception: raise pytest.fail("Unexpected raise {0}".format(exception)) def kern32_script_test(scripts, specs=None): if specs is None: specs = DefaultKern32Specs ids = [] params...
Scripts = [dump_types, dump_user, dump_scripts, extract_md5, extract_version]
Predict the next line after this snippet: <|code_start|> @contextmanager def not_raises(exception): try: yield except exception: raise pytest.fail("Unexpected raise {0}".format(exception)) def kern32_script_test(scripts, specs=None): if specs is None: specs = DefaultKern32Specs ...
Scripts = [dump_types, dump_user, dump_scripts, extract_md5, extract_version]
Based on the snippet: <|code_start|> @contextmanager def not_raises(exception): try: yield except exception: raise pytest.fail("Unexpected raise {0}".format(exception)) def kern32_script_test(scripts, specs=None): if specs is None: specs = DefaultKern32Specs ids = [] params...
Scripts = [dump_types, dump_user, dump_scripts, extract_md5, extract_version]
Based on the snippet: <|code_start|> @contextmanager def not_raises(exception): try: yield except exception: raise pytest.fail("Unexpected raise {0}".format(exception)) def kern32_script_test(scripts, specs=None): if specs is None: specs = DefaultKern32Specs ids = [] param...
SlowScripts = [dump_btree, extract_function_names]
Here is a snippet: <|code_start|> @contextmanager def not_raises(exception): try: yield except exception: raise pytest.fail("Unexpected raise {0}".format(exception)) def kern32_script_test(scripts, specs=None): if specs is None: specs = DefaultKern32Specs ids = [] params = ...
Scripts = [dump_types, dump_user, dump_scripts, extract_md5, extract_version]
Here is a snippet: <|code_start|> @contextmanager def not_raises(exception): try: yield except exception: raise pytest.fail("Unexpected raise {0}".format(exception)) def kern32_script_test(scripts, specs=None): if specs is None: specs = DefaultKern32Specs ids = [] params = ...
Scripts = [dump_types, dump_user, dump_scripts, extract_md5, extract_version]
Using the snippet: <|code_start|> class DummyProvider: def __init__(self, files): self.files = files; def list(self): return self.files def has(self, filename): return filename in self.list() def open(self, filename, *args, **kwargs): if not self...
raise filesystem.FileNotFound(filename)
Predict the next line for this snippet: <|code_start|> assert transfs.list() == { '/', '/x', '/x/a.txt', '/x/a.txt.rot13', '/x/b.png' } def test_transform_list_after(fs): fs.transform('.txt$', DummyTransformer) fs.mount('/x', DummyProvider({ '/a.txt', '/b.png' })) test_transform_list(fs) def test_transform_list_re...
assert isinstance(f, filesystem.File)
Given snippet: <|code_start|> for fmt, pattern in FORMAT_PATTERNS.items(): if _formats & fmt: game.resources.register_loader(ImageLoader, pattern) _log.debug('Loaded support for {fmt} images.', fmt=FORMAT_NAMES[fmt]) else: _log.warn('Failed to load support for {fmt...
handle = fs_to_rwops(fd)
Using the snippet: <|code_start|> def test_empty(fs): assert fs.list() == { '/' } assert fs.listdir('/') == set() def test_clear(dummyfs): dummyfs.clear() test_empty(dummyfs) def test_list(dummyfs): assert dummyfs.list() == { '/', '/x', '/x/a.txt', '/x/b.png' } assert dummyfs.list('/x') == { '/', '/a.txt', '...
with raises(filesystem.FileNotFound):
Continue the code snippet: <|code_start|># Copyright 2020 Google LLC # # 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...
_, payload, _, _ = jwt._unverified_decode(token)
Given the code 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, ...
new_credentials = _oauth2client._convert_oauth2_credentials(old_credentials)
Based on the snippet: <|code_start|># Copyright 2020 Google LLC # # 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 appl...
_, payload, _, _ = jwt._unverified_decode(token)
Predict the next line for this snippet: <|code_start|># See the License for the specific language governing permissions and # limitations under the License. class _AppIdentityModule(object): """The interface of the App Idenity app engine module. See https://cloud.google.com/appengine/docs/standard/python/r...
monkeypatch.setattr(app_engine, "app_identity", app_identity_module)
Next line prediction: <|code_start|># Copyright 2020 Google LLC # # 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 appl...
credentials, project_id = _default_async.default_async()
Given snippet: <|code_start|> # Apply the default credentials to the headers to make the request. headers = {} credentials.apply(headers) response = request( url="https://dns.googleapis.com/dns/v1/projects/{}".format(project_id), headers=headers, ) if response.status == 200: ...
result = service_account.IDTokenCredentials.from_service_account_file(
Next line prediction: <|code_start|> class TestResponse: def test_ctor(self): response = aiohttp_requests._Response(mock.sentinel.response) assert response._response == mock.sentinel.response @pytest.mark.asyncio async def test_headers_prop(self): rm = core.RequestMatch("url", heade...
class TestRequestResponse(async_compliance.RequestResponseTests):
Here is a snippet: <|code_start|># Copyright 2020 Google LLC # # 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 applica...
combined_response = aiohttp_requests._CombinedResponse(response)
Given snippet: <|code_start|> # Blame Google translate... TEST_APP_ES = { "title": "Pruebas", "tagline": "Aplicación de prueba", "description": "Esta es una aplicación de prueba para, así, las cosas de la prueba.", "slug": "test-app", "icon": "test", "colour": "#F4A15D", "categories": ["co...
apps = get_applications()
Predict the next line after this snippet: <|code_start|>KDESK_EXEC = '/usr/bin/kdesk' def _get_kdesk_icon_path(app): kdesk_dir = os.path.expanduser(KDESK_DIR) return kdesk_dir + re.sub(' ', '-', app["title"]) + ".lnk" def _create_kdesk_icon(app): icon_theme = Gtk.IconTheme.get_default() icon_info = ...
kdesk_entry += ' IconHover: {}\n'.format(media_dir() +
Using the snippet: <|code_start|> def install_app(app, sudo_pwd=None, gui=True): pkgs = " ".join(app["packages"] + app["dependencies"]) cmd = "" if gui: cmd = "rxvt -title 'Installing {}' -e bash -c ".format(app["title"]) if sudo_pwd: cmd = "echo {} | sudo -S ".format(sudo_pwd) ...
installed_packages = get_dpkg_dict()[0]
Predict the next line for this snippet: <|code_start|># coding: utf-8 # test_AppManage.py # # Copyright (C) 2016, 2015 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # # Tests for AppManage @patch('kano_apps.AppManage.query_for_app') @patch('kano_apps.AppManage.download_url') @pat...
download_app('foo')
Given snippet: <|code_start|># coding: utf-8 # test_AppManage.py # # Copyright (C) 2016, 2015 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # # Tests for AppManage @patch('kano_apps.AppManage.query_for_app') @patch('kano_apps.AppManage.download_url') @patch('kano_apps.AppManage.h...
with pytest.raises(AppDownloadError) as excinfo:
Using the snippet: <|code_start|># AppData.py # # Copyright (C) 2014, 2015 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # # Which apps to look for on the system # The system directory that contains *.app and *.desktop entries _SYSTEM_APPLICATIONS_LOC = '/usr/share/applications/' ...
_INSTALLED_PKGS = get_dpkg_dict()[0]
Given snippet: <|code_start|> THROTTLE_PARAMS = [10, 60, 'user_reads'] def throttle(*args, **kwargs): @decorator def inner_func(func, *inner_args, **inner_kwargs): return func(*inner_args, **inner_kwargs) return inner_func def fullurl(url): return settings.SITE_DOMAIN + url class Parliamen...
return [{"href": self.get_url(p)} for p in Parliament.objects.all()]
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- class BundesOpenidConsumer(SessionConsumer): session_key = 'openid' openid_required_message = 'Gib eine OpenID ein' xri_disabled_message = 'i-names werden nicht unterstützt' openid_invalid_message = 'Die OpenID ist nicht gültig' request...
login(request, identity_url)
Using the snippet: <|code_start|> session_key = 'openid' openid_required_message = 'Gib eine OpenID ein' xri_disabled_message = 'i-names werden nicht unterstützt' openid_invalid_message = 'Die OpenID ist nicht gültig' request_cancelled_message = 'Die Anfrage wurde abgebrochen' message_loggedin = ...
logout(request)
Predict the next line for this snippet: <|code_start|>class ParliamentSession(models.Model): parliament = models.ForeignKey(Parliament) number = models.PositiveSmallIntegerField(db_index=True) date = models.DateTimeField() until = models.DateTimeField() checked = models.BooleanField(default=False) ...
return "http://dip21.bundestag.de/dip21/btp/%(leg)d/%(leg)d%(id)s.pdf" % {"leg":self.parliament.number, "id": padd_zeros(self.number)}
Given the following code snippet before the placeholder: <|code_start|> date = models.DateTimeField() until = models.DateTimeField() checked = models.BooleanField(default=False) tags = models.TextField(blank=True) objects = ParliamentSessionManager() def __unicode__(self): ...
invalidate_cache(reverse("bundestagger-bundestag-list_sessions"))
Predict the next line after this snippet: <|code_start|> tags = models.TextField(blank=True) objects = ParliamentSessionManager() def __unicode__(self): return u"%d. Sitzung (%s) des %d. Deutschen Bundestags" % (self.number, self.date.strftime("%d.%m.%Y"), self.parliament.number) ...
invalidate_cache_all_pages(url, last_speech.ordernr, settings.SPEECHES_PER_PAGE)
Based on the snippet: <|code_start|> def __unicode__(self): return u"Rede von %s in der %s" % (self.speaker, self.session) def text(self): return u"\n".join(map(lambda x:x.text, self.speechpart_set.order_by("ordernr"))) @property def tag_list(self): return [...
page = get_page(self.ordernr, settings.SPEECHES_PER_PAGE)
Next line prediction: <|code_start|> register = Library() class TagsFormNode(Node): def __init__(self, context_var): self.context_var = context_var def render(self, context): <|code_end|> . Use current file imports: (from django.template import Library, Node, TemplateSyntaxError from django....
context[self.context_var] = TagsForm(auto_id=False)
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- @is_post def logout(request): logout_func(request) next = "/" if "next" in request.POST: next = request.POST["next"] return redirect(next) @is_post <|code_end|> using the current file's imports: from django.http...
@logged_in
Using the snippet: <|code_start|># -*- coding: utf-8 -*- @is_post def logout(request): logout_func(request) next = "/" if "next" in request.POST: next = request.POST["next"] return redirect(next) @is_post @logged_in def change_username(request): if "username" in request.POST: ...
uc = User.objects.filter(username=username).count()
Given snippet: <|code_start|> def get_user(request): if "bundesuser" in request.session: return request.session["bundesuser"] return None def login(request, openid): try: <|code_end|> , continue by predicting the next line. Consider current file imports: from django.core.exceptions import Permissi...
user = User.objects.get(openid=openid)
Given the following code snippet before the placeholder: <|code_start|> except (EmptyPage, InvalidPage): page_obj = paginator.page(paginator.num_pages) gt = ((page - 1) * settings.SPEECHES_PER_PAGE) lte = (page * settings.SPEECHES_PER_PAGE) speech_parts = SpeechPart.objects.filter(speech__session...
@logged_in
Here is a snippet: <|code_start|> page_obj = paginator.page(page) except (EmptyPage, InvalidPage): page_obj = paginator.page(paginator.num_pages) gt = ((page - 1) * settings.SPEECHES_PER_PAGE) lte = (page * settings.SPEECHES_PER_PAGE) speech_parts = SpeechPart.objects.filter(speech__sessi...
@is_post
Based on the snippet: <|code_start|> if i % 1000 == 0: print "%d/%d" % (i, count) # if i>2000: break i+=1 key = key_function(result) aggregated.setdefault(key,0) aggregated[key]+=1 sorted_aggregation = sorted(aggregated, ...
politician = models.ForeignKey(Politician, null=True, blank=True)
Using the snippet: <|code_start|> print "%d/%d" % (i, count) # if i>2000: break i+=1 key = key_function(result) aggregated.setdefault(key,0) aggregated[key]+=1 sorted_aggregation = sorted(aggregated, key=lambda x: aggregated[x], reve...
party = models.ForeignKey(Party, null=True, blank=True)
Predict the next line for this snippet: <|code_start|> urlpatterns = patterns('', url(r'^add/(?P<content_type>\d+)/(?P<object_id>\d+)/$', add_tags, name='tagging_add-tags'), url(r'^autocomplete/$', autocomplete, name='tagging_autocomplete'), ) urlpatterns += patterns('', <|code_end|> with the help of current ...
('^(?P<tag>[^/]+)$', 'tagging.views.tagged_object_list', {'queryset_or_model': Speech, 'template_name': "bundestagging/tag.html"}, 'tagging-tag_url'),
Given the code snippet: <|code_start|> for pyfile in py_files: if 'mysql/__init__.py' in pyfile: continue os.unlink(pyfile) if LICENSE == 'Commercial': util.byte_compile = _byte_compile # Development Status Trove Classifiers significant for Connector/Python DEVELOPMENT_STATUSES = {...
version = '{0}.{1}.{2}'.format(*VERSION[0:3])
Next line prediction: <|code_start|> for base, dirs, files in os.walk(django_dir): for file_ in files: if file_.endswith('.py'): pyfile = os.path.join(base, file_) if os.path.getsize(pyfile) > 10: self._check_copyright_ab...
commercial.remove_gpl(tmpfile.name)
Given snippet: <|code_start|> raise ValueError("Failed reading server error message") def _serverr_get_translations(self): """Create a dictionary of server codes with translations This method will return a dictionary where the key is the server error code and value another d...
license = opensource.GPLGNU2_LICENSE_NOTICE.format(
Predict the next line for this 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 o...
self._api = client.VitrageClient(session, service_type=service_type,
Based on the 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 wri...
self.alarm = alarm.Alarm(self._api)
Using the 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 writin...
self.event = event.Event(self._api)
Given 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 w...
self.healthcheck = healthcheck.HealthCheck(self._api)
Next line prediction: <|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 wri...
self.rca = rca.Rca(self._api)
Given the following code snippet before the placeholder: <|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...
self.resource = resource.Resource(self._api)
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 i...
self.service = service.Service(self._api)
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 i...
self.status = status.Status(self._api)
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 i...
self.template = template.Template(self._api)
Predict the next line for this 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 o...
self.topology = topology.Topology(self._api)
Given 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 w...
self.webhook = webhook.Webhook(self._api)
Given the code snippet: <|code_start|> 'Valid graph types: [tree, graph]') parser.add_argument('--all-tenants', default=False, dest='all_tenants', action='store_true', ...
topology = utils.get_client(self).topology.get(limit=limit,
Continue the code snippet: <|code_start|> default='graph', dest='type', help='graph type. ' 'Valid graph types: [tree, graph]') parser.add_argument('--all-tenants', de...
raise exc.CommandError("Graph-type 'graph' "
Continue the code snippet: <|code_start|># noinspection PyAbstractClass class TemplateValidate(show.ShowOne): """Validate a template file""" def get_parser(self, prog_name): parser = super(TemplateValidate, self).get_parser(prog_name) parser.add_argument('--path', re...
result = utils.get_client(self).template.validate(
Predict the next line for this snippet: <|code_start|> ), templates) def _check_finished_loading(self, templates): if all( ( template['status'] == 'ERROR' for template in templates ) ): return True ...
api_template = find_template_with_uuid(uuid, api_templates)
Given snippet: <|code_start|> name: cpu problem host: type: nova.host scenarios: - condition: alarm [ on ] host actions: - set_state: state: ERROR target: host """ class TestTemplate(base.BaseTestCase): def test_validate_by_path(self): template_path = get_resources_dir() + '/...
self.assertRaises(exc.CommandError, template.validate)
Here is a snippet: <|code_start|># WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. TEMPLATE_STRING = """ metadata: version: 3 name: template1 description: simple template type: standard entiti...
template_path = get_resources_dir() + '/template1.yaml'
Next line prediction: <|code_start|># License for the specific language governing permissions and limitations # under the License. TEMPLATE_STRING = """ metadata: version: 3 name: template1 description: simple template type: standard entities: alarm: name: cpu problem host: type: nova.host scenarios: - c...
template = Template(mock.Mock())
Predict the next line after this snippet: <|code_start|># Copyright 2019 - Nokia Corporation # # 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....
service = utils.get_client(self).service.list()
Given the code snippet: <|code_start|> @mock.patch.object(ArgumentParser, "error") def test_parser_topology_limit_with_a_negative_number(self, mock_parser): mock_parser.side_effect = self._my_parser_error_func parser = self.topology_show.get_parser('vitrage topology show') with Expected...
formatter = DOTFormatter()
Predict the next line after this snippet: <|code_start|> @mock.patch.object(ArgumentParser, "error") def test_parser_topology_limit_with_a_string(self, mock_parser): mock_parser.side_effect = self._my_parser_error_func parser = self.topology_show.get_parser('vitrage topology show') with ...
formatter = GraphMLFormatter()
Given snippet: <|code_start|> <data key="d2">2018-12-30T08:30:33Z</data> <data key="d3">RESOURCE</data> <data key="d4">neutron.network</data> <data key="d5">OK</data> <data key="d6">ACTIVE</data> <data key="d7">a0eeca0ab2c865915e23319a2e6d0fd7</data> <data key="d8">neutron.netwo...
class TopologyShowTest(CliTestCase):
Using the snippet: <|code_start|> <data key="d6">ACTIVE</data> <data key="d7">a0eeca0ab2c865915e23319a2e6d0fd7</data> <data key="d8">neutron.network</data> <data key="d9">2018-12-31T13:44:04Z</data> <data key="d12">public neutron.network</data> <data key="d10">ACTIVE</data> <dat...
self.topology_show = TopologyShow(mock.Mock(), mock.Mock())
Given the code snippet: <|code_start|># Copyright 2017 Nokia # # 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 applica...
self.event_post = EventPost(self.app, mock.Mock())
Using the snippet: <|code_start|> # noinspection PyAbstractClass class RcaShow(show.ShowOne): """Show the Root Cause Analysis for a certain alarm""" def get_parser(self, prog_name): parser = super(RcaShow, self).get_parser(prog_name) parser.add_argument('alarm_vitrage_id', ...
alarm = utils.get_client(self).rca.get(alarm_id=alarm_id,
Given snippet: <|code_start|># under the License. profiler_web = importutils.try_import('osprofiler.web') # noinspection PyPep8Naming def Client(version, *args, **kwargs): module = importutils.import_versioned_module('vitrageclient', version, 'client') clien...
raise exc.from_response(resp, url, method)
Given the following code snippet before the placeholder: <|code_start|> parser.add_argument("vitrage_id", default='all', nargs='?', metavar="<vitrage id>", help="Vitrage id of the affected resource") ...
alarms = utils.get_client(self).alarm.list(vitrage_id=vitrage_id,
Using the snippet: <|code_start|> help='Shows alarms of all the tenants in the ' 'entity graph') parser.add_argument('--limit', dest='limit', help='Maximal number of alarms to show. Default ' ...
raise exc.CommandError("--end argument must be used with --start")
Using the 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 writin...
resource = utils.get_client(self).resource.get(vitrage_id=vitrage_id)
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 i...
webhook = utils.get_client(self).webhook.show(id=id)
Predict the next line for this snippet: <|code_start|> self._load_template(path=path, template_str=template_str) api_params = dict(templates=files_content, template_type=template_type, params=params) return self.api.post(self.url, json=api_p...
return yaml_utils.load(yaml_content)
Using the snippet: <|code_start|> return self.api.post(self.url, json=api_params).json() @classmethod def _load_yaml_files(cls, path): if os.path.isdir(path): files_content = [] for file_name in os.listdir(path): file_path = '%s/%s' % (path, file_name) ...
raise exc.CommandError(message)
Next line prediction: <|code_start|> online_funcs.extend(['http.client.HTTPConnection.request', 'http.client.HTTPSConnection.request']) for func in online_funcs: monkeypatch.setattr(func, mock.Mock(side_effect=Exception('Online tests should use @pytest.mark.online'))) ...
return RakutenWebService(debug=ws_debug, **credentials)