# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

def make_placeholder(s):
  '''Converts a string to placeholder format {{string}}'''

  return '{{'+s+'}}'


def convert_placeholder_reps(reps):
  
  for old_key in list(reps.keys()):
    new_key = make_placeholder(old_key)
    reps[new_key] = str(reps.pop(old_key))

  return reps



def gen_job_array(ids, num_jobs):
  '''Given list of ids, generate list of starting and endign job numbers

  Output: {start_ids: [], end_ids: []}
  '''

  num_per_job = math.ceil(len(ids) / num_jobs)


def multi_str_replace(text, reps):
  ''' Makes multiple string substitutions

  Keyword arguments:
  text -- original string 
  reps -- dictionary where keys are old substrings and values are new substrings
  '''

  for old, new in reps.items():
    text = text.replace(old, new)

  return text



reps = {'sape': 4139, 'jack': 4098, 'guido': 412}


num_jobs = 3
ids = range(10)

import math

num_per_job = math.ceil(len(ids) / num_jobs)

start_idx = list(range(0, len(ids), num_per_job))

start_idx

[x+num_per_job-1 for x in start_idx]

StarcoderdataJupyterScriptsDedupFiltered