query stringlengths 9 9.05k | document stringlengths 10 222k | negatives listlengths 19 20 | metadata dict |
|---|---|---|---|
Copy config file to tempest results directory | def backup_tempest_config(conf_file, res_dir):
if not os.path.exists(res_dir):
os.makedirs(res_dir)
shutil.copyfile(conf_file,
os.path.join(res_dir, 'tempest.conf')) | [
"def copy_config(RESULTSDIR, main_config, io_config):\n print(\"Saving results to: {}\".format(RESULTSDIR))\n\n if not os.path.exists(RESULTSDIR):\n os.makedirs(RESULTSDIR)\n\n mconfig = os.path.join(\n RESULTSDIR, \"copy_main_config_\" + main_config.split(os.sep)[-1]\n )\n dconfig = os... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns verifier id for current Tempest | def get_verifier_id():
cmd = ("rally verify list-verifiers | awk '/" +
getattr(config.CONF, 'tempest_verifier_name') +
"/ {print $2}'")
with subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL) as proc:
... | [
"def get_verifier_id():\n cmd = (\"rally verify list-verifiers | awk '/\" +\n getattr(config.CONF, 'tempest_verifier_name') +\n \"/ {print $2}'\")\n proc = subprocess.Popen(cmd, shell=True,\n stdout=subprocess.PIPE,\n stderr=subprocess.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns installed verifier repo directory for Tempest | def get_verifier_repo_dir(verifier_id):
return os.path.join(getattr(config.CONF, 'dir_rally_inst'),
'verification',
f'verifier-{verifier_id}',
'repo') | [
"def get_verifier_repo_dir(verifier_id):\n return os.path.join(getattr(config.CONF, 'dir_rally_inst'),\n 'verification',\n 'verifier-{}'.format(verifier_id),\n 'repo')",
"def get_verifier_deployment_dir(verifier_id, deployment_id):\n retur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns Rally deployment directory for current verifier | def get_verifier_deployment_dir(verifier_id, deployment_id):
return os.path.join(getattr(config.CONF, 'dir_rally_inst'),
'verification',
f'verifier-{verifier_id}',
f'for-deployment-{deployment_id}') | [
"def get_verifier_deployment_dir(verifier_id, deployment_id):\n return os.path.join(getattr(config.CONF, 'dir_rally_inst'),\n 'verification',\n 'verifier-{}'.format(verifier_id),\n 'for-deployment-{}'.format(deployment_id))",
"def get_verifie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add/update needed parameters into tempest.conf file | def configure_tempest_update_params(
tempest_conf_file, image_id=None, flavor_id=None,
compute_cnt=1, image_alt_id=None, flavor_alt_id=None,
admin_role_name='admin', cidr='192.168.120.0/24',
domain_id='default'):
# pylint: disable=too-many-branches,too-many-argume... | [
"def configure_tempest_update_params(\n tempest_conf_file, image_id=None, flavor_id=None,\n compute_cnt=1, image_alt_id=None, flavor_alt_id=None,\n admin_role_name='admin', cidr='192.168.120.0/24',\n domain_id='default'):\n # pylint: disable=too-many-branches,too-many-arguments,too-ma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Execute rally verify configureverifier, which generates tempest.conf | def configure_verifier(deployment_dir):
cmd = ['rally', 'verify', 'configure-verifier', '--reconfigure',
'--id', str(getattr(config.CONF, 'tempest_verifier_name'))]
output = subprocess.check_output(cmd)
LOGGER.info("%s\n%s", " ".join(cmd), output.decode("utf-8"))
LOGGER.d... | [
"def configure_verifier(deployment_dir):\n cmd = ['rally', 'verify', 'configure-verifier', '--reconfigure',\n '--id', str(getattr(config.CONF, 'tempest_verifier_name'))]\n output = subprocess.check_output(cmd)\n LOGGER.info(\"%s\\n%s\", \" \".join(cmd), output)\n\n LOGGER.debug(\"Looking for t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate test list based on the test mode. | def generate_test_list(self, **kwargs):
LOGGER.debug("Generating test case list...")
self.backup_tempest_config(self.conf_file, '/etc')
if kwargs.get('mode') == 'custom':
if os.path.isfile(self.tempest_custom):
shutil.copyfile(
self.tempest_custom,... | [
"def _build_tests_list_helper(self, suite):\n tests = list(iterate_tests(suite))\n return tests",
"def generate_test_list(tdir):\n\n # Skip this if it already exists\n if os.path.exists(os.path.join(tdir.name, \"kstest-list\")):\n return\n\n kstest_log = os.path.join(tdir.name, \"kst... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse and save test results. | def parse_verifier_result(self):
stat = self.get_verifier_result(self.verification_id)
try:
num_executed = stat['num_tests'] - stat['num_skipped']
try:
self.result = 100 * stat['num_success'] / num_executed
except ZeroDivisionError:
sel... | [
"def parse_test_result(self):\n if not os.path.isdir(ACS_REPORTS_FOLDER):\n self.logger('{} folder does not exist.'.format(ACS_REPORTS_FOLDER))\n return\n\n log_list = []\n def list_files(folder, file_list):\n dir_list = os.listdir(folder)\n if not di... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Detect and update the default role if required | def update_default_role(self, rally_conf='/etc/rally/rally.conf'):
role = self.get_default_role(self.cloud)
if not role:
return
rconfig = configparser.RawConfigParser()
rconfig.read(rally_conf)
if not rconfig.has_section('openstack'):
rconfig.add_section('... | [
"def get_default_role(self):\n return False",
"def _overrideRole(self, newRole, args):\n oldRole = args.get('role', None)\n args['role'] = newRole\n return oldRole",
"def default_role(self):\n return utils.find(lambda r: r.is_everyone, self.roles)",
"def init_default_roles()... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update auth section in tempest.conf | def update_auth_section(self):
rconfig = configparser.RawConfigParser()
rconfig.read(self.conf_file)
if not rconfig.has_section("auth"):
rconfig.add_section("auth")
if env.get("NEW_USER_ROLE").lower() != "member":
tempest_roles = []
if rconfig.has_opti... | [
"def auth(self) -> Config:\n self[FLOWSERV_AUTH] = AUTH_DEFAULT\n return self",
"def set_auth(self, request, auth):\n request.auth = auth",
"def enable_auth(self, auth_file):\n auth = Authenticator()\n auth.load_or_create(auth_file)\n sec_settings = {\n 'tool... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update network section in tempest.conf | def update_network_section(self):
rconfig = configparser.RawConfigParser()
rconfig.read(self.conf_file)
if self.ext_net:
if not rconfig.has_section('network'):
rconfig.add_section('network')
rconfig.set('network', 'public_network_id', self.ext_net.id)
... | [
"def update_compute_section(self):\n rconfig = configparser.RawConfigParser()\n rconfig.read(self.conf_file)\n if not rconfig.has_section('compute'):\n rconfig.add_section('compute')\n rconfig.set(\n 'compute', 'fixed_network_name',\n self.network.name if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update compute section in tempest.conf | def update_compute_section(self):
rconfig = configparser.RawConfigParser()
rconfig.read(self.conf_file)
if not rconfig.has_section('compute'):
rconfig.add_section('compute')
rconfig.set(
'compute', 'fixed_network_name',
self.network.name if self.networ... | [
"def configure_tempest_update_params(\n tempest_conf_file, image_id=None, flavor_id=None,\n compute_cnt=1, image_alt_id=None, flavor_alt_id=None,\n admin_role_name='admin', cidr='192.168.120.0/24',\n domain_id='default'):\n # pylint: disable=too-many-branches,too-many-arguments,too-ma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update validation section in tempest.conf | def update_validation_section(self):
rconfig = configparser.RawConfigParser()
rconfig.read(self.conf_file)
if not rconfig.has_section('validation'):
rconfig.add_section('validation')
rconfig.set(
'validation', 'connect_method',
'floating' if self.ext_n... | [
"def validate_config(self):\n pass",
"def _validate_config(self):\n pass",
"def validate_settings(_cfg, _ctx):\n pass",
"def validate_config():\n\n # diff/sync settings, not including templates (see below)\n nori.setting_check_list('action', ['diff', 'sync'])\n nori.setting_check_type(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update scenario section in tempest.conf | def update_scenario_section(self):
rconfig = configparser.RawConfigParser()
rconfig.read(self.conf_file)
filename = getattr(
config.CONF, f'{self.case_name}_image', self.filename)
if not rconfig.has_section('scenario'):
rconfig.add_section('scenario')
rcon... | [
"def test_update_web_section(self):\n pass",
"def updateScenario(self, scenario):\n\n if not scenario:\n return\n\n for limb in ['lp', 'rp', 'lm', 'rm']:\n for entry in scenario.entries[limb]:\n if entry:\n uid = entry['uid']\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update dashboard section in tempest.conf | def update_dashboard_section(self):
rconfig = configparser.RawConfigParser()
rconfig.read(self.conf_file)
if env.get('DASHBOARD_URL'):
if not rconfig.has_section('dashboard'):
rconfig.add_section('dashboard')
rconfig.set('dashboard', 'dashboard_url', env.g... | [
"def test_dashboard_partially_update_dashboard(self):\n pass",
"def test_update_dashboard_panel_setting(self):\n pass",
"def test_update_dashboard_panel(self):\n pass",
"def test_dashboard_update_dashboard(self):\n pass",
"def test_update_dashboard(self):\n pass",
"def t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Turns a waze linestring into a geojson linestring | def get_linestring(value):
line = value['line']
coords = [(x['x'], x['y']) for x in line]
return geojson.Feature(
geometry=geojson.LineString(coords),
properties=value
) | [
"def transform_linestring(orig_geojs, in_crs, out_crs):\n line_wgs84 = orig_geojs\n wgs84_coords = []\n # transfrom each coordinate\n for x, y in orig_geojs['geometry']['coordinates']:\n x1, y1 = transform(in_crs, out_crs, x, y)\n line_wgs84['geometry']['coordinates'] = x1, y1\n wgs... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a dict with keys of segment id, and val a list of waze jams (for now, just jams), the properties of a road segment, and the total number of snapshots we're looking at, update the road segment's properties to include features | def get_features(waze_info, properties, num_snapshots):
# Waze feature list
# jam_percent - percentage of snapshots that have a jam on this segment
if properties['segment_id'] in waze_info:
# only count one jam per snapshot on a road
num_jams = len(set([x['properties']['snapshotId']
... | [
"def _update_segments(self):\n self._validate_CFG()\n self._define_segments()\n # must redefine this Segments list,\n # the code does not work otherwise\n self.segments = [self.P, self.T, self.C,\n self.A1, self.A2, self.B1, self.B2,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Map a set of waze segment info (jams) onto segments drawn from | def map_segments(datadir, filename):
items = json.load(open(filename))
# Only look at jams for now
items = [get_linestring(x) for x in items if x['eventType'] == 'jam']
items = util.reproject_records(items)
# Get the total number of snapshots in the waze data
num_snapshots = max([x['propertie... | [
"def _generate_segment_maps(self):\n segment_length = np.diff(self.s) / self.s[-1]\n\n # Betatron motion normalized to this particular segment.\n dQ_x = self.Q_x * segment_length\n dQ_y = self.Q_y * segment_length\n\n n_segments = len(self.s) - 1\n for seg in range(n_segmen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
change self.O to index of V | def trans_o(self):
temp_array = []
for j in range(self.O.shape[1]):
for i in range(self.V.shape[1]):
if self.V[0, i] == self.O[0, j]:
temp_array.append(i)
self.O = mat(temp_array) | [
"def __setitem__(self, i, v):\n return _vector.Vector___setitem__(self, i, v)",
"def transform(self, V): \n raise NotImplementedError(\"Please Implement this method\")",
"def operate(V, A):",
"def other(self,idx):\n\n if idx == self.v.index:\n return self.w.index\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method is so that child classes can define additional object state checks before cloning (e.g. see ModelWrapperBase which should not clone if the modelcaching manager has already been set) | def additional_cloning_checks(self):
pass | [
"def clone(self):\r\n import copy\r\n return self._wrap(copy.copy(self.obj))",
"def _base_clone(self, queryset, klass=None, setup=False, **kwargs):\r\n cache_query = kwargs.get('_cache_query', getattr(self, '_cache_query', False))\r\n kwargs['_cache_query'] = cache_query\r\n if ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
`r` is in units of h^1 where h is the smoothing length of the object in consideration. The kernels are in units of h^3, hence the need to divide by h^2 at the end. Defined kernels at the moment are `uniform`, `sphanarchy`, `gadget2`, `cubic`, `quintic` | def inp_kernel(r, ktype):
if ktype == 'uniform':
if r < 1.:
return 1./((4./3.)*pi)
else:
return 0.
elif ktype == 'sph-anarchy':
if r <= 1.: return (21./(2.*pi)) * ((1. - r)*(1. - r)*(1. - r)*(1. - r)*(1. + 4.*r))
else: return 0... | [
"def gadget_kernel(r, h):\n factor = r/h\n factor2 = factor * factor\n prefactor = 4/(3 * h)\n\n if factor <= 0.5:\n poly = 1 - 6 * factor2 + 6 * factor2 * factor\n elif factor <= 1:\n one_minus_factor = 1 - factor\n poly = 2 * one_minus_factor * one_minus_factor * one_minus_fact... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Saves the computed kernel for easy lookup as .npz file | def create_kernel(ktype='sph-anarchy'):
kernel = get_kernel(ktype)
header = np.array([{'kernel': ktype, 'bins': kernsize}])
np.savez('kernel_{}.npz'.format(ktype), header=header, kernel=kernel)
print (header)
return kernel | [
"def save(self, filename):\n np.savez(temp_dir + '/' + filename + '.npz', chip_ids=self.chip_ids, core_ids=self.core_ids, cx_ids=self.cx_ids)",
"def writeKernel(self, output_file):\n\t\tout_fh = open(output_file, 'w')\n\t\tcx = self.kernel.tocoo()\n\t\tedges = {}\n\t\tfor i,j,v in zip(cx.row, cx.col, cx.da... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Custom save method to autoset the phs field. | def save(self, *args, **kwargs):
self.phs = self.set_phs()
super(Study, self).save(*args, **kwargs) | [
"def pre_save(self):",
"def save(self, *args, **kwargs):\n if not self.unique_id:\n self.unique_id = self._generate_unique_id()\n if not self.price:\n self.price = self._update_price()\n super().save(*args, **kwargs)",
"def save(self, *args, **kwargs):\n super()... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Automatically set phs from the study's accession number. Properly format the phs number for this study, so it's easier to get to in templates. | def set_phs(self):
return 'phs{:06}'.format(self.i_accession) | [
"def user_enters_policy_number_hofl200163690(policynumber):\n avatarClaimsHomepage.add_policy_number(policynumber)",
"def _set_sgnum(self, v):\n self._sgnum = v\n self._Hall = lookupHall[v]\n #\n # Set point group and laue group\n #\n # * Point group dictionary maps a ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the absolute URL of the detail page for a given Study instance. | def get_absolute_url(self):
return reverse('trait_browser:source:studies:pk:detail', kwargs={'pk': self.pk}) | [
"def detail_url(self):\n return self._detail_url",
"def get_absolute_url(self):\n return ('publication_detail', (), {'slug': self.slug})",
"def get_absolute_url(self):\n \n return reverse('school-detail', args=[str(self.slug)]) # school-detail is a view",
"def get_absolute_url(self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Produce a url to initially populate checkboxes in the search page based on the study. | def get_search_url(self):
return reverse('trait_browser:source:studies:pk:traits:search', kwargs={'pk': self.pk}) | [
"def study_search(request):\n solr = StudySearch(ident=request.user)\n query = request.GET.get('q', 'active:true')\n opt = request.GET.copy()\n opt['edismax'] = True\n data = solr.query(query=query, options=opt.dict())\n # loop through results and attach URL to each\n query_response = data['res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Produce a url to search datasets wtihin the study. | def get_dataset_search_url(self):
return reverse('trait_browser:source:studies:pk:datasets:search', kwargs={'pk': self.pk}) | [
"def get_dataset_url(self, dataset: Dict) -> str:\n return f\"{self.site_url}/dataset/{dataset['name']}\"",
"def url(self) -> str:\n return self.DATASET_URLS[self.name]",
"def make_public_url(self, path):\n url = urljoin(settings.DATASET_URL, f\"{self.name}/\")\n return urljoin(url, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get html for study's name linking to study detail page. | def get_name_link_html(self):
url_text = "{{% url 'trait_browser:source:studies:pk:detail' pk={} %}} ".format(self.pk)
return URL_HTML.format(url=url_text, name=self.i_study_name) | [
"def study():\n return render_template('study.html')",
"def get_study_name_from_id(self, study_id: int) -> str:\n raise NotImplementedError",
"def get_student():\n\n github = request.args.get('github')\n\n first, last, github = hackbright.get_student_by_github(github)\n title_grade_list =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a count of the number of tags for which current traits are tagged, but archived, in this study. | def get_archived_tags_count(self):
return apps.get_model('tags', 'TaggedTrait').objects.archived().filter(
trait__source_dataset__source_study_version__study=self
).current().aggregate(
models.Count('tag', distinct=True))['tag__count'] | [
"def get_archived_traits_tagged_count(self):\n return apps.get_model('tags', 'TaggedTrait').objects.archived().filter(\n trait__source_dataset__source_study_version__study=self\n ).current().aggregate(\n models.Count('trait', distinct=True)\n )['trait__count']",
"def get... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a queryset of all of the current TaggedTraits from this study. | def get_all_tagged_traits(self):
return apps.get_model('tags', 'TaggedTrait').objects.filter(
trait__source_dataset__source_study_version__study=self,
).current() | [
"def get_archived_tagged_traits(self):\n return apps.get_model('tags', 'TaggedTrait').objects.archived().filter(\n trait__source_dataset__source_study_version__study=self\n ).current()",
"def get_all_traits_tagged_count(self):\n return SourceTrait.objects.filter(\n sourc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a queryset of the current archived TaggedTraits from this study. | def get_archived_tagged_traits(self):
return apps.get_model('tags', 'TaggedTrait').objects.archived().filter(
trait__source_dataset__source_study_version__study=self
).current() | [
"def archived_tags(self):\n archived_tagged_traits = apps.get_model('tags', 'TaggedTrait').objects.archived().filter(trait=self)\n return apps.get_model('tags', 'Tag').objects.filter(\n pk__in=archived_tagged_traits.values_list('tag__pk', flat=True))",
"def get_non_archived_tagged_traits(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a queryset of the current nonarchived TaggedTraits from this study. | def get_non_archived_tagged_traits(self):
return apps.get_model('tags', 'TaggedTrait').objects.current().non_archived().filter(
trait__source_dataset__source_study_version__study=self) | [
"def get_archived_tagged_traits(self):\n return apps.get_model('tags', 'TaggedTrait').objects.archived().filter(\n trait__source_dataset__source_study_version__study=self\n ).current()",
"def get_all_tagged_traits(self):\n return apps.get_model('tags', 'TaggedTrait').objects.filter... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the count of all current traits that have been tagged in this study. | def get_all_traits_tagged_count(self):
return SourceTrait.objects.filter(
source_dataset__source_study_version__study=self
).current().exclude(all_tags=None).count() | [
"def get_non_archived_traits_tagged_count(self):\n return apps.get_model('tags', 'TaggedTrait').objects.current().non_archived().filter(\n trait__source_dataset__source_study_version__study=self).aggregate(\n models.Count('trait', distinct=True))['trait__count']",
"def get_archived_tr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the count of current traits that have been tagged (and the tag archived) in this study. | def get_archived_traits_tagged_count(self):
return apps.get_model('tags', 'TaggedTrait').objects.archived().filter(
trait__source_dataset__source_study_version__study=self
).current().aggregate(
models.Count('trait', distinct=True)
)['trait__count'] | [
"def get_non_archived_traits_tagged_count(self):\n return apps.get_model('tags', 'TaggedTrait').objects.current().non_archived().filter(\n trait__source_dataset__source_study_version__study=self).aggregate(\n models.Count('trait', distinct=True))['trait__count']",
"def get_archived_ta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the count of current traits that have been tagged (and the tag not archived) in this study. | def get_non_archived_traits_tagged_count(self):
return apps.get_model('tags', 'TaggedTrait').objects.current().non_archived().filter(
trait__source_dataset__source_study_version__study=self).aggregate(
models.Count('trait', distinct=True))['trait__count'] | [
"def get_all_traits_tagged_count(self):\n return SourceTrait.objects.filter(\n source_dataset__source_study_version__study=self\n ).current().exclude(all_tags=None).count()",
"def get_archived_traits_tagged_count(self):\n return apps.get_model('tags', 'TaggedTrait').objects.archive... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the most recent SourceStudyVersion linked to this study. | def get_latest_version(self):
try:
version = self.sourcestudyversion_set.filter(
i_is_deprecated=False
).order_by( # We can't use "latest" since it only accepts one field in Django 1.11.
'-i_version',
'-i_date_added'
).first()
... | [
"def get_latest_version(self):\n study = self.source_study_version.study\n current_study_version = self.source_study_version.study.get_latest_version()\n if current_study_version is None:\n return None\n # Find the same dataset associated with the current study version.\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a dbGaP link to the page for the latest SourceStudyVersion. | def get_latest_version_link(self):
return self.get_latest_version().dbgap_link | [
"def version_link(self):\n release_link = url_for('data.data', selected_release=self.DATASET_RELEASE)\n return Markup(f\"<a href='{release_link}'>{self.DATASET_RELEASE}</a>\")",
"def get_latest_version(self):\n try:\n version = self.sourcestudyversion_set.filter(\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Automatically set full_accession from the study's phs value. | def set_full_accession(self):
return self.STUDY_VERSION_ACCESSION.format(self.study.phs, self.i_version, self.i_participant_set) | [
"def set_full_accession(self):\n return self.DATASET_ACCESSION.format(\n self.i_accession, self.i_version, self.source_study_version.i_participant_set)",
"def set_full_accession(self):\n return self.VARIABLE_ACCESSION.format(\n self.i_dbgap_variable_accession, self.i_dbgap_vari... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return an ordered queryset of previous versions. | def get_previous_versions(self):
return self.study.sourcestudyversion_set.filter(
i_version__lte=self.i_version,
i_date_added__lt=self.i_date_added
).order_by(
'-i_version',
'-i_date_added'
) | [
"def get_previous_version(self):\n return self.get_previous_versions().first()",
"def prev(self, date):\n return self.published().filter(date__lt=date)",
"def update_previous_all_versions():\n\n # get all the ids\n version_ids = m.meta.Session.query(distinct(tst.TestVersion.id)).filter_by(ar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the previous version of this study. | def get_previous_version(self):
return self.get_previous_versions().first() | [
"def previous_version(self):\n \n if self.version == 1:\n raise Exception(\"There is nothing before v1\")\n # Lazily retrieve history\n if len(self.history) == 0:\n self.__retrieve_history()\n # Go back in time until we find a valid previous version \n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a queryset of SourceTraits that are new in this version compared to past versions. | def get_new_sourcetraits(self):
previous_study_version = self.get_previous_version()
SourceTrait = apps.get_model('trait_browser', 'SourceTrait')
if previous_study_version is not None:
qs = SourceTrait.objects.filter(
source_dataset__source_study_version=self
... | [
"def get_previous_versions(self):\n return self.study.sourcestudyversion_set.filter(\n i_version__lte=self.i_version,\n i_date_added__lt=self.i_date_added\n ).order_by(\n '-i_version',\n '-i_date_added'\n )",
"def get_new_sourcedatasets(self):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a queryset of SourceDatasets that are new in this version compared to past versions. | def get_new_sourcedatasets(self):
previous_study_version = self.get_previous_version()
SourceDataset = apps.get_model('trait_browser', 'SourceDataset')
if previous_study_version is not None:
qs = SourceDataset.objects.filter(source_study_version=self)
# We can probably wr... | [
"def get_previous_versions(self):\n return self.study.sourcestudyversion_set.filter(\n i_version__lte=self.i_version,\n i_date_added__lt=self.i_date_added\n ).order_by(\n '-i_version',\n '-i_date_added'\n )",
"def old_releases(self):\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply tags from traits in the previous version of this Study to traits from this version. | def apply_previous_tags(self, user):
previous_study_version = self.get_previous_version()
if previous_study_version is not None:
SourceTrait = apps.get_model('trait_browser', 'SourceTrait')
TaggedTrait = apps.get_model('tags', 'TaggedTrait')
DCCReview = apps.get_model... | [
"def apply_previous_tags(self, creator):\n TaggedTrait = apps.get_model('tags', 'TaggedTrait')\n DCCReview = apps.get_model('tags', 'DCCReview')\n StudyResponse = apps.get_model('tags', 'StudyResponse')\n previous_trait = self.get_previous_version()\n if previous_trait is not None... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Custom save method to autoset full_accession and dbgap_link. | def save(self, *args, **kwargs):
self.full_accession = self.set_full_accession()
self.dbgap_link = self.set_dbgap_link()
super(SourceDataset, self).save(*args, **kwargs) | [
"def save(self, *args, **kwargs):\n self.full_accession = self.set_full_accession()\n self.dbgap_link = self.set_dbgap_link()\n super(SourceTrait, self).save(*args, **kwargs)",
"def save(self,\n force_insert=False,\n force_update=False,\n using=None,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the absolute URL of the detail page for a given SourceDataset instance. | def get_absolute_url(self):
return reverse('trait_browser:source:datasets:detail', kwargs={'pk': self.pk}) | [
"def detail_url(self):\n return self._detail_url",
"def get_absolute_url(self):\n return reverse('trait_browser:source:studies:pk:detail', kwargs={'pk': self.pk})",
"def detail_url(self) -> str:\n return reverse(f'{self.get_meta().app_label}:detail', args=[self.pk])",
"def display_url(sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Automatically set full_accession from the dataset's dbGaP identifiers. | def set_full_accession(self):
return self.DATASET_ACCESSION.format(
self.i_accession, self.i_version, self.source_study_version.i_participant_set) | [
"def set_full_accession(self):\n return self.VARIABLE_ACCESSION.format(\n self.i_dbgap_variable_accession, self.i_dbgap_variable_version,\n self.source_dataset.source_study_version.i_participant_set)",
"def set_full_accession(self):\n return self.STUDY_VERSION_ACCESSION.format(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Automatically set dbgap_link from dbGaP identifier information. | def set_dbgap_link(self):
return self.DATASET_URL.format(self.source_study_version.full_accession, self.i_accession) | [
"def set_dbgap_link(self):\n return self.VARIABLE_URL.format(\n self.source_dataset.source_study_version.full_accession, self.i_dbgap_variable_accession)",
"def fpga_link_id(self):",
"def update_gpdbid_file(array):\n \n standby_datadir = os.path.normpath(array.standbyMaster.getSegmentDat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get html for the dataset name linked to the dataset's detail page, with description as popover. | def get_name_link_html(self, max_popover_words=80):
if not self.i_dbgap_description:
description = '—'
else:
description = Truncator(self.i_dbgap_description).words(max_popover_words)
return POPOVER_URL_HTML.format(url=self.get_absolute_url(), popover=description,
... | [
"def get_dataset_name_html(self):\n if self.logical_file.dataset_name:\n dataset_name_div = div(cls=\"content-block\")\n with dataset_name_div:\n legend(\"Title\")\n p(self.logical_file.dataset_name)\n return dataset_name_div",
"def dataset_htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find the most recent version of this dataset. | def get_latest_version(self):
study = self.source_study_version.study
current_study_version = self.source_study_version.study.get_latest_version()
if current_study_version is None:
return None
# Find the same dataset associated with the current study version.
try:
... | [
"def latest_version(self):\r\n return self.versions.get(latest=True)",
"def get_latest_version(self):\n try:\n version = self.sourcestudyversion_set.filter(\n i_is_deprecated=False\n ).order_by( # We can't use \"latest\" since it only accepts one field in Django... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets a list of trait_flavor_names for harmonized traits in this trait set version. | def get_trait_names(self):
return self.harmonizedtrait_set.values_list('trait_flavor_name', flat=True) | [
"def set_trait_flavor_name(self):\n return '{}_{}'.format(self.i_trait_name, self.harmonized_trait_set_version.harmonized_trait_set.i_flavor)",
"def all_trait_names ( self ):\n return self.__class_traits__.keys()",
"def describe_flavors(self):\r\n print(\"The flavors at Sticky Sweet are \" ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the absolute URL of the detail page for a given HarmonizedTraitSet instance. | def get_absolute_url(self):
return reverse('trait_browser:harmonized:traits:detail', kwargs={'pk': self.pk}) | [
"def get_absolute_url(self):\n return reverse('trait_browser:source:traits:detail', kwargs={'pk': self.pk})",
"def detail_url(self):\n return self._detail_url",
"def get_absolute_url(self):\n return reverse('trait_browser:source:studies:pk:detail', kwargs={'pk': self.pk})",
"def get_absol... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a queryset of all the SourceTraits components for this harmonization unit (age, batch, or source). | def get_all_source_traits(self):
return self.component_source_traits.all() | self.component_batch_traits.all() | self.component_age_traits.all() | [
"def get_new_sourcetraits(self):\n previous_study_version = self.get_previous_version()\n SourceTrait = apps.get_model('trait_browser', 'SourceTrait')\n if previous_study_version is not None:\n qs = SourceTrait.objects.filter(\n source_dataset__source_study_version=sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a list containing all of the studies linked to component traits for this unit. | def get_source_studies(self):
return list(set([trait.source_dataset.source_study_version.study for trait in self.get_all_source_traits()])) | [
"def get_studies():\n return [\n study\n for study in get_source_labels_and_configs()\n if study[1].name.startswith(\"studies.\")\n ]",
"def studies(self):\n return self._study_queryset",
"def get_all_tagged_traits(self):\n return apps.get_model('tags', 'TaggedTrait').ob... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get html for a panel of component traits for the harmonization unit. Includes an inline list of included studies if applicable. | def get_component_html(self):
study_list = '\n'.join([study.get_name_link_html() for study in self.get_source_studies()])
age_list = '\n'.join([trait.get_name_link_html() for trait in self.component_age_traits.all()])
component_html = '\n'.join([
trait.get_component_html(harmonizatio... | [
"def get_component_html(self, harmonization_unit):\n source = [tr.get_name_link_html() for tr in (\n self.component_source_traits.all() & harmonization_unit.component_source_traits.all())]\n harmonized_trait_set_versions = [trait_set_version for trait_set_version in (\n self.comp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Custom save method to autoset full_accession and dbgap_link. | def save(self, *args, **kwargs):
self.full_accession = self.set_full_accession()
self.dbgap_link = self.set_dbgap_link()
super(SourceTrait, self).save(*args, **kwargs) | [
"def save(self, *args, **kwargs):\n self.full_accession = self.set_full_accession()\n self.dbgap_link = self.set_dbgap_link()\n super(SourceDataset, self).save(*args, **kwargs)",
"def save(self,\n force_insert=False,\n force_update=False,\n using=None,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Automatically set full_accession from the variable's dbGaP identifiers. | def set_full_accession(self):
return self.VARIABLE_ACCESSION.format(
self.i_dbgap_variable_accession, self.i_dbgap_variable_version,
self.source_dataset.source_study_version.i_participant_set) | [
"def set_full_accession(self):\n return self.DATASET_ACCESSION.format(\n self.i_accession, self.i_version, self.source_study_version.i_participant_set)",
"def set_full_accession(self):\n return self.STUDY_VERSION_ACCESSION.format(self.study.phs, self.i_version, self.i_participant_set)",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Automatically set dbgap_link from dbGaP identifier information. | def set_dbgap_link(self):
return self.VARIABLE_URL.format(
self.source_dataset.source_study_version.full_accession, self.i_dbgap_variable_accession) | [
"def fpga_link_id(self):",
"def set_dbgap_link(self):\n return self.DATASET_URL.format(self.source_study_version.full_accession, self.i_accession)",
"def update_gpdbid_file(array):\n \n standby_datadir = os.path.normpath(array.standbyMaster.getSegmentDataDirectory())\n\n # MPP-13245, use single ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the absolute URL of the detail page for a given SourceTrait instance. | def get_absolute_url(self):
return reverse('trait_browser:source:traits:detail', kwargs={'pk': self.pk}) | [
"def detail_url(self):\n return self._detail_url",
"def get_absolute_url(self):\n return reverse('trait_browser:source:studies:pk:detail', kwargs={'pk': self.pk})",
"def get_absolute_url(self):\n return reverse('trait_browser:harmonized:traits:detail', kwargs={'pk': self.pk})",
"def get_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return queryset of archived tags linked to this trait. | def archived_tags(self):
archived_tagged_traits = apps.get_model('tags', 'TaggedTrait').objects.archived().filter(trait=self)
return apps.get_model('tags', 'Tag').objects.filter(
pk__in=archived_tagged_traits.values_list('tag__pk', flat=True)) | [
"def non_archived_tags(self):\n non_archived_tagged_traits = apps.get_model('tags', 'TaggedTrait').objects.non_archived().filter(trait=self)\n return apps.get_model('tags', 'Tag').objects.filter(\n pk__in=non_archived_tagged_traits.values_list('tag__pk', flat=True))",
"def get_archived_ta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return queryset of nonarchived tags linked to this trait. | def non_archived_tags(self):
non_archived_tagged_traits = apps.get_model('tags', 'TaggedTrait').objects.non_archived().filter(trait=self)
return apps.get_model('tags', 'Tag').objects.filter(
pk__in=non_archived_tagged_traits.values_list('tag__pk', flat=True)) | [
"def get_non_archived_tagged_traits(self):\n return apps.get_model('tags', 'TaggedTrait').objects.current().non_archived().filter(\n trait__source_dataset__source_study_version__study=self)",
"def archived_tags(self):\n archived_tagged_traits = apps.get_model('tags', 'TaggedTrait').object... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get html for the trait name linked to the trait's detail page, with description as popover. | def get_name_link_html(self, max_popover_words=80):
if not self.i_description:
description = '—'
else:
description = Truncator(self.i_description).words(max_popover_words)
return POPOVER_URL_HTML.format(url=self.get_absolute_url(), popover=description,
... | [
"def get_name_link_html(self, max_popover_words=80):\n url_text = \"{{% url 'trait_browser:harmonized:traits:detail' pk={} %}} \".format(\n self.harmonized_trait_set_version.pk)\n if not self.i_description:\n description = '—'\n else:\n description = Trunc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the most recent version of a trait. | def get_latest_version(self):
current_study_version = self.source_dataset.source_study_version.study.get_latest_version()
if current_study_version is None:
return None
# Find the same trait associated with the current study version.
try:
current_trait = SourceTrai... | [
"def latest_version(self):\r\n return self.versions.get(latest=True)",
"def latest_version(self):\n return self._latest_version",
"def latest_version(self):\n from leonardo_system.pip import check_versions\n return check_versions(True).get(self.name, None).get('new', None)",
"def L... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the version of this SourceTrait from the previous study version. | def get_previous_version(self):
previous_study_version = self.source_dataset.source_study_version.get_previous_version()
if previous_study_version is not None:
try:
previous_trait = SourceTrait.objects.get(
source_dataset__source_study_version=previous_stu... | [
"def get_latest_version(self):\n current_study_version = self.source_dataset.source_study_version.study.get_latest_version()\n if current_study_version is None:\n return None\n # Find the same trait associated with the current study version.\n try:\n current_trait =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply tags from the previous version of this SourceTrait to this version. | def apply_previous_tags(self, creator):
TaggedTrait = apps.get_model('tags', 'TaggedTrait')
DCCReview = apps.get_model('tags', 'DCCReview')
StudyResponse = apps.get_model('tags', 'StudyResponse')
previous_trait = self.get_previous_version()
if previous_trait is not None:
... | [
"def apply_previous_tags(self, user):\n previous_study_version = self.get_previous_version()\n if previous_study_version is not None:\n SourceTrait = apps.get_model('trait_browser', 'SourceTrait')\n TaggedTrait = apps.get_model('tags', 'TaggedTrait')\n DCCReview = apps... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Custom save method for making the trait flavor name. Automatically sets the value for the harmonized trait's trait_flavor_name. | def save(self, *args, **kwargs):
self.trait_flavor_name = self.set_trait_flavor_name()
# Call the "real" save method.
super(HarmonizedTrait, self).save(*args, **kwargs) | [
"def set_trait_flavor_name(self):\n return '{}_{}'.format(self.i_trait_name, self.harmonized_trait_set_version.harmonized_trait_set.i_flavor)",
"def save(self, *args, **kwargs):\n self.name = unique_slugify(\n self.name,\n instance=self,\n queryset=AccountTeam.object... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Automatically set trait_flavor_name from the trait's i_trait_name and the trait set's flavor name. Properly format the trait_flavor_name for this harmonized trait so that it's available for easy use later. | def set_trait_flavor_name(self):
return '{}_{}'.format(self.i_trait_name, self.harmonized_trait_set_version.harmonized_trait_set.i_flavor) | [
"def save(self, *args, **kwargs):\n self.trait_flavor_name = self.set_trait_flavor_name()\n # Call the \"real\" save method.\n super(HarmonizedTrait, self).save(*args, **kwargs)",
"def get_trait_names(self):\n return self.harmonizedtrait_set.values_list('trait_flavor_name', flat=True)"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get html for the trait name linked to the harmonized trait's detail page, with description as popover. | def get_name_link_html(self, max_popover_words=80):
url_text = "{{% url 'trait_browser:harmonized:traits:detail' pk={} %}} ".format(
self.harmonized_trait_set_version.pk)
if not self.i_description:
description = '—'
else:
description = Truncator(self.i_d... | [
"def get_name_link_html(self, max_popover_words=80):\n if not self.i_description:\n description = '—'\n else:\n description = Truncator(self.i_description).words(max_popover_words)\n return POPOVER_URL_HTML.format(url=self.get_absolute_url(), popover=description,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get html for inline lists of source and harmonized component phenotypes for the harmonized trait. | def get_component_html(self, harmonization_unit):
source = [tr.get_name_link_html() for tr in (
self.component_source_traits.all() & harmonization_unit.component_source_traits.all())]
harmonized_trait_set_versions = [trait_set_version for trait_set_version in (
self.component_har... | [
"def get_component_html(self):\n study_list = '\\n'.join([study.get_name_link_html() for study in self.get_source_studies()])\n age_list = '\\n'.join([trait.get_name_link_html() for trait in self.component_age_traits.all()])\n component_html = '\\n'.join([\n trait.get_component_html(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pretty printing of HarmonizedTraitEncodedValue objects. | def __str__(self):
return 'encoded value {} for {}\nvalue = {}'.format(self.i_category, self.harmonized_trait, self.i_value) | [
"def pprint(self):\n\t\tPrettyPrintUnicode().pprint(self.data)",
"def pprint(self):\n\n classifiers = []\n for n in xrange(len(self._final)):\n values = []\n for (name, val) in self._final[n]:\n if val > 0:\n pval = 'Yes'\n else:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
generate images using the latest saved check points and the images will be saved in 'save_path/images/' | def generate_image(noise_list, save_path):
check_points_path = os.path.join(save_path, 'check_points')
output_image_path = os.path.join(save_path, 'images')
components.create_folder(output_image_path, False)
latest_checkpoint = tf.train.latest_checkpoint(check_points_path)
assert... | [
"def save_img(self):\r\n self.extract_info_from_file()\r\n path_0 = os.path.join(self.output_path, self.field_id, self.patient_id + self.ext)\r\n path_1 = os.path.join(self.output_path, self.field_id + '_' + self.instance, self.patient_id + self.ext)\r\n if self.shot == '0': # first sho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build personalization instance from a dict | def create_personalization(self, **kwargs):
personalization = Personalization()
_diff = set(emailconf.PERSONALIZATION_KEYS).intersection(set(kwargs.keys()))
if _diff:
for key in _diff:
item = kwargs.get(key)
if item:
if key in email... | [
"def from_dict(d: Dict[str, Any]) -> \"Provider\":\n return Provider(\n name=d[\"name\"],\n description=d.get(\"description\"),\n roles=d.get(\n \"roles\",\n ),\n url=d.get(\"url\"),\n extra_fields={\n k: v\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of all Server Emojis | async def emojis(self, ctx):
server = ctx.message.server
await self.bot.say('This may take some time, generating list...')
data = discord.Embed(description="Emojilist")
for ej in server.emojis:
data.add_field(
name=ej.name, value=str(ej) + " " + ej.id, inline=... | [
"async def emojis(self, ctx):\r\n\r\n if not ctx.guild.emojis:\r\n return await ctx.send(\"This server doesn't have any custom emojis. :'(\")\r\n\r\n emojis = map('{0} = {0.name} ({0.id})'.format, ctx.guild.emojis)\r\n pages = ListPaginator(ctx, emojis, title=f'Emojis in {ctx.guild}'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Coinflip, defaults to Kopf/Zahl if no players are given | async def coinflip(self, ctx, player1=None, *, player2=None):
rng = randint(1, 10)
if player1 is None and player2 is None:
if rng < 5:
return await self.bot.say("Kopf gewinnt!")
else:
return await self.bot.say("Zahl gewinnt!")
else:
... | [
"def flip_a_coin():\n coin_flip = random.randint(0,1)\n return coin_flip",
"async def coinflip(self, ctx: commands.Context):\n await ctx.send(M.coinflip.heads if random.randint(0, 1) else M.coinflip.tails)",
"async def flipcoin(self, ctx):\n flip = random.choice([True, False])\n if fl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create roles to each channel that begins with "übungsgruppe and set permissions | async def createroles(self, ctx):
server = ctx.message.server
author = ctx.message.author
all_channels = server.channels
all_roles = []
group_channels = []
# Collect already available roles
for role in server.roles:
all_roles.append(role.name)
... | [
"async def _set_roles(self, ctx: Context):\n\n guild: discord.Guild = ctx.guild\n\n host = await guild.create_role(\n name=\"Host\", colour=discord.Color(0xFFBF37),\n hoist=True, mentionable=True\n )\n await self.config.guild(guild).host_id.set(host.id)\n awa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Moves all clients randomly in other channels for duration seconds. After the whirpool event, all clients will be in the same channel as before. Between the whirlpool cycles, the programm will sleep for relax_time seconds. | def whirlpool(ts3conn, duration=10, relax_time=0.5):
# Countdown till whirlpool
for i in range(5, 0, -1):
ts3conn.sendtextmessage(
targetmode=ts3.definitions.TextMessageTargetMode.SERVER,
target=0, msg="Whirpool in {}s".format(i))
time.sleep(1)
# Fetch the clientlist... | [
"def rewire_rand(self):\n start = time.time()\n while len(self.rand_queue) > 0 and time.time() - start < self.t_rand:\n xqueue = self.rand_queue.pop()\n nearby = self.find_nodes_near(xqueue)\n for xnear in nearby:\n if self.cost(xqueue) + self.euclidean_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts all seat strings into seat IDs and returns the highest seat ID found. | def highest_seat_id(raw_seat_string):
seat_list = raw_seat_string.split('\n')
return max(list(map(find_seat, seat_list))) | [
"def highest_seat_id(seat_list):\n highest_id = 0\n for seat_id in seat_list:\n if highest_id < seat_id:\n highest_id = seat_id\n\n return highest_id",
"def get_highest_seat_id(seat_ids):\n\n return max(seat_ids)",
"def seat_id_calc(seat_id_string):\n seat_id = 0\n row_id = 0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
All seats start out empty | def __init__(self):
self.empty_seats = [row * 8 + col for row in self.rows for col in self.cols] | [
"def clear_rooms(self) -> None:\n for room in self.grid.rooms_list:\n for seat in room.seats:\n seat.available = True",
"def empty_seats(seats, seat_numbers):\n\n for seat in seat_numbers:\n seats[seat] = None\n\n return seats",
"def assign_seats(self):\n # C... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Each time a passenger is seated, the seat_id is removed from the empty seats list | def seat_passenger(self, seat_id):
self.empty_seats.remove(seat_id) | [
"def empty_seats(seats, seat_numbers):\n\n for seat in seat_numbers:\n seats[seat] = None\n\n return seats",
"def remove_player(self, seat_id):\n player_id = seat_id\n try:\n idx = self._seats.index(self._player_dict[player_id])\n self._seats[idx] = Player(0, stack=0, emptyplayer=True... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Puts the skips in sequential cut | def put_skips_in_seq_cut(self):
# first, put skips when in some cut there is an ending activity
in_end_act = set(self.initial_end_activities)
i = 0
while i < len(self.children) - 1:
activities_set = set(self.children[i].activities)
intersection = activities_set.in... | [
"def _calc_skips(self, heatmap, num_lines):\n if num_lines < self.MIN_SKIP_SIZE:\n return []\n skips, prev_line = [], 0\n for line in sorted(heatmap):\n curr_skip = line - prev_line - 1\n if curr_skip > self.SKIP_LINES:\n skips.append((prev_line, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Start the monitoring loop for the downloads. | def start(self):
self._logger.info("Starting download monitor (interval: %d seconds)" % self.interval)
self.monitor_lc = ensure_future(looping_call(0, self.interval, self.monitor_downloads)) | [
"def run(self):\n self.monitor.start()",
"def _monitor(self) -> None:\r\n while not self._shut_down:\r\n _logger.info(f\"{self._pending_download.qsize()} downloads pending, \"\r\n f\"{self._current_downloads} downloads in progress, \"\r\n f\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the cooldown is ready. | def ready(self):
return self.time >= self.cooldown | [
"def is_on_cooldown(self):\n return self.cooldown_release is not None",
"def in_cooldown(self) -> bool:\n return self.cooldown_counter > 0",
"def check_cooldown(self):\n\n if self.cooldown <= 0:\n self.cooldown = 0\n return True\n return False",
"def is_ready(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get api_key in metadata, raise error if does not exist | def get_api_key(context) -> str:
provided_api_key = ""
for key, value in context.invocation_metadata():
if key == "api_key":
provided_api_key = str(value)
return provided_api_key
return provided_api_key | [
"def get_api_key(api_key):\n api.get(api_key)",
"def resolve_apikey(self):\n # check the instance variable\n apikey = self.apikey\n if apikey is not None:\n return apikey\n\n # check the class variable and environment\n apikey = resolve_apikey()\n if apikey ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update prefix with operator with best price. | def _update_prefix(self, prefix: str, operator: Operator):
cached_operator: Optional[Operator] = self.lookup(prefix)
if cached_operator:
cached_price = cached_operator.price_for_prefix(prefix)
if cached_price:
if operator.has_better_price_for_prefix(prefix, cached... | [
"def update_with_operator(self, operator: Operator):\n if not isinstance(operator, Operator):\n raise TypeError(\n f\"operator expected to be of type `Operator` but got type \"\n f\"{type(operator)}\"\n )\n\n for prefix in operator.rates.keys():\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates `PrefixCache` with data from given operator. | def update_with_operator(self, operator: Operator):
if not isinstance(operator, Operator):
raise TypeError(
f"operator expected to be of type `Operator` but got type "
f"{type(operator)}"
)
for prefix in operator.rates.keys():
self._up... | [
"def _update_prefix(self, prefix: str, operator: Operator):\n cached_operator: Optional[Operator] = self.lookup(prefix)\n if cached_operator:\n cached_price = cached_operator.price_for_prefix(prefix)\n if cached_price:\n if operator.has_better_price_for_prefix(pref... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a prefix, returns operator with best price in `PrefixCache` | def lookup(self, prefix: str) -> Optional[Operator]:
return self.data.get(prefix, None) # noqa | [
"def _update_prefix(self, prefix: str, operator: Operator):\n cached_operator: Optional[Operator] = self.lookup(prefix)\n if cached_operator:\n cached_price = cached_operator.price_for_prefix(prefix)\n if cached_price:\n if operator.has_better_price_for_prefix(pref... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
map given prefix to operator, overwriting exsisting cache for prefix entry. | def add_prefix(self, prefix: str, operator: Operator):
if not isinstance(operator, Operator):
raise TypeError(
f"`operator` expected to be of type `str` but got type "
f"`{type(operator)}`"
)
if not isinstance(prefix, str):
raise TypeE... | [
"def _update_prefix(self, prefix: str, operator: Operator):\n cached_operator: Optional[Operator] = self.lookup(prefix)\n if cached_operator:\n cached_price = cached_operator.price_for_prefix(prefix)\n if cached_price:\n if operator.has_better_price_for_prefix(pref... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return prefix for `phone_number`. Use `lookup` to fetch operator. | def find_prefix(self, phone_number: str) -> Optional[str]:
if not isinstance(phone_number, str):
raise TypeError(
f"`phone_number` expected to be of type `str` "
f"but got type `{type(phone_number)}`"
)
if not phone_number.isdigit():
r... | [
"def lookup_prefix(digits: str) -> int:\n return lookup_company_prefix(digits)",
"def strip_phone_prefix(self, phone_num):\n # FIXME more accurate check\n if phone_num.startswith('+86'):\n return phone_num.replace('+86', '')\n if len(phone_num) != 11:\n return Non... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build a `PrefixCache` from a tuple of `Operators`. | def build_cache(klass: "PrefixCache", operators: Tuple[Operator, ...]) -> "PrefixCache":
prefix_cache = klass()
for operator in operators:
prefix_cache.update_with_operator(operator)
return prefix_cache | [
"def declare_operators(*op_list):\n operators.update({op.__name__:op for op in op_list})\n return operators",
"def build_mutations(ops, to_ops):\n # note: mutations to self are excluded.\n # None is a special mutation meaning to delete the operator!\n # 1) when to_op is None isinstance(from_op, Non... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Plots the latest COVID19 status of the country if name is not given then it plots the top10 | def plot(self, context=None):
response = requests.get(self.url).content
table = pd.read_html(response, attrs={"id": "main_table_countries_today"})
df = table[0].fillna(0)
# df.drop(df.index[0], inplace=True) # World
df.drop(["ActiveCases", 'Serious,Critical', 'Serious,Critical'... | [
"def visualize(country_names):\n countries_array = modified_data()\n current_countries = []\n if type(country_names) != list:\n country_names = [country_names]\n for country in countries_array:\n for country_name in country_names:\n if country_name == country.country_name:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create the luis api query url from a csv. Requires the csv to contain the endpoint url, app id and primary key | def get_luis_url(folder: WindowsPath = None) -> str:
if folder is None:
folder = Path.cwd().joinpath('CONFIG')
path = folder.joinpath('luis_keys.csv')
df = pd.read_csv(path, index_col='key')
endpoint = df.loc['endpoint', 'value']
app_id = df.loc['app_id', 'value']
prim... | [
"def _prepare_query(self, endpoints, options=\"\"):\r\n if self._key == \"Batch\" :\r\n endpoints = ','.join(endpoints)\r\n symbols = ','.join(self.symbolList)\r\n url = (\"{0}{1}?symbols={2}&types={3}&{4}\".format(self._IEX_API_URL, self.IEX_ENDPOINT_NAME, symbols, endpoints... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends student comments to the LUIS.ai API in batches and saves the intemediate results into the OUTPUT folder | def request_api(
student_comments: pd.Series,
url: str,
chunk_size: int = 50
) -> pd.Series:
for i, chunk in enumerate(chunks(student_comments, chunk_size)):
print(f'Processing batch {i} of size {len(chunk)}')
response = chunk.apply(lambda x: ... | [
"def main():\r\n \r\n data_dir = Path.cwd().joinpath('OUTPUT')\r\n config_dir = Path.cwd().joinpath('CONFIG')\r\n \r\n # Load deduplicated comments\r\n data = utils.load(data_dir, 'student_comment_deduplicated')\r\n \r\n # Get the luis API url\r\n with open(config_dir.joinpath('luis_url.t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merging the results from the luis response with the lemmatised comments. | def merge_comments(df1: pd.DataFrame, df2: pd.DataFrame, out_dir: str) -> pd.DataFrame:
nlp = spacy.load('en_core_web_lg')
df1 = pd.DataFrame(load_pickles(out_dir))
df1.columns = ['response']
df1['student_comment_apostrophe'] = df1.response.apply(lambda x: x['query'] if x is not None else No... | [
"def get_results(self, request):\n super(ModeratorChangeList, self).get_results(request)\n comment_ids = []\n object_pks = []\n\n results = list(self.result_list)\n for obj in results:\n comment_ids.append(obj.id)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract the element, e.g. topScoringIntent, from the LUIS.api json response s the pd.Series of the unravelled json response element the elements, such as "sentiment" or "intent" | def get_luis_element(s: pd.Series, element: str) -> pd.Series:
result = 0
if element == 'intent':
result = s.apply(lambda x: x['topScoringIntent']['intent'])
elif element == 'entities':
result = s.apply(lambda x: x['entities'])
elif element == 'sentiment':
valence = s.appl... | [
"def extractSentimentFromUrl(self,url):\n \n #creating AlchemyAPI object\n alchemyapi = AlchemyAPI()\n \n #requesting json response from AlchemyAPI server\n response = alchemyapi.sentiment('url', url)\n \n if response['status'] == 'OK':\n \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load the deduplicated comments Get the luis url Call the API in batches Aggregate the batched pickled files with 'luis_result' in the filename, Extract the top scoring intent, entities and the sentiment of each row Save each of the three series as separate pickle files | def main():
data_dir = Path.cwd().joinpath('OUTPUT')
config_dir = Path.cwd().joinpath('CONFIG')
# Load deduplicated comments
data = utils.load(data_dir, 'student_comment_deduplicated')
# Get the luis API url
with open(config_dir.joinpath('luis_url.txt'), 'r') as f:
... | [
"def request_api(\r\n student_comments: pd.Series, \r\n url: str, \r\n chunk_size: int = 50\r\n ) -> pd.Series:\r\n \r\n for i, chunk in enumerate(chunks(student_comments, chunk_size)):\r\n print(f'Processing batch {i} of size {len(chunk)}')\r\n \r\n response =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create table from csv file to input into database. | def create_table(engine, csv_filename, tablename):
# Read csv file and changes all column names to be lowercase
csv_df = pd.read_csv(f'./data/{csv_filename}.csv')
csv_df.columns = [c.lower() for c in csv_df.columns]
# Change date types to datetime
todateformat = []
for c in csv_df.columns:
... | [
"def populate_table_from_csv(csv_file, csv_encoding='iso-8859-15'):\n try:\n with open(file=csv_file, mode='r', encoding=csv_encoding) as input_file:\n # Could find a good place to add iterators/generators/comprehensions elsewhere, so made a new function\n # Also, yet another pylint ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns args including etcd endpoint and certificates if necessary. As dcosetcdctl and etcdctl share the same arguments, such as endpoints, ever considering the certificates involved, we group these arguments to generate the basic items to execute either etcdctl or dcosetcdctl | def get_etcdctl_with_base_args(
cert_type: str = "root",
endpoint_ip: str = LOCAL_ETCD_ENDPOINT_IP,
) -> List[str]:
return [ETCDCTL_PATH, "--endpoints=http://{}:2379".format(endpoint_ip)] | [
"def process_cli_args(args):\n\n if not args.server:\n print(\"Using vcenter server specified in testbed.py\")\n args.server = testbed.config['SERVER']\n if not args.server:\n raise Exception(\"vcenter server is required\")\n print(\"vcenter server = {}\".format(args.server))\n\n if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
assigns the value to the key. etcd is not exposed outside of the DC/OS cluster,so we have to execute etcdctl inside the DC/OS cluster, on a master in our case. | def put(self, key: str, value: str) -> None:
master = list(self.masters)[0]
etcdctl_with_args = get_etcdctl_with_base_args(endpoint_ip=MASTER_DNS)
etcdctl_with_args += ["put", key, value]
master.run(args=etcdctl_with_args, output=Output.LOG_AND_CAPTURE) | [
"def consul_set(self, key, value):\n self.consul.kv.put(join(self.consul_prefix, key), value)",
"def set(self, key, value):",
"def setK(self, client_name, key, value):\n\t\tclient_current_data = {}\n\t\ttry:\n\t\t\tclient_current_data = json.loads(self.redis_server.hget('clients', client_name))\n\t\texce... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
gets the value of the key on given master node | def get_key_from_node(
self,
key: str,
master_node: Node,
) -> str:
etcdctl_with_args = get_etcdctl_with_base_args(
endpoint_ip=str(master_node.private_ip_address))
etcdctl_with_args += ["get", key, "--print-value-only"]
result = master_node.ru... | [
"def get(self, key):\r\n res = self.nodeMap.get(key, [-1, 0])[0]\r\n if res != -1:\r\n self.put(key, res)\r\n return res",
"def get_node(self, key):\n url = self.sharding.get_node(key)\n return self.mapping.get(url)",
"def consul_get(self, key):\n _, data = s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Separate train or validation annotations to single video annotation. | def separate_annotations():
data_root = '/home/ubuntu/datasets/YT-VIS/'
ann_file = data_root + 'annotations/instances_train_sub.json'
import json
with open(ann_file, 'r') as f:
ann = json.load(f)
# ann['videos'] = ann['videos'][15]
# video_id = [0]
from tqdm import tqdm
... | [
"def demo(videos, annots, trk_results, isMotformat):\n video_id = 0\n for video, annot in zip(videos, annots):\n video_name = basename(video)\n if basename(annot).find(video_name) == -1:\n raise Exception(\"No corresding video and annotation!\")\n\n if video_name != \"person14_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Preprocess requests by attempting to extract face image, and transforming to fit the model's input Returns list of NDArray Processed images in the model's expected input shape | def preprocess(self, request):
img_list = []
input_shape = self.signature['inputs'][0]['data_shape']
[height, width] = input_shape[2:]
param_name = self.signature['inputs'][0]['data_name']
# Iterate over all input images provided with the request, transform and append for infere... | [
"def preprocess_image(self, batched_inputs):\n images = [x.to(self.device) for x in batched_inputs]\n norms = [self.normalizer(x) for x in images]\n size = (norms[0].shape[1],norms[0].shape[2])\n images = ImageList.from_tensors(norms, self.backbone.size_divisibility)\n return imag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |