Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Next line prediction: <|code_start|>// Set socket options
void zsocket_set_ipv6 (void *zocket, int ipv6);
void zsocket_set_immediate (void *zocket, int immediate);
void zsocket_set_router_raw (void *zocket, int router_raw);
void zsocket_set_ipv4only (void *zocket, int ipv4only);
void zsocket_set_delay_attach_on_c... | void zsocket_set_sndbuf (void *zocket, int sndbuf); |
Based on the snippet: <|code_start|>
__doc__ = """
The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll
API, for the very common case of reading from a number of sockets. It
does not provide polling for output, nor polling on file handles. If
<|code_end|>
, predict the immediate next line with the hel... | you need either of these, use the zmq_poll API directly. |
Given snippet: <|code_start|>
__doc__ = """
The zmsg class provides methods to send and receive multipart messages
across 0MQ sockets. This class provides a list-like container
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from pyczmq._cffi import C, ptop, cdef
and context:
# Pa... | interface, with methods to work with the overall container. zmsg_t |
Based on the snippet: <|code_start|>
__doc__ = """
The zctx class wraps 0MQ contexts. It manages open sockets in the
context and automatically closes these before terminating the
context. It provides a simple way to set the linger timeout on
sockets, and configure contexts for number of I/O threads. Sets-up
signal (int... | calls such as zmq_recv() and zmq_poll() will return when the user |
Using the snippet: <|code_start|>
__doc__ = """
The zctx class wraps 0MQ contexts. It manages open sockets in the
context and automatically closes these before terminating the
context. It provides a simple way to set the linger timeout on
<|code_end|>
, determine the next line of code. You have imports:
from pyczmq._c... | sockets, and configure contexts for number of I/O threads. Sets-up |
Using the snippet: <|code_start|>
__doc__ = """
The zctx class wraps 0MQ contexts. It manages open sockets in the
context and automatically closes these before terminating the
context. It provides a simple way to set the linger timeout on
sockets, and configure contexts for number of I/O threads. Sets-up
signal (interr... | is therefore like 0MQ/2.0, immediate termination with loss of any |
Given the following code snippet before the placeholder: <|code_start|>
__doc__ = """
The zctx class wraps 0MQ contexts. It manages open sockets in the
context and automatically closes these before terminating the
context. It provides a simple way to set the linger timeout on
sockets, and configure contexts for number ... | default usage is 1 I/O thread. Lets you configure this value. |
Here is a snippet: <|code_start|>
__doc__ = """
The zbeacon class implements a peer-to-peer discovery service for
local networks. A beacon can broadcast and/or capture service
announcements using UDP messages on the local area network. This
implementation uses IPv4 UDP broadcasts. You can define the format of
your outg... | messages on. Incoming beacons are always delivered as two frames: the |
Given the following code snippet before the placeholder: <|code_start|>
__doc__ = """
The zbeacon class implements a peer-to-peer discovery service for
local networks. A beacon can broadcast and/or capture service
announcements using UDP messages on the local area network. This
<|code_end|>
, predict the next line usin... | implementation uses IPv4 UDP broadcasts. You can define the format of |
Here is a snippet: <|code_start|>
__doc__ = """
The zbeacon class implements a peer-to-peer discovery service for
local networks. A beacon can broadcast and/or capture service
announcements using UDP messages on the local area network. This
implementation uses IPv4 UDP broadcasts. You can define the format of
your outg... | messages on. Incoming beacons are always delivered as two frames: the |
Given the following code snippet before the placeholder: <|code_start|>
CURVE_ALLOW_ANY = "*"
cdef('typedef struct _zauth_t zauth_t;')
@cdef('void zauth_destroy (zauth_t **self_p);')
<|code_end|>
, predict the next line using imports from the current file:
from pyczmq._cffi import C, ffi, cdef, ptop
and context ... | def destroy(auth): |
Given the following code snippet before the placeholder: <|code_start|>
__doc__ = """
The zstr class provides utility functions for sending and receiving
strings across 0MQ sockets. It sends strings without a terminating
null, and appends a null byte on received strings. This class is for
<|code_end|>
, predict the nex... | simple message sending. |
Predict the next line for this snippet: <|code_start|>UNSUBSCRIBE = 7
RATE = 8
RECOVERY_IVL = 9
SNDBUF = 11
RCVBUF = 12
RCVMORE = 13
FD = 14
EVENTS = 15
TYPE = 16
LINGER = 17
RECONNECT_IVL = 18
BACKLOG = 19
RECONNECT_IVL_MAX = 21
MAXMSGSIZE = 22
SNDHWM = 23
RCVHWM = 24
MULTICAST_HOPS = 25
RCVTIMEO = 27
SNDTIMEO = 28
LA... | MECHANISM = 43 |
Next line prediction: <|code_start|>
IO_THREADS = 1
MAX_SOCKETS = 2
IO_THREADS_DFLT = 1
MAX_SOCKETS_DFLT = 1024
POLLIN = 1
POLLOUT = 2
POLLERR = 4
EVENT_CONNECTED = 1
EVENT_CONNECT_DELAYED = 2
EVENT_CONNECT_RETRIED = 4
EVENT_LISTENING = 8
EVENT_BIND_FAILED = 16
EVENT_ACCEPTED = 32
EVENT_ACCEPT_FAILED = 64
<|code_... | EVENT_CLOSED = 128 |
Continue the code snippet: <|code_start|>
IO_THREADS = 1
MAX_SOCKETS = 2
IO_THREADS_DFLT = 1
MAX_SOCKETS_DFLT = 1024
POLLIN = 1
POLLOUT = 2
POLLERR = 4
EVENT_CONNECTED = 1
EVENT_CONNECT_DELAYED = 2
EVENT_CONNECT_RETRIED = 4
EVENT_LISTENING = 8
EVENT_BIND_FAILED = 16
EVENT_ACCEPTED = 32
EVENT_ACCEPT_FAILED = 64
EV... | EVENT_CLOSE_FAILED = 256 |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 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
#
# ... | DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 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... | class UserEventServiceTransport(abc.ABC): |
Continue the code snippet: <|code_start|>
class PurgeUserEventsRequest(proto.Message):
r"""Request message for PurgeUserEvents method.
Attributes:
parent (str):
Required. The resource name of the event_store under which
the events are created. The format is
``project... | Override this flag to true to actually perform |
Given the code snippet: <|code_start|> api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
assert api_endpoint == client_class.DEFAULT_ENDPOINT
assert cert_source is None
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
with mock.patch.dict(os.environ, {... | ( |
Here is a snippet: <|code_start|> with mock.patch.object(type(client.transport.predict), "__call__") as call:
# Set the response to a series of pages.
call.side_effect = (
prediction_service.PredictResponse(
results=[
prediction_service.PredictResponse.... | async def test_predict_async_pager(): |
Here is a snippet: <|code_start|> grpc_transport.assert_called_once_with(
credentials=None,
credentials_file=None,
host="squid.clam.whelk",
scopes=None,
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transpo... | client_class, transport_class, transport_name, grpc_helpers |
Here is a snippet: <|code_start|>def test_prediction_service_transport_channel_mtls_with_adc(transport_class):
mock_ssl_cred = mock.Mock()
with mock.patch.multiple(
"google.auth.transport.grpc.SslCredentials",
__init__=mock.Mock(return_value=None),
ssl_credentials=mock.PropertyMock(retur... | ("grpc.max_send_message_length", -1), |
Using the snippet: <|code_start|>__protobuf__ = proto.module(
package="google.cloud.recommendationengine.v1beta1",
manifest={
"GcsSource",
"CatalogInlineSource",
"UserEventInlineSource",
"ImportErrorsConfig",
"ImportCatalogItemsRequest",
"ImportUserEventsRequest",... | be up to 2 GB. See `Importing catalog |
Continue the code snippet: <|code_start|># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
__protobuf__ = proto.module(
package="google.cloud.recommendationengine.v1beta1",
manife... | input_uris (Sequence[str]): |
Predict the next line for this snippet: <|code_start|>
__protobuf__ = proto.module(
package="google.cloud.recommendationengine.v1beta1",
manifest={"CatalogItem", "ProductCatalogItem", "Image",},
)
class CatalogItem(proto.Message):
r"""CatalogItem captures all metadata information of items to be
reco... | Accessories" -> "Shoes"] and ["Sports & Fitness" -> |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 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
#
# ... | "google-cloud-recommendations-ai", |
Given snippet: <|code_start|> event_type = proto.Field(proto.STRING, number=1,)
user_info = proto.Field(proto.MESSAGE, number=2, message="UserInfo",)
event_detail = proto.Field(proto.MESSAGE, number=3, message="EventDetail",)
product_event_detail = proto.Field(
proto.MESSAGE, number=4, message="P... | (e.g. 104.133.9.80) or IPv6 (e.g. |
Based on 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 fo... | event_type (str): |
Continue the code snippet: <|code_start|> expected = "projects/{project}/locations/{location}/catalogs/{catalog}".format(
project=project, location=location, catalog=catalog,
)
actual = CatalogServiceClient.catalog_path(project, location, catalog)
assert expected == actual
def test_parse_catalo... | expected = { |
Here is a snippet: <|code_start|> type(client.transport.delete_catalog_item), "__call__"
) as call:
# Designate an appropriate return value for the call.
call.return_value = None
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
# Call the method with a truthy v... | ) |
Given the following code snippet before the placeholder: <|code_start|> with mock.patch.multiple(
"google.auth.transport.grpc.SslCredentials",
__init__=mock.Mock(return_value=None),
ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
):
with mock.patch.object(
... | ], |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 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/licen... | DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 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/licen... | ) |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 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
#
# ... | DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 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
#
# ... | DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
# Copyright 2022 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/licen... | "ListCatalogItemsRequest", |
Here is a snippet: <|code_start|>#
# Copyright 2014-2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.... | log_task = functools.partial(log_utils.log_task, logger=LOGGER) |
Next line prediction: <|code_start|>#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in... | def _create_ip(subnet, index): |
Continue the code snippet: <|code_start|>#
# Copyright 2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later versi... | @contextlib.contextmanager |
Predict the next line after this snippet: <|code_start|> @sdk_utils.expose
class some_class():
pass
assert hasattr(some_class, '_sdkmetaclass')
def test_expose_class_functions(self):
class some_class(object):
@sdk_utils.expose
def exposed(self, a,... | assert hasattr(getattr(inst, 'not_exposed'), '_sdkmeta') is False |
Given the following code snippet before the placeholder: <|code_start|>
@pytest.fixture
def event():
return Event()
@pytest.fixture
def p_wrapper(lockfile, event):
duration = 60
event.clear()
return ProcessWrapper(target=lock_path, args=(lockfile, duration, event))
def test_should_fail_to_lock_when... | pass |
Here is a snippet: <|code_start|> self._p.daemon = daemon
def __getattr__(self, name):
return getattr(self._p, name)
def kill(self, sig=None):
sig = signal.SIGKILL if sig is None else sig
kill(self.pid, sig)
def waitpid(self):
return waitpid(self.pid, WNOHANG)
... | def p_wrapper(lockfile, event): |
Predict the next line for this snippet: <|code_start|> assert result == os.path.abspath(str(tmpdir))
def test_curdir_has_prefix(self, tmpdir, local_prefix):
result = prefix.Prefix.resolve_prefix_path(str(tmpdir))
assert result == os.path.abspath(str(local_prefix))
def test_parent_has_pr... | { |
Based on the snippet: <|code_start|>
def test_curdir_has_prefix(self, tmpdir, local_prefix):
result = prefix.Prefix.resolve_prefix_path(str(tmpdir))
assert result == os.path.abspath(str(local_prefix))
def test_parent_has_prefix(self, tmpdir, local_prefix):
sub_dir = tmpdir.mkdir('subdir... | 'nets': { |
Given the code snippet: <|code_start|> for argname, opts in args:
parser.add_argument(argname, **opts)
return parser
@patch.dict(
'lago.config.os.environ', {
'LAGO_GLOBAL_VAR_1': 'v1',
'LAGO__SECTION__VAR': 'v2',
'LAGO__LONG_SECTION_NAME__LONG_VAR_NAME': 'v3',
'IGNOR... | 'LAGO_GLOBAL': '', |
Predict the next line after this snippet: <|code_start|> with tempfile.NamedTemporaryFile(mode="w+", delete=False) as f:
f.write(init_str)
return f.name
@pytest.fixture(scope='module')
def test_results(request, global_test_results):
results_path = os.path.join(
global_test_results, str(requ... | yield env |
Given the code snippet: <|code_start|>from __future__ import absolute_import
@pytest.fixture(scope='module')
def init_str(images):
<|code_end|>
, generate the next line using the imports in this file:
import pytest
import textwrap
import tempfile
import os
import logging
import uuid
import filecmp
from time import... | init_template = textwrap.dedent( |
Given the code snippet: <|code_start|>from __future__ import absolute_import
class SDKWrapper(wrapt.ObjectProxy):
"""A proxy object that exposes only methods which were decorated with
:func:`expose` decorator."""
def __getattr__(self, name):
attr = getattr(self.__wrapped__, name)
return ... | class SDKMethod(object): |
Here is a snippet: <|code_start|> sdk.add_stream_logger(level=level, name=name)
logger = logging.getLogger(name)
assert logger.getEffectiveLevel() == getattr(logging, level)
log_at_level = getattr(logger, level.lower())
log_at_level(msg)
assert caplog.record_tuples == [
... | logging.root.removeHandler(handler) |
Based on the snippet: <|code_start|>#
# Copyright 2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#... | def __init__(self, spec, host_cpu): |
Given the code snippet: <|code_start|>
@pytest.fixture()
def subnet_store(self, tmpdir):
subnet_store_path = tmpdir.mkdir('subnet_store')
return subnet_lease.SubnetStore(str(subnet_store_path))
@pytest.fixture()
def prefixes(self, tmpdir):
return self.create_workdir_with_prefixe... | assert \ |
Given the code snippet: <|code_start|> def path(self):
return self._path
@property
def uuid_path(self):
return self._uuid_path
@pytest.fixture
def prefix_mock_gen(tmpdir):
def gen():
while True:
yield PrefixMock(path=str(tmpdir.mkdtemp(rootdir=str(tmpdir))))
re... | @pytest.fixture() |
Predict the next line after this snippet: <|code_start|> subnet_store.acquire(prefix.uuid_path)
def test_recalim_lease(self, subnet_store, prefix):
network = subnet_store.acquire(prefix.uuid_path)
reclaimed_network = subnet_store.acquire(
prefix.uuid_path, str(network)
... | subnet_store.acquire(next(gen).uuid_path) |
Continue the code snippet: <|code_start|> for i in range(0, num_of_prefixes):
prefix_path = os.path.join(path_to_workdir, 'prefix_{}'.format(i))
prefixes.append(PrefixMock(prefix_path))
return prefixes
def create_workdir_with_prefixes(self, temp_dir, num_of_prefixes=2):
... | ) |
Given snippet: <|code_start|> def _create_uuid(self):
with open(self.uuid_path, mode='wt') as f:
f.write(uuid.uuid1().hex)
def remove(self):
shutil.rmtree(self.path)
@property
def path(self):
return self._path
@property
def uuid_path(self):
return se... | prefixes.append(PrefixMock(prefix_path)) |
Using the snippet: <|code_start|>from __future__ import absolute_import
def lease_has_valid_uuid(path_to_lease):
with open(path_to_lease, mode='rt') as f:
<|code_end|>
, determine the next line of code. You have imports:
from lago import subnet_lease
from lago.subnet_lease import (
LagoSubnetLeaseOutOfRang... | uuid_path, uuid_value = json.load(f) |
Continue the code snippet: <|code_start|> @pytest.fixture()
def subnet_store(self, tmpdir):
subnet_store_path = tmpdir.mkdir('subnet_store')
return subnet_lease.SubnetStore(str(subnet_store_path))
@pytest.fixture()
def prefixes(self, tmpdir):
return self.create_workdir_with_prefi... | len(dirnames) == 0 and \ |
Using the snippet: <|code_start|>#
# Refer to the README and COPYING files for full details of the license
#
from __future__ import absolute_import
LOGGER = logging.getLogger(__name__)
try:
except ImportError:
LOGGER.debug('guestfs not available, ignoring')
def _guestfs_version():
if 'guestfs' in sys.mo... | trim_blocks=True, |
Given the code snippet: <|code_start|> loaded_conf = utils.load_virt_stream(virt_fd=json_fd)
assert deep_compare(self.virt_conf, loaded_conf)
def test_fallback_to_yaml(self):
bad_json = StringIO("{'one': 1,}")
expected = {'one': 1}
loaded_conf = utils.load_virt_stream(virt_fd... | def test_temporary_directory_should_respect_ignoring_errors_in(): |
Continue the code snippet: <|code_start|>
return ServiceState.MISSING
class SystemdContainerService(ServicePlugin):
BIN_PATH = '/usr/bin/docker'
HOST_BIN_PATH = '/usr/bin/systemctl'
def _request_start(self):
super()._request_start()
ret = self._vm.ssh(
[self.BIN_PATH, ... | def state(self): |
Predict the next line for this snippet: <|code_start|> print(msg)
def info(self, msg):
print(msg)
class TestLogUtils(object):
@pytest.fixture(scope='class')
def logger(self):
return LoggerMock()
def thrower(self, logger):
with LogTask('I should throw the exception', lo... | except RuntimeError: |
Using the snippet: <|code_start|>from __future__ import absolute_import
from __future__ import print_function
class LoggerMock(object):
def debug(self, msg):
print(msg)
def info(self, msg):
print(msg)
class TestLogUtils(object):
@pytest.fixture(scope='class')
def logger(self):
... | try: |
Here is a snippet: <|code_start|># it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even t... | return ret, out, err |
Based on the snippet: <|code_start|> with pytest.raises(AssertionError):
my_prefix.assert_called_with()
my_prefix.initialize.assert_called_with()
my_prefix_instance = my_workdir.initialize(prefix_name=prefix_name)
my_prefix.assert_called_with(my_workdir.join(prefix_name)... | topatch=os, |
Given the following code snippet before the placeholder: <|code_start|> template.write(content)
def add_base(self, content):
self.add(content=content, name='sysprep-base.j2')
@fixture
def factory(tmpdir):
return TemplateFactory(dst=str(tmpdir))
class TestSysprep(object):
@pytest.mark... | assert lines[0].strip() == '# sysprep-{0}.j2'.format(expected) |
Based on the snippet: <|code_start|> disk_path, disk_root, retries=retries, wait=0
) as conn:
assert call.mount_ro(disk_root, '/') in conn.mock_calls
assert call.add_drive_ro(disk_path) in conn.mock_calls
assert conn.mount_ro.call_count == retries
... | assert mock_gfs.return_value.add_drive_ro.call_count == retries |
Continue the code snippet: <|code_start|>
@pytest.mark.parametrize(
'disk_path,disk_root', [('/path/to/file.qcow', '/dev/sda')]
)
def test_guestfs_conn_mount_ro(self, mock_gfs, disk_path, disk_root):
with patch('lago.guestfs_tools.find_rootfs') as mock_rootfs:
mock_rootfs.return_... | disk_path, disk_root, retries=retries, wait=0 |
Based on the snippet: <|code_start|> def is_file(self):
pass
def is_dir(self):
pass
def copy_out(self):
pass
@pytest.fixture
def mock_gfs():
with patch(
'lago.guestfs_tools.guestfs.GuestFS', spec=MockGuestFS
) as mocked:
yield mocked
@pytest.fixture
def m... | { |
Continue the code snippet: <|code_start|> """
<cpu>
<arch>{arch}</arch>
<model>{model}</model>
<vendor>{vendor}</vendor>
</cpu>
... | <cpu mode="host-passthrough"> |
Here is a snippet: <|code_start|>
_numa2 = """
<numa>
<cell cpus="0" id="0" memory="1023" unit="MiB"/>
<cell cpus="1" id="1" memory="1023" unit="MiB"/>
</numa>
"""
empty_cpu = cpu.CPU(spec={'memory': 2047}, host_cpu=None)
vcpu_num = 2
self.... | <cell cpus="4-7" id="1" memory="2048" unit="MiB"/> |
Given snippet: <|code_start|>
CL_ITEMS = [
dict(id="A", name={"en": "Average of observations through period"}),
dict(id="B", name={"en": "Beginning of period"}),
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import pytest
from pandasdmx import message
from pandasdmx.model... | dict(id="B1", name={"en": "Child code of B"}), |
Given snippet: <|code_start|>
CL_ITEMS = [
dict(id="A", name={"en": "Average of observations through period"}),
dict(id="B", name={"en": "Beginning of period"}),
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import pytest
from pandasdmx import message
from pandasdmx.model... | dict(id="B1", name={"en": "Child code of B"}), |
Continue the code snippet: <|code_start|>
CL_ITEMS = [
dict(id="A", name={"en": "Average of observations through period"}),
dict(id="B", name={"en": "Beginning of period"}),
dict(id="B1", name={"en": "Child code of B"}),
]
<|code_end|>
. Use current file imports:
import pytest
from pandasdmx import mess... | @pytest.fixture |
Next line prediction: <|code_start|>
# Regular expression for URNs
URN = re.compile(
r"urn:sdmx:org\.sdmx\.infomodel"
r"\.(?P<package>[^\.]*)"
r"\.(?P<class>[^=]*)=((?P<agency>[^:]*):)?"
r"(?P<id>[^\(\.]*)(\((?P<version>[\d\.]*)\))?"
<|code_end|>
. Use current file imports:
(import re
from typing impo... | r"(\.(?P<item_id>.*))?" |
Given the code snippet: <|code_start|>
# Regular expression for URNs
URN = re.compile(
r"urn:sdmx:org\.sdmx\.infomodel"
r"\.(?P<package>[^\.]*)"
r"\.(?P<class>[^=]*)=((?P<agency>[^:]*):)?"
r"(?P<id>[^\(\.]*)(\((?P<version>[\d\.]*)\))?"
r"(\.(?P<item_id>.*))?"
)
_BASE = (
"urn:sdmx:org.sdmx.inf... | "{ma.maintainer.id}:{ma.id}({ma.version}){extra_id}" |
Predict the next line for this snippet: <|code_start|>
@pytest.mark.xfail(raises=RuntimeError, match="sdmx.format.protobuf_pb2 missing")
def test_codelist(caplog, codelist):
msg = StructureMessage()
<|code_end|>
with the help of current file imports:
import logging
import pytest
from pandasdmx.message import S... | msg.codelist[codelist.id] = codelist |
Predict the next line after this snippet: <|code_start|>
@pytest.mark.xfail(raises=RuntimeError, match="sdmx.format.protobuf_pb2 missing")
def test_codelist(caplog, codelist):
msg = StructureMessage()
msg.codelist[codelist.id] = codelist
<|code_end|>
using the current file's imports:
import logging
import... | caplog.set_level(logging.ERROR) |
Using the snippet: <|code_start|> def add_obs(self, observations, series_key=None):
"""Add *observations* to a series with *series_key*.
Checks consistency and adds group associations."""
if series_key is not None:
# Associate series_key with any GroupKeys that apply to it
... | def _validate_action(cls, value):
|
Predict the next line after this snippet: <|code_start|> if isinstance(target, Observation):
self.group[group_key].append(target)
def add_obs(self, observations, series_key=None):
"""Add *observations* to a series with *series_key*.
Checks consistency and a... | self.series[series_key].append(obs)
|
Using the snippet: <|code_start|> #: :mod:`sdmx` extension not in the IM.
series: DictLike[SeriesKey, List[Observation]] = dictlike_field()
#: Map of group key → list of observations.
#: :mod:`sdmx` extension not in the IM.
group: DictLike[GroupKey, List[Observation]] = dictlike_field()
de... | for obs in observations:
|
Given the following code snippet before the placeholder: <|code_start|> return len(self.obs)
def _add_group_refs(self, target):
"""Associate *target* with groups in this dataset.
*target* may be an instance of SeriesKey or Observation.
"""
for group_key in self.group:... | if series_key is not None:
|
Next line prediction: <|code_start|>
def _add_group_refs(self, target):
"""Associate *target* with groups in this dataset.
*target* may be an instance of SeriesKey or Observation.
"""
for group_key in self.group:
if group_key in (target if isinstance(target, Serie... | if obs.series_key is None:
|
Here is a snippet: <|code_start|> if isinstance(target, Observation):
self.group[group_key].append(target)
def add_obs(self, observations, series_key=None):
"""Add *observations* to a series with *series_key*.
Checks consistency and adds group associations.... | self.series[series_key].append(obs)
|
Continue the code snippet: <|code_start|> return len(self.obs)
def _add_group_refs(self, target):
"""Associate *target* with groups in this dataset.
*target* may be an instance of SeriesKey or Observation.
"""
for group_key in self.group:
if group_key in ... | if series_key is not None:
|
Here is a snippet: <|code_start|> if series_key is not None:
# Associate series_key with any GroupKeys that apply to it
self._add_group_refs(series_key)
# Maybe initialize empty series
self.series.setdefault(series_key, [])
for obs in observations:
... | return ActionType[value]
|
Given the code snippet: <|code_start|>
class CityManager(models.Manager):
def get_by_natural_key(self, slug):
return self.get(slug=slug)
@register_snippet
class City(models.Model):
<|code_end|>
, generate the next line using the imports in this file:
from django.contrib.gis.db import models
from dja... | name = models.CharField(max_length=255) |
Given the following code snippet before the placeholder: <|code_start|>
class CityManager(models.Manager):
def get_by_natural_key(self, slug):
return self.get(slug=slug)
<|code_end|>
, predict the next line using imports from the current file:
from django.contrib.gis.db import models
from django.con... | @register_snippet |
Continue the code snippet: <|code_start|>
class CityManager(models.Manager):
def get_by_natural_key(self, slug):
return self.get(slug=slug)
@register_snippet
<|code_end|>
. Use current file imports:
from django.contrib.gis.db import models
from django.conf import settings
from django.templatetags.l1... | class City(models.Model): |
Based on the snippet: <|code_start|>
class CityManager(models.Manager):
def get_by_natural_key(self, slug):
return self.get(slug=slug)
@register_snippet
class City(models.Model):
name = models.CharField(max_length=255)
<|code_end|>
, predict the immediate next line with the help of imports:
from... | slug = models.SlugField(max_length=255) |
Using the snippet: <|code_start|>
def neighbourhoods(request):
city_id = request.GET.get('city', None)
term = slugify(request.GET.get('term', ''))
results = Neighbourhood.objects.filter(
city__id=city_id,
slug__contains=term,
).values_list('id', 'name')
results = [{'id': r[0], '... | def condominiums(request): |
Predict the next line after this snippet: <|code_start|>
urlpatterns = [
url(r'^ajax/neighbourhoods.json', neighbourhoods,
name='dashboard_neighbourhoods_json'),
url(r'^ajax/condominiums.json', condominiums,
<|code_end|>
using the current file's imports:
from django.conf.urls import url
from dashboa... | name='dashboard_condominiums_json'), |
Next line prediction: <|code_start|>
urlpatterns = [
url(r'^ajax/neighbourhoods.json', neighbourhoods,
name='dashboard_neighbourhoods_json'),
url(r'^ajax/condominiums.json', condominiums,
name='dashboard_condominiums_json'),
<|code_end|>
. Use current file imports:
(from django.conf.urls impo... | ] |
Predict the next line for this snippet: <|code_start|># standard libraries
# rubiks cube libraries
logger = logging.getLogger(__name__)
class NoSteps(Exception):
pass
class NoIDASolution(Exception):
pass
<|code_end|>
with the help of current file imports:
import datetime as dt
import hashlib
import js... | class NoPruneTableState(Exception): |
Continue the code snippet: <|code_start|># -*- encoding: utf-8 -*-
logger = logging.getLogger('jenkins')
def update_build_info():
lint_jenkins = LintJenkins(settings.JENKINS_URL,
username=settings.JENKINS_USER,
password=settings.JENKIN... | new_build_numbers = list(set(remote_build_numbers) - set(local_build_numbers))
|
Here is a snippet: <|code_start|> permission_classes = (
permissions.AllowAny, # TODO: 上下后需要改为登陆用户
)
pagination_class = StandardResultsSetPagination
filter_backends = (
filters.DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter
)
class JobViewSet(Defa... | username=str(job_info['svn_username']), |
Continue the code snippet: <|code_start|> ordering_fields = ('name',)
filter_fields = ('name', )
# 普通的字段匹配这样够了,如果需要实现高级匹配比如日期基于某个范围等,就需要定义自己的FilterSet类了
# http://www.django-rest-framework.org/api-guide/filtering/#djangofilterbackend
def perform_create(self, serializer):
serializer.save()
... | serializer = self.get_serializer(page, many=True) |
Predict the next line for this snippet: <|code_start|> filters.SearchFilter,
filters.OrderingFilter
)
class JobViewSet(DefaultsMixin, viewsets.ModelViewSet):
queryset = Job.objects.all()
serializer_class = JobSerializer
search_fields = ('name',)
ordering_fields = ('name',)
filte... | raise Exception(e) |
Given the following code snippet before the placeholder: <|code_start|># -*- encoding: utf-8 -*-
User = get_user_model()
class JobSerializer(serializers.ModelSerializer):
links = serializers.SerializerMethodField()
violation_info = serializers.SerializerMethodField()
class Meta:
model = Job
<... | fields = ('id', 'name', 'description', |
Predict the next line after this snippet: <|code_start|># -*- encoding: utf-8 -*-
User = get_user_model()
class JobSerializer(serializers.ModelSerializer):
links = serializers.SerializerMethodField()
violation_info = serializers.SerializerMethodField()
class Meta:
model = Job
fields =... | return violation_info |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
#
# Atizo - The Open Innovation Platform
# http://www.atizo.com/
#
# Copyright (c) 2008-2010 Atizo AG. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as publi... | help='a directory to write the dump to'), |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.