Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Predict the next line after this snippet: <|code_start|> dtype=dtype, initializer=init_ops.constant_initializer( bias_start, dtype=dtype)) return res + bias_term def linear(args, output_size, bias, bias_start=0.0, scope=None, squeeze=...
out = reconstruct(flat_out, args[0], 1)
Next line prediction: <|code_start|> x: number to correct dataset: string that identifies the correction to make Returns: The rescaled score x. Raises: ValueError: if dataset is none of train, dev, test. """ if dataset == 'train': return x * 90843 / (90843 + 8977) elif dataset == 'dev': ...
environment_fn = environment_client.make_environment_reward_fn(
Continue the code snippet: <|code_start|> def _correct_searchqa_score(x, dataset): """Method to correct for deleted datapoints in the sets. Args: x: number to correct dataset: string that identifies the correction to make Returns: The rescaled score x. Raises: ValueError: if dataset is none o...
reformulator_instance = reformulator.Reformulator(
Next line prediction: <|code_start|> f1s.extend(f1_scores) return np.mean(f1s) def _run_eval_with_selector(questions, annotations, docid_2_answer, reformulator_instance, selector_model, batch_size, environment_fn): """Runs a joined eval with the reformul...
safe_string(questions_batch[0]), safe_string(annotations_batch[0])))
Next line prediction: <|code_start|># Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
from px.selector import selector_keras as selector
Given snippet: <|code_start|> If False, F1 scores are from the BiDAF environment, which uses the intersection between predicted answer span and ground-truth spans. Returns: originals_and_rewrites: a nested list of strings of lengths [batch_size, n_rewrites + 1]. answers: a nested list of str...
eval_utils.compute_f1_single(
Given snippet: <|code_start|> for epoch in range(FLAGS.epochs): for batch_id, (questions_batch, annotations_batch) in enumerate( batch(questions, annotations, FLAGS.batch_size_train)): # Run eval every num_steps_per_eval batches. if global_step % FLAGS.num_steps_per_eval is 0: if FLAGS....
misc_utils.add_summary(
Continue the code snippet: <|code_start|> annot_dataset = None ctx_dataset = None if use_placeholders: src_placeholder = tf.placeholder(shape=[None], dtype=tf.string) src_dataset = tf.data.Dataset.from_tensor_slices(src_placeholder) tgt_placeholder = tf.placeholder(shape=[None], dtype=tf.s...
iterator = iterator_utils.get_iterator(
Predict the next line after this snippet: <|code_start|> "ExtraArgs", ("single_cell_fn", "model_device_fn", "attention_mechanism_fn"))): pass class TrainModel( collections.namedtuple( "TrainModel", ("graph", "model", "iterator", "src_placeholder", "tgt_placeholder", "anno...
src_vocab_table, tgt_vocab_table = vocab_utils.create_vocab_tables(
Here is a snippet: <|code_start|> xi = list(map(word_tokenize, sent_tokenize(context))) xi = [process_tokens(tokens) for tokens in xi] # process tokens # given xi, add chars cxi = [[list(xijk) for xijk in xij] for xij in xi] xp.append(xi) cxp.append(cxi) pp.append(context) ...
yi0, yi1 = get_word_span(context, xi, answer_start, answer_stop)
Based on the snippet: <|code_start|> for xij in xi: for xijk in xij: word_counter[xijk] += len(para['qas']) lower_word_counter[xijk.lower()] += len(para['qas']) for xijkl in xijk: char_counter[xijkl] += len(para['qas']) rxi = [ai, pi] assert len(x) - ...
i0 = get_word_idx(context, xi, yi0)
Here is a snippet: <|code_start|> raise Exception() if not args.split: sent_tokenize = lambda para: [para] source_path = in_path or os.path.join(args.source_dir, '{}-v1.1.json'.format(data_type)) source_data = json.load(tf.gfile.Open(source_path, 'r')) q, cq, y,...
xi = [process_tokens(tokens) for tokens in xi] # process tokens
Given snippet: <|code_start|> """"Constructor for the BiDAF server.""" data_dir = kwargs.pop('squad_data_dir', None) shared_file = kwargs.pop('bidaf_shared_file', None) model_dir = kwargs.pop('bidaf_model_dir', None) load_test = kwargs.pop('load_test', False) load_impossible_questions = kwargs.po...
self._environment = bidaf.BidafEnvironment(
Here is a snippet: <|code_start|> out = defaultdict(list) for key, val in self.data.items(): out[key].extend(val[idx] for idx in idxs) return out elif isinstance(self.data, Data): return self.data.get_by_idxs(idxs) raise Exception() def get_batches(self, batch...
sorted_grouped = lambda: list(grouper(sorted_idxs, batch_size))
Predict the next line for this snippet: <|code_start|> num_batches_per_epoch = int(math.ceil(self.num_examples / batch_size)) if num_batches is None: num_batches = num_batches_per_epoch num_epochs = int(math.ceil(num_batches / num_batches_per_epoch)) if shuffle: random_idxs = random.sample(s...
index(self.shared[shared_key], each) for each in val
Using the snippet: <|code_start|> class MasterConfig(UserDict): """compile configuration data""" def __init__(self, changes={}): UserDict.__init__(self) self.network_config=BikeNetworkConfigDirectFromCube() self.outer_network_config=OuterNetworkConfig() self.output_config=BikeOutputConfig() self.choice...
self.assign_config=AssignConfig()
Given the following code snippet before the placeholder: <|code_start|> def path_size(G,choice_sets,choice_set_config): result=[] config=choice_set_config the_network=G if G.orig_network is not None: the_network=G.orig_network for path_list in choice_sets: temp=[] hashes=[]; lengths=[] for cur_...
use_path=get_orig_path(cur_path)
Continue the code snippet: <|code_start|> def param_worker(work_queue,done_queue,network,trip_data,master_config,trip_times,ext_bound,trip_ids): this_network=network.copy() #initialize link randomizer link_randomizer=None if master_config.choice_set_config['method']=='doubly_stochastic': link_randomizer=mast...
the_set,chosen_overlap=generate_choice_set(this_network,trip_data[trip_id],master_config.choice_set_config,link_randomizer,master_config['time_dependent_relation'],trip_times[trip_id[0]],ext_bound)
Predict the next line after this snippet: <|code_start|> def generate_choice_set(G,chosen,choice_set_config,link_randomizer=None,time_dependent_relation=None,trip_time=None,ext_bound=None): config=choice_set_config if config['method']=='link_elimination': <|code_end|> using the current file's imports: import ra...
return le_generate(G,chosen,config)
Next line prediction: <|code_start|> def generate_choice_set(G,chosen,choice_set_config,link_randomizer=None,time_dependent_relation=None,trip_time=None,ext_bound=None): config=choice_set_config if config['method']=='link_elimination': return le_generate(G,chosen,config) if config['method']=='doubly_stochas...
return ds_generate(G,chosen,config,link_randomizer,ext_bound,time_dependent_relation,trip_time)
Given the code snippet: <|code_start|> self['tolerance']=0.01 # percentage threshold to stop binary search when extracting prior distribution self['log_prior']=True # use log-uniform prior? (False means uniform prior) """variable configuration""" self['variables']=['DISTANCE','BNE1','BNE2','BNE3','...
self['randomizer_fun']=BetaUnifRandomizer
Predict the next line for this snippet: <|code_start|> self['tolerance']=0.01 # percentage threshold to stop binary search when extracting prior distribution self['log_prior']=True # use log-uniform prior? (False means uniform prior) """variable configuration""" self['variables']=['DISTANCE','BNE1'...
self['randomizer_fun']=BetaUnifRandomizer
Using the snippet: <|code_start|> for e2 in G.edges([e1[1]],data=True): dual_data=e2[2] dual_data['TURN']=0 dual_data['L_TURN']=0 dual_data['R_TURN']=0 dual_data['U_TURN']=0 the_turn=G.turn_dir(e1,e2) if the_turn: dual_data['TURN']=1 if the_turn=='L': dual_data['L_TURN']=1 if the_...
network_config=NetworkConfig()
Continue the code snippet: <|code_start|> name="event_slides" ), path('<slug:slug>/videos/', video_list, name="event_video_list"), path('<slug:slug>/all-comments/', event_all_comments_list, name="event_comments"), path('<slug:slug>/map/', EventDetail, {'template_name': 'happenings/event_...
'queryset': Update.objects.all()
Using the snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), <|code_end|> , determine the next line of code. You have imports: from django.urls import path, re_path from djan...
path('<slug:slug>/add-recap/', add_recap, name="add_recap"),
Based on the snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', EventList, nam...
path('<slug:slug>/ical/', create_ical, name="event_ical"),
Continue the code snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS <|code_end|> . Use cur...
path('', EventList, name="events_index"),
Here is a snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', EventList, name="...
path('<slug:slug>/', EventDetail, name="event_detail"),
Given the following code snippet before the placeholder: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVEN...
EventsForPeriod,
Based on the snippet: <|code_start|> path('<slug:slug>/ical/', create_ical, name="event_ical"), # **************** Event children ************/ path('<slug:slug>/slides/', EventDetail, {'template_name': 'happenings/event_slides.html'}, name="event_slides" ), path('<slug:slug>/videos...
path('<slug:event_slug>/updates/<int:pk>/', EventUpdate, name="event_update_detail"),
Based on the snippet: <|code_start|> re_path( r'^(?P<m>\d{2})/(?P<y>\d{4})/$', EventsForPeriod, name="events_for_month" ), # ************* EVENT DETAILS *************/ path('<slug:slug>/', EventDetail, name="event_detail"), path('<slug:slug>/ical/', create_ical, name="event_...
path('<slug:event_slug>/memories/<int:pk>/', MemoryDetail, name="memory_detail"),
Next line prediction: <|code_start|> ), # ************* EVENT DETAILS *************/ path('<slug:slug>/', EventDetail, name="event_detail"), path('<slug:slug>/ical/', create_ical, name="event_ical"), # **************** Event children ************/ path('<slug:slug>/slides/', EventDetail, ...
path('<slug:event_slug>/extra/<slug:slug>/', ExtraInfoDetail, name="special_event_extra"),
Given snippet: <|code_start|> path('<slug:slug>/', EventDetail, name="event_detail"), path('<slug:slug>/ical/', create_ical, name="event_ical"), # **************** Event children ************/ path('<slug:slug>/slides/', EventDetail, {'template_name': 'happenings/event_slides.html'}, na...
path('<slug:slug>/updates/', event_update_list, name="event_update_list"),
Given the following code snippet before the placeholder: <|code_start|>urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', EventList...
path('<slug:slug>/videos/', video_list, name="event_video_list"),
Using the snippet: <|code_start|> # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', EventList, name="events_index"), path('by-region/<slug:regi...
path('<slug:slug>/all-comments/', event_all_comments_list, name="event_comments"),
Here is a snippet: <|code_start|> re_path( r'^(?P<m>\d{2})/(?P<d>\d{2})/(?P<y>\d{4})/$', EventsForPeriod, name="events_for_day" ), re_path( r'^(?P<m>\d{2})/(?P<y>\d{4})/$', EventsForPeriod, name="events_for_month" ), # ************* EVENT DETAILS ***...
path('<slug:slug>/attending/add/', add_attending, name="attending_add"),
Next line prediction: <|code_start|> r'^(?P<m>\d{2})/(?P<y>\d{4})/$', EventsForPeriod, name="events_for_month" ), # ************* EVENT DETAILS *************/ path('<slug:slug>/', EventDetail, name="event_detail"), path('<slug:slug>/ical/', create_ical, name="event_ical"), ...
path('<slug:slug>/memories/add/', add_memory, name="add_memory"),
Continue the code snippet: <|code_start|> {'template_name': 'happenings/event_slides.html'}, name="event_slides" ), path('<slug:slug>/videos/', video_list, name="event_video_list"), path('<slug:slug>/all-comments/', event_all_comments_list, name="event_comments"), path('<slug:slug>/map/',...
queryset=Update.objects.all()
Predict the next line after this snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), <|code_end|> using the current file's imports: from django.urls import path, re_path from...
path('<slug:slug>/add-recap/', add_recap, name="add_recap"),
Based on the snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', event_list, na...
path('<slug:slug>/ical/', create_ical, name="event_ical"),
Given the code snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS <|code_end|> , generate t...
path('', event_list, name="events_index"),
Continue the code snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', event_lis...
path('<slug:slug>/', event_detail, name="event_detail"),
Here is a snippet: <|code_start|> # CRUD and admin functions urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', event_list, name=...
events_period,
Predict the next line for this snippet: <|code_start|> path('<slug:slug>/ical/', create_ical, name="event_ical"), # **************** Event children ************/ path('<slug:slug>/slides/', event_detail, {'template_name': 'happenings/event_slides.html'}, name="event_slides" ), path(...
path('<slug:event_slug>/updates/<int:pk>/', event_update, name="event_update_detail"),
Predict the next line for this snippet: <|code_start|> re_path( r'^(?P<m>\d{2})/(?P<y>\d{4})/$', events_period, name="events_for_month" ), # ************* EVENT DETAILS *************/ path('<slug:slug>/', event_detail, name="event_detail"), path('<slug:slug>/ical/', create_i...
path('<slug:event_slug>/memories/<int:pk>/', memory_detail, name="memory_detail"),
Using the snippet: <|code_start|> ), # ************* EVENT DETAILS *************/ path('<slug:slug>/', event_detail, name="event_detail"), path('<slug:slug>/ical/', create_ical, name="event_ical"), # **************** Event children ************/ path('<slug:slug>/slides/', event_detail, ...
path('<slug:event_slug>/extra/<slug:slug>/', extrainfo_detail, name="special_event_extra"),
Given the code snippet: <|code_start|> path('<slug:slug>/', event_detail, name="event_detail"), path('<slug:slug>/ical/', create_ical, name="event_ical"), # **************** Event children ************/ path('<slug:slug>/slides/', event_detail, {'template_name': 'happenings/event_slides.html'},...
path('<slug:slug>/updates/', event_update_list, name="event_update_list"),
Given the code snippet: <|code_start|>urlpatterns = [ # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', event_list, name="events_index"), path...
path('<slug:slug>/videos/', video_list, name="event_video_list"),
Next line prediction: <|code_start|> # FORMS path('add/', add_event, name="add_event"), path('<slug:slug>/edit-event/', edit_event, name="edit-event"), path('<slug:slug>/add-recap/', add_recap, name="add_recap"), # EVENT LISTS path('', event_list, name="events_index"), path('by-region/<slug:...
path('<slug:slug>/all-comments/', event_all_comments_list, name="event_comments"),
Given the code snippet: <|code_start|> re_path( r'^(?P<m>\d{2})/(?P<d>\d{2})/(?P<y>\d{4})/$', events_period, name="events_for_day" ), re_path( r'^(?P<m>\d{2})/(?P<y>\d{4})/$', events_period, name="events_for_month" ), # ************* EVENT DETAILS **...
path('<slug:slug>/attending/add/', add_attending, name="attending_add"),
Based on the snippet: <|code_start|> r'^(?P<m>\d{2})/(?P<y>\d{4})/$', events_period, name="events_for_month" ), # ************* EVENT DETAILS *************/ path('<slug:slug>/', event_detail, name="event_detail"), path('<slug:slug>/ical/', create_ical, name="event_ical"), #...
path('<slug:slug>/memories/add/', add_memory, name="add_memory"),
Continue the code snippet: <|code_start|> try: img_file = SimpleUploadedFile(clean_filename, temp_handle.read(), 'image/jpeg',) except Exception: img_file = None if img_file is not None: try: ...
signals.post_save.connect(update_time, sender=Comment)
Continue the code snippet: <|code_start|> """ Print the svg instructions to draw the axis to the output. :arg output: Stream where to write. :type output: file :arg x_coord: x-coordinate where to start (bottom) the Y-axis in the svg. :type x_coord: float :arg y_coord: y-coordinate where to s...
def draw_ellipse(output, x_center, y_center, x_radius, y_radius, colour=BLACK,
Predict the next line after this snippet: <|code_start|> :type width: float :arg height: Height of the box containing the 'A'. :type height: float :arg colour: Color of the 'A' (default: black). The colour is given in RGB. :type colour: tuple (int, int, int) :arg opacity: Opacity of the '...
draw_polygon(output, [pt1, pt2, pt3], WHITE)
Predict the next line after this snippet: <|code_start|> RGB. :type colour: tuple (int, int, int) :arg opacity: Opacity of the 'A' (default: 1.0) :type opacity: float :note: The 'A' is drawn by creating a red polygon giving the shape and a white internal triangle above to make the bar in...
def draw_letter_c(output, x_coord, y_coord, width, height, colour=BLUE,
Given the following code snippet before the placeholder: <|code_start|> opacity=1.0): """ Print the svg instructions to draw an rectangle to the output. :arg output: Stream where to write. :type output: file :arg x_coord: x-coordinate of the bottom-left corner of the rectangle. ...
def draw_letter_a(output, x_coord, y_coord, width, height, colour=RED,
Given snippet: <|code_start|> :type y_coord: float :arg width: Width of the box containing the 'G'. :type width: float :arg height: Height of the box containing the 'G'. :type height: float :arg colour: Color of the box containing the 'G' (default: black). The colour is given in RGB. ...
def draw_letter_t(output, x_coord, y_coord, width, height, colour=GREEN,
Using the snippet: <|code_start|> :type x_coord: float :arg y_coord: y-coordinate of the bottom left corner ot the box containing the 'C'. :type y_coord: float :arg width: Width of the box containing the 'C'. :type width: float :arg height: Height of the box containing the 'C'. :type ...
def draw_letter_g(output, x_coord, y_coord, width, height, colour=YELLOW,
Based on the snippet: <|code_start|> :type step: float :note: The computation of the information content is done within the drawing since it follows the same algorithm computing the emission probabilities. So we do not call the get_information_content method for an algorithmic improvemen...
ALPHABET[i])
Next line prediction: <|code_start|> step=10.): """ Print the svg instructions to draw the letters of the logo and return the information content to be printed. :arg output: Stream where to write the svg instruction to draw the logo. :type output: file :arg tffm: The TFFM f...
if tffm.kind == TFFM_KIND.ZERO_ORDER:
Given snippet: <|code_start|> :arg output: Stream where to write the svg instruction to draw the logo. :type output: file :arg tffm: The TFFM for which drawing the logo. :type tffm: :class:`TFFM` :arg logo_type: Kind of logo to draw (either 'summary' or 'dense') :type logo_type: str :arg xpos...
if logo_type == LOGO_TYPE.SUMMARY:
Next line prediction: <|code_start|> model excluding the background. """ if self.kind == TFFM_KIND.FIRST_ORDER: return self.N - 2 elif self.kind == TFFM_KIND.DETAILED: return self.N / 4 - 1 else: # 0-order HMM here return self.N - 1 def ...
emissions[ALPHABET[i]] = self.getEmission(0)[i]
Next line prediction: <|code_start|> considered significant (given in this order). :rtype: tuple """ pos_ic = self.get_positions_ic() first = 1 last = len(self) while first <= last and pos_ic[first - 1] < threshold: first += 1 while last >...
ghmm_extended_alphabet = ghmm.Alphabet(EXTENDED_ALPHABET)
Predict the next line for this snippet: <|code_start|> functions :func:`tffm_from_xml` or :func:`tffm_from_meme`. """ def __init__(self, emission_domain, distribution, cmodel, kind, name="TFFM"): """ Construct an instance of the TFFM class. :arg emission_domain...
if(kind != TFFM_KIND.FIRST_ORDER and kind != TFFM_KIND.DETAILED and
Using the snippet: <|code_start|> and the corresponding probabilities as values. :rtype: dict """ emissions = {'A': 0., 'C': 0., 'G': 0., 'T': 0.} if self.kind == TFFM_KIND.FIRST_ORDER: emissions = background_emission_proba_1storder(self) elif self.kind =...
drawing.draw_logo(output, self, LOGO_TYPE.SUMMARY)
Next line prediction: <|code_start|> linkingAgentIdentifierRole.text = 'implementer' linkingAgentIdentifierType.text = i[0] linkingAgentIdentifierValue.text = i[1] def main(): print 'This is not a standalone script. It is a library of functions that other scripts can ...
append_csv(uuid_csv, (filmographic, source_accession, uuid) )
Predict the next line after this snippet: <|code_start|> linkingAgentIdentifierRole = create_unit(2,linkingAgentIdentifier,'linkingAgentRole') linkingAgentIdentifierRole.text = 'implementer' linkingAgentIdentifierType.text = i[0] linkingAgentIdentifierValu...
create_csv(uuid_csv, ('reference number','source accession number' 'uuid'))
Based on the snippet: <|code_start|>#!/usr/bin/env python ''' Generates sidecar MD5 or SHA512 checksum manifest. ''' def remove_bad_files(root_dir, log_name_source): ''' Removes unwanted files. Verify if this is different than the same function in ififuncs. ''' rm_these = ['.DS_Store', 'Thumbs.db'...
generate_log(
Given the following code snippet before the placeholder: <|code_start|> generate_log( log_name_source, 'EVENT = Generating manifest: status=started, eventType=message digest calculation, module=%s, agent=OSX' % module ) elif sys.platform == "linux2": ge...
count_in_manifest = manifest_file_count(manifest)
Using the snippet: <|code_start|> if os.path.isfile(source): print('\nFile checksum is not currently supported, only directories.\n') generate_log(log_name_source, 'Error: Attempted to generate manifest for file. Only Directories/Folders are currently supported') generate_log(log_name_source,...
hashlib_manifest(source, manifest, source)
Using the snippet: <|code_start|> action='store_true', help='Generates sha512 checksums instead of md5' ) args = parser.parse_args(args_) source = args.source source_parent_dir = os.path.dirname(source) normpath = os.path.normpath(source) relative_path = normpath.split(os.sep)[-1]...
desktop_logs_dir = make_desktop_logs_dir()
Given the following code snippet before the placeholder: <|code_start|> parser.add_argument( '-sha512', action='store_true', help='Generates sha512 checksums instead of md5' ) args = parser.parse_args(args_) source = args.source source_parent_dir = os.path.dirname(source) ...
desktop_manifest_dir = make_desktop_manifest_dir()
Continue the code snippet: <|code_start|> logs_dir = os.path.join(sip_dir, 'logs') logfile = os.path.join(logs_dir, logname) if os.path.isfile(logfile): with open(log, 'r') as fo: validate_log = fo.readlines() with open(logfile, 'a') as ba: for lines in validate_log: ...
desktop_logs_dir = make_desktop_logs_dir()
Using the snippet: <|code_start|>#!/usr/bin/env python ''' This script will ask mediainfo to get all durations with a folder ''' def main(): ''' Recursively search for AV files and print duration in seconds ''' all_files = sys.argv[1:] duration = 0 for parent_directory in all_files: fo...
milliseconds = get_milliseconds(
Continue the code snippet: <|code_start|> # make sure that the alternate log filename is more recent if int( os.path.basename(logs)[-12:-4].replace('_', '')) > int(os.path.basename(i)[-12:-4].replace('_', '')): print(' - trying t...
desktop_logs_dir = make_desktop_logs_dir()
Next line prediction: <|code_start|> output = filename + "_h264.mov" ffmpeg_args = [ 'ffmpeg', '-i', filename, ] if args.logo: ffmpeg_args.extend(['-i', args.logo]) ffmpeg_args += [ '-c:a', 'aac', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-...
h264_md5 = hashlib_md5(filename)
Continue the code snippet: <|code_start|>#!/usr/bin/env python ''' This script will create a new UUID via ififuncs.create_uuid and print to terminal ''' def main(): ''' Prints a new UUID to the terminal ''' <|code_end|> . Use current file imports: from ififuncs import create_uuid and context (classes, f...
new_uuid = create_uuid()
Next line prediction: <|code_start|> if dirname == '': rootpos = 'y' ''' dirname = raw_input( 'What do you want your destination folder to be called?\n' ) ''' relative_path = normpath.split(os.sep)[-1] # or hardcode destination_final_path = os.path.join...
desktop_logs_dir = make_desktop_logs_dir()
Based on the snippet: <|code_start|> if os.path.isdir(dircheck): source = check_for_sip(args.source) destination = os.path.join(args.destination, os.path.basename(args.source)) os.makedirs(destination) else: source = os.path.abspath(args.source) destination...
desktop_manifest_dir = make_desktop_manifest_dir()
Predict the next line after this snippet: <|code_start|> last_percent_done = 0 md5_object = hashlib.md5() total_size = os.path.getsize(filename) with open(str(filename), 'rb') as file_object: while True: buf = file_object.read(2**20) if not buf: break ...
generate_log(
Given the following code snippet before the placeholder: <|code_start|> objects_dir = os.path.join(sip_path, 'objects') uuid = os.path.basename(sip_path) old_basename, ext = os.path.splitext(item) new_path = os.path.join(objects_dir, uuid + ext) ...
print(("%-*s : copyit job was a %s" % (50, os.path.basename(i)[:-24], analyze_log(i))))
Given the following code snippet before the placeholder: <|code_start|> print('Exiting as you selected -dryrun') sys.exit() logs = [] if args.y: proceed = 'Y' else: proceed = ififuncs.ask_yes_no( 'Do you want to proceed?' ) if proceed == 'Y': fo...
print(("%-*s : copyit job was a %s" % (50, os.path.basename(i), analyze_log(i))))
Continue the code snippet: <|code_start|> 'Accepts a parent folder as input and will generate manifest for each subfolder.' ' Designed for a specific IFI Irish Film Archive workflow. ' 'Written by Kieran O\'Leary.' ) parser.add_argument( 'input', help='file path of parent director...
hashlib_manifest(full_path, manifest_textfile, full_path)
Given snippet: <|code_start|> ''' parser = argparse.ArgumentParser( description='Batch MD5 checksum generator.' 'Accepts a parent folder as input and will generate manifest for each subfolder.' ' Designed for a specific IFI Irish Film Archive workflow. ' 'Written by Kieran O\'Lear...
generate_log(log_name, 'batchfixity started')
Given snippet: <|code_start|> codes = attr.ib(default=attr.Factory(list)) @attr.s class Data(object): soc_id = attr.ib() sub_case = attr.ib() year = attr.ib() var_id = attr.ib() code = attr.ib() comment = attr.ib() references = attr.ib(convert=semicolon_split) source_coded_data = at...
return Source.objects.create(
Predict the next line for this snippet: <|code_start|># coding: utf8 from __future__ import unicode_literals class Test(APITestCase): """Tests rest-framework API""" def _fixture_teardown(self): try: APITestCase._fixture_teardown(self) except: pass def get_json(se...
load(Path(__file__).parent.joinpath('data'))
Using the snippet: <|code_start|># coding: utf8 from __future__ import unicode_literals class Test(APITestCase): """Tests rest-framework API""" def _fixture_teardown(self): try: APITestCase._fixture_teardown(self) except: pass def get_json(self, urlname, *args, *...
sources._SOURCE_CACHE = {}
Predict the next line after this snippet: <|code_start|> log = logging.getLogger('profile') class VariableViewSet(viewsets.ReadOnlyModelViewSet): serializer_class = serializers.VariableSerializer filter_fields = ('label', 'name', 'index_categories', 'niche_categories', 'source') <|code_end|> using the cu...
queryset = models.Variable.objects\
Continue the code snippet: <|code_start|> class EATestCase(TestCase): """ Tests basic functionality of Ethnographic Atlas variable codings in model """ @classmethod def setUpTestData(cls): <|code_end|> . Use current file imports: from django.test import TestCase from dplace_app import models and...
cls.source = models.Source.objects.create(
Given snippet: <|code_start|> # constants for SocietyResult SEARCH_LANGUAGE = 'l' SEARCH_ENVIRONMENTAL = 'e' SEARCH_VARIABLES = 'v' SEARCH_GEOGRAPHIC = 'g' class SourceSerializer(serializers.ModelSerializer): class Meta(object): <|code_end|> , continue by predicting the next line. Consider current file imports: ...
model = models.Source
Continue the code snippet: <|code_start|># coding: utf8 from __future__ import unicode_literals def society_locations(repos): societies = {s.ext_id: s for s in Society.objects.all()} <|code_end|> . Use current file imports: import logging from dplace_app.models import Society, GeographicRegion, SocietyRelation...
regions = {r.region_nam: r for r in GeographicRegion.objects.all()}
Given snippet: <|code_start|> def society_locations(repos): societies = {s.ext_id: s for s in Society.objects.all()} regions = {r.region_nam: r for r in GeographicRegion.objects.all()} count = 0 for soc_id, spec in repos.read_json('geo', 'societies_tdwg.json').items(): society = societies.get(s...
SocietyRelation.objects.create(
Given snippet: <|code_start|> families, languages = {}, {} societies = {s.ext_id: s for s in Society.objects.all()} for ds in repos.datasets: for soc in ds.societies: ldata = languoids.get(soc.glottocode) if not ldata: # pragma: no cover logging.warning("No la...
language = Language.objects.create(
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- def load_languages(repos): languoids = { l.id: l for l in repos.read_csv('csv', 'glottolog.csv', namedtuples=True)} families, languages = {}, {} societies = {s.ext_id: s for s in Society.objects.all()} for ds in repos.datasets: ...
family = LanguageFamily.objects.create(name=family_name)
Using the snippet: <|code_start|># -*- coding: utf-8 -*- def load_languages(repos): languoids = { l.id: l for l in repos.read_csv('csv', 'glottolog.csv', namedtuples=True)} families, languages = {}, {} <|code_end|> , determine the next line of code. You have imports: import logging from dplace_app.m...
societies = {s.ext_id: s for s in Society.objects.all()}
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals _SOURCE_CACHE = {} def get_source(ds): dsid = getattr(ds, 'id', ds) if dsid not in _SOURCE_CACHE: try: <|code_end|> , generate the next line using the imports in this file: import logging from clld...
o = Source.objects.get(year=ds.year, author=ds.author)
Predict the next line for this snippet: <|code_start|>router.register(r'codes', api_views.CodeDescriptionViewSet) router.register(r'values', api_views.ValueViewSet) router.register(r'societies', api_views.SocietyViewSet) router.register(r'language_families', api_views.LanguageFamilyViewSet) router.register(r'languages'...
url(r'^home/?$', views.angular),
Predict the next line for this snippet: <|code_start|> def load_phylogenies(repos): sources, sequences = {}, [] for obj in repos.phylogenies: _load(obj, sources, sequences) LanguageTreeLabelsSequence.objects.bulk_create(sequences) return len(repos.phylogenies) def _load(obj, sources, sequenc...
tree = LanguageTree.objects.create(name=obj.id)
Using the snippet: <|code_start|> def _load(obj, sources, sequences): # now add languages to the tree reader = NexusReader(obj.trees.as_posix()) tree = LanguageTree.objects.create(name=obj.id) source = sources.get((obj.author, obj.year)) if not source: sources[(obj.author, obj.year)] = sour...
label = LanguageTreeLabels.objects.create(languageTree=tree, label=name_on_tip)
Given the following code snippet before the placeholder: <|code_start|> def load_phylogenies(repos): sources, sequences = {}, [] for obj in repos.phylogenies: _load(obj, sources, sequences) <|code_end|> , predict the next line using imports from the current file: import re from clldutils.misc import ...
LanguageTreeLabelsSequence.objects.bulk_create(sequences)