Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the code snippet: <|code_start|> assert "spawned uWSGI worker 2" in logs assert "spawned uWSGI worker 3" not in logs assert 'running "unix_signal:15 gracefully_kill_them_all" (master-start)' in logs assert "success: nginx entered RUNNING state, process has stayed up for" in logs assert "success...
container.stop()
Continue the code snippet: <|code_start|> client = docker.from_env() def verify_container(container: Container) -> None: logs = get_logs(container) assert 'unable to find "application" callable in file /app/main.py' in logs assert ( "unable to load app 0 (mountpoint='') (callable not found or impo...
path = test_path.parent / "broken_app"
Given the code snippet: <|code_start|> client = docker.from_env() def verify_container(container: Container) -> None: logs = get_logs(container) assert 'unable to find "application" callable in file /app/main.py' in logs assert ( "unable to load app 0 (mountpoint='') (callable not found or impor...
dockerfile = "Dockerfile"
Predict the next line after this snippet: <|code_start|> "unable to load app 0 (mountpoint='') (callable not found or import error)" in logs ) assert "*** no app loaded. GAME OVER ***" in logs assert "INFO exited: uwsgi (exit status 22; not expected)" in logs assert ( "INFO succes...
verify_container(container)
Given the code snippet: <|code_start|> client = docker.from_env() def verify_container(container: Container) -> None: logs = get_logs(container) assert 'unable to find "application" callable in file /app/main.py' in logs assert ( "unable to load app 0 (mountpoint='') (callable not found or impor...
)
Given the code snippet: <|code_start|> assert "listen 8080;" in nginx_config assert "worker_connections 1024;" in nginx_config assert "worker_rlimit_nofile;" not in nginx_config assert "daemon off;" in nginx_config assert "include uwsgi_params;" in nginx_config assert "uwsgi_pass unix:///tmp/uwsg...
assert "success: uwsgi entered RUNNING state, process has stayed up for" in logs
Based on the snippet: <|code_start|> def verify_container(container: Container, response_text: str) -> None: response = requests.get("http://127.0.0.1:8000") assert response.text == response_text nginx_config = get_nginx_config(container) assert "client_max_body_size 0;" in nginx_config assert "wor...
assert "Running script /app/prestart.sh" in logs
Given snippet: <|code_start|> client = docker.from_env() def verify_container(container: Container, response_text: str) -> None: response = requests.get("http://127.0.0.1:8000") assert response.text == response_text nginx_config = get_nginx_config(container) assert "client_max_body_size 0;" in nginx...
assert "daemon off;" in nginx_config
Continue the code snippet: <|code_start|> assert "socket = /tmp/uwsgi.sock" in logs assert "chown-socket = nginx:nginx" in logs assert "chmod-socket = 664" in logs assert "hook-master-start = unix_signal:15 gracefully_kill_them_all" in logs assert "need-app = true" in logs assert "die-on-term = t...
test_path = Path(__file__)
Predict the next line after this snippet: <|code_start|>def verify_container(container: Container, response_text: str) -> None: response = requests.get("http://127.0.0.1:8000") assert response.text == response_text nginx_config = get_nginx_config(container) assert "client_max_body_size 0;" in nginx_conf...
assert "spawned uWSGI master process" in logs
Given the code snippet: <|code_start|> assert "ini = /etc/uwsgi/uwsgi.ini" in logs assert "socket = /tmp/uwsgi.sock" in logs assert "chown-socket = nginx:nginx" in logs assert "chmod-socket = 664" in logs assert "hook-master-start = unix_signal:15 gracefully_kill_them_all" in logs assert "need-ap...
tag = "uwsgi-nginx-testimage"
Predict the next line for this snippet: <|code_start|> assert response.text == response_text nginx_config = get_nginx_config(container) assert "client_max_body_size 0;" in nginx_config assert "worker_processes 1;" in nginx_config assert "listen 80;" in nginx_config assert "worker_connections 1024...
assert "spawned uWSGI master process" in logs
Continue the code snippet: <|code_start|> assert "cheaper = 2" in logs assert "Checking for script in /app/prestart.sh" in logs assert "Running script /app/prestart.sh" in logs assert ( "Running inside /app/prestart.sh, you could add migrations to this file" in logs ) assert "spawned uWSG...
verify_container(container, response_text)
Continue the code snippet: <|code_start|> assert "Checking for script in /app/prestart.sh" in logs assert "Running script /app/prestart.sh" in logs assert ( "Running inside /app/prestart.sh, you could add migrations to this file" in logs ) assert "spawned uWSGI master process" in logs ass...
container.stop()
Here is a snippet: <|code_start|> assert "hook-master-start = unix_signal:15 gracefully_kill_them_all" in logs assert "need-app = true" in logs assert "die-on-term = true" in logs assert "show-config = true" in logs assert "wsgi-file = /app/main.py" in logs assert "processes = 16" in logs ass...
time.sleep(sleep_time)
Given the following code snippet before the placeholder: <|code_start|> client = docker.from_env() def verify_container(container: Container, response_text: str) -> None: response: Response = requests.get("http://127.0.0.1:8000") assert response.text == response_text nginx_config = get_nginx_config(cont...
assert "die-on-term = true" in logs
Here is a snippet: <|code_start|> ) assert "spawned uWSGI master process" in logs assert "spawned uWSGI worker 1" in logs assert "spawned uWSGI worker 2" in logs assert "spawned uWSGI worker 3" not in logs assert 'running "unix_signal:15 gracefully_kill_them_all" (master-start)' in logs asser...
container.start()
Based on the snippet: <|code_start|> client = docker.from_env() def verify_container(container: Container, response_text: str) -> None: response = requests.get("http://127.0.0.1:8000") assert response.text == response_text nginx_config = get_nginx_config(container) assert "client_max_body_size 0;" in...
assert "processes = 16" in logs
Given snippet: <|code_start|> assert "chmod-socket = 664" in logs assert "hook-master-start = unix_signal:15 gracefully_kill_them_all" in logs assert "need-app = true" in logs assert "die-on-term = true" in logs assert "show-config = true" in logs assert "wsgi-file = /app/main.py" in logs ass...
test_path = Path(__file__)
Here is a snippet: <|code_start|> assert "client_max_body_size 0;" in nginx_config assert "worker_processes 1;" in nginx_config assert "listen 80;" in nginx_config assert "worker_connections 1024;" in nginx_config assert "worker_rlimit_nofile;" not in nginx_config assert "daemon off;" in nginx_co...
assert "spawned uWSGI worker 2" in logs
Using the snippet: <|code_start|> assert "uwsgi_pass unix:///tmp/uwsgi.sock;" in nginx_config logs = get_logs(container) assert "getting INI configuration from /app/uwsgi.ini" in logs assert "getting INI configuration from /etc/uwsgi/uwsgi.ini" in logs assert "ini = /app/uwsgi.ini" in logs assert...
def test_env_vars_1() -> None:
Given the following code snippet before the placeholder: <|code_start|> client = docker.from_env() def verify_container(container: Container, response_text: str) -> None: response = requests.get("http://127.0.0.1:8000") assert response.text == response_text nginx_config = get_nginx_config(container) ...
assert "need-app = true" in logs
Given snippet: <|code_start|> class ArloDoorBell(ArloChildDevice): def __init__(self, name, arlo, attrs): super().__init__(name, arlo, attrs) self._motion_time_job = None self._ding_time_job = None def _motion_stopped(self): self._save_and_do_callbacks('motionDetected', False)...
def _button_unpressed(self):
Based on the snippet: <|code_start|> @property def is_on(self): return self._arlo.st.get([self._device_id, LAMP_STATE_KEY], "off") == "on" def turn_on(self): self._arlo.bg.run(self._arlo.be.notify, base=self.base_station, body={ ...
if cap in 'motionDetected':
Given the following code snippet before the placeholder: <|code_start|> # pass on to lower layer super()._event_handler(resource, event) @property def is_on(self): return self._arlo.st.get([self._device_id, LAMP_STATE_KEY], "off") == "on" def turn_on(self): self._arlo.bg.run...
if cap in 'battery_level':
Next line prediction: <|code_start|> if stream is True: return r elif method == 'PUT': r = self._session.put(url, json=params, headers=headers, timeout=timeout) elif method == 'POST': r = self._session.pos...
self._arlo.debug('Fetching device list after ev-reconnect')
Given snippet: <|code_start|> # include token and session details class ArloBackEnd(object): def __init__(self, arlo): self._arlo = arlo self._lock = threading.Condition() self._req_lock = threading.Lock() self._dump_file = self._arlo.cfg.storage_dir + '/' + 'packets.dump' ...
self._user_id = None
Given the code snippet: <|code_start|> # logged out? signal exited if response.get('action') == 'logout': with self._lock: self._ev_connected_ = False self._requests = {} self._lock.notify_all() self._arl...
self._arlo.debug('starting event loop')
Given the code snippet: <|code_start|> with self._lock: self._ev_connected_ = True self._lock.notify_all() continue # is this from a notify? then signal to waiting entity, also # pass into dispatcher tid = respon...
if self._arlo.cfg.stream_timeout == 0:
Given snippet: <|code_start|> self._arlo.warning('event loop timeout') except AttributeError as e: self._arlo.warning('forced close ' + str(e)) except Exception as e: self._arlo.warning('general exception ' + str(e)) # restart login... ...
body['to'] = base.device_id
Given the following code snippet before the placeholder: <|code_start|> self._device_id = attrs.get('deviceId', None) self._device_type = attrs.get('deviceType', None) self._unique_id = attrs.get('uniqueId', None) # add a listener self._arlo.be.add_listener(self, self._event_hand...
cbs.append(cb)
Continue the code snippet: <|code_start|> class ArloDevice(object): def __init__(self, name, arlo, attrs): self._name = name self._arlo = arlo self._attrs = attrs self._lock = threading.Lock() self._attr_cbs_ = [] # stuff we use a lot self._device_id = at...
def __repr__(self):
Continue the code snippet: <|code_start|> class ArloDevice(object): def __init__(self, name, arlo, attrs): self._name = name self._arlo = arlo self._attrs = attrs self._lock = threading.Lock() self._attr_cbs_ = [] # stuff we use a lot self._device_id = at...
def __repr__(self):
Continue the code snippet: <|code_start|> value = props.get(key, None) if value is not None: self._save_and_do_callbacks(key, value) def _do_callbacks(self, attr, value): cbs = [] with self._lock: for watch, cb in self._attr_cbs_: ...
@property
Based on the snippet: <|code_start|> class ArloDevice(object): def __init__(self, name, arlo, attrs): self._name = name self._arlo = arlo self._attrs = attrs self._lock = threading.Lock() self._attr_cbs_ = [] # stuff we use a lot self._device_id = attrs.g...
self._device_type = attrs.get('deviceType', None)
Given snippet: <|code_start|> def _event_handler(self, resource, event): self._arlo.debug("*DEVICE* {}: got {} event {}".format(self.name, resource, event)) # Find properties. Event either contains a item called properites or it # is the whole thing. props = event.get("properties", ...
self._save(attr, value)
Next line prediction: <|code_start|> class ArloDevice(object): def __init__(self, name, arlo, attrs): self._name = name self._arlo = arlo self._attrs = attrs self._lock = threading.Lock() <|code_end|> . Use current file imports: (import threading from .constant import (BATTERY_K...
self._attr_cbs_ = []
Using the snippet: <|code_start|> self._attr_cbs_ = [] # stuff we use a lot self._device_id = attrs.get('deviceId', None) self._device_type = attrs.get('deviceType', None) self._unique_id = attrs.get('uniqueId', None) # add a listener self._arlo.be.add_listener(s...
with self._lock:
Given snippet: <|code_start|> class TaskSpy: def resolved(self, value): return value def rejected(self, value): return value def mapper(self, arg): return arg + 1 <|code_end|> , continue by predicting the next line. Consider current file imports: from testers.functor_law_tes...
def side_effect(self, arg): # remove?
Using the snippet: <|code_start|> class FunctorLawTester: # pragma: no cover def __init__(self, functor, mapper1, mapper2, get_fn=identity): self.functor = functor self.mapper1 = mapper1 self.mapper2 = mapper2 self.get_fn = get_fn def _assert(self, x, y): assert self....
if run_composition_law_test:
Given snippet: <|code_start|> class MonadLawTester: # pragma: no cover def __init__(self, monad, value, mapper1, mapper2, get_fn=identity): self.monad = monad self.value = value self.mapper1 = mapper1 self.mapper2 = mapper2 self.get_fn = get_fn def _assert(self, x, y)...
if run_associativity_law_test:
Predict the next line after this snippet: <|code_start|> @given(text(), integers()) def test_identity_should_return_first_argument(text, integer): assert identity(text) is text assert identity(integer) is integer @given(integers()) def test_compose_should_applied_function_on_value_and_return_it_result(integ...
def test_eq(text):
Predict the next line after this snippet: <|code_start|>class MemoizeSpy: def fn(*args): return args def key(_, value, new_value): return value['compare_key'] == new_value['compare_key'] def test_utils_memoize_should_call_fn_once_when_args_are_equal(mocker): memoize_spy = MemoizeSpy() ...
assert memoize_spy.fn.call_count == 1
Based on the snippet: <|code_start|> def execute_function(self, *args): print(args) assert args == (mocked_args, ) return 42 def execute_function1(self, *args): assert args == (mocked_args, ) return 0 @pytest.fixture def cond_spy(mocker): cond_spy = CondSpy() mo...
assert cond_spy.execute_function.call_count == 1
Next line prediction: <|code_start|> class ApplicativeLawTester: def __init__(self, applicative, value, mapper1, mapper2, get_fn=identity): self.applicative = applicative self.value = value <|code_end|> . Use current file imports: (from pymonet.utils import identity) and context including class ...
self.mapper1 = mapper1
Based on the snippet: <|code_start|> @curry def fn(arg1): return arg1 assert fn(integer1) == fn(integer1) @given(integers(), integers()) def test_curry_2_arguments(integer1, integer2): @curry def fn(arg1, arg2): return arg1 + arg2 assert fn(integer1)(integer2) == fn(integer1...
@given(integers(), integers(), integers(), integers())
Continue the code snippet: <|code_start|>#!/usr/bin/env python # Copyright 2018 Criteo # # 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 # # U...
bgutil.main(["--driver=memory", "read", "**"], self.accessor)
Predict the next line after this snippet: <|code_start|> [ ["a"], ["b"], [ bg_glob.SequenceIn(["c", "d"]), "-", bg_glob.SequenceIn(["e", "f"]), ], ...
),
Given the following code snippet before the placeholder: <|code_start|># Copyright (c) 2013 Alan McIntyre class BTCEScraper(HTMLParser): def __init__(self): HTMLParser.__init__(self) self.messageId = None self.messageTime = None self.messageUser = None self.messageText = N...
self.inMessageSpan = False
Next line prediction: <|code_start|> if self.messageText is None: # messageText will be None if the message consists entirely # of emoticons. self.messageText = '' # parse message time t = datetime.datetime.now() messageTime...
self.reserves24change = None
Given the code snippet: <|code_start|># performs tick data retrieval to be replayed later. brokers = create_brokers('PAPER', config.PAIRS, config.EXCHANGES) bot = DataGatherBot(config, brokers) bot.start(sleep=20, duration=60 * 60 * 4, maxdepth=6) # 5 hours of data, one minute intervals <|code_end|> , generate the ne...
print('Done!')
Next line prediction: <|code_start|># performs tick data retrieval to be replayed later. brokers = create_brokers('PAPER', config.PAIRS, config.EXCHANGES) bot = DataGatherBot(config, brokers) bot.start(sleep=20, duration=60 * 60 * 4, maxdepth=6) # 5 hours of data, one minute intervals <|code_end|> . Use current file ...
print('Done!')
Given snippet: <|code_start|> super(Broker, self).__init__() self.mode = mode # TRADING mode (PAPER or LIVE) self.xchg = xchg # stores live balances self.balances = {} # self. depth consists of keys = the bases that I define in config, and each lists buy/sell orders ...
swapped_slug = alt + "_" + base
Continue the code snippet: <|code_start|> brokers = create_brokers('BACKTEST', config.PAIRS, config.EXCHANGES) bot = ArbitrageBot(config, brokers) # this automatically loads the data path file. backtest_data = '/Users/ericjang/Desktop/LiClipse_Workspace/btc_arbitrage/data/Mar-29-2014_19-00-35__20_14400.p' bot.backtest(...
print('done!')
Based on the snippet: <|code_start|> self.date = datetime.datetime.strptime(self.date, "%Y-%m-%d %H:%M:%S") def __getstate__(self): return dict((k, getattr(self, k)) for k in Trade.__slots__) def __setstate__(self, state): f...
if count is not None:
Given snippet: <|code_start|># Copyright (c) 2013 Alan McIntyre class InvalidNonceException(Exception): def __init__(self, method, expectedNonce, actualNonce): Exception.__init__(self) self.method = method self.expectedNonce = expectedNonce self.actualNonce = actualNonce def...
self.server_time = datetime.fromtimestamp(info.get(u'server_time'))
Given snippet: <|code_start|> '''A list of instances of this class will be returned by a successful call to TradeAPI.activeOrders.''' def __init__(self, order_id, info): self.order_id = int(order_id) vnames = ("pair", "type", "amount", "rate", "timestamp_created", "status")...
self.order_id = info.get(u"order_id")
Given snippet: <|code_start|> class Product(models.Model): name = models.CharField(max_length=30) race = models.ForeignKey(Race, null=True, related_name='race') seller = models.ForeignKey(UserDetail, null=False) gender = models.CharField(max_length=3, choices=GENDERS, default='NON') sterile = models...
def _get_state_id(self):
Using the snippet: <|code_start|> class Product(models.Model): name = models.CharField(max_length=30) race = models.ForeignKey(Race, null=True, related_name='race') seller = models.ForeignKey(UserDetail, null=False) gender = models.CharField(max_length=3, choices=GENDERS, default='NON') sterile = mo...
def _get_state_id(self):
Predict the next line for this snippet: <|code_start|> class Product(models.Model): name = models.CharField(max_length=30) race = models.ForeignKey(Race, null=True, related_name='race') seller = models.ForeignKey(UserDetail, null=False) gender = models.CharField(max_length=3, choices=GENDERS, default='N...
sterile = models.BooleanField(default=False)
Predict the next line after this snippet: <|code_start|> price = models.FloatField(null=False, default=0) category = models.ForeignKey(Category) active = models.BooleanField(null=False, default=True) location = models.PointField(null=False) created_at = models.DateTimeField(auto_now_add=True) upd...
def __str__(self):
Given the code snippet: <|code_start|> class Product(models.Model): name = models.CharField(max_length=30) race = models.ForeignKey(Race, null=True, related_name='race') seller = models.ForeignKey(UserDetail, null=False) gender = models.CharField(max_length=3, choices=GENDERS, default='NON') sterile...
return str(self.state.id)
Predict the next line after this snippet: <|code_start|> class StatesViewSet (GenericViewSet): permission_classes = [StatePermission] queryset = State.objects.filter(active=1) serializer_class = StatesSerializer def list(self, request): queryset = self.filter_queryset(self.get_queryset()) ...
"detail": "Error parse 'date-update' parameter needs user ISO-8601"
Continue the code snippet: <|code_start|> class StatesViewSet (GenericViewSet): permission_classes = [StatePermission] queryset = State.objects.filter(active=1) serializer_class = StatesSerializer def list(self, request): queryset = self.filter_queryset(self.get_queryset()) date_updat...
return self.get_paginated_response(serializer.data)
Predict the next line for this snippet: <|code_start|> permission_classes = [StatePermission] queryset = State.objects.filter(active=1) serializer_class = StatesSerializer def list(self, request): queryset = self.filter_queryset(self.get_queryset()) date_update_string = self.request.que...
return Response(serializer.data)
Here is a snippet: <|code_start|> class ProductsViewSet (ModelViewSet): permission_classes = [ProductPermission] serializer_class = ProductsSerializer queryset = Product.objects.filter(active=1) def list(self, request, *args, **kwargs): latitude_update_string = self.request.query_params.get...
lat1 = float(latitude_update_string) - int(distance_filter) / 111.1
Based on the snippet: <|code_start|> serializer = ProductsListSerializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = ProductsListSerializer(queryset, many=True) return Response(serializer.data) def retrieve(self, request, pk): q...
return Response({"longitude": "Not have longitude"}, status=status.HTTP_400_BAD_REQUEST)
Here is a snippet: <|code_start|> class ProductsViewSet (ModelViewSet): permission_classes = [ProductPermission] serializer_class = ProductsSerializer queryset = Product.objects.filter(active=1) def list(self, request, *args, **kwargs): latitude_update_string = self.request.query_params.get...
state_id_filter = self.request.query_params.get('state', None)
Predict the next line after this snippet: <|code_start|> uuid_id = uuid.uuid4() up_file = upload_files[index] key_file = str(uuid_id) + ".jpeg" bucket.put_object(ACL='public-read', Key=key_file, Body=up_file, ContentType='image/jpeg') photo...
state_id_filter = self.request.query_params.get('state', None)
Here is a snippet: <|code_start|> class SavedSearch(models.Model): user = models.ForeignKey(User) keywords = models.CharField(max_length=80) longitude = models.FloatField(null=True) latitude = models.FloatField(null=True) category = models.ForeignKey(Category) race = models.ForeignKey(Race) <|co...
name = models.CharField(max_length=60)
Given snippet: <|code_start|> class TransactionsSerializer(serializers.ModelSerializer): class Meta: model = Transaction fields = ('id', 'product') class TransactionsListSerializer(serializers.ModelSerializer): <|code_end|> , continue by predicting the next line. Consider current file imports: ...
seller = serializers.StringRelatedField()
Predict the next line after this snippet: <|code_start|> if page is not None: serializer = TransactionsListSerializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = TransactionsListSerializer(queryset, many=True) retu...
else:
Predict the next line after this snippet: <|code_start|> serializer = TransactionsListSerializer(queryset, many=True) return Response(serializer.data) else: queryset = Transaction.objects.filter(Q(buyer=self.request.user) | Q(seller=self.request.user)) page = se...
def retrieve(self, request, pk):
Next line prediction: <|code_start|> serializer = TransactionsListSerializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = TransactionsListSerializer(queryset, many=True) return Response(serializer.data) else: ...
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Using the snippet: <|code_start|> class TransactionsViewSet(GenericViewSet): serializer_class = TransactionsSerializer permission_classes = (TransactionPermission,) queryset = Transaction.objects.filter() def list(self, request): if self.request.user.is_staff: queryset = self.ge...
page = self.paginate_queryset(queryset)
Given the code snippet: <|code_start|> serializer = TransactionsListSerializer(queryset, many=True) return Response(serializer.data) else: queryset = Transaction.objects.filter(Q(buyer=self.request.user) | Q(seller=self.request.user)) page = self.paginate_querys...
def retrieve(self, request, pk):
Based on the snippet: <|code_start|> class ImageSerializer(serializers.ModelSerializer): class Meta: model = Image <|code_end|> , predict the immediate next line with the help of imports: from rest_framework import serializers from images.models import Image and context (classes, functions, sometimes c...
fields = ('id', 'name', 'photo_url', 'photo_thumbnail_url')
Predict the next line for this snippet: <|code_start|> class Transaction(models.Model): product = models.ForeignKey(Product) seller = models.ForeignKey(User, related_name='user_seller') buyer = models.ForeignKey(User, related_name='user_buyer') date_transaction = models.DateTimeField(auto_now_add=True) ...
def __unicode__(self):
Predict the next line after this snippet: <|code_start|> class SaveSearchesViewSet (ModelViewSet): serializer_class = SaveSearchesSerializer permission_classes = (SaveSearchesPermission,) def get_queryset(self): return SavedSearch.objects.filter(user=self.request.user) def get_serializer_clas...
if self.action in ('list', 'retrieve'):
Given the code snippet: <|code_start|> class SaveSearchesViewSet (ModelViewSet): serializer_class = SaveSearchesSerializer permission_classes = (SaveSearchesPermission,) def get_queryset(self): return SavedSearch.objects.filter(user=self.request.user) def get_serializer_class(self): i...
assert self.paginator is not None
Continue the code snippet: <|code_start|> class SaveSearchesViewSet (ModelViewSet): serializer_class = SaveSearchesSerializer permission_classes = (SaveSearchesPermission,) def get_queryset(self): return SavedSearch.objects.filter(user=self.request.user) def get_serializer_class(self): ...
assert self.paginator is not None
Continue the code snippet: <|code_start|> class SaveSearchesViewSet (ModelViewSet): serializer_class = SaveSearchesSerializer permission_classes = (SaveSearchesPermission,) def get_queryset(self): return SavedSearch.objects.filter(user=self.request.user) def get_serializer_class(self): ...
return self.paginator.get_paginated_response(data)
Here is a snippet: <|code_start|> class ProductsSerializer(serializers.ModelSerializer): class Meta: model = Product fields = ('id', 'name', 'race', 'gender', 'sterile', 'description', 'state', 'price', 'category', <|code_end|> . Write the next line using the current file imports: from rest_fram...
'active', 'created_at')
Given snippet: <|code_start|> class ProductsSerializer(serializers.ModelSerializer): class Meta: model = Product fields = ('id', 'name', 'race', 'gender', 'sterile', 'description', 'state', 'price', 'category', 'active', 'created_at') class ProductsListSerializer(serializers.Mo...
state = serializers.StringRelatedField()
Given the following code snippet before the placeholder: <|code_start|> class ProductsSerializer(serializers.ModelSerializer): class Meta: model = Product fields = ('id', 'name', 'race', 'gender', 'sterile', 'description', 'state', 'price', 'category', 'active', 'created_at') c...
state = serializers.StringRelatedField()
Next line prediction: <|code_start|> class UserSerializer(serializers.Serializer): id = serializers.ReadOnlyField(source='user.id') first_name = serializers.CharField(allow_null=True, source='user.first_name', default='') last_name = serializers.CharField(allow_null=True, source='user.last_name', default='...
return user_ext
Given snippet: <|code_start|> class RacesViewSet(GenericViewSet): permission_classes = [RacesPermission] queryset = Race.objects.filter(active=1) serializer_class = RacesSerializer def list(self, request): queryset = self.filter_queryset(self.get_queryset()) date_update_string = sel...
)
Predict the next line for this snippet: <|code_start|> class RacesViewSet(GenericViewSet): permission_classes = [RacesPermission] queryset = Race.objects.filter(active=1) serializer_class = RacesSerializer def list(self, request): queryset = self.filter_queryset(self.get_queryset()) ...
return Response(
Using the snippet: <|code_start|> class RacesViewSet(GenericViewSet): permission_classes = [RacesPermission] queryset = Race.objects.filter(active=1) serializer_class = RacesSerializer def list(self, request): queryset = self.filter_queryset(self.get_queryset()) date_update_string =...
try:
Given the following code snippet before the placeholder: <|code_start|> class CategoryViewSet(GenericViewSet): permission_classes = [CategoryPermission] queryset = Category.objects.filter(active=1) serializer_class = CategorySerializer def list(self, request): queryset = self.filter_queryset...
)
Predict the next line for this snippet: <|code_start|> permission_classes = [CategoryPermission] queryset = Category.objects.filter(active=1) serializer_class = CategorySerializer def list(self, request): queryset = self.filter_queryset(self.get_queryset()) date_update_string = self.re...
serializer = self.get_serializer(queryset, many=True)
Given the following code snippet before the placeholder: <|code_start|> class CategoryViewSet(GenericViewSet): permission_classes = [CategoryPermission] queryset = Category.objects.filter(active=1) serializer_class = CategorySerializer def list(self, request): queryset = self.filter_queryset...
"detail": "Error parse 'date-update' parameter needs user ISO-8601"
Using the snippet: <|code_start|> class Test_SimpleConfig(unittest.TestCase): def setUp(self): super(Test_SimpleConfig, self).setUp() # make sure "read_user_config" and "user_dir" return a temporary directory. <|code_end|> , determine the next line of code. You have imports: import ast import sy...
self.electrum_dir = tempfile.mkdtemp()
Here is a snippet: <|code_start|> self.assertEqual(expected_label, label) self.assertEqual(expected_message, message) self.assertEqual(expected_request_url, request_url) def test_parse_URI_address(self): self._do_test_parse_URI('myriadcoin:MRBurdDdLMqWLCy4Fp1wMDiKT1MK7DJFkS', 'MRBurd...
self._do_test_parse_URI('myriadcoin:?r=http://domain.tld/page?h%3D2a8628fc2fbe', '', '', '', '', 'http://domain.tld/page?h=2a8628fc2fbe')
Given the following code snippet before the placeholder: <|code_start|> class TestUtil(unittest.TestCase): def test_format_satoshis(self): result = format_satoshis(1234) expected = "0.00001234" self.assertEqual(expected, result) def test_format_satoshis_diff_positive(self): res...
self.assertEqual(expected_request_url, request_url)
Based on the snippet: <|code_start|> class Test_bitcoin(unittest.TestCase): def test_crypto(self): for message in ["Chancellor on brink of second bailout for banks", chr(255)*512]: self._do_test_crypto(message) def _do_test_crypto(self, message): G = generator_secp256k1 _r...
assert dec2 == message
Based on the snippet: <|code_start|> try: except ImportError: sys.exit("Error: python-ecdsa does not seem to be installed. Try 'sudo pip install ecdsa'") class Test_bitcoin(unittest.TestCase): def test_crypto(self): for message in ["Chancellor on brink of second bailout for banks", chr(255)*512]: ...
Pub = pvk*G
Predict the next line for this snippet: <|code_start|> G = generator_secp256k1 _r = G.order() pvk = ecdsa.util.randrange( pow(2,256) ) %_r Pub = pvk*G pubkey_c = point_to_ser(Pub,True) #pubkey_u = point_to_ser(Pub,False) addr_c = public_key_to_bc_address(pubkey_c...
assert xpub == "xpub6H1LXWLaKsWFhvm6RVpEL9P4KfRZSW7abD2ttkWP3SSQvnyA8FSVqNTEcYFgJS2UaFcxupHiYkro49S8yGasTvXEYBVPamhGW6cFJodrTHy"
Here is a snippet: <|code_start|> def _do_test_crypto(self, message): G = generator_secp256k1 _r = G.order() pvk = ecdsa.util.randrange( pow(2,256) ) %_r Pub = pvk*G pubkey_c = point_to_ser(Pub,True) #pubkey_u = point_to_ser(Pub,False) addr_c = public_key_to_...
xpub, xprv = self._do_test_bip32("000102030405060708090a0b0c0d0e0f", "m/0'/1/2'/2/1000000000", testnet=False)
Given the following code snippet before the placeholder: <|code_start|> try: except ImportError: sys.exit("Error: python-ecdsa does not seem to be installed. Try 'sudo pip install ecdsa'") class Test_bitcoin(unittest.TestCase): def test_crypto(self): for message in ["Chancellor on brink of second ba...
_r = G.order()