conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Fix .bible: v2 was deprecated, the v3 API requires a key.\n" }, { "from": "human", "value": "from util import hook, http\n\n\n@hook.command('god')\n@hook.command\ndef bible(inp):\n \".bible <passage> -- gets <passage> from the Bible (ESV)\"\n\n base_url = ('ht...
python
chosen
[ { "from": "system", "value": "Fix for periodic task scheduler (3)\n" }, { "from": "human", "value": "__author__ = 'onur'\n\nfrom celery import Celery\n\nimport direnaj_api.config.server_celeryconfig as celeryconfig\n\napp_object = Celery()\n\napp_object.config_from_object(celeryconfig)\n\n@app_o...
python
chosen
[ { "from": "system", "value": "Update to use signals as use_for_related_fields does not work for all cases\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport logging\nimport uuid\n\nfrom django.db.models.signals import post_save, post_delete\n\nfrom .backends.sharing.types import ...
python
chosen
[ { "from": "system", "value": "Add handling for basic twitch controls\n" }, { "from": "human", "value": "from flask import Flask, jsonify, request\nfrom dotenv import load_dotenv, find_dotenv\nfrom twilio import twiml\n\napp = Flask(__name__)\nload_dotenv(find_dotenv())\n\n@app.route('/message', ...
python
chosen
[ { "from": "system", "value": "Save Image to File, Open Image if found\n\nAdd image checking using urllib and opencv.\n" }, { "from": "human", "value": "import praw\nimport urllib\nr = praw.Reddit('/u/powderblock Glasses Bot')\n\nfor post in r.get_subreddit('all').get_new(limit=5):\n if \"...
python
chosen
[ { "from": "system", "value": "Fix overlooked use case for workdir.\n" }, { "from": "human", "value": "import datetime\nimport multiprocessing\n\nfrom lobster.cmssw.plotting import Plotter\n\nlogger = multiprocessing.get_logger()\n\nclass DummyQueue(object):\n def start(*args):\n pass\n...
python
chosen
[ { "from": "system", "value": "Document exception raised when a store does not exist\n" }, { "from": "human", "value": "from axiom import substore\n\n\ndef createStore(rootStore, pathSegments):\n \"\"\"\n Creates amd returns substore under the given root store with the given\n path segme...
python
chosen
[ { "from": "system", "value": "Add tests for blog index view and post view\n" }, { "from": "human", "value": "from django.test import TestCase\n\n\nclass BlogViewsTestCase(TestCase):\n def setUp(self):\n" }, { "from": "gpt", "value": "from django import test\nfrom django.core.urlre...
python
chosen
[ { "from": "system", "value": "Change BaseWorker to new style class.\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n\"\"\"This module define base class of mass worker.\n\"\"\"\n\n# built-in modules\nfrom functools import wraps\nimport sys\nimport traceback\n...
python
chosen
[ { "from": "system", "value": "Change error message of the weight validator." }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom schematics.exceptions import ConversionError, ValidationError\n\n\ndef validate(schema, data):\n try:\n schema.import_data(data)\n schema....
python
chosen
[ { "from": "system", "value": "Add default for `is_cli` to pyinfra.\n" }, { "from": "human", "value": "# pyinfra\n# File: pyinfra/__init__.py\n# Desc: some global state for pyinfra\n\n'''\nWelcome to pyinfra.\n'''\n\nimport logging\n\n\n# Global pyinfra logger\nlogger = logging.getLogger('pyinfra...
python
chosen
[ { "from": "system", "value": "Remove deprecation warning from compiler package\n" }, { "from": "human", "value": "\"\"\"Package for parsing and compiling Python source code\n\nThere are several functions defined at the top level that are imported\nfrom modules contained in the package.\n\nparse(...
python
chosen
[ { "from": "system", "value": "Update the print help and add returns to delete and link methods.\n\nSigned-off-by: messiasthi <8562fc1efba9a3c99753c749fdfb1b6932b70fbf@gmail.com>\n" }, { "from": "human", "value": "from dduplicated import scans, fileManager\n\ndef detect(paths):\n\treturn scans.sc...
python
chosen
[ { "from": "system", "value": "Simplify code introduced in 7f7ea810.\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nfrom django.conf import settings\nfrom django.utils.importlib import import_module\n\nfrom debug_toolbar.toolbar.loader import load_panel_classes\nfro...
python
chosen
[ { "from": "system", "value": "Add test to verify login required for protected pages\n" }, { "from": "human", "value": "from app.test_base import BaseTestCase\n\nclass TestTopLevelFunctions(BaseTestCase):\n def test_index_response(self):\n response = self.client.get('/')\n self.a...
python
chosen
[ { "from": "system", "value": "Add tests for reindenting line\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\nimport sshrc.core.lexer as lexer\n\nimport pytest\n\n\n@pytest.mark.parametrize(\"input_, output_\", (\n (\"\", \"\"),\n (\" \", \"\"),\n (\" #\", \"\...
python
chosen
[ { "from": "system", "value": "Update method call for test server\n" }, { "from": "human", "value": "#\n# Hello World server in Python\n# Binds REP socket to tcp://*:5555\n# Expects b\"Hello\" from client, replies with b\"World\"\n#\n\nimport logging\nimport time\nimport zmq\n\ncontext = zm...
python
chosen
[ { "from": "system", "value": "Add test for no title search\n" }, { "from": "human", "value": "from sharepa.search import basic_search\n\n\ndef test_basic_search():\n results = basic_search.execute()\n assert results.hits\n assert results.aggregations\n" }, { "from": "gpt", "...
python
chosen
[ { "from": "system", "value": "Fix bugs in item and user knn\n" }, { "from": "human", "value": "from distutils.core import setup\nfrom setuptools import find_packages\n\n__author__ = \"Arthur Fortes\"\n\nsetup(\n name='CaseRecommender',\n packages=find_packages(),\n version='0.0.12',\n ...
python
chosen
[ { "from": "system", "value": "Fix required Django version (doesnt support 1.8 yet)\n" }, { "from": "human", "value": "from setuptools import setup\n\n\nsetup(\n name='django-simpleimages',\n version='1.2.0',\n author='Saul Shanabrook',\n author_email='s.shanabrook@gmail.com',\n pa...
python
chosen
[ { "from": "system", "value": "Add get/set methods to the Message class\n" }, { "from": "human", "value": "\nimport io\n\nimport eccodes\n\nclass Message:\n def __init__(self, handle):\n self.handle = handle\n\n def __del__(self):\n eccodes.codes_release(self.handle)\n\n de...
python
chosen
[ { "from": "system", "value": "Add another inane test to trigger Landscape\n" }, { "from": "human", "value": "from edison.tests import unittest\n\n\nclass SanityTests(unittest.TestCase):\n def test_psych(self):\n self.assertTrue(True)\n" }, { "from": "gpt", "value": "from ed...
python
chosen
[ { "from": "system", "value": "Raise AttributeError instead of None\n" }, { "from": "human", "value": "import imp\nimport json\nimport os\nimport sys\n\n\nclass Dot(dict):\n\n def __init__(self, d):\n super(dict, self).__init__()\n for k, v in d.iteritems():\n if isins...
python
chosen
[ { "from": "system", "value": "Connect the UI to the code and start to connect slots to actions.\n" }, { "from": "human", "value": "\n\n\ndef run(args=None):\n \"\"\"Main entry point of the application.\"\"\"\n pass\n" }, { "from": "gpt", "value": "import sys\n\nfrom PyQt4.QtGui...
python
chosen
[ { "from": "system", "value": "Fix bug where previous instances would populate the new OutputPipe\n" }, { "from": "human", "value": "import sys\nimport re\nfrom xc_exception import TestFailureError\nfrom colors import Colors\nfrom meta_line import MetaLine\nfrom line import Line\n\nclass OutputPi...
python
chosen
[ { "from": "system", "value": "Change message parsing to not break on prefixes with spaces. May find a way to bring back clean suffix and clean args.\n" }, { "from": "human", "value": "from typing import Tuple, List\nimport shlex\nimport discord\n\n\ndef get_cmd(string: str) -> str:\n '''Gets ...
python
chosen
[ { "from": "system", "value": "Change platform and python fields to lists\n" }, { "from": "human", "value": "import sys\nimport json\n\n\nrelease_tag = sys.argv[1]\npython_version = sys.argv[2]\nci_os = sys.argv[3]\n\nplatform_mapping = {\n \"ubuntu-latest\": \"linux-64\",\n \"macOS-latest\...
python
chosen
[ { "from": "system", "value": "Add new WHOWAS keys when upgrading the data to 0.5\n" }, { "from": "human", "value": "# This file upgrades data.db from the 0.4 format data to 0.5 format data.\n\n# SETUP: Open data.db\nimport argparse, shelve, sys\nargumentParser = argparse.ArgumentParser(descripti...
python
chosen
[ { "from": "system", "value": "Make override more global, not just within patch scope\n" }, { "from": "human", "value": "# After this function, any futher calls to import RPi.GPIO\n# will instead import .gpio.Gpio instead\ndef patch_fake_gpio():\n print('Warning, not in RPi, using mock GPIO')\...
python
chosen
[ { "from": "system", "value": "Fix bad logic for missing RPi package\n" }, { "from": "human", "value": "from __future__ import print_function\nimport sys\n\n\nis_active = False\n\n\n# After this function, any futher calls to import RPi.GPIO\n# will instead import .gpio.Gpio instead\ndef patch_fak...
python
chosen
[ { "from": "system", "value": "Stop on error from streaming API\n" }, { "from": "human", "value": "# Pipe the output of this to file, e.g.:\n#\n# `python twitter_streaming.py > twitter_data.txt`\n#\n# The output is in JSON format.\n\n# This uses Tweepy, a Python library for accessing the Twit...
python
chosen
[ { "from": "system", "value": "Allow reading word list from stdin.\n" }, { "from": "human", "value": "import fire\nimport json\nimport sys\n\nfrom source import VocabularyCom\nfrom airtable import Airtable\n\nclass CLI:\n class source:\n \"\"\"Import word lists from various sources\"\"\...
python
chosen
[ { "from": "system", "value": "Allow plots to be disposed of sooner\n" }, { "from": "human", "value": "\"\"\"\n`Singleton` plot helper module\nAll its variables are bound to the module,\nwhich can not be instantiated repeatedly so IDs are session-specific.\n\"\"\"\nimport sys\n\n# TODO Refactor t...
python
chosen
[ { "from": "system", "value": "Fix imports after renaming healthcheck module\n" }, { "from": "human", "value": "from django.core.management.base import BaseCommand, CommandError\n\nfrom fjord.heartbeat.healthchecks import run_healthchecks, email_healthchecks\n\n\nclass Command(BaseCommand):\n ...
python
chosen
[ { "from": "system", "value": "Use TemplateView to simplify Index view.\n" }, { "from": "human", "value": "\"\"\"Index page admin view.\"\"\"\n\nimport logging\nfrom django.contrib.auth.decorators import user_passes_test\nfrom django.shortcuts import render\nfrom django.utils.decorators import me...
python
chosen
[ { "from": "system", "value": "Use the naive datetime format for MySQL as well\n\nSee the SQLAlchemy docs for more information:\nhttp://docs.sqlalchemy.org/en/latest/dialects/mysql.html#sqlalchemy.dial\nects.mysql.DATETIME\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\n fl...
python
chosen
[ { "from": "system", "value": "Fix type causing import error.\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nfrom .impl import verify_spec_name\nfrom .impl import get_spec_plugin_list\nfrom .impl import Spec\nfrom .rules import SpecParsingError\n\n__all__ = ['get_sp...
python
chosen
[ { "from": "system", "value": "Update lock plugin so admins could write messages\n" }, { "from": "human", "value": "\"\"\"\nEcho plugin example\n\"\"\"\nimport octeon\nglobal locked\nlocked = []\nPLUGINVERSION = 2\n# Always name this variable as `plugin`\n# If you dont, module loader will fail to...
python
chosen
[ { "from": "system", "value": "Remove exceptions containing whitespace / no special chars" }, { "from": "human", "value": "# encoding: utf8\nfrom __future__ import unicode_literals\n\nfrom ..symbols import *\nfrom ..language_data import PRON_LEMMA\n\n\nTOKENIZER_EXCEPTIONS = {\n \n}\n\n\nORTH_...
python
chosen
[ { "from": "system", "value": "Fix for DummyLayout: pass 'focussed_element' instead of 'focussed_window'.\n" }, { "from": "human", "value": "\"\"\"\nDummy layout. Used when somebody creates an `Application` without specifying a\n`Layout`.\n\"\"\"\nfrom __future__ import unicode_literals\n\nfrom p...
python
chosen
[ { "from": "system", "value": "Resolve `SyntaxWarning: \"is\" with a literal`\n" }, { "from": "human", "value": "# coding: utf-8\nfrom collections import OrderedDict\n\n\ndef _convert_sheets_to_lists(content):\n cols = OrderedDict()\n if not content or len(content) is 0:\n return [],...
python
chosen
[ { "from": "system", "value": "Add function to get just stderr from subprocess command\n" }, { "from": "human", "value": "#! /usr/bin/env python\n\nfrom subprocess import Popen, PIPE\n\n\ndef launch(cmd):\n \"\"\"\n Fork the specified command, returning a tuple of (stdout, stderr)\n \"\"...
python
chosen
[ { "from": "system", "value": "Fix splashscreen size on HiDPI (windows) screens\n" }, { "from": "human", "value": "# Copyright (c) 2015 Ultimaker B.V.\n# Uranium is released under the terms of the AGPLv3 or higher.\n\nfrom PyQt5.QtCore import Qt\nfrom PyQt5.QtGui import QPixmap, QColor, QFont\nfr...
python
chosen
[ { "from": "system", "value": "Replace Markdown README with reStructured text\n" }, { "from": "human", "value": "__version_info__ = (1, 0, 2)\n__version__ = '.'.join(map(str, __version_info__))\n" }, { "from": "gpt", "value": "__version_info__ = (1, 0, 3)\n__version__ = '.'.join(map(s...
python
chosen
[ { "from": "system", "value": "Change 'patron' to 'customer' in BarterAccount\n" }, { "from": "human", "value": "from django.db import models\n\n# Create your models here.\nclass BarterEvent(models.Model):\n\tbarter_account = models.ForeignKey(\n\t\t'BarterAccount',\n\t\t#on_delete=models.CASCADE...
python
chosen
[ { "from": "system", "value": "Add signal handler for sigterm.\n" }, { "from": "human", "value": "import logging.config\nfrom setproctitle import setproctitle\n\n\ndef process_setup():\n setproctitle('ksurctrobot')\n\n logging.config.dictConfig({\n 'version': 1,\n 'formatters'...
python
chosen
[ { "from": "system", "value": "Rearrange the photo upload success URL for consistency\n" }, { "from": "human", "value": "from django.conf.urls import patterns, url\n\nfrom .views import upload_photo, PhotoUploadSuccess\n\nurlpatterns = patterns('',\n url(r'^photo/upload/(?P<popit_person_id>\\d...
python
chosen
[ { "from": "system", "value": "Connect to MySQL only when needed\n" }, { "from": "human", "value": "import mysql.connector\nimport config\nimport threading\n\nenabled = False\n\ndb_lock = threading.Lock()\nconn = mysql.connector.connect(host=config.get('db_logger.host'), user=config.get('db_logge...
python
chosen
[ { "from": "system", "value": "Remove redundant import and fix package's __all__\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n\n\"\"\"Logging package for specific and general needs.\n\nThis exposes all the defined loggers, and a generic ready-to-use Logger\nfor general needs, which ...
python
chosen
[ { "from": "system", "value": "Add normalize_source hook for parsers\n\nBy default, this hook will replace macros (such as \\newcommand) with\ntheir content. Parser implementations can do additional work to\nnormalize/resolve TeX content.\n" }, { "from": "human", "value": "from __future__ import ...
python
chosen
[ { "from": "system", "value": "Fix to handle case where parameters are not passed-in as a KL\n" }, { "from": "human", "value": "import copy\nimport sys\n\nimport scipy\n\nimport SloppyCell.KeyedList_mod as KeyedList_mod\nKeyedList = KeyedList_mod.KeyedList\n\ndef fmin_powell_log_params(m, params,...
python
chosen
[ { "from": "system", "value": "Put parsed_text into the full-text search index\n" }, { "from": "human", "value": "from django_elasticsearch_dsl import DocType, GeoPointField\n\nfrom mainapp.documents.utils import mainIndex\nfrom mainapp.models import File\n\n\n@mainIndex.doc_type\nclass FileDocum...
python
chosen
[ { "from": "system", "value": "Correct bug in auth where username=None\n" }, { "from": "human", "value": "from django.contrib.auth.models import User\nfrom django.contrib.auth.backends import ModelBackend\n\n\nclass Emailbackend(ModelBackend):\n def authenticate(self, email=None, password=None...
python
chosen
[ { "from": "system", "value": "Change variable name & int comparison.\n" }, { "from": "human", "value": "from flask import jsonify, current_app\nimport json\n\nfrom . import status\nfrom . import utils\nfrom .. import models\n\n\n@status.route('/_status')\ndef status():\n\n api_response = util...
python
chosen
[ { "from": "system", "value": "Fix DB errors on stop/re-up\nDue to the fact that this code was being run before everything else, it would cause server-stopping errors -- but only when starting the server for the first time. It took a little bit to track down, but this is the correct way to override this vari...
python
chosen
[ { "from": "system", "value": "SCons: Disable embree-based modules on x86 (32-bit)\n\nFixes #48482.\n\n(cherry picked from commit e53422c8f96770c9a9b7497955c84f4b742fdd73)\n" }, { "from": "human", "value": "def can_build(env, platform):\n if platform == \"android\":\n return env[\"andro...
python
chosen
[ { "from": "system", "value": "Add more time to mqtt.test.client\n" }, { "from": "human", "value": "import time\nfrom django.test import TestCase\n\nfrom django.contrib.auth.models import User\nfrom django.conf import settings\n\nfrom rest_framework.renderers import JSONRenderer\nfrom rest_framew...
python
chosen
[ { "from": "system", "value": "Use current time if no arguments given\n" }, { "from": "human", "value": "#!/bin/python\n\nimport argparse\n\nimport requests\nimport timetable\n\nif __name__ == '__main__':\n\tparser = argparse.ArgumentParser()\n\n\tparser.add_argument(\"-d\", \"--day\", default=''...
python
chosen
[ { "from": "system", "value": "Add back guid in the discovery pane API\n" }, { "from": "human", "value": "from rest_framework import serializers\n\nfrom olympia.addons.models import Addon\nfrom olympia.addons.serializers import AddonSerializer, VersionSerializer\nfrom olympia.versions.models impo...
python
chosen
[ { "from": "system", "value": "Refactor codes and revise main\n" }, { "from": "human", "value": "\"\"\"Leetcode 172. Factorial Trailing Zeroes\nEasy\n\nURL: https://leetcode.com/problems/factorial-trailing-zeroes/\n\nGiven an integer n, return the number of trailing zeroes in n!.\n\nExample 1:\nI...
python
chosen
[ { "from": "system", "value": "Add a timestamp to the filename to allow for chronological ordering in the filesystem\n" }, { "from": "human", "value": "from utils.utils import limit_file_name\n\n\nclass Image():\n _file_name_pattern = \"reddit_%s_%s_album_%s_%s_%s\"\n\n def __init__(self, u...
python
chosen
[ { "from": "system", "value": "Create new figure in plot command\n" }, { "from": "human", "value": "\"\"\"Convenience functions for matplotlib plotting and image viewing.\"\"\"\nimport numpy as np\nfrom matplotlib import pyplot as plt\n\n\ndef show(image, blocking=False, **kwargs):\n \"\"\"Sho...
python
chosen
[ { "from": "system", "value": "Add docker helper to get ip\n" }, { "from": "human", "value": "# Helper functions for docker\n\nimport docker\nimport os\n\nDEFAULT_DOCKER_API_VERSION = '1.10'\nBASEIMAGETAG = \"glusterbase:latest\"\nGLUSTERIMAGENAME = \"gluster:latest\"\nBASEDIR=os.getcwd()\n\nclas...
python
chosen
[ { "from": "system", "value": "Remove ancient TODO that was resolved a long time ago.\n" }, { "from": "human", "value": "import json\n\nfrom go.vumitools.conversation.definition import (\n ConversationDefinitionBase, ConversationAction)\n\n\nclass ViewLogsAction(ConversationAction):\n actio...
python
chosen
[ { "from": "system", "value": "Hotswap: Remove all references to actually swapping\n" }, { "from": "human", "value": "import os\nimport logging\nimport threading\n\nlog = logging.getLogger(__name__)\n\n\nclass Hotswap(threading.Thread):\n def __init__(self, out, mod, *args, **kwargs):\n ...
python
chosen
[ { "from": "system", "value": "bug: Remove description from Restaurant class\n" }, { "from": "human", "value": "import sys\nfrom sqlalchemy import Column, ForeignKey, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import relationship\nfrom sqlalchemy...
python
chosen
[ { "from": "system", "value": "Return a copy of extension state\n" }, { "from": "human", "value": "import json\nimport logging\n\nlog = logging.getLogger(__name__)\n\n\n# TODO persist state to file\n\n\nclass CogBotState:\n def __init__(self, state_file: str):\n with open(state_file) as...
python
chosen
[ { "from": "system", "value": "Update signature of to_text and to_html\n" }, { "from": "human", "value": "class OdkCalculate:\n def __init__(self, row):\n self.row = row\n\n def to_html(self):\n return \"\"\n\n def to_text(self):\n return \"\"\n\n def __repr__(sel...
python
chosen
[ { "from": "system", "value": "Add ids to parametrized tests\n" }, { "from": "human", "value": "import glob\nimport json\nimport os\nimport time\n\n\nimport pytest\n\nfrom helpers import solutions_dir\n\n\n# NOTE: If we make solution files a fixture instead of a normal attr/function,\n# then we c...
python
chosen
[ { "from": "system", "value": "Initialize empty tiles array for Meld object\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom mahjong.tile import TilesConverter\n\n\nclass Meld(object):\n CHI = 'chi'\n PON = 'pon'\n KAN = 'kan'\n CHANKAN = 'chankan'\n NUKI = 'nuki'\n...
python
chosen
[ { "from": "system", "value": "Add in more unit tests.\n\nSigned-off-by: Chris Lalancette <281cd07d7578d97c83271fbbf2faddb83ab3791c@gmail.com>\n" }, { "from": "human", "value": "import pytest\nimport subprocess\nimport os\nimport sys\n\nprefix = '.'\nfor i in range(0,3):\n if os.path.exists(os...
python
chosen
[ { "from": "system", "value": "Verify we handle null HTPasswd files\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nTest the root Web application\n\"\"\"\nimport imp\n\nfrom lmod_proxy.tests.common import CommonTest\n\n\nclass TestWeb(CommonTest):\n \"\"\"Verify the root We...
python
chosen
[ { "from": "system", "value": "Use right env variable to build redis url\n\nIt is for the events stream daemon.\n" }, { "from": "human", "value": "import os\n\nfrom flask import Flask\nfrom flask_sse import sse\n\napp = Flask(__name__)\nredis_host = os.environ.get(\"KV_HOST\", \"localhost\")\nre...
python
chosen
[ { "from": "system", "value": "Fix permission path for customer role lookup\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nfrom django.contrib.auth import get_user_model\n\nfrom nodeconductor.core.permissions import FilteredCollaboratorsPermissionLogic\nfrom nodecon...
python
chosen
[ { "from": "system", "value": "Fix URL pattern in new versions of Django\n" }, { "from": "human", "value": "from django.conf.urls import patterns, include, url\n\nurlpatterns = patterns(\n '',\n url(r'^ajax/', include('ajax.urls', namespace='ajax')),\n url(r'^', include('pages.urls', nam...
python
chosen
[ { "from": "system", "value": "Fix bug in no sha use case\n" }, { "from": "human", "value": "from elasticsearch import Elasticsearch\n\nfrom storage import Storage\n\nclass ElasticSearchStorage(Storage):\n def __init__(self, config_dict):\n self.db = config_dict['database']\n sel...
python
chosen
[ { "from": "system", "value": "Remove development auto admin user creation\n" }, { "from": "human", "value": "from functools import wraps\n\nfrom flask import request, abort, redirect, url_for, render_template\nfrom flask.ext.login import LoginManager, login_user, logout_user, login_required\n\nf...
python
chosen
[ { "from": "system", "value": "feat: Improve annotating of code segements\n" }, { "from": "human", "value": "import re\n\n\nclass ArtifactAnnotator:\n def linkify_artifacts(marked_tree, artifacts):\n big_string = ArtifactAnnotator._marked_tree_to_big_string(marked_tree)\n\n for a...
python
chosen
[ { "from": "system", "value": "Fix user in reservations responses\n" }, { "from": "human", "value": "from models import Reservation\nfrom setup import ma\n\nfrom marshmallow import fields\n\nclass ReservationSchema(ma.ModelSchema):\n user = fields.Method('get_user')\n\n def get_user(self, r...
python
chosen
[ { "from": "system", "value": "Add mu_in_rad and mu_in_deg, use built in method to convert rad to deg\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n\nfrom math import atan, pi, sqrt\n\nfrom properties.constants import GAMMA\n\n\ndef nu_in_rad(m):\n if m < 1:\n raise ValueE...
python
chosen
[ { "from": "system", "value": "Add functions to get external alerts\n\nFor the purpose of getting unscheduled events\n" }, { "from": "human", "value": "class GameEvent:\n def __init__(self, name, start, end = None):\n self.name = name\n self.start = start\n self.end = end\...
python
chosen
[ { "from": "system", "value": "Update kb test to check for port_num\n\nSigned-off-by: Brandon Myers <9cda508be11a1ae7ceef912b85c196946f0ec5f3@mozilla.com>\n" }, { "from": "human", "value": "from scoring_engine.models.kb import KB\n\nfrom tests.scoring_engine.unit_test import UnitTest\n\n\nclass T...
python
chosen
[ { "from": "system", "value": "Make safe_qualname more permissive (getting syntax errors on travis in 2.6)\n" }, { "from": "human", "value": "import traceback\n\nfrom qualname import qualname\n\n\ndef safe_qualname(cls):\n # type: (type) -> str\n result = _safe_qualname_cache.get(cls)\n ...
python
chosen
[ { "from": "system", "value": "Comment mxtoolbox because of limited requests\n" }, { "from": "human", "value": "from functools import reduce\nimport pprint\nimport time\nimport shodan\nimport requests\nimport api_key\nfrom google_api import query_google_api\nfrom shodan_api import query_shodan_ap...
python
chosen
[ { "from": "system", "value": "Implement functions to obtain position and orientation given a pose\n\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport rospy\n\ndef compute_control_actions(msg):\n pass\n\nif __name__ == '__main__':\n rospy.init_node('controller')\n subscrib...
python
chosen
[ { "from": "system", "value": "Add pebble.ink to allowed hosts (flynn deployment)\n" }, { "from": "human", "value": "from .base import *\nimport dj_database_url\n\nDEBUG = False\nTEMPLATE_DEBUG = DEBUG\n\nDATABASES['default'] = dj_database_url.config()\n\nSECRET_KEY = get_env_variable(\"SECRET_KE...
python
chosen
[ { "from": "system", "value": "Fix qmentaobject test to work with dynamic metaobject.\n" }, { "from": "human", "value": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n'''Tests for static methos conflicts with class methods'''\n\nimport unittest\n\nfrom PySide.QtCore import *\n\nclass Foo(QFile):\n ...
python
chosen
[ { "from": "system", "value": "Update delete warning to include instructions that same query parameters need to be in request\n" }, { "from": "human", "value": "from django.utils.translation import ugettext_lazy as _\n\nBEFORE_BULK_DELETE = _('Are you sure you want to delete these projects? They ...
python
chosen
[ { "from": "system", "value": "Support deletion of trait delegate\n" }, { "from": "human", "value": "\"\"\"\nMinimal traits implementation:\n\n @traits\n class MyClass(object):\n\n attr = Instance(SomeClass)\n my_delegation = Delegate('attr')\n\"\"\"\n\nimport inspect\n\n# fro...
python
chosen
[ { "from": "system", "value": "Remove commented-out RunPython from migration" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.1 on 2017-10-20 08:13\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom frontend.management.commands.im...
python
chosen
[ { "from": "system", "value": "Move the database config to the basic Config\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import\n\nimport os\n\n\nclass Config(object):\n SECRET_KEY = '123456790' # Create dummy secrey key ...
python
chosen
[ { "from": "system", "value": "[FIX] product_management_group: Allow superuser to skip that restriction on products\n\ncloses ingadhoc/product#409\n\nSigned-off-by: Nicolas Mac Rouillon <8d34fe7b7c65100e706828a8c0d03426900ffb59@adhoc.com.ar>\n" }, { "from": "human", "value": "####################...
python
chosen
[ { "from": "system", "value": "Fix brackets in the user number migration.\n" }, { "from": "human", "value": "\"\"\"hide user numbers\n\nRevision ID: 2945717e3720\nRevises: f8acbd22162\nCreate Date: 2016-01-31 00:43:02.777003\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\nfrom sqlalch...
python
chosen
[ { "from": "system", "value": "Fix negative offsets in read_list\n" }, { "from": "human", "value": "from typing import Iterable, Optional\n\nfrom redis import Redis\n\n\ndef read_list(\n redis_conn: Redis, key: str, *, chunk_size: int = 4096, last_n: Optional[int] = None\n) -> Iterable[bytes]:...
python
chosen
[ { "from": "system", "value": "Set auto_init=True when creating new github repo through osf\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport httplib as http\n\nfrom flask import request\nfrom github3 import GitHubError\n\nfrom framework.exceptions import HTTPError\nfrom framew...
python
chosen
[ { "from": "system", "value": "Change the timeout, and reissue_time\n\nWe want to make sure that the session never expires, since this also\ncauses our CSRF token to expire, which causes issues...\n" }, { "from": "human", "value": "from pyramid.session import SignedCookieSessionFactory\n\ndef inc...
python
chosen
[ { "from": "system", "value": "Fix control flow for main app entry\n" }, { "from": "human", "value": "from cherrypy import wsgiserver\nfrom app import app\nimport jinja2.ext\n\nif app.debug:\n app.run('0.0.0.0', port=8080, debug=app.debug)\nelse:\n # from http://flask.pocoo.org/snippets/24/...
python
chosen
[ { "from": "system", "value": "Use updated user profile model for pdf output\n\n" }, { "from": "human", "value": "from django.views import generic\nfrom django.shortcuts import get_object_or_404\nfrom django.template.loader import get_template\nfrom django.http import HttpResponse\nfrom z3c.rml i...
python
chosen
[ { "from": "system", "value": "Use tanh activation for word C2W embeddings " }, { "from": "human", "value": "from keras.layers import LSTM, Input, Dense, TimeDistributed, Masking, merge\nfrom keras.models import Model\nfrom layers import Projection\n\n\ndef C2W(params, V_C):\n one_hots = Input(...
python
chosen
[ { "from": "system", "value": "Send text response when Content-Type is text/plain\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\nfrom flask import Flask, render_template, request\nfrom names import get_full_name\n\n\napp = Flask(__name__)\n\n\n@app.route(\"/\")\ndef index():...
python
chosen