Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Predict the next line after this snippet: <|code_start|>
@pytest.mark.django_db
class TestRegistrationBulkUploadJob:
@pytest.fixture()
def payload_hash(self):
return str(uuid.uuid4()).replace('-', '')
@pytest.fixture()
<|code_end|>
using the current file's imports:
import uuid
import pytest
f... | def initiator(self): |
Given the following code snippet before the placeholder: <|code_start|> save=True,
category='spam',
date=date - timedelta(seconds=4)
)
self.comment_3.report_abuse(
user=self.user_2,
save=True,
category='spam',
date=date -... | nt.assert_equal(len(res), 6) |
Given the following code snippet before the placeholder: <|code_start|> def setUp(self):
super(TestUserCommentListView, self).setUp()
self.project = ProjectFactory(is_public=True)
self.user_1 = AuthUserFactory()
self.user_2 = AuthUserFactory()
self.project.add_contributor(self... | self.view = setup_view(self.view, self.request, user_guid=self.user_1._id) |
Given snippet: <|code_start|> date=date - timedelta(seconds=4)
)
self.comment_3.report_abuse(
user=self.user_2,
save=True,
category='spam',
date=date - timedelta(seconds=3)
)
self.comment_4.report_abuse(
user=self.use... | should_be = [ |
Given snippet: <|code_start|> def test_exceeds_size_limit(self, app, user, url_allow_bulk_upload, file_content_exceeds_limit):
resp = app.request(
url_allow_bulk_upload,
method='PUT',
expect_errors=True,
body=file_content_exceeds_limit,
headers=_add... | resp = app.request( |
Based on the snippet: <|code_start|> def test_unauthorized_user(self, app, unauthorized_user, url_not_allow_bulk_upload, url_allow_bulk_upload):
resp = app.put(url_allow_bulk_upload, auth=unauthorized_user.auth, expect_errors=True)
assert resp.status_code == 403
resp = app.put(url_not_allow_b... | headers=_add_auth(user.auth, None), |
Continue the code snippet: <|code_start|> provider = RegistrationProviderFactory()
provider.allow_bulk_uploads = True
provider.add_to_group(user, 'admin')
provider.save()
return provider
@pytest.fixture()
def provider_not_allow_bulk(self, user):
provider = Registr... | def test_unauthorized_user(self, app, unauthorized_user, url_not_allow_bulk_upload, url_allow_bulk_upload): |
Predict the next line for this snippet: <|code_start|>
class PreprintMixin(PermissionRequiredMixin):
def get_object(self):
preprint = Preprint.objects.get(guids___id=self.kwargs['guid'])
# Django template does not like attributes with underscores for some reason
preprint.guid = prepr... | def get_success_url(self): |
Continue the code snippet: <|code_start|>
class PreprintMixin(PermissionRequiredMixin):
def get_object(self):
preprint = Preprint.objects.get(guids___id=self.kwargs['guid'])
# Django template does not like attributes with underscores for some reason
preprint.guid = preprint._id
<|cod... | return preprint |
Given the code snippet: <|code_start|>
class PreprintMixin(PermissionRequiredMixin):
def get_object(self):
preprint = Preprint.objects.get(guids___id=self.kwargs['guid'])
# Django template does not like attributes with underscores for some reason
preprint.guid = preprint._id
... | return reverse_lazy('preprints:preprint', kwargs={'guid': self.kwargs['guid']}) |
Using the snippet: <|code_start|>
class PreprintMixin(PermissionRequiredMixin):
def get_object(self):
preprint = Preprint.objects.get(guids___id=self.kwargs['guid'])
# Django template does not like attributes with underscores for some reason
preprint.guid = preprint._id
<|code_end|>
... | return preprint |
Continue the code snippet: <|code_start|>
class PreprintMixin(PermissionRequiredMixin):
def get_object(self):
preprint = Preprint.objects.get(guids___id=self.kwargs['guid'])
# Django template does not like attributes with underscores for some reason
preprint.guid = preprint._id
<|cod... | return preprint |
Given the code snippet: <|code_start|>
class PreprintMixin(PermissionRequiredMixin):
def get_object(self):
preprint = Preprint.objects.get(guids___id=self.kwargs['guid'])
# Django template does not like attributes with underscores for some reason
preprint.guid = preprint._id
... | class PreprintView(PreprintMixin, GuidView): |
Predict the next line for this snippet: <|code_start|>
retraction.to_MODERATOR_REJECTED()
registration.refresh_from_db()
assert registration.moderation_state == RegistrationModerationStates.EMBARGO.db_name
retraction.to_REJECTED()
registration.refresh_from_db()
assert re... | registration = embargo_termination.target_registration |
Predict the next line for this snippet: <|code_start|> registration.registration_approval.save()
sub_reg = registration._nodes.first()._nodes.first()
assert sub_reg.is_registration_approved is True
def test_is_retracted(self):
retraction = factories.RetractionFactory(stat... | factories.NodeFactory(creator=user, parent=child) |
Given snippet: <|code_start|> context = {}
context['login_url'] = web_url_for('dashboard', _absolute=True)
return context
@collect_auth
def redirect_unsupported_institution(auth):
"""
Sends user back to the "Unsupported Institution" page on CAS. Logs user out if they are
already logged in.
... | return _forgot_password_post(mail_template=mails.FORGOT_PASSWORD, |
Given snippet: <|code_start|> if not dry_run:
row.save()
try:
handle_registration_row(row, initiator, provider, schema, auto_approval=auto_approval, dry_run=dry_run)
successful_row_count += 1
except RegistrationBulkCreationRowError as e:
logger.erro... | row.draft_registration.delete() |
Given the code snippet: <|code_start|> if dry_run:
logger.info('Dry run: complete. Bulk creation started in dry-run mode and the job state was not updated')
logger.info(f'Done. [{number_of_jobs}] jobs have been picked up and kicked off.')
@celery_app.task()
def bulk_create_registrations(upload_id, dry_... | is_completed=False, |
Next line prediction: <|code_start|># SPDX-License-Identifier: MIT
from __future__ import absolute_import, division, print_function
_operation_names = {"eq": "==", "lt": "<", "le": "<=", "gt": ">", "ge": ">="}
def cmp_using(
eq=None,
lt=None,
le=None,
gt=None,
ge=None,
<|code_end|>
. Use curr... | require_same_type=True, |
Based on the snippet: <|code_start|># SPDX-License-Identifier: MIT
from __future__ import absolute_import, division, print_function
_operation_names = {"eq": "==", "lt": "<", "le": "<=", "gt": ">", "ge": ">="}
def cmp_using(
eq=None,
lt=None,
<|code_end|>
, predict the immediate next line with the help o... | le=None, |
Here is a snippet: <|code_start|># -*-encoding:utf-8-*-
class Test(object):
pass
handlers = {
"/test": Test,
"/path/{test}": Test
}
def test():
router = Router(handles=handlers, url="/test")
handler = router.get_handler()
if Test != handler[0] and (not isinstance(handler[1], PathParam)):
... | assert "Router get handler error" |
Based on the snippet: <|code_start|># -*-encoding:utf-8-*-
class Test(object):
pass
handlers = {
"/test": Test,
"/path/{test}": Test
}
def test():
router = Router(handles=handlers, url="/test")
handler = router.get_handler()
if Test != handler[0] and (not isinstance(handler[1], PathParam)... | print(handler) |
Next line prediction: <|code_start|>
class JSONReportObject(EmbeddedDocument):
name = StringField(required=True)
_json_data = FileField()
def get_as_dict(self):
return json.loads(self._json_data.read())
class RawReportObject(EmbeddedDocument):
name = StringField(required=True)
_raw_data... | REPORT_STATUS_CODE_FAILURE = 1 |
Given snippet: <|code_start|>
class JSONReportObject(EmbeddedDocument):
name = StringField(required=True)
_json_data = FileField()
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from flask import json
from mass_flask_config.app import db
from mongoengine import StringFie... | def get_as_dict(self): |
Based on the snippet: <|code_start|> (REPORT_STATUS_CODE_FAILURE, 'FAIL'),
)
analysis_system = ReferenceField(AnalysisSystem, required=True)
sample = ReferenceField(Sample, required=True)
analysis_date = DateTimeField()
upload_date = DateTimeField(default=TimeFunctions.get_timestamp, require... | def add_json_report_object(self, file): |
Given the code snippet: <|code_start|> def get_as_dict(self):
return json.loads(self._json_data.read())
class RawReportObject(EmbeddedDocument):
name = StringField(required=True)
_raw_data = FileField()
def get_raw_data(self):
return self._raw_data.read()
class Report(db.Document):
... | json_report_objects = MapField(field=FileField()) |
Here is a snippet: <|code_start|> 'view_sample',
'submit_sample',
]
class APIKey(db.Document):
expiry_date = DateTimeField()
scopes = ListField(StringField(choices=API_SCOPES))
meta = {
'allow_inheritance': True,
}
def is_expired(self):
if self.expiry_date is not None and ... | @staticmethod |
Given the code snippet: <|code_start|>
class UserAPIKey(APIKey):
user = ReferenceField(User, required=True)
@staticmethod
def get_or_create(user):
api_key = UserAPIKey.objects(user=user.id).first()
if not api_key:
api_key = UserAPIKey(user=user.id)
api_key.save()
... | return self.instance |
Given the code snippet: <|code_start|> return None
@staticmethod
def api_key_loader(key):
s = Serializer(app.secret_key)
try:
data = s.loads(key)
api_key = APIKey.objects(id=data).first()
if api_key.is_expired():
api_key.delete()
... | return self.user |
Given the code snippet: <|code_start|>
API_SCOPES = [
'view_sample',
'submit_sample',
]
class APIKey(db.Document):
expiry_date = DateTimeField()
scopes = ListField(StringField(choices=API_SCOPES))
<|code_end|>
, generate the next line using the imports in this file:
from mongoengine import DateTimeF... | meta = { |
Next line prediction: <|code_start|>
API_SCOPES = [
'view_sample',
'submit_sample',
]
class APIKey(db.Document):
expiry_date = DateTimeField()
scopes = ListField(StringField(choices=API_SCOPES))
meta = {
'allow_inheritance': True,
}
def is_expired(self):
if self.expiry_da... | return False |
Here is a snippet: <|code_start|> def referenced_entity(self):
return None
@staticmethod
def api_key_loader(key):
s = Serializer(app.secret_key)
try:
data = s.loads(key)
api_key = APIKey.objects(id=data).first()
if api_key.is_expired():
... | def referenced_entity(self): |
Given the code snippet: <|code_start|>
class AnalysisSystemTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
obj = mixer.blend(AnalysisSystem, identifier_name='Test')
self.assertEqual(obj.__repr__(), '[AnalysisSystem] Test')
self.assertEqual(obj.__str__(), '[AnalysisSystem] T... | def test_is_short_name_forbidden(self): |
Here is a snippet: <|code_start|>
class AnalysisSystemTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
obj = mixer.blend(AnalysisSystem, identifier_name='Test')
self.assertEqual(obj.__repr__(), '[AnalysisSystem] Test')
self.assertEqual(obj.__str__(), '[AnalysisSystem] Test')... | with self.assertRaises(ValidationError): |
Here is a snippet: <|code_start|>
def get_pagination_compatible_schema(schema_class):
class PaginationCompatibleSchema(Schema):
results = Nested(schema_class, many=True)
next = Int()
previous = Int()
return PaginationCompatibleSchema()
def register_api_endpoint(endpoint_name, resourc... | resource_view = resource.as_view(endpoint_name) |
Based on the snippet: <|code_start|>
def _get_sample_statistics():
result = []
now = TimeFunctions.get_timestamp().replace(hour=0, minute=0, second=0, microsecond=0)
for i in range(0,14):
start = now - datetime.timedelta(days=i)
end = now - datetime.timedelta(days=i-1)
number = Sa... | def index(): |
Next line prediction: <|code_start|>
def _get_sample_statistics():
result = []
now = TimeFunctions.get_timestamp().replace(hour=0, minute=0, second=0, microsecond=0)
for i in range(0,14):
start = now - datetime.timedelta(days=i)
<|code_end|>
. Use current file imports:
(import datetime
from flas... | end = now - datetime.timedelta(days=i-1) |
Continue the code snippet: <|code_start|>
def _get_sample_statistics():
result = []
now = TimeFunctions.get_timestamp().replace(hour=0, minute=0, second=0, microsecond=0)
for i in range(0,14):
start = now - datetime.timedelta(days=i)
end = now - datetime.timedelta(days=i-1)
number... | return result |
Predict the next line for this snippet: <|code_start|>
class AnalysisSystemSchema(BaseSchema):
url = URLFor('.analysis_system_detail', identifier_name='<identifier_name>', _external=True)
class Meta(BaseSchema.Meta):
model = AnalysisSystem
dump_only = [
'id',
<|code_end|>
with the... | '_cls', |
Continue the code snippet: <|code_start|>
class AnalysisSystemSchema(BaseSchema):
url = URLFor('.analysis_system_detail', identifier_name='<identifier_name>', _external=True)
class Meta(BaseSchema.Meta):
model = AnalysisSystem
dump_only = [
<|code_end|>
. Use current file imports:
from flask_... | 'id', |
Here is a snippet: <|code_start|>
class LoginForm(Form):
username = StringField(validators=[DataRequired()])
password = PasswordField(validators=[DataRequired()])
submit = SubmitField()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.user = None
def va... | return False |
Continue the code snippet: <|code_start|>
@webui_blueprint.route('/report/<report_id>/')
def report_detail(report_id):
report = Report.objects(id=report_id).first()
<|code_end|>
. Use current file imports:
from flask import render_template
from mass_flask_core.models import Report
from mass_flask_webui.config im... | return render_template('report_generic.html', report=report) |
Predict the next line for this snippet: <|code_start|>
class RequestDispatchTestCase(FlaskTestCase):
def test_are_requests_correct_after_sample_creation(self):
system = mixer.blend(AnalysisSystem, tag_filter_expression='sample-type:ipsample')
ipsample = mixer.blend(IPSample, tags=['sample-type:ips... | def test_are_requests_correct_after_analysis_system_creation(self): |
Here is a snippet: <|code_start|>
class RequestDispatchTestCase(FlaskTestCase):
def test_are_requests_correct_after_sample_creation(self):
system = mixer.blend(AnalysisSystem, tag_filter_expression='sample-type:ipsample')
ipsample = mixer.blend(IPSample, tags=['sample-type:ipsample'])
uris... | self.assertEqual(ipsample.dispatched_to, [system]) |
Using the snippet: <|code_start|>
class RequestDispatchTestCase(FlaskTestCase):
def test_are_requests_correct_after_sample_creation(self):
system = mixer.blend(AnalysisSystem, tag_filter_expression='sample-type:ipsample')
ipsample = mixer.blend(IPSample, tags=['sample-type:ipsample'])
uris... | with self.assertRaises(DoesNotExist): |
Next line prediction: <|code_start|>
class RequestDispatchTestCase(FlaskTestCase):
def test_are_requests_correct_after_sample_creation(self):
system = mixer.blend(AnalysisSystem, tag_filter_expression='sample-type:ipsample')
ipsample = mixer.blend(IPSample, tags=['sample-type:ipsample'])
u... | self._are_requests_correct(ipsample, urisample, system) |
Given the following code snippet before the placeholder: <|code_start|>
class DevelopmentConfig(BaseConfig):
DEBUG = True
MONGODB_SETTINGS = {
'host': 'mongodb://localhost:27017/mass-flask-development',
<|code_end|>
, predict the next line using imports from the current file:
from mass_flask_config.co... | 'tz_aware': True |
Using the snippet: <|code_start|>
class RelationGraphTestCase(FlaskTestCase):
def assertGraphEqual(self, sample, result_set, depth=None):
if depth is None:
self.assertEqual(GraphFunctions.get_relation_graph(sample), result_set)
<|code_end|>
, determine the next line of code. You have imports:
... | else: |
Based on the snippet: <|code_start|> return datetime.strptime(string, '%Y-%m-%dT%H:%M:%S+00:00')
@staticmethod
def _create_list_from_string(string):
return string.split(',')
@property
def schema(self):
return Ref('schema').resolve(self)
@property
def pagination_schema(s... | if parameter in request.args: |
Using the snippet: <|code_start|> 'shannon_entropy__lte',
'shannon_entropy__gte'
]
return _exact_fields_to_dict(file_form_data, exact_fields)
def _get_ip_filters(ip_form_data):
exact_fields = [
'ip_address'
]
return _exact_fields_to_dict(ip_form_data, exact_fields)
def _ge... | return _exact_fields_to_dict(uri_form_data, exact_fields) |
Predict the next line for this snippet: <|code_start|>
def _is_present_and_not_empty(form_data, variable):
return variable in form_data and form_data[variable]
def _exact_fields_to_dict(form_data, exact_fields):
result_dict = {}
<|code_end|>
with the help of current file imports:
from flask import render_... | for field in exact_fields: |
Here is a snippet: <|code_start|> 'file_size__gte',
'shannon_entropy__lte',
'shannon_entropy__gte'
]
return _exact_fields_to_dict(file_form_data, exact_fields)
def _get_ip_filters(ip_form_data):
exact_fields = [
'ip_address'
]
return _exact_fields_to_dict(ip_form_dat... | ] |
Continue the code snippet: <|code_start|>
def _get_file_filters(file_form_data):
exact_fields = [
'mime_type',
'file_names',
'md5sum',
'sha1sum',
'sha256sum',
'sha512sum',
'file_size__lte',
'file_size__gte',
'shannon_entropy__lte',
'sha... | ] |
Given snippet: <|code_start|>
class AnalysisSystemInstanceTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='InstanceTestSystem')
instance = mixer.blend(AnalysisSystemInstance, uuid='e25b2339-23d4-4544-8c99-f2968a935319', analysis_... | self.assertTrue(obj.is_online) |
Based on the snippet: <|code_start|>
class AnalysisSystemInstanceTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='InstanceTestSystem')
instance = mixer.blend(AnalysisSystemInstance, uuid='e25b2339-23d4-4544-8c99-f2968a935319', an... | def test_is_online_interval_working(self): |
Next line prediction: <|code_start|>
class AnalysisSystemInstanceTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='InstanceTestSystem')
instance = mixer.blend(AnalysisSystemInstance, uuid='e25b2339-23d4-4544-8c99-f2968a935319', an... | self.assertEqual(instance.__str__(), '[AnalysisSystemInstance] InstanceTestSystem e25b2339-23d4-4544-8c99-f2968a935319') |
Here is a snippet: <|code_start|>
class FileSampleSubmitForm(Form):
file = FileField('File', validators=[FileRequired()])
tlp_level = SelectField('Sample privacy (TLP level)', coerce=int, choices=[
(TLPLevelField.TLP_LEVEL_WHITE, 'WHITE (unlimited)'),
(TLPLevelField.TLP_LEVEL_GREEN, 'GREEN (com... | ]) |
Here is a snippet: <|code_start|>
class AnalysisRequestTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='RequestTestSystem')
sample = mixer.blend(Sample, id='55c863b79b65210a5625411a')
obj = mixer.blend(AnalysisRequest, sa... | obj.save() |
Given snippet: <|code_start|>
class AnalysisRequestTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='RequestTestSystem')
sample = mixer.blend(Sample, id='55c863b79b65210a5625411a')
obj = mixer.blend(AnalysisRequest, sample... | obj.save() |
Given snippet: <|code_start|>
class AnalysisRequestTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='RequestTestSystem')
sample = mixer.blend(Sample, id='55c863b79b65210a5625411a')
obj = mixer.blend(AnalysisRequest, sample... | obj.save() |
Continue the code snippet: <|code_start|>
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
class SampleRelation(db.Document):
sample = ReferenceField(Sample, required=True)
other = ReferenceField(Sample, required=True)
meta = {
'allow_inheritance': True,
}
def __repr_... | def __str__(self): |
Given the following code snippet before the placeholder: <|code_start|>
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
class SampleRelation(db.Document):
sample = ReferenceField(Sample, required=True)
other = ReferenceField(Sample, required=True)
meta = {
'allow_inheritance'... | def __str__(self): |
Given the code snippet: <|code_start|>
class ReportTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='ReportTestSystem')
sample = mixer.blend(Sample, id='55cdd8e89b65211708b7da46')
obj = mixer.blend(Report, sample=sample, ... | self.assertEqual(obj.__repr__(), '[Report] 55cdd8e89b65211708b7da46 on ReportTestSystem') |
Based on the snippet: <|code_start|>
class ReportTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='ReportTestSystem')
sample = mixer.blend(Sample, id='55cdd8e89b65211708b7da46')
obj = mixer.blend(Report, sample=sample, an... | self.assertEqual(obj.__repr__(), '[Report] 55cdd8e89b65211708b7da46 on ReportTestSystem') |
Continue the code snippet: <|code_start|>
class ReportTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='ReportTestSystem')
sample = mixer.blend(Sample, id='55cdd8e89b65211708b7da46')
obj = mixer.blend(Report, sample=sampl... | self.assertEqual(obj.__str__(), '[Report] 55cdd8e89b65211708b7da46 on ReportTestSystem') |
Based on the snippet: <|code_start|>
class ReportTestCase(FlaskTestCase):
def test_is_repr_and_str_correct(self):
system = mixer.blend(AnalysisSystem, identifier_name='ReportTestSystem')
sample = mixer.blend(Sample, id='55cdd8e89b65211708b7da46')
obj = mixer.blend(Report, sample=sample, an... | self.assertEqual(obj.__str__(), '[Report] 55cdd8e89b65211708b7da46 on ReportTestSystem') |
Predict the next line for this snippet: <|code_start|>
def _filter_matches_tags(tags, tag_filter):
return TagParser(tags).parse_string(tag_filter)
def _match_sample_and_system(sample, system):
if system in sample.dispatched_to:
return
if not _filter_matches_tags(sample.tags, system.tag_filter_exp... | _match_sample_and_system(document, system) |
Predict the next line after this snippet: <|code_start|>
def _filter_matches_tags(tags, tag_filter):
return TagParser(tags).parse_string(tag_filter)
def _match_sample_and_system(sample, system):
if system in sample.dispatched_to:
return
if not _filter_matches_tags(sample.tags, system.tag_filter_e... | sample.dispatched_to.append(system) |
Using the snippet: <|code_start|>
def _filter_matches_tags(tags, tag_filter):
return TagParser(tags).parse_string(tag_filter)
def _match_sample_and_system(sample, system):
if system in sample.dispatched_to:
return
if not _filter_matches_tags(sample.tags, system.tag_filter_expression):
ret... | _match_sample_and_system(document, system) |
Predict the next line for this snippet: <|code_start|>
def _filter_matches_tags(tags, tag_filter):
return TagParser(tags).parse_string(tag_filter)
def _match_sample_and_system(sample, system):
if system in sample.dispatched_to:
return
if not _filter_matches_tags(sample.tags, system.tag_filter_exp... | sample.dispatched_to.append(system) |
Given the code snippet: <|code_start|>
class AnalysisSystem(db.Document):
identifier_name = StringField(min_length=3, max_length=50, unique=True, required=True)
verbose_name = StringField(max_length=200, required=True)
<|code_end|>
, generate the next line using the imports in this file:
from mongoengine impo... | information_text = StringField() |
Given snippet: <|code_start|>
class FlaskTestCase(TestCase):
@staticmethod
def _clean_test_database():
conn = connection.get_connection()
db = connection.get_db()
conn.drop_database(db)
def __call__(self, result=None):
<|code_end|>
, continue by predicting the next line. Consider c... | self._pre_setup() |
Predict the next line after this snippet: <|code_start|>
class FlaskTestCase(TestCase):
@staticmethod
def _clean_test_database():
<|code_end|>
using the current file's imports:
from unittest import TestCase
from mongoengine import connection
from mass_flask_config.app import app
from mass_flask_config.bootst... | conn = connection.get_connection() |
Predict the next line for this snippet: <|code_start|>
def _get_instance_with_minimum_count(instance_list):
min_count = sys.maxsize
min_instance = None
for instance in instance_list:
if instance.analyses_count < min_count:
min_count = instance.analyses_count
min_instance = in... | return True |
Predict the next line for this snippet: <|code_start|>
def _prepare_instance_dict():
instance_dict = {}
instances = AnalysisSystemInstance.objects().no_dereference()
for instance in instances:
if instance.analysis_system.id not in instance_dict.keys():
instance_dict[instance.analysis_sy... | continue |
Given the following code snippet before the placeholder: <|code_start|> s = ScheduledAnalysis(analysis_system_instance=instance, sample=request.sample)
s.save()
instance.analyses_count += 1
def _schedule_analysis_request(request, instance_dict):
if request.analysis_system.id not in instance_dict:
... | requests_scheduled += 1 |
Predict the next line for this snippet: <|code_start|>
@webui_blueprint.route('/login/', methods=['GET', 'POST'])
def login():
if current_authenticated_entity.is_authenticated:
return redirect(url_for('.profile'))
else:
form = LoginForm()
if form.validate_on_submit():
app.s... | flash('Logged out successfully!', 'success') |
Using the snippet: <|code_start|>
@webui_blueprint.route('/login/', methods=['GET', 'POST'])
def login():
if current_authenticated_entity.is_authenticated:
return redirect(url_for('.profile'))
<|code_end|>
, determine the next line of code. You have imports:
from flask import flash, render_template, redi... | else: |
Using the snippet: <|code_start|>
@webui_blueprint.route('/login/', methods=['GET', 'POST'])
def login():
if current_authenticated_entity.is_authenticated:
return redirect(url_for('.profile'))
else:
form = LoginForm()
if form.validate_on_submit():
app.session_provider.login... | return render_template('login.html', form=form) |
Given the code snippet: <|code_start|>
if __name__ == '__main__':
print('mass-server-flask version' + app.version)
username = input('Please enter username to create: ')
password = getpass(prompt='Please enter the password for the new user: ')
password_verify = getpass(prompt='Enter password again to ver... | if password != password_verify: |
Predict the next line after this snippet: <|code_start|>
if __name__ == '__main__':
print('mass-server-flask version' + app.version)
username = input('Please enter username to create: ')
password = getpass(prompt='Please enter the password for the new user: ')
password_verify = getpass(prompt='Enter pas... | user.username = username |
Given the code snippet: <|code_start|>
@webui_blueprint.route('/apidocs/')
def apidocs():
return render_template('apidocs.html')
@webui_blueprint.route('/cli_scripts/')
<|code_end|>
, generate the next line using the imports in this file:
from flask import render_template
from mass_flask_webui.config import we... | def cli_scripts(): |
Here is a snippet: <|code_start|>
class Comment(db.EmbeddedDocument):
comment = StringField(max_length=1000, verbose_name='Comment', help_text='Leave a comment', required=True)
post_date = DateTimeField(default=TimeFunctions.get_timestamp, required=True)
user = ReferenceField(User, required=True)
class C... | comments = ListField(EmbeddedDocumentField(Comment)) |
Based on the snippet: <|code_start|>
class Comment(db.EmbeddedDocument):
comment = StringField(max_length=1000, verbose_name='Comment', help_text='Leave a comment', required=True)
post_date = DateTimeField(default=TimeFunctions.get_timestamp, required=True)
user = ReferenceField(User, required=True)
clas... | def add_comment(self, comment, post_date, user): |
Given the code snippet: <|code_start|>
class RequestAnalysisForm(Form):
analysis_system = SelectField('Analysis system', choices=[], validators=[InputRequired()])
priority = IntegerField('Priority', validators=[InputRequired()], default=0)
submit = SubmitField('Request')
def __init__(self):
su... | def _query_analysis_system_choices(self): |
Given the code snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': ExecutableBinarySampleSchema... | return model_conversion[model_class_name] |
Next line prediction: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': ExecutableBinarySampleSchema,
... | raise ValueError('Unsupported model type: {}'.format(model_class_name)) |
Predict the next line for this snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': ExecutableBi... | else: |
Continue the code snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': ExecutableBinarySampleSch... | else: |
Continue the code snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': ExecutableBinarySampleSch... | raise ValueError('Unsupported model type: {}'.format(model_class_name)) |
Given the following code snippet before the placeholder: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySamp... | return model_conversion[model_class_name] |
Here is a snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': ExecutableBinarySampleSchema,
... | if model_class_name in model_conversion: |
Based on the snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': ExecutableBinarySampleSchema,
... | if model_class_name in model_conversion: |
Given the following code snippet before the placeholder: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySamp... | } |
Predict the next line after this snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': Executable... | } |
Given the code snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
<|code_end|>
, generate the next line using the imports in this file:
from mass_flask_api.schemas import SampleSchema, FileSampleSchema, ExecutableBinarySampleSchema, ReportSchema, IPSam... | model_conversion = { |
Predict the next line for this snippet: <|code_start|>
class SchemaMapping:
@staticmethod
def get_schema_for_model_class(model_class_name):
model_conversion = {
'Sample': SampleSchema,
'FileSample': FileSampleSchema,
'ExecutableBinarySample': ExecutableBi... | if model_class_name in model_conversion: |
Based on the snippet: <|code_start|>
class AnalysisRequest(db.Document):
analysis_system = ReferenceField(AnalysisSystem, required=True)
sample = ReferenceField(Sample, required=True)
analysis_requested = DateTimeField(default=TimeFunctions.get_timestamp, required=True)
priority = IntField(default=0, r... | 'indexes': ['analysis_requested'] |
Here is a snippet: <|code_start|>
class AnalysisRequest(db.Document):
analysis_system = ReferenceField(AnalysisSystem, required=True)
sample = ReferenceField(Sample, required=True)
analysis_requested = DateTimeField(default=TimeFunctions.get_timestamp, required=True)
priority = IntField(default=0, requ... | 'indexes': ['analysis_requested'] |
Next line prediction: <|code_start|>
class AnalysisRequest(db.Document):
analysis_system = ReferenceField(AnalysisSystem, required=True)
sample = ReferenceField(Sample, required=True)
analysis_requested = DateTimeField(default=TimeFunctions.get_timestamp, required=True)
priority = IntField(default=0, r... | meta = { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.