Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Here is a snippet: <|code_start|> 'type': 'cppdbg', 'request': 'launch', 'program': path, 'args': [], 'stopAtEntry': stop_at_entry[1], 'cwd': cwd, 'MIMod...
for verb_name, verb_mod in verb.verbs.items() :
Predict the next line after this snippet: <|code_start|> log.info(' writing {}'.format(ws_path)) with open(ws_path, 'w') as f: json.dump(ws, f, indent=1, separators=(',',':')) #------------------------------------------------------------------------------- def remove_vscode_tasks_launch_files(fips_dir,...
success, impex = dep.get_all_imports_exports(fips_dir, proj_dir)
Given snippet: <|code_start|> # dictionary of "name: module" verbs = {} # dictionary of "projname: name" proj_verbs = OrderedDict() #------------------------------------------------------------------------------- def import_verbs_from(proj_name, proj_dir, verb_dir) : """import all verb modules from a directory, ...
spec = importlib.util.spec_from_file_location(verb_module_name, verb_path)
Given the following code snippet before the placeholder: <|code_start|> verb_module_name = os.path.split(verb_path)[1] verb_module_name = os.path.splitext(verb_module_name)[0] if not verb_module_name.startswith('__') : if is_python3: ...
_, imported_projs = dep.get_all_imports_exports(fips_dir, proj_dir)
Continue the code snippet: <|code_start|> os.makedirs(get_sdkroot_dir(fips_dir)) #------------------------------------------------------------------------------- def get_emsdk_dir(fips_dir): return get_sdkroot_dir(fips_dir) + '/emsdk' #-----------------------------------------------------------------------...
log.error("emsdk script not found at '{}', please run './fips emsdk install'".format(get_emsdk_path(fips_dir)))
Predict the next line for this snippet: <|code_start|> Backend code for the new 'emsdk' verb. This provides a more flexible wrapper for the emsdk emscripten SDK installer. Changes to the previous approach: - emsdk is installed via git - things like updating or switching SDK versions work b...
return util.get_workspace_dir(fips_dir) + '/fips-sdks'
Here is a snippet: <|code_start|>def get_emsdk_path(fips_dir): emsdk_script = 'emsdk.bat' if util.get_host_platform() == 'win' else 'emsdk' emsdk_path = get_emsdk_dir(fips_dir) + '/' + emsdk_script return emsdk_path #------------------------------------------------------------------------------- def check_...
return git.update_force_and_ignore_local_changes(emsdk_dir)
Given the following code snippet before the placeholder: <|code_start|>"""helper verb for CLion support clion clean -- removes all .idea directories in all dependencies """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : if not util.is_valid...
log.error('must be run in a project directory')
Next line prediction: <|code_start|>"""helper verb for CLion support clion clean -- removes all .idea directories in all dependencies """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : if not util.is_valid_project_dir(proj_dir) : lo...
clion.cleanup(fips_dir, proj_dir)
Based on the snippet: <|code_start|>"""implement 'make' verb (builds a single target) make make [target] make [target] [config] """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : """build a single target""" if not util.is_valid_project_dir...
log.error('must be run in a project directory')
Based on the snippet: <|code_start|>"""implement 'make' verb (builds a single target) make make [target] make [target] [config] """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : """build a single target""" <|code_end|> , predict the immediate...
if not util.is_valid_project_dir(proj_dir) :
Here is a snippet: <|code_start|>"""implement 'make' verb (builds a single target) make make [target] make [target] [config] """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : """build a single target""" if not util.is_valid_project_dir(pr...
cfg_name = settings.get(proj_dir, 'config')
Predict the next line after this snippet: <|code_start|>"""implement 'make' verb (builds a single target) make make [target] make [target] [config] """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : """build a single target""" if not util....
project.make_clean(fips_dir, proj_dir, cfg_name)
Predict the next line for this snippet: <|code_start|> value = None settings = load(proj_dir) if key in settings : value = settings[key] if value is None : value = get_default(key) return value #------------------------------------------------------------------------------- def set...
log.info("'{}' set to '{}' in project '{}'".format(key, value_str, proj_name))
Continue the code snippet: <|code_start|>"""project-specific settings""" valid_settings = ['config', 'target', 'jobs', 'ccache', 'iosteam', 'vscode-launch-configs'] default_settings = { 'config': config.get_default_config(), 'target': None, <|code_end|> . Use current file imports: import yaml import os...
'jobs': util.get_num_cpucores() + 2,
Given snippet: <|code_start|> target_cwd = None dic = load_fips_yml(proj_dir) if 'run' in dic : if target in dic['run'] : if 'cwd' in dic['run'][target] : target_cwd = proj_dir + '/' + dic['run'][target]['cwd'] return target_cwd #--------------------------------------...
log.error("'{}' is not a valid project directory".format(proj_dir))
Using the snippet: <|code_start|>'''CLion helper functions''' name = 'clion' platforms = ['osx','linux','win'] optional = True not_found = 'used as IDE with clion configs' #------------------------------------------------------------------------------ def check_exists(fips_dir) : """test if 'clion' is in the path...
host = util.get_host_platform()
Given snippet: <|code_start|> # or added to the path using the "create launcher" command in CLion, which would by default # create a symlink from clion.sh to /usr/local/bin/clion. # This will also pick up CLion if it was installed using snap. if find_executable("clion.sh") is not None or ...
log.error("Failed to run JetBrains CLion as 'clion' or 'clion.sh'")
Here is a snippet: <|code_start|>""" wrapper for node's http-server module, this is preferred over python's SimpleHTTPServer module because it supports HTTP range requests """ name = 'http-server' platforms = ['osx', 'linux', 'win'] optional = True not_found = "required for running emscripten targets (npm...
log.error("http-server tool not found (npm install http-server -g)")
Predict the next line for this snippet: <|code_start|>""" wrapper for node's http-server module, this is preferred over python's SimpleHTTPServer module because it supports HTTP range requests """ name = 'http-server' platforms = ['osx', 'linux', 'win'] optional = True not_found = "required for running em...
if util.get_host_platform() == 'osx' :
Given snippet: <|code_start|> urls = { 'linux': 'https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-14/wasi-sdk-14.0-linux.tar.gz', 'osx': 'https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-14/wasi-sdk-14.0-macos.tar.gz', 'win': 'https://github.com/WebAssembly/wasi-sdk/r...
log.colored(log.YELLOW, '=== installing WASI SDK:')
Here is a snippet: <|code_start|>""" Manage the wasisdk. """ if sys.version_info[0] >= 3: else: dir_name = 'wasi-sdk-14.0' urls = { 'linux': 'https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-14/wasi-sdk-14.0-linux.tar.gz', 'osx': 'https://github.com/WebAssembly/wasi-sdk/releases/down...
return util.get_workspace_dir(fips_dir) + '/fips-sdks/wasisdk'
Predict the next line after this snippet: <|code_start|>"""implements the cache verb Opens the CMakeCache.txt in a text editor for a given config cache cache [config-name] """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : if not util.is...
log.error('must be run in a project directory')
Continue the code snippet: <|code_start|>"""implements the cache verb Opens the CMakeCache.txt in a text editor for a given config cache cache [config-name] """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : <|code_end|> . Use current file i...
if not util.is_valid_project_dir(proj_dir) :
Predict the next line after this snippet: <|code_start|>"""implements the cache verb Opens the CMakeCache.txt in a text editor for a given config cache cache [config-name] """ #------------------------------------------------------------------------------- def run(fips_dir, proj_dir, args) : if not util.is...
cfg_name = settings.get(proj_dir, 'config')
Given the code snippet: <|code_start|>"""wrapper for some git commands""" name = 'git' platforms = ['linux', 'osx', 'win'] optional = False not_found = "git not found in path, can't happen(?)" # default git clone depth clone_depth = 10 #-------------------------------------------------------------------------------...
log.error("git not found, please run and fix './fips diag tools'")
Continue the code snippet: <|code_start|>"""fips main module""" VERSION = '0.0.1' init() #------------------------------------------------------------------------------- def show_help(args) : """show help text""" if len(args) > 0 : # show help for one verb verb_name = args[0] if ver...
log.error("unknown verb '{}'".format(verb))
Continue the code snippet: <|code_start|>"""fips main module""" VERSION = '0.0.1' init() #------------------------------------------------------------------------------- def show_help(args) : """show help text""" if len(args) > 0 : # show help for one verb verb_name = args[0] <|code_end|> ....
if verb_name in verb.verbs :
Predict the next line after this snippet: <|code_start|>VERSION = '0.0.1' init() #------------------------------------------------------------------------------- def show_help(args) : """show help text""" if len(args) > 0 : # show help for one verb verb_name = args[0] if verb_name in...
fips_path = util.fix_path(fips_path)
Next line prediction: <|code_start|>#!/usr/bin/env python3 IGNORE_PET_NPCID = [ 185475, # Tezpet https://www.wowhead.com/npc=185475 125494, # SpeedyNumberIII https://www.wowhead.com/npc=125494 ] PET_SOURCE_ENUM = { 0: 'Drop', 1: 'Quest', 2: 'Vendor', 3: 'Profession', 4: 'Wild', ...
class PetFixer(WowToolsFixer):
Predict the next line for this snippet: <|code_start|> 'creatureId': int(creature_id), 'spellid': int(spell_id), **({'itemId': int(item_id)} if item_id else {}) } def get_pet_source(self, pet_id): return PET_SOURCE_ENUM.get( int(self.wt_battlepetspecie...
icat(self.battlepets, 'TODO', 'TODO')['items'].append(pet)
Next line prediction: <|code_start|> return { 'ID': int(pet_id), 'name': name, 'icon': icon_name, 'creatureId': int(creature_id), 'spellid': int(spell_id), **({'itemId': int(item_id)} if item_id else {}) } def get_pet_source(se...
changelog('Pet {} missing: https://www.wowhead.com/npc={}'
Next line prediction: <|code_start|>#!/usr/bin/env python3 class RealmFixer: def __init__(self, realms_eu, realms_us, build=None): self.realms_eu = realms_eu self.realms_us = realms_us def fix_realms(self, region): <|code_end|> . Use current file imports: (from .providers import wowgraphql...
master_list = wowgraphql.get_realm_list_sync(region)
Based on the snippet: <|code_start|> 1738, # Defender Illona 1739, # Vivianne 1740, # Aeda Brightdawn 1741, # Leorajh # Venthyr Ember Court 2446, # Baroness Vashj 2447, # Lady Moonberry 2448, # Mikanikos 2449, # The Countess 2450, # Alexandros Mograine 2451, # Hunt-...
res = find_or_create_item(dct, cat, 'factions')
Here is a snippet: <|code_start|> # visible. and not int(rep['ReputationFlags[0]']) & 0x2 ) ): return if not children: self.wt_faction[int(rep['ID'])] = rep for row in childre...
changelog(
Given snippet: <|code_start|> # Venthyr Ember Court 2446, # Baroness Vashj 2447, # Lady Moonberry 2448, # Mikanikos 2449, # The Countess 2450, # Alexandros Mograine 2451, # Hunt-Captain Korayn 2452, # Polemarch Adrestes 2453, # Rendle and Cudgelface 2454, # Choofa 24...
class FactionFixer(WowToolsFixer):
Here is a snippet: <|code_start|> 'icon': icon_name, 'spellid': int(spell_id), **({'itemId': item_id} if item_id else {}) } def get_mount_source(self, mount_id: int): return MOUNT_SOURCE_ENUM.get( int(self.wt_mount[mount_id]['SourceTypeEnum']), ...
icat(self.mounts, 'TODO', source)['items'].append(mount)
Given the following code snippet before the placeholder: <|code_start|> except KeyError: item_id = None return { 'ID': int(mount_id), 'name': name, 'icon': icon_name, 'spellid': int(spell_id), **({'itemId': item_id} if item_id else ...
changelog(
Predict the next line for this snippet: <|code_start|> 333, # Magic Rooster https://www.wowhead.com/mount/333 334, # Magic Rooster https://www.wowhead.com/mount/334 335, # Magic Rooster https://www.wowhead.com/mount/335 462, # White Riding Yak https://www.wowhead.com/mount/462 484, # Black ...
class MountFixer(WowToolsFixer):
Based on the snippet: <|code_start|> class WowToolsFixer: """Base class for Wowtools-based data fixers.""" load_files = False def __init__(self, *args, build=None): self.build = build self._store_init(*args) if self.load_files: self.wt_files = { int(e['I...
return wowtools.get_table(table_name, self.build)
Given the code snippet: <|code_start|> IGNORE_TOY_ITEMID = [ 88587, 110586, 119220, 119221, 129111, 130249, 141300, 143545, 166851, 174445, 183810, ] TOY_SOURCE_ENUM = { 0: 'Drop', 1: 'Quest', 2: 'Vendor', 3: 'Profession', 4: 'NPC', 5: 'Achievement'...
class ToyFixer(WowToolsFixer):
Given the following code snippet before the placeholder: <|code_start|> def get_toy(self, toy_id): toy_id = str(toy_id) # Name if toy_id not in self.wt_itemsparse: return None name = self.wt_itemsparse[toy_id]['Display_lang'] # Icon icon_id = self.wt_ite...
changelog('Toy {} missing: https://www.wowhead.com/item={}'
Based on the snippet: <|code_start|> # Name if toy_id not in self.wt_itemsparse: return None name = self.wt_itemsparse[toy_id]['Display_lang'] # Icon icon_id = self.wt_item[toy_id]['IconFileDataID'] icon_name = self.get_icon_name(int(icon_id)) return ...
icat(self.toys, 'TODO', source)['items'].append(toy)
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python3 IGNORE_ACHIEV_ID = [ 7268, 7269, 7270, ] <|code_end|> with the help of current file imports: import collections from .fixer import WowToolsFixer from .tools import (changelog, genid, filter_del, sort_try_respect_order, ...
class AchievementFixer(WowToolsFixer):
Continue the code snippet: <|code_start|> 0: 'H', 1: 'A', }.get(int(wt_ach['Faction'])) def genach(self, ach_id): ach_id = int(ach_id) if ach_id in self.id_to_sa_ach: return self.id_to_sa_ach[ach_id] else: wt_ach = self.wt_achiev[ach_id...
changelog("* Deleted removed achievements: {}"
Given the code snippet: <|code_start|> if deleted_supcats: changelog("* Deleted super-categories:\n{}" .format('\n'.join(deleted_supcats))) def fix_moved_subcategories(self): for supercat in self.achievs['supercats']: for cat in supercat['cats']: ...
'id': genid(),
Next line prediction: <|code_start|> for item in subcat['items']: self.id_to_sa_ach[int(item['id'])] = item def get_faction(self, ach_id: int): wt_ach = self.wt_achiev[int(ach_id)] return { 0: 'H', 1: 'A', }.get(int(wt_ach['...
subcat['items'] = filter_del(
Based on the snippet: <|code_start|> faction)) if faction is not None: item['side'] = faction else: item.pop('side', '') def fix_types_data(self): ...
sort_try_respect_order(
Here is a snippet: <|code_start|> lambda item: ' - {}'.format(item['name']) ) if deleted_supcats: changelog("* Deleted super-categories:\n{}" .format('\n'.join(deleted_supcats))) def fix_moved_subcategories(self): for supercat in self.achievs['s...
(iscat(self.achievs, *path)
Here is a snippet: <|code_start|> for cat in supercat['cats']: for subcat in cat['subcats']: for item in subcat['items']: ach_id = int(item['id']) wt_ach = self.wt_achiev[ach_id] item['id'] = int(ach_i...
wt_supercat = list_find(
Here is a snippet: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Utility functions for Error Reporting...
return HTTPContext(
Next line prediction: <|code_start|> # Save the credentials. self._credentials = credentials def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.list_group_stats: gapic_v1.method.wrap_method( self...
[error_stats_service.ListGroupStatsRequest],
Using the snippet: <|code_start|> - Inside the requested time interval - Non-overlapping, and - Ordered by ascending time. first_seen_time (google.protobuf.timestamp_pb2.Timestamp): Approximate first occurrence that was ever seen for this group and whic...
group = proto.Field(proto.MESSAGE, number=1, message=common.ErrorGroup,)
Next line prediction: <|code_start|> credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. self._credentials = credentials def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { ...
Union[common.ErrorGroup, Awaitable[common.ErrorGroup]],
Given the following code snippet before the placeholder: <|code_start|> ): credentials = credentials.with_always_use_jwt_access(True) # Save the credentials. self._credentials = credentials def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. ...
[error_group_service.GetGroupRequest],
Given the following code snippet before the placeholder: <|code_start|> channel creation. Returns: grpc.Channel: A gRPC channel object. Raises: google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are p...
[report_errors_service.ReportErrorEventRequest],
Given the following code snippet before the placeholder: <|code_start|> always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access") ): credentials = credentials.with_always_us...
[report_errors_service.ReportErrorEventRequest],
Given the code snippet: <|code_start|> metadata: Sequence[Tuple[str, str]] = () ): """Instantiate the pager. Args: method (Callable): The method that was originally called, and which instantiated this pager. request (google.cloud.errorreporting_v1beta1...
def __iter__(self) -> Iterator[common.ErrorEvent]:
Given the code snippet: <|code_start|># # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions a...
method: Callable[..., error_stats_service.ListGroupStatsResponse],
Based on the snippet: <|code_start|> package="google.devtools.clouderrorreporting.v1beta1", manifest={"GetGroupRequest", "UpdateGroupRequest",}, ) class GetGroupRequest(proto.Message): r"""A request to return an individual group. Attributes: group_name (str): Required. The group re...
group = proto.Field(proto.MESSAGE, number=1, message=common.ErrorGroup,)
Using the snippet: <|code_start|> contain a header (typically consisting of the exception type name and an error message) and an exception stack trace in one of the supported programming languages and formats. Supported languages are Java, Python, JavaScript, Ruby, C#, ...
proto.MESSAGE, number=2, message=common.ServiceContext,
Given the following code snippet before the placeholder: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ...
self._encoders[feat_type] = sparse_lookup.SparseLookupEncoder(
Using the snippet: <|code_start|># limitations under the License. # Lint as: python3 """Metric calculator for classification tasks.""" CONFIDENCE_CALIBRATION_HISTOGRAM_KEY = "full_confidence_calibration_histogram" RISK_CALIBRATION_HISTOGRAM_KEY = "full_risk_calibration_histogram" METRICS_EPSILON = 1e-5 ListOrArray =...
num_calibration_bins: int = calibration.DEFAULT_NUM_BINS,
Predict the next line after this snippet: <|code_start|> return { "positive_rate_histogram": self._positive_rate_histogram, "risk_histogram": self._risk_histogram, "risk_bin_counts": self._risk_bin_counts } def expected_confidence_calibration_error(self) -> float: """Compute the ex...
return pr_roc.weighted_area_under_curve_from_raw_scores(
Continue the code snippet: <|code_start|># coding=utf-8 # Copyright 2021 Google Health Research. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
class ClassificationTaskMetricCalculator(base.MetricCalculatorBase):
Predict the next line for this snippet: <|code_start|># limitations under the License. # Lint as: python3 """Base class for EHR embeddings.""" if typing.TYPE_CHECKING: class InputEmbeddingBase(metaclass=abc.ABCMeta): """The base embedding class declaring the interface.""" def __init__(self, en...
self._is_training = types.ModelMode.is_train(
Given the code snippet: <|code_start|># coding=utf-8 # Copyright 2021 Google Health Research. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
types.RNNCellType.SRU,
Given the following code snippet before the placeholder: <|code_start|> num_units=config.ndim_lstm, activation=config.activation_fn), # Simple Recurrent Unit. Faster training. types.RNNCellType.SRU: functools.partial( tf_contrib.rnn.SRUCell, n...
cell_config: "configdict.ConfigDict") -> reset_core.ResetCore:
Given the following code snippet before the placeholder: <|code_start|># Copyright 2021 Google Health Research. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
AT_DISCHARGE_MASK = label_utils.DISCHARGE_LABEL
Predict the next line for this snippet: <|code_start|># coding=utf-8 # Copyright 2021 Google Health Research. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
loss_type: str = types.TaskLossType.CE,
Next line prediction: <|code_start|># coding=utf-8 # Copyright 2021 Google Health Research. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
task_coordinator: Optional[coordinator.Coordinator],
Given snippet: <|code_start|> # Lint as: python3 """TensorFlow utility functions to extract Tensor and batch from tf protos.""" class BatchGenerator(object): """Tool for working with a TF dataset.""" def __init__( self, config: configdict.ConfigDict, is_training: bool, task_coordinator...
def batch(self) -> batches.TFBatch:
Here is a snippet: <|code_start|># coding=utf-8 # Copyright 2021 Google Health Research. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #...
config: configdict.ConfigDict,
Given the following code snippet before the placeholder: <|code_start|># You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRAN...
if regularizer_type == types.RegularizationType.NONE:
Based on the snippet: <|code_start|>def get_task_specific_snr_routing_connections(model, encoder, losses_per_task): """Returns the task-specific SNR connections. If use_task_specific_routing is disabled in both the model and the encoder it will return an (empty dictionary, empty list) tuple. For sub-network r...
if (isinstance(model, snrnn_model.SNRNNModel) or
Given snippet: <|code_start|> For sub-network routing when optimizing task specific connections we want to optimize each corresponding to the specific task loss they're associated with. If the model type is not SNRNN and the encoder type is not SNR then this function will return empty collections. Args: ...
if isinstance(enc, deep_encoders.SNREncoder):
Continue the code snippet: <|code_start|> # Lint as: python3 """Coordinator for metrics of various targets in evaluation.""" @dataclasses.dataclass(frozen=True) class MetricsTarget(object): """Describes a target metrics will be computed for.""" target_name: str split_name: str mask_name: Optional[str] = No...
metrics_data_type: Type[metrics_data.MetricsTypes],
Given the following code snippet before the placeholder: <|code_start|> embedding_size: Union[int, List[int]], name: str): """Initializes the parameters of the model. Args: config: Configuration specifying model parameters. embedding_size: The total size of the embedding. name: ...
return self._config.get("mode", types.ModelMode.TRAIN)
Based on the snippet: <|code_start|> class SearchEventForm(forms.Form): countries._countries.append(Event.CUSTOM_COUNTRY_ENTRIES[0]) countries._countries.append(Event.CUSTOM_COUNTRY_ENTRIES[1]) # XK is temp code for Kosovo; remove from COUNTRIES_OVERRIDE when # Kosovo gets its own ISO code and is adde...
queryset=EventTheme.objects.all(),
Here is a snippet: <|code_start|> if not 'Kosovo' in list(dict(countries._countries).values()): countries._countries.append((u'XK', u'Kosovo')) q = forms.CharField( required=False, widget=forms.TextInput( attrs={ 'placeholder': 'Search for event name or tag', ...
queryset=EventAudience.objects.all(),
Here is a snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- ''' Generates and sends event report to ambassadors users ''' def send_event_report_email(user, event): template = loader.get_template("mailer/event_email.txt") context = Context({'user': user, 'event': event}) txt_content = tem...
ambassadors = get_ambassadors_for_country(event.country)
Predict the next line after this snippet: <|code_start|>@login_required @never_cache def user_profile(request): if request.method == 'POST': # populate form with original instance and add post info on top of that uform = UserForm(request.POST, instance=request.user) pform = UserProfileForm(r...
user_ip = get_client_ip(
Predict the next line for this snippet: <|code_start|> uform.save() pform.save() messages.success(request, 'Profile details updated') else: user = request.user uform = UserForm(instance=user) profile = user.profile pform = UserProfileForm(instance=p...
countries_ambassadors = get_ambassadors_for_countries()
Using the snippet: <|code_start|> if request.method == 'POST': # populate form with original instance and add post info on top of that uform = UserForm(request.POST, instance=request.user) pform = UserProfileForm(request.POST, instance=request.user.profile) if uform.is_valid() and pfo...
user_country = get_country_from_user_ip(user_ip)
Given the following code snippet before the placeholder: <|code_start|> class EventListSerializers(serializers.ModelSerializer): description_short = serializers.CharField(source='description') class Meta: <|code_end|> , predict the next line using imports from the current file: from django.utils.text import...
model = Event
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- class CachedListAPIView(generics.ListAPIView): """ Concrete cached view for listing a queryset. """ @cache_response(timeout=21600, key_func='calculate_cache_key') def get(self, request, *args, **kwargs): return self.list(r...
serializer_class = EventListSerializers
Predict the next line for this snippet: <|code_start|> def calculate_cache_key(self, view_instance, view_method, request, args, kwargs): return sha1('-'.join([ repr(request.GET), repr(args), repr(kwargs), ])).hexdigest() class EventListApi(CachedL...
serializer_class = EventDetailSerializer
Given the following code snippet before the placeholder: <|code_start|> @cache_response(timeout=21600, key_func='calculate_cache_key') def get(self, request, *args, **kwargs): return self.list(request, *args, **kwargs) def calculate_cache_key(self, view_instance, view_method, request, args, kwargs):...
return get_approved_events(**params)
Given the following code snippet before the placeholder: <|code_start|> class EventListApi(CachedListAPIView): """ Lists approved Events, takes the following optional GET parameters: * limit * order * country_code * past """ serializer_class = EventListSerializers def get_queryset(self): param...
return get_event_detail(**params)
Given the following code snippet before the placeholder: <|code_start|>* country_code * past """ serializer_class = EventListSerializers def get_queryset(self): params = { 'limit': self.request.GET.get('limit', None), 'order': self.request.GET.get('order', None), ...
serializer_class = ScoreboardSerializer
Based on the snippet: <|code_start|> serializer_class = EventListSerializers def get_queryset(self): params = { 'limit': self.request.GET.get('limit', None), 'order': self.request.GET.get('order', None), 'country_code': self.request.GET.get('country_code', None), ...
return count_approved_events_for_country()
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- urlpatterns = patterns('', url(r'^event/list/$', EventListApi.as_view(), name='event.list'), url(r'^event/detail/$', <|code_end|> using t...
EventDetailApi.as_view(),
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- urlpatterns = patterns('', url(r'^event/list/$', EventListApi.as_view(), name='event.list'), url(r'^event/detail/$', ...
ScoreBoardApi.as_view(),
Predict the next line for this snippet: <|code_start|> class TestRestApi: def test_event_list_all(self, client, admin_user): event_data = { "start_date": datetime.datetime.now() - datetime.timedelta( days=1, hours=3), "end_date": dateti...
event = create_or_update_event(**event_data)
Predict the next line for this snippet: <|code_start|> status = models.CharField( max_length=50, choices=STATUS_CHOICES, default='PENDING') title = models.CharField(max_length=255, default=None) slug = models.SlugField(max_length=255, null=True, blank=True) creator = models.Forei...
validators=[MaxLengthValidator(70), validate_ascii_text]
Predict the next line for this snippet: <|code_start|> # in case we have geoposition data in event_data if 'geoposition' in event_data and event_data['geoposition'] != '': # updating geoposition field is a bit fuzzy event_latitude = event_data['geoposition'][0] ...
send_email_to_country_ambassadors(event)
Predict the next line for this snippet: <|code_start|> action='store', dest='emails_per_run', help='Required. The number of emails to send per run.' ), make_option('--notifications-limit', type='int', action='store', dest='notificati...
events_to_report = events_pending_for_report().filter(
Based on the snippet: <|code_start|> "manage.py remind_organizers_to_report_events --emails-per-run 100" ) exit(1) events_to_report = events_pending_for_report().filter( Q(last_report_notification_sent_at=None) | Q(last_report_notification_...
unreported_organizer_events = events_pending_for_report_for(organizer)
Given snippet: <|code_start|> default=21, help="If we're allowed to send more than one reminder email, notifications will be sent each X days." ), ) def handle(self, *args, **options): last_reminder_sent_before = datetime.now() - timedelta(days=options['notifications_inte...
organizers = User.objects.filter(id__in=organizer_ids)
Based on the snippet: <|code_start|> 'report_notifications_count', 'start_date' ) organizer_ids = events_to_report.distinct().values_list('creator_id', flat=True) # The values above may not be unique as we're using ordering. See here for more info: # https://docs.dja...
send_reminder_for_event_report_and_certificate(