Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the code snippet: <|code_start|> limit=limit, sort_keys=sort_keys, sort_dirs=sort_dirs, fields=fields, filters=filters ) return self._list(url % query_string, response_key='tasks') def get(self, id): self._ensure_not_empty(id...
'reset': reset
Predict the next line after this snippet: <|code_start|> def send_ladder_emails(): # search current season ladders that have result in last 24 hours season = Season.objects.latest('start_date') print(season) ladders = season.ladder_set.all() # iterate through subscriptions and send email <|code_e...
for ladder in ladders:
Next line prediction: <|code_start|> def send_ladder_emails(): # search current season ladders that have result in last 24 hours season = Season.objects.latest('start_date') print(season) ladders = season.ladder_set.all() # iterate through subscriptions and send email for ladder in ladders: ...
for subscription in subscriptions:
Here is a snippet: <|code_start|> class AddResultForm(forms.ModelForm): result = forms.IntegerField(min_value=0, max_value=8, label='Losing Result') # filter the player fields by ladder on init def __init__(self, ladder, *args, **kwargs): super(AddResultForm, self).__init__(*args, **kwargs) # pop...
exclude = ['date_added', 'ladder']
Predict the next line after this snippet: <|code_start|> class AddResultForm(forms.ModelForm): result = forms.IntegerField(min_value=0, max_value=8, label='Losing Result') # filter the player fields by ladder on init def __init__(self, ladder, *args, **kwargs): super(AddResultForm, self).__init__(...
class Meta(object):
Predict the next line for this snippet: <|code_start|> router = routers.DefaultRouter() router.register('seasons', views.SeasonViewSet) router.register('players', views.PlayerViewSet) router.register('ladders', views.LadderViewSet) router.register('leagues', views.LeagueViewSet) router.register('results', views.ResultV...
urlpatterns = [
Given the following code snippet before the placeholder: <|code_start|> # python manage.py shell < ladder/management/shell/import_users.py # format first_name, last_name, email players = [ ["John", "Doe", "jo@hn.doe"], ] group_object = Group.objects.get(name='player') for player in players: first_name = playe...
is_staff=False,
Given the following code snippet before the placeholder: <|code_start|> urlpatterns = [ re_path(r'^$', views.index, name='index'), re_path(r'^list/$', views.list_rounds, name='list'), re_path(r'^current/$', views.current_season_redirect, name='current'), # ex: /2013/round/1/ re_path(r'^(?P<year>\d+...
]
Given the code snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] <|code_end|> , generate the next line using the imports in this file: from cogent.util.unit_test import main, TestCase from cogent impor...
__license__ = "GPL"
Here is a snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] __license__ = "GPL" __version__ = "1.1.4" __maintainer__ = "Jesse Zaneveld" __email__ = "zaneveld@gmail.com" <|code_end|> . Write the next lin...
__status__ = "Development"
Given snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] __license__ = "GPL" __version__ = "1.1.4" <|code_end|> , continue by predicting the next line. Consider current file imports: from cogent.util.un...
__maintainer__ = "Jesse Zaneveld"
Based on the snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] __license__ = "GPL" <|code_end|> , predict the immediate next line with the help of imports: from cogent.util.unit_test import main, TestC...
__version__ = "1.1.4"
Given the code snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] __license__ = "GPL" __version__ = "1.1.4" <|code_end|> , generate the next line using the imports in this file: from cogent.util.unit_te...
__maintainer__ = "Jesse Zaneveld"
Continue the code snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] <|code_end|> . Use current file imports: from cogent.util.unit_test import main, TestCase from cogent import LoadTree from cogent.par...
__license__ = "GPL"
Continue the code snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] __license__ = "GPL" __version__ = "1.1.4" __maintainer__ = "Jesse Zaneveld" <|code_end|> . Use current file imports: from cogent.util...
__email__ = "zaneveld@gmail.com"
Given snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] __license__ = "GPL" __version__ = "1.1.4" <|code_end|> , continue by predicting the next line. Consider current file imports: from cogent.util.un...
__maintainer__ = "Jesse Zaneveld"
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] __license__ = "GPL" __version__ = "1.1.4" __maintainer__ = "Jesse Zaneveld" <|code_end|> , predict the n...
__email__ = "zaneveld@gmail.com"
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Jesse Zaneveld"] <|code_end|> with the help of current file imports: from cogent.util.unit_test import main, TestCase from cogent import...
__license__ = "GPL"
Given snippet: <|code_start|> script_info['required_options'] = [\ make_option('-i','--input_dir',type="existing_dirpath",help='directory containing one or more test datasets'),\ make_option('-t','--ref_tree',type="existing_filepath",help='reference tree that was used with make_test_datasets'),\ ] # Choices for choice...
make_option('-w','--weighting_method',type='choice',\
Given the code snippet: <|code_start|>weighting_choices = ['linear','exponential','equal'] script_info['optional_options'] = [\ make_option('-o','--output_dir',type="new_dirpath",help='the output directory [default: <input_dir>]'),\ make_option('-j','--parallel_method',type='choice',\ help='Method for para...
]
Given the code snippet: <|code_start|> predict_traits_accuracy_out_fp=join(output_dir,'--'.join(['predict_traits',predict_traits_method,\ opts.weighting_method,'accuracy_metrics',test_id])) if opts.check_for_null_files and exists(predict_traits_out_fp) and file_contains_nulls(predict_t...
predict_traits_cmd = predict_traits_cmd + confidence_param
Here is a snippet: <|code_start|>#!/usr/bin/env python # File created on 1 Feb 2012 from __future__ import division __author__ = "Morgan Langille" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Morgan Langille","Jesse Zaneveld"] __license__ = "GPL" __version__ = "1.1.4" __maintainer__ = "Mo...
script_info['script_description'] = "\
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python # File created on 15 Jul 2011 from __future__ import division __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2015, The PICRUSt Project" __credits__ = ["Jesse Zaneveld", "Morgan Langille"] __license__ = "GPL" __versio...
def reformat_tree_and_trait_table(tree,trait_table_lines,trait_to_tree_mapping,\
Next line prediction: <|code_start|>__license__ = "GPL" __url__ = "http://picrust.github.com" __version__ = "1.1.4" __maintainer__ = "Morgan Langille" __email__ = "morgan.g.i.langille@gmail.com" PROJECT_ROOT = os.path.dirname(os.path.abspath(picrust.__file__)) DATA_DIR = os.path.join(PROJECT_ROOT, 'data') BASE_URL...
('ko', '18may2012'): 'ko_18may2012_precalculated.tab.gz',
Predict the next line after this snippet: <|code_start|> """ actual,ci= ace_for_picrust(self.in_tree2_fp,self.in_trait3_fp, method="pic") expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','1.2727','3'],['11','0.6667','3'],['10','5','2']]) self.assertEqual(actual.t...
D 5 2"""
Based on the snippet: <|code_start|>script_info = {} script_info['brief_description'] = "Starts multiple jobs in parallel on multicore or multiprocessor systems." script_info['script_description'] = "This script is designed to start multiple jobs in parallel on systems with no queueing system, for example a multiple pr...
raise OSError, "Error creating jobs directory in working dir: %s" % output_dir +\
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python from __future__ import division __author__ = "Morgan Langille" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Morgan Langille"] __license__ = "GPL" <|code_end|> with the help of current file imports: from collecti...
__version__ = "1.1.4"
Continue the code snippet: <|code_start|>#!/usr/bin/env python # File created on 22 Feb 2012 from __future__ import division __author__ = "Greg Caporaso" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Greg Caporaso","Jesse Zaneveld","Morgan Langille"] __license__ = "GPL" __version__ = "1.1....
script_info = {}
Based on the snippet: <|code_start|>#!/usr/bin/env python # File created on 22 Feb 2012 from __future__ import division __author__ = "Greg Caporaso" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Greg Caporaso"] __license__ = "GPL" __version__ = "1.1.4" __maintainer__ = "Greg Caporaso" __em...
class ParseTests(TestCase):
Predict the next line after this snippet: <|code_start|>otu_table_lines =[\ '# QIIME v1.3.0 OTU table',\ '#OTU ID\tS1\tS2\tS3\tS4\tS5\tS6\tS7\tS8\tS9\tConsensus Lineage',\ '39\t0\t0\t1\t0\t0\t5\t3\t0\t1\tArchaea;Euryarchaeota;Halobacteria;Halobacteriales;Halobacteriaceae',\ '238\t0\t1\t5\t6\t0\t1\t5\t2\t3\tArchaea;Eur...
if __name__ == "__main__":
Based on the snippet: <|code_start|>#!/usr/bin/env python # File created on 22 Feb 2012 from __future__ import division __author__ = "Greg Caporaso" __copyright__ = "Copyright 2015, The PICRUSt Project" <|code_end|> , predict the immediate next line with the help of imports: from numpy import abs,compress, dot, array...
__credits__ = ["Greg Caporaso", "Jesse Zaneveld", "Morgan Langille"]
Given snippet: <|code_start|>#!/usr/bin/env python # File created on 27 Feb 2012 from __future__ import division __author__ = "Morgan Langille" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Morgan Langille"] __license__ = "GPL" <|code_end|> , continue by predicting the next line. Consider ...
__version__ = "1.1.4"
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # File created on 09 Jan 2013 from __future__ import division __author__ = "Daniel McDonald" __copyright__ = "Copyright 2011-2013, The PICRUSt Project" __credits__ = ["Daniel McDonald", "Morgan Langille", "Jesse Zaneveld"] __license__ = "GPL...
make_option('-o','--output_fp',type='new_filepath', help='the resulting table'),
Given the code snippet: <|code_start|> action='store_true', help='suppress script usage tests [default: %default]', default=False), make_option('--unittest_glob', help='wildcard pattern to match tests to run [default: run all]', default=None), make_optio...
if not opts.suppress_unit_tests:
Here is a snippet: <|code_start|>script_info = {} script_info['brief_description'] = "" script_info['script_description'] = "" script_info['script_usage'] = [("","","")] script_info['output_description']= "" script_info['required_options'] = [] script_info['optional_options'] = [ make_option('--suppress_unit_tests', ...
option_parser.error("You're suppressing both test types. Nothing to run.")
Given snippet: <|code_start|>#!/usr/bin/env python # File created on 22 Feb 2012 from __future__ import division __author__ = "Jesse Zaneveld" __copyright__ = "Copyright 2015, The PICRUST project" __credits__ = ["Jesse Zaneveld"] __license__ = "GPL" __version__ = "1.1.4" __maintainer__ = "Jesse Zaneveld" __email__ = "...
search_only_pathway_level=None):
Continue the code snippet: <|code_start|> return hasattr(t, '__thunk__') def _make_thunk(t): setattr(t, '__thunk__', True) class _ThunkBuilder: """This is used to create a thunk from a linq-style method. """ def __init__(self, func): self.func = func self.__name__ = func.__name_...
if _is_thunk(thunk):
Using the snippet: <|code_start|> class Id(Base): def __init__(self, id_replacements, markdown_preview, lowercase): super().__init__() self.id_replacements = id_replacements self.markdown_preview = markdown_preview self.lowercase = lowercase def heading_to_id(self, h...
_id = "".join(chr(ord(x) + ("A" <= x <= "Z") * 32) for x in heading)
Here is a snippet: <|code_start|> files = sublime.find_resources("MarkdownTOC.sublime-settings") files.remove(DEFAULT) settings = self.decode_value(DEFAULT) for f in files: user_settings = self.decode_value(f) if user_settings != None: Util....
pp.pprint(arg)
Using the snippet: <|code_start|> for field in model_fields: for method_name in methods_that_should_raise: with self.assertRaises(NotImplementedError): getattr(field, method_name)() def test_get_pk_value_on_save_returns_true_if_field_has_default(self): ...
def test_field_check_returns_error_when_name_ends_underscore(self):
Given snippet: <|code_start|> class DjangoCassandraModelSerializer(serializers.ModelSerializer): serializer_field_mapping = { columns.Text: serializers.CharField, columns.UUID: serializers.CharField, columns.Integer: serializers.IntegerField, columns.TinyInt: serializers.IntegerFi...
def get_field_kwargs(self, field_name, model_field):
Here is a snippet: <|code_start|> class Command(FlushCommand): def handle_noargs(self, **options): engine = get_engine_from_db_alias(options["database"]) if engine == "django_cassandra_engine": options.update({"interactive": False, "inhibit_post_migrate": True}) return super(C...
def emit_post_syncdb(verbosity, interactive, database):
Predict the next line for this snippet: <|code_start|> connection.register_connection( self.alias, default=self.default, session=session ) else: connection.register_connection( self.alias, hosts=self.h...
self.session.set_keyspace(self.keyspace)
Based on the snippet: <|code_start|> self.alias = alias self.hosts = options.get("HOST").split(",") self.keyspace = options.get("NAME") self.user = options.get("USER") self.password = options.get("PASSWORD") self.options = options.get("OPTIONS", {}) self.cluster_op...
if self.default:
Predict the next line after this snippet: <|code_start|> self.alias = alias self.hosts = options.get("HOST").split(",") self.keyspace = options.get("NAME") self.user = options.get("USER") self.password = options.get("PASSWORD") self.options = options.get("OPTIONS", {}) ...
if self.default:
Here is a snippet: <|code_start|> self.alias, default=self.default, session=session ) else: connection.register_connection( self.alias, hosts=self.hosts, default=self.default, c...
return self.session.execute(qs, *args, **kwargs)
Here is a snippet: <|code_start|> self.close() class FakeConnection(object): def commit(self): pass def rollback(self): pass def cursor(self): return Cursor(None) def close(self): pass class CassandraConnection(object): def __init__(self, alias, **option...
"consistency": self.cluster_options.pop("consistency", None),
Next line prediction: <|code_start|> class Cursor(object): def __init__(self, connection): self.connection = connection def execute(self, *args, **kwargs): return self.connection.execute(*args, **kwargs) def close(self): pass def fetchmany(self, _): return [] <|code...
def __enter__(self):
Using the snippet: <|code_start|> router = routers.DefaultRouter() router.register(r"thing-modelviewset", ThingModelViewSet) urlpatterns = [ re_path( r"^thing-viewset/$", ThingMultiplePKViewSet.as_view({"get": "list"}), name="thing_viewset_api", ), re_path( r"^thing-listcre...
),
Given the code snippet: <|code_start|> router = routers.DefaultRouter() router.register(r"thing-modelviewset", ThingModelViewSet) urlpatterns = [ re_path( r"^thing-viewset/$", ThingMultiplePKViewSet.as_view({"get": "list"}), name="thing_viewset_api", ), re_path( r"^thing-li...
name="thing_listview_api",
Given snippet: <|code_start|> router = routers.DefaultRouter() router.register(r"thing-modelviewset", ThingModelViewSet) urlpatterns = [ re_path( r"^thing-viewset/$", ThingMultiplePKViewSet.as_view({"get": "list"}), name="thing_viewset_api", ), <|code_end|> , continue by predicting the...
re_path(
Here is a snippet: <|code_start|> self.assertDictEqual(response.json(), expected_json) model = CassandraThingMultiplePK.objects.get(id=self.data["id"]) self.assertEqual(str(model.id), self.data["id"]) self.assertEqual(str(model.another_id), self.data["another_id"]) self.assertEq...
self.assertEqual(model.last_name, "Simpson")
Predict the next line for this snippet: <|code_start|> class AbstractBaseSession(Model): __abstract__ = True session_key = columns.Text(primary_key=True, max_length=40) expire_date = columns.DateTime() session_data = columns.Text() def __str__(self): return self.session_key @classme...
session_store_class = self.get_session_store_class()
Here is a snippet: <|code_start|> class Command(MakeMigrationsCommand): @staticmethod def _change_cassandra_engine_name(name): for alias, _ in get_cassandra_connections(): connections[alias].settings_dict["ENGINE"] = name <|code_end|> . Write the next line using the current file imports: ...
def handle(self, *args, **options):
Next line prediction: <|code_start|> class TestModelForm(CassandraTestCase): def setUp(self): self.some_uuid = uuid.uuid4() self.family_member = CassandraFamilyMember.objects.create( id=self.some_uuid, first_name="Homer", last_name="Simpson", is_rea...
favourite_number=666,
Given the code snippet: <|code_start|> class Command(MigrateCommand): def handle(self, *args, **options): engine = get_engine_from_db_alias(options["database"]) # Call regular migrate if engine is different from ours if engine != "django_cassandra_engine": <|code_end|> , generate the next...
return super(Command, self).handle(*args, **options)
Given the following code snippet before the placeholder: <|code_start|> def test_cluster_property(self): self.assertEqual( self.connection.cluster, cql_connection._connections[self.connection.alias].cluster, ) def test_connection_options(self): connection_option...
"default",
Predict the next line for this snippet: <|code_start|> connection = CassandraConnection("default", **settings) connection_mock.get_connection.side_effect = CQLEngineException() connection.register() connection_mock.register_connection.assert_called_once_with( "default", ...
@patch("django_cassandra_engine.connection.CassandraConnection.register")
Here is a snippet: <|code_start|> self.connection = self.cassandra_connection.connection self.cassandra_connection.connect() def test_cursor(self): self.assertIsInstance(self.connection.cursor(), Cursor) self.assertEqual(self.connection.cursor().connection, self.connection) def...
def test_connection_options(self):
Given the following code snippet before the placeholder: <|code_start|> class ModelsTestCase(TestCase): def test_check_if_test_model_synced(self): now = datetime(2010, 1, 1, 1, 1) TestModel.objects.create(id=1, created_at=now) self.assertEqual(TestModel.objects.count(), 1) obj ...
self.assertEqual(obj.created_at, now)
Here is a snippet: <|code_start|> self.session.modified = False self.session.accessed = False self.assertIn("some key", self.session) self.assertTrue(self.session.accessed) self.assertFalse(self.session.modified) def test_values(self): self.assertEqual(list(self.sessi...
self.assertEqual(list(i), [1])
Given the following code snippet before the placeholder: <|code_start|> def test_store(self): self.session["cat"] = "dog" self.assertTrue(self.session.modified) self.assertEqual(self.session.pop("cat"), "dog") def test_pop(self): self.session["some key"] = "exists" # Need...
self.session.update({"update key": 1})
Continue the code snippet: <|code_start|> self.assertEqual(self.session.get("some key"), None) def test_pop_default(self): self.assertEqual( self.session.pop("some key", "does not exist"), "does not exist" ) self.assertTrue(self.session.accessed) self.assertFalse(...
self.assertEqual(list(self.session.values()), [])
Predict the next line for this snippet: <|code_start|> class ModelsTestCase(TestCase): def test_check_if_model_synced(self): now = datetime(2010, 1, 1, 1, 1) ExampleModel.objects.create(id=1, created_at=now) self.assertEqual(ExampleModel.objects.count(), 1) obj = ExampleModel.obje...
self.assertEqual(ExampleModel2.objects.count(), 0)
Based on the snippet: <|code_start|> class TestCase(DjangoTestCase): databases = list(get_cassandra_db_aliases()) def _should_reload_connections(self): <|code_end|> , predict the immediate next line with the help of imports: from django.core.management import call_command from django.test import TestCase as...
return False
Given the following code snippet before the placeholder: <|code_start|> class CassandraDatabaseIntrospection(BaseDatabaseIntrospection): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._cql_models = {} self._models_discovered = False <|code_end|> , predict the...
def _discover_models(self):
Given the code snippet: <|code_start|> class CassandraDatabaseIntrospection(BaseDatabaseIntrospection): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._cql_models = {} self._models_discovered = False <|code_end|> , generate the next line using the imports in ...
def _discover_models(self):
Given the code snippet: <|code_start|> class Command(SyncCommand): def handle_noargs(self, **options): engine = get_engine_from_db_alias(options["database"]) # Call regular syncdb if engine is different from ours if engine != "django_cassandra_engine": return super(Command, sel...
else:
Using the snippet: <|code_start|> @freeze_time("14-06-15 15:44:25") class TestListCreateAPIView(CassandraTestCase): def test_get_when_no_records_exist(self): response = self.client.get(reverse("thing_listcreate_api")) self.assertEqual(response.status_code, client.OK) self.assertEqual(respons...
}
Based on the snippet: <|code_start|> class ThingMultiplePKViewSet(ViewSet): def list(self, request): queryset = CassandraThingMultiplePK.objects.all() serializer = ThingMultiplePKSerializer(queryset, many=True) return Response(serializer.data) <|code_end|> , predict the immediate next li...
class ThingMultiplePKListCreateAPIView(ListCreateAPIView):
Based on the snippet: <|code_start|> class ThingMultiplePKViewSet(ViewSet): def list(self, request): queryset = CassandraThingMultiplePK.objects.all() serializer = ThingMultiplePKSerializer(queryset, many=True) return Response(serializer.data) class ThingMultiplePKListCreateAPIView(ListC...
permission_classes = ()
Predict the next line after this snippet: <|code_start|> class ThingMultiplePKViewSet(ViewSet): def list(self, request): queryset = CassandraThingMultiplePK.objects.all() serializer = ThingMultiplePKSerializer(queryset, many=True) return Response(serializer.data) class ThingMultiplePKLis...
permission_classes = ()
Next line prediction: <|code_start|> class ThingMultiplePKViewSet(ViewSet): def list(self, request): queryset = CassandraThingMultiplePK.objects.all() serializer = ThingMultiplePKSerializer(queryset, many=True) return Response(serializer.data) class ThingMultiplePKListCreateAPIView(ListC...
permission_classes = ()
Given snippet: <|code_start|> class TextSendInline(admin.TabularInline): editable = False model = TextSend @admin.register(ShowerThought) class ShowerThoughtAdmin(admin.ModelAdmin): list_display = ('date', 'thought_text', 'post_id', 'active') @admin.register(Subscriber) <|code_end|> , continue by predi...
class SubscriberAdmin(admin.ModelAdmin):
Based on the snippet: <|code_start|> class TextSendInline(admin.TabularInline): editable = False model = TextSend @admin.register(ShowerThought) class ShowerThoughtAdmin(admin.ModelAdmin): list_display = ('date', 'thought_text', 'post_id', 'active') @admin.register(Subscriber) class SubscriberAdmin(adm...
]
Given the following code snippet before the placeholder: <|code_start|> class TextSendInline(admin.TabularInline): editable = False model = TextSend @admin.register(ShowerThought) class ShowerThoughtAdmin(admin.ModelAdmin): list_display = ('date', 'thought_text', 'post_id', 'active') @admin.register(Su...
]
Given the following code snippet before the placeholder: <|code_start|> class Texter(object): def __init__(self): self.client = TwilioRestClient(settings.TWILIO_SID, settings.TWILIO_TOKEN) def send_text(self, subscriber, message, post_id): if TextSend.objects.filter(subscriber=subscriber, po...
try:
Here is a snippet: <|code_start|> class Texter(object): def __init__(self): self.client = TwilioRestClient(settings.TWILIO_SID, settings.TWILIO_TOKEN) def send_text(self, subscriber, message, post_id): if TextSend.objects.filter(subscriber=subscriber, post_id=post_id).exists(): l...
except TwilioRestException as e:
Using the snippet: <|code_start|> self.client = TwilioRestClient(settings.TWILIO_SID, settings.TWILIO_TOKEN) def send_text(self, subscriber, message, post_id): if TextSend.objects.filter(subscriber=subscriber, post_id=post_id).exists(): logging.warning('Attempted to send a duplicate text...
)
Predict the next line for this snippet: <|code_start|> subscriber.active = False subscriber.save() logging.error('Exception sending number to: ' + subscriber.sms_number + ' - ' + str(e)) return 'I couldn\'t send a text to that number! (' + str(e.msg) + ')' ...
logging.error('Duplicate initial thought. Shouldn\'t happen - odd.')
Predict the next line after this snippet: <|code_start|> def subscribe(sms_number): if not sms_number: return 'You sent nothing yo.' sms_number = filter(str.isdigit, str(sms_number)) subscriber, created = Subscriber.objects.get_or_create(sms_number=sms_number) texter = Texter() if not creat...
if subscriber.expired:
Here is a snippet: <|code_start|> def subscribe(sms_number): if not sms_number: return 'You sent nothing yo.' sms_number = filter(str.isdigit, str(sms_number)) subscriber, created = Subscriber.objects.get_or_create(sms_number=sms_number) texter = Texter() if not created: if subscrib...
subscriber.save()
Given the following code snippet before the placeholder: <|code_start|> def subscribe(sms_number): if not sms_number: return 'You sent nothing yo.' sms_number = filter(str.isdigit, str(sms_number)) subscriber, created = Subscriber.objects.get_or_create(sms_number=sms_number) texter = Texter() ...
subscriber.renew()
Given the following code snippet before the placeholder: <|code_start|> class TestFetch(unittest.TestCase): def test_fetch(self): thought = util.showerthoughts.get_todays_thought() print thought print ShowerThought.objects.all() assert ShowerThought.objects.count() == 1 def tes...
submission = util.showerthoughts.get_thought()
Using the snippet: <|code_start|> if not hasattr(w, 'testcounter'): w.testcounter = 0 w.testcounter += 1 if w.testcounter % 2: raise Exception("failed task!") if w.testcounter > 10: #TODO: Look up condition variables in pytho...
w.submit_work(1, g)
Predict the next line after this snippet: <|code_start|> if __name__ == "__main__": test_log() def test_shutdown(w): async def f(w): taskloaf.worker.shutdown(w) w.start(f) def test_run_work(): <|code_end|> using the current file's imports: import os import pytest import asyncio import taskloaf.w...
val = [0, 1]
Predict the next line for this snippet: <|code_start|> def test_await_work(): val = [0] async def f(w): def h(w, x): val[0] = x S = 'dang' await w.wait_for_work(h, S) assert(val[0] == S) run(f) def test_run_output(): async def f(w): return 1 asser...
w.submit_work(0, success)
Next line prediction: <|code_start|> def random_test_matrix(nrows, nnz): rows = np.random.randint(0, nrows, nnz).astype(np.int) cols = np.random.randint(0, nrows, nnz).astype(np.int) data = np.random.rand(nnz) A = scipy.sparse.coo_matrix( (data, (rows, cols)), shape=(nrows, nrows) ).tocsr...
for i in range(n_repeats):
Next line prediction: <|code_start|> mat = random_test_matrix(nrows, nnz) vec = np.random.rand(nrows) - 0.5 t = tsk.Timer() for i in range(n_repeats): correct = mat.dot(vec) t.report("simple dot") gang = await tsk.ctx().wait_for_workers(cfg.n_workers) ...
tsk.zmq_run(cfg=cfg, f=f)
Given the code snippet: <|code_start|> test_cfg = dict() def queue_test_helper(q): q.put(123) def test_queue(): <|code_end|> , generate the next line using the imports in this file: import cloudpickle from multiprocessing import Process, Queue from mpi4py import MPI from taskloaf.local import LocalComm from task...
q = Queue()
Continue the code snippet: <|code_start|> test_cfg = dict() def queue_test_helper(q): q.put(123) def test_queue(): q = Queue() p = Process(target = queue_test_helper, args = (q, )) p.start() <|code_end|> . Use current file imports: import cloudpickle from multiprocessing import Process, Queue from mp...
assert(q.get() == 123)
Given snippet: <|code_start|> def sum_shmem(filepath): with Shmem(filepath) as sm: return np.sum(np.frombuffer(sm.mem)) def test_shmem(): A = np.random.rand(100) with alloc_shmem(A.nbytes, 'test') as filepath: with Shmem(filepath) as sm: <|code_end|> , continue by predicting the next line....
sm.mem[:] = A.data.cast('B')
Using the snippet: <|code_start|> def sum_shmem(filepath): with Shmem(filepath) as sm: return np.sum(np.frombuffer(sm.mem)) def test_shmem(): A = np.random.rand(100) with alloc_shmem(A.nbytes, 'test') as filepath: with Shmem(filepath) as sm: sm.mem[:] = A.data.cast('B') ...
def test_shmem_edit():
Continue the code snippet: <|code_start|> def pytest_runtest_protocol(item, nextitem): n_procs = getattr(item.function, 'n_procs', 1) rank = MPI.COMM_WORLD.Get_rank() size = MPI.COMM_WORLD.Get_size() if n_procs > size: print( 'skipping ' + str(item.name) + ' because it...
res = _pytest.runner.pytest_runtest_protocol(item, nextitem)
Predict the next line after this snippet: <|code_start|># Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
cls.__next_petition_id += 1
Continue the code snippet: <|code_start|> def __check_docker_run_args(self, docker_run_args, display_id, docker_display_id): self.assertEqual(docker_run_args['environment'], [f'DISPLAY=:{docker_display_id}']) src_path = f'/tmp/.X11-unix/X{display_id}' des...
suite = unittest.TestLoader().loadTestsFromTestCase(TestXvncCapability)
Given snippet: <|code_start|># Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
def enable_capability(self, docker_node):
Given the following code snippet before the placeholder: <|code_start|># # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific...
},
Predict the next line after this snippet: <|code_start|> def name(self): return "Bluetooth" def get_docker_run_args(self, docker_node): return { 'environment': { 'BLE_ADAPT': self.ble_adapt, }, 'volumes': [ '/var/run/dbus:/var/r...
ret = utils.host_run(self.logger, command)
Predict the next line after this snippet: <|code_start|># limitations under the License. class ThreadCapability(BaseCapability): def __init__(self, node_id, petition_id, daemons=['wpantund', 'otbr-agent'], rcp=False): self.thread_endpoint = ThreadSim...
'{}:/dev/ttyUSB0'.format(self.thread_endpoint.pipe_path_for_user)