Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Here is a snippet: <|code_start|>
class HomeView(View):
http_method_names = [u'get']
def get(self, request):
response = render(request, 'home.html')
return response
def renderAdvertisements(request):
queryset = Product.objects.all()
<|code_end|>
. Write the next line using the current fi... | context = { |
Given the code snippet: <|code_start|>
class CartManagement(View):
def addToCart(request, product_id, quantity):
product = Product.objects.get(id=product_id)
cart = Cart(request)
cart.add(product, product.price, quantity)
@csrf_exempt
def removeFromCart(request, product_id):
... | CartManagement.removeFromCart(request, product_id) |
Predict the next line after this snippet: <|code_start|>
class CartManagement(View):
def addToCart(request, product_id, quantity):
product = Product.objects.get(id=product_id)
cart = Cart(request)
cart.add(product, product.price, quantity)
@csrf_exempt
def removeFromCart(request, ... | CartManagement.removeFromCart(request, product_id) |
Given snippet: <|code_start|>
class DefaultPermission(permissions.IsAuthenticated):
def has_permission(self, request, view):
permission = super().has_permission(request, view)
try:
if permission and request.user.is_active:
permission = True
except ObjectDoesNot... | self.user_id = '' |
Given snippet: <|code_start|> def has_permission(self, request, view):
if request.user.is_anonymous:
return False
elif request.user.is_superuser:
return True
elif 'credit_cards' in request.path:
self.request = request
self.user_id = str(self.... | self.user_id = str(self.request.user.id) |
Here is a snippet: <|code_start|>
def productIndexView(request):
queryset = Product.objects.all()
context = {
"products": queryset,
}
return render(request, "productIndex.html", context)
<|code_end|>
. Write the next line using the current file imports:
from cart.views import CartManagemen... | def productDetailView(request, product_id): |
Continue the code snippet: <|code_start|>
def productIndexView(request):
queryset = Product.objects.all()
context = {
"products": queryset,
}
return render(request, "productIndex.html", context)
def productDetailView(request, product_id):
try:
product = Product.objects.get(pk=pr... | if var_get_search is not None: |
Given snippet: <|code_start|>
class ProductSerializerDefault(serializers.ModelSerializer):
class Meta:
model = Product
fields = "__all__"
class ProductSerializerPOST(serializers.ModelSerializer):
class Meta:
model = Product
fields = ('pk', 'product_name', 'category_id', 'stock... | fields = "__all__" |
Using the snippet: <|code_start|># Remenber to use test_TESTNAME.py
@pytest.mark.django_db
def test_customer_user():
user = CustomerUser()
<|code_end|>
, determine the next line of code. You have imports:
import pytest
from products.models import ProductCategory
from cart.models import (
Cart,
# ItemMana... | user.name = 'Gabriela' |
Given the code snippet: <|code_start|>#
# category.save()
#
# product = Product()
#
# product.product_name = "Metcon"
# product.category_id = category
# product.stock_quantity = 10
# product.price = 459
# product.weight = 10
# product.width = 20
# product.height = 10
# product.pr... | cart.save() |
Given snippet: <|code_start|># Remenber to use test_TESTNAME.py
@pytest.mark.django_db
def test_customer_user():
user = CustomerUser()
user.name = 'Gabriela'
user.last_name = 'Gama'
user.set_password('123456')
user.email = 'gaby@mail.com'
user.phone_number = '98765432'
user.cellphone = '12... | user.delete() |
Predict the next line after this snippet: <|code_start|># Remenber to use test_TESTNAME.py
@pytest.mark.django_db
def test_customer_user():
user = CustomerUser()
user.name = 'Gabriela'
<|code_end|>
using the current file's imports:
import pytest
from products.models import ProductCategory
from cart.models i... | user.last_name = 'Gama' |
Continue the code snippet: <|code_start|>
app_name = UsersConfig.name
urlpatterns = [
url(r'^$', CustomerUserListView.as_view(),
name='list_view'),
url(r'^sign_up/$', CustomerUserRegistrationView.as_view(),
name='sign_up'),
url(r'^excluir_conta/$', CustomerUserDelectionView.as_view(),
... | ] |
Predict the next line after this snippet: <|code_start|>
app_name = UsersConfig.name
urlpatterns = [
url(r'^$', CustomerUserListView.as_view(),
name='list_view'),
url(r'^sign_up/$', CustomerUserRegistrationView.as_view(),
name='sign_up'),
url(r'^excluir_conta/$', CustomerUserDelectionView.a... | ] |
Predict the next line after this snippet: <|code_start|>
app_name = UsersConfig.name
urlpatterns = [
url(r'^$', CustomerUserListView.as_view(),
<|code_end|>
using the current file's imports:
from django.conf.urls import url
from .apps import UsersConfig
from .views import (CustomerUserRegistrationView,
... | name='list_view'), |
Using the snippet: <|code_start|>
app_name = UsersConfig.name
urlpatterns = [
url(r'^$', CustomerUserListView.as_view(),
<|code_end|>
, determine the next line of code. You have imports:
from django.conf.urls import url
from .apps import UsersConfig
from .views import (CustomerUserRegistrationView,
... | name='list_view'), |
Here is a snippet: <|code_start|>
app_name = UsersConfig.name
urlpatterns = [
url(r'^$', CustomerUserListView.as_view(),
name='list_view'),
url(r'^sign_up/$', CustomerUserRegistrationView.as_view(),
<|code_end|>
. Write the next line using the current file imports:
from django.conf.urls import url
fro... | name='sign_up'), |
Given the code snippet: <|code_start|>
app_name = UsersConfig.name
urlpatterns = [
url(r'^$', CustomerUserListView.as_view(),
name='list_view'),
url(r'^sign_up/$', CustomerUserRegistrationView.as_view(),
name='sign_up'),
url(r'^excluir_conta/$', CustomerUserDelectionView.as_view(),
... | name='login'), |
Given snippet: <|code_start|>
app_name = UsersConfig.name
urlpatterns = [
url(r'^$', CustomerUserListView.as_view(),
name='list_view'),
url(r'^sign_up/$', CustomerUserRegistrationView.as_view(),
name='sign_up'),
url(r'^excluir_conta/$', CustomerUserDelectionView.as_view(),
name='exc... | name='detail'), |
Predict the next line after this snippet: <|code_start|>
app_name = UsersConfig.name
urlpatterns = [
url(r'^$', CustomerUserListView.as_view(),
name='list_view'),
url(r'^sign_up/$', CustomerUserRegistrationView.as_view(),
name='sign_up'),
url(r'^excluir_conta/$', CustomerUserDelectionView.a... | name='login'), |
Given snippet: <|code_start|>
def auth_view_decorator(function_decorator):
def simple_decorator(View):
View.dispatch = method_decorator(function_decorator)(View.dispatch)
return View
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from django.contrib import mes... | return simple_decorator |
Continue the code snippet: <|code_start|>
def auth_view_decorator(function_decorator):
def simple_decorator(View):
View.dispatch = method_decorator(function_decorator)(View.dispatch)
return View
return simple_decorator
<|code_end|>
. Use current file imports:
from django.contrib import mess... | class CustomerUserRegistrationView(FormView): |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
app = Flask(__name__)
print_queue = Queue()
prints_folder = pkConfig["paths"]["event_prints"]
monitor_folder = pkConfig["paths"]["event_composites"]
glob_string = "*" + pkConfig["compositor"]["filetype"]
regex = re.compile(r"^(.*?)-(\d+)$")
config = dict()
... | def get_filenames_to_serve(): |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
sys.path.extend(['..', '.'])
async def test_render():
renderer = TemplateRenderer()
builder = YamlTemplateBuilder()
root = builder.read('tailor/resources/templates/standard.yaml')
im = Image.new('RGB', (... | im = Image.new('RGB', (1024, 1024), (0, 128, 0)) |
Predict the next line for this snippet: <|code_start|>
async def test_render():
renderer = TemplateRenderer()
builder = YamlTemplateBuilder()
root = builder.read('tailor/resources/templates/standard.yaml')
im = Image.new('RGB', (5184, 3456), (128, 0, 0))
root.push_image(im)
im = Image.new('R... | class TestRenderer(TestCase): |
Predict the next line for this snippet: <|code_start|> super(SharingControls, self).__init__(*args, **kwargs)
def disable(self):
def derp(*arg):
return False
for widget in self.children:
widget.on_touch_down = derp
widget.on_touch_up = derp
wi... | content=layout, |
Next line prediction: <|code_start|> label = Label(
text="You want to print {} copies?".format(self.prints), font_size=30
)
button0 = Button(
text="Just do it!", font_size=30, background_color=(0, 1, 0, 1)
)
button1 = Button(text="No", font_size=30, backgro... | layout.add_widget(button) |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
class TimingTests(TestCase):
def test_normal(self):
exp = [(False, 2), (False, 2), (False, 2), (True, 2)]
res = list(timing_generator(2, 4))
self.assertEqual(exp, res)
def test_with_initial(self):
exp = [(False, 10),... | self.assertEqual(exp, res) |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
class SenderThread:
def __init__(self, address, filename):
self.address = address
self.filename = filename
def run(self):
sender = pkConfig["email"]["sender"]
subject = pkConfig["email"]["subject"]
auth_file ... | auth = pickle.load(fh) |
Continue the code snippet: <|code_start|> feed = filelike
else:
feed = filelike.read()
self.raw = feed
self.parsed = feedparser.parse(self.raw)
self.feed = FeedGenerator()
# Set feed-level values.
self.build_feed()
self.build_entries()
... | self.feed.image(**image_kwargs) |
Continue the code snippet: <|code_start|> )
def self_test(self):
# Do something that will raise an exception if the credentials are invalid.
# Return a string that will let the user know if they somehow gave
# credentials to the wrong account.
verification = self.api.account_... | media_ids.append(media['id']) |
Based on the snippet: <|code_start|>
#dj.config['external-odor'] = {'protocol': 'file',
# 'location': '/mnt/dj-stor01/pipeline-externals'}
schema = dj.schema('pipeline_odor', locals(), create_tables=False)
@schema
class Odorant(dj.Lookup):
definition = """ # Odorants used in solut... | odorant : varchar(32) # name of odorant |
Based on the snippet: <|code_start|> self.img = img
self.draw_img = np.asarray(img / img.max(), dtype=float)
self.mask = 1 + 0 * img
self.exit = False
self.r = 40
self.X, self.Y = np.mgrid[:img.shape[0], :img.shape[1]]
def grab(self):
print('Contrast (std)', n... | elif event == cv2.EVENT_LBUTTONUP: |
Predict the next line after this snippet: <|code_start|> [2, 'rigid2', '3-d cross-correlation (100 microns above and below estimated z)', 'python'],
[3, 'affine', ('exhaustive search of 3-d rotations + cross-correlation (40 microns'
'above and below estimated z)'), 'python'],
... | details : varchar(255) |
Using the snippet: <|code_start|>__author__ = 'SolarLune'
# Random level generation module.
# TODO: Add rectangular rooms to the GenNodes room styles.
# CONSTANTS
# Connection styles for the GenNodes function;
GN_CONNECTION_STYLE_ONE = 0 # ONE = all nodes connect to another one (other than themselves) randomly
... | RLG_POP_END = 1 |
Based on the snippet: <|code_start|>__author__ = 'SolarLune'
# Random level generation module.
# TODO: Add rectangular rooms to the GenNodes room styles.
# CONSTANTS
# Connection styles for the GenNodes function;
GN_CONNECTION_STYLE_ONE = 0 # ONE = all nodes connect to another one (other than themselves) random... | RLG_POP_STRAIGHT = 2 |
Based on the snippet: <|code_start|># Copyright 2021 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... | "2.8.0-dev20211105", |
Given the code snippet: <|code_start|>from __future__ import division
from __future__ import print_function
def toy_dataspec():
dataspec = data_spec_pb2.DataSpecification()
f1 = dataspec.columns.add()
f1.name = "f1"
f1.type = data_spec_pb2.ColumnType.NUMERICAL
f2 = dataspec.columns.add()
f2.name = "f2... | f4.discretized_numerical.boundaries[:] = [0, 1, 2] |
Based on the snippet: <|code_start|># Copyright 2021 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... | for name, value in ops.__dict__.items(): |
Given snippet: <|code_start|>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
class ValueTest(parameterized.TestCase, tf.test.TestCase):
def test_regression(self):
value = value_lib.RegressionValue(
value=5.0, num_examples=10, standard_devia... | core_node.regressor.distribution.sum = 10.0 |
Predict the next line for this snippet: <|code_start|>
# pylint: disable=g-long-lambda
class ObjectiveTest(parameterized.TestCase, tf.test.TestCase):
def test_classification(self):
objective = objective_lib.ClassificationObjective(
label="label", num_classes=5)
logging.info("objective: %s", objecti... | self.assertRaises( |
Here is a snippet: <|code_start|> "external/ydf/yggdrasil_decision_forests/test_data")
class TfOpTest(parameterized.TestCase, tf.test.TestCase):
@parameterized.named_parameters(
("base", False, False),
("boolean", True, False),
("catset", False, True),
)
def test_toy_rf_c... | model.init_op() |
Predict the next line after this snippet: <|code_start|> "external/ydf/yggdrasil_decision_forests/test_data")
class TfOpTest(parameterized.TestCase, tf.test.TestCase):
@parameterized.named_parameters(
("base", False, False),
("boolean", True, False),
("catset", False, True),
... | model.init_op() |
Given the code snippet: <|code_start|> features, has_catset=has_catset))
logging.info("dense_predictions_values: %s", dense_predictions_values)
logging.info("dense_col_representation_values: %s",
dense_col_representation_values)
expected_proba, expected_class... | sess.run(model.init_op()) |
Using the snippet: <|code_start|> @parameterized.named_parameters(("base", False), ("boolean", True))
def test_toy_rf_classification_weighted(self, add_boolean_features):
with tf.Graph().as_default():
# Create toy model.
model_path = os.path.join(
tempfile.mkdtemp(dir=self.get_temp_dir())... | add_boolean_features=add_boolean_features) |
Here is a snippet: <|code_start|>
class ConditionTest(parameterized.TestCase, tf.test.TestCase):
def test_column_spec_bitmap_to_items_integer(self):
column_spec = data_spec_pb2.Column()
column_spec.categorical.number_of_unique_values = 10
column_spec.categorical.is_already_integerized = True
# b11001... | column_spec = dataspec.columns.add() |
Continue the code snippet: <|code_start|># You may obtain a copy of the License at
#
# https://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 KIN... | column_spec.categorical.number_of_unique_values = 10 |
Here is a snippet: <|code_start|># Copyright 2021 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applic... | for name, value in ops.__dict__.items(): |
Continue the code snippet: <|code_start|>
def prefetch_initial_objects(self):
objects = self \
.object_class().objects.filter(**self.initial_prefetch_dict) \
.exclude(id__in=CurrentObjectState.objects.filter(workflow=self).values_list("object_id",
flat=True)) if self.init... | else: |
Given the code snippet: <|code_start|>
class Function(models.Model):
workflow = models.ForeignKey(Workflow, on_delete=PROTECT, verbose_name=ugettext_lazy("Workflow"),
editable=False)
function_name = models.CharField(max_length=200, verbose_name=ugettext_lazy("Function"))
function_module = models.Ch... | editable=False) |
Next line prediction: <|code_start|># import a definition from a module at runtime
def object_attribute_value(*, workflow, object_id, user, object_state, **kwargs):
params = parse_parameters(workflow=workflow, object_id=object_id, user=user, object_state=object_state, **kwargs)
if "attribute_name" in params:... | attribute_name = params.pop('attribute_name') |
Given the code snippet: <|code_start|># coding: utf-8
log = log_manager.get_logger(__name__)
RAW_DATA_INPUT_SOURCE = 0xFFFFFFFF
VOLTAGE_EXCITATION = 10322
CURRENT_EXCITATION = 10134
<|code_end|>
, generate the next line using the imports in this file:
import numpy as np
import numpy.polynomial.polynomial as pol... | class NoOpScaling(object): |
Given the following code snippet before the placeholder: <|code_start|> thermocouple = thermocouples.Thermocouple(
forward_polynomials=[
thermocouples.Polynomial(
applicable_range=thermocouples.Range(None, 10),
coefficients=[0.0, 1.0]),
thermocouples.Po... | coefficients=[2.0, 3.0]), |
Continue the code snippet: <|code_start|>
sys.path = ['..'] + sys.path
class OpenMock:
def __init__(self, *args, **kw):
self.writes = []
def read(self):
return """LABEL core
<|code_end|>
. Use current file imports:
from functools import reduce
from unittest.mock import MagicMock, patch, senti... | MENU LABEL SliTaz core Live |
Predict the next line for this snippet: <|code_start|>
log = logging.getLogger(__name__)
class ConfigWriter(Config):
def __init__(self):
super(ConfigWriter, self).__init__()
<|code_end|>
with the help of current file imports:
from copilot.models.config import Config
import logging
and context from othe... | log.info("example config loaded.") |
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
# Lice... | ('b', 'B'), |
Predict the next line after this snippet: <|code_start|> help='Number of workers for notifier service. '
'default value is 1.')
]
LISTENER_OPTS = [
cfg.IntOpt('workers',
default=1,
min=1,
help='Number of workers for listener service. '
... | profiler_opts.set_defaults(conf) |
Based on the snippet: <|code_start|># under the License.
profiler_opts = importutils.try_import('osprofiler.opts')
OPTS = [
cfg.IntOpt('http_timeout',
default=600,
help='Timeout seconds for HTTP requests. Set it to None to '
'disable timeout.'),
cfg.IntOpt('... | help='Number of workers for notifier service. ' |
Given the code snippet: <|code_start|>]
EVALUATOR_OPTS = [
cfg.IntOpt('workers',
default=1,
min=1,
help='Number of workers for evaluator service. '
'default value is 1.')
]
NOTIFIER_OPTS = [
cfg.IntOpt('workers',
default=1,
... | log.register_options(conf) |
Given the code snippet: <|code_start|>#!/usr/bin/env python
#
# Copyright 2013-2017 Red Hat, Inc
# Copyright 2012-2015 eNovance <licensing@enovance.com>
#
# 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 L... | help='Timeout seconds for HTTP requests. Set it to None to ' |
Using the snippet: <|code_start|>#!/usr/bin/env python
#
# Copyright 2013-2017 Red Hat, Inc
# Copyright 2012-2015 eNovance <licensing@enovance.com>
#
# 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 Licens... | cfg.IntOpt('evaluation_interval', |
Using the snippet: <|code_start|># Copyright (c) 2018 NEC, Corp.
#
# 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 ... | else: |
Predict the next line for this snippet: <|code_start|> cfg.StrOpt('notifier_topic',
default='alarming',
help='The topic that aodh uses for alarm notifier '
'messages.'),
]
LOG = log.getLogger(__name__)
class AlarmNotifier(object):
def __init__(self, conf):
... | 'severity': alarm.severity, |
Predict the next line for this snippet: <|code_start|> current, reason, reason_data)
mock_heatclient.assert_called_once_with(self.conf, "fake_trust_id")
mock_client.resources.mark_unhealthy.assert_called_once_with(
"fake_asg_id",
"fake_resource_name",
... | notifier.notify(action, alarm_id, alarm_name, severity, previous, |
Here is a snippet: <|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 language governing permis... | def __init__(self, resource_name): |
Next line prediction: <|code_start|> super(AggregationMetricByResourcesLookupRule,
cls).validate_alarm(alarm)
rule = alarm.gnocchi_aggregation_by_resources_threshold_rule
# check the query string is a valid json
try:
query = json.loads(rule.query)
excep... | rule.query = json.dumps(query) |
Using the snippet: <|code_start|>
class MetricOfResourceRule(AlarmGnocchiThresholdRule):
metric = wsme.wsattr(wtypes.text, mandatory=True)
"The name of the metric"
resource_id = wsme.wsattr(wtypes.text, mandatory=True)
"The id of a resource"
resource_type = wsme.wsattr(wtypes.text, mandatory=True... | 'resources') |
Next line prediction: <|code_start|> raise GnocchiUnavailable(e)
class MetricOfResourceRule(AlarmGnocchiThresholdRule):
metric = wsme.wsattr(wtypes.text, mandatory=True)
"The name of the metric"
resource_id = wsme.wsattr(wtypes.text, mandatory=True)
"The id of a resource"
resource_typ... | 'Otherwise Gnocchi will try to create the aggregate against obsolete ' |
Here is a snippet: <|code_start|> "--config-file=%s" % self.tempfile])
self.assertEqual(0, subp.wait())
def test_run_expirer_ttl_disabled(self):
subp = subprocess.Popen(['aodh-expirer',
'-d',
"--config... | msg = "Dropping alarm history 10 data with TTL 1" |
Given the following code snippet before the placeholder: <|code_start|>#
# Copyright 2015 Huawei Technologies Co., Ltd.
#
# 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
#
# ht... | metaclass=ABCSkip): |
Continue the code snippet: <|code_start|>#
# Copyright 2015 Huawei Technologies Co., Ltd.
#
# 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/L... | super(ModelsMigrationsSync, self).setUp() |
Next line prediction: <|code_start|>#
# Copyright 2015 Huawei Technologies Co., Ltd.
#
# 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/LICENS... | @staticmethod |
Predict the next line for this snippet: <|code_start|># Copyright 2019 Catalyst Cloud Ltd.
#
# 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/L... | "ID of a Heat autoscaling group that contains the load balancer member." |
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 ... | super(ProjectNotAuthorized, self).__init__( |
Continue the code snippet: <|code_start|># Copyright 2015 Huawei Technologies Co., Ltd.
#
# 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
#
#... | params = dict(aspect=aspect, id=id) |
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 ... | 'be a dict with an "and" or "or" as key, and the ' |
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 w... | 'value of dict should be a list of basic threshold ' |
Predict the next line after this snippet: <|code_start|># Copyright 2020 Catalyst Cloud LTD.
#
# 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... | limit = wsme.wsattr(wtypes.IntegerType(minimum=-1), mandatory=True) |
Using the snippet: <|code_start|># Copyright 2020 Catalyst Cloud LTD.
#
# 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
#
# Unl... | project_id = wsme.wsattr(wtypes.text, mandatory=True) |
Using the snippet: <|code_start|> t1 = messaging.get_transport(self.CONF, 'fake://')
t2 = messaging.get_transport(self.CONF, 'fake://')
self.assertEqual(t1, t2)
def test_get_transport_default_url_caching(self):
t1 = messaging.get_transport(self.CONF, )
t2 = messaging.get_tran... | self.CONF.set_override('transport_url', 'non-url') |
Continue the code snippet: <|code_start|># Copyright 2015 eNovance
#
# 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 a... | 'interface': conf.service_credentials.interface, |
Predict the next line for this snippet: <|code_start|>#
# Copyright 2015 eNovance
#
# 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
#
# Unles... | adapter_options={ |
Here is a snippet: <|code_start|>#
# Copyright 2015 NEC 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.0
#
# Unless required by... | "value": voluptuous.In(["string", "integer", "float", "boolean", ""])}) |
Predict the next line after 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... | auth_project = on_behalf_of |
Given the code snippet: <|code_start|># 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 writing, software
# distributed under the License is distributed on an "AS ... | return auth_project |
Next line prediction: <|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... | received_events = [] |
Given the code snippet: <|code_start|>#
# Copyright 2015 NEC 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.0
#
# Unless requir... | @mock.patch('aodh.storage.get_connection_from_config', |
Next line prediction: <|code_start|>
# consistency
num_nodes += 1
nodes.append(str(num_nodes + 1))
hr = coordination.HashRing(nodes)
for k in range(num_keys):
n = int(hr.get_node(str(k)))
assignments[k] -= n
reassigned = len([c for c in assignments... | return pc |
Given the code snippet: <|code_start|> def test_reconnect(self, mock_info, mocked_exception):
coord = self._get_new_started_coordinator({}, 'a',
MockToozCoordExceptionRaiser)
with mock.patch('tooz.coordination.get_coordinator',
... | self.assertTrue(coord._coordinator.is_started) |
Here is a snippet: <|code_start|> group='coordination')
with mock.patch('tooz.coordination.get_coordinator',
lambda _, member_id:
coordinator_cls(member_id, shared_storage)):
pc = coordination.PartitionCoordinator(self.CON... | self.assertEqual(['agent1', 'agent2'], |
Here is a snippet: <|code_start|> # YAML is a superset of JSON so we should be able to load
# each line of the log file and pull the object out of with
# Because of the way syslog-ng logs JSON, we can't simply
# grab the entire thing because there isn't array markers in
# the file ..,
for log in... | finally: |
Next line prediction: <|code_start|> # pop a message off for each log
# YAML is a superset of JSON so we should be able to load
# each line of the log file and pull the object out of with
# Because of the way syslog-ng logs JSON, we can't simply
# grab the entire thing because there isn't array mark... | log_upload.load_into_queue() |
Given snippet: <|code_start|>
<table>
<elem key="value">CA:FALSE</elem>
<elem key="critical">true</elem>
<elem key="name">X509v3 Basic Constraints</elem>
</table>
<table>
<elem key="value">12:AA:04:F6:4F:A8:01:F4:2B:CF:A9:DE:88:D1:93:8C:37:F7:AD:3E</elem>
<elem key="n... | def from_dict(cls, script_output_dict): |
Predict the next line for this snippet: <|code_start|> else:
return found_hosts
def find_by_ip(self, ip_str):
'''Takes an IPv4 or IPv6 address and tries to match that to a host
Returns NmapHost if found, else None
'''
ip_obj = ipaddress.ip_address(ip_str)
... | for host in self.hosts: |
Given the following code snippet before the placeholder: <|code_start|> Returns NmapHost if found, else None
'''
ip_obj = ipaddress.ip_address(ip_str)
for host in self.hosts:
if host.addr == ip_obj:
return host
return None
def full_ip_and_mac_lis... | if mac not in mac_to_ip: |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/python3
# This file is part of NDR.
#
# Copyright (C) 2017 - Secured By THEM
# Original Author: Michael Casadevall <mcasadevall@them.com>
#
# NDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU Gene... | class SyslogTest(unittest.TestCase): |
Based on the snippet: <|code_start|> self.assertTrue(np.allclose(hpscres, 0.))
print('\nHeun-Step:')
heunrhs = M * iniv - .5 * dt * \
(A * iniv + iniconvvec + hpconvvec) + dt * fv
matvp = M * cnhev + .5 * dt * A * cnhev - dt * JT * cnhep
hcscres = np.linalg.norm(matvp... | self.assertTrue(np.allclose(abfnres, 0.)) |
Here is a snippet: <|code_start|> cdclfac = 2./(rho*L*Um**2)
print('Computed via testing the residual: ')
print('Cl: {0}'.format(cdclfac*lift))
print('Cd: {0}'.format(cdclfac*drag))
phionevec = np.zeros((femp['V'].dim(), 1))
phionevec[femp['ldsbcinds'], :] = 1.
phione = dolfin.Function(femp... | 'dfg_benchmark1_re20.html:') |
Predict the next line after this snippet: <|code_start|>
# from dolfin_navier_scipy.residual_checks import get_steady_state_res
def twod_simu(nu=None, charvel=None, rho=1., rhosolid=10., meshparams=None,
inirot=None, inivfun=None,
t0=0.0, tE=.1, Nts=1e2+1,
start_steadystate... | phionevec = np.zeros((femp['V'].dim(), 1)) |
Predict the next line after this snippet: <|code_start|> data_prfx = problem + '{2}_mesh{0}_Re{1}'.\
format(meshlvl, femp['Re'], scheme)
soldict.update(fv=rhsd['fv'], fp=rhsd['fp'],
N=meshlvl, nu=nu,
verbose=True,
vel_pcrd_stps=0,
... | if ParaviewOutput: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.