Parallel

Convert a function into parallel run.

handypy.parallel.parallel(func, np=8)[source]

Convert a function to parallel version

Example:

def mul2(x):
  return x*2

parallel_mul2 = parallel(mul2)
parallel_mul2([(i,) for i in range(10)])
Parameters
  • func – function

  • np – number of parallel jobs

Returns

a function takes a list of lists.

handypy.parallel.parallel_bash(scripts, np=8)[source]

Run bash script line by line in parallel Example:

parallel_bash(open("script.sh").readlines())
Parameters
  • scripts – list of scripts to run

  • np – number of parallel jobs

handypy.parallel.parallel_bash_tqdm(scripts, np=8)[source]

Run bash script line by line in parallel with tqdm progress bar Example:

parallel_bash_tqdm(open("script.sh").readlines())
Parameters
  • scripts – list of scritps to run

  • np – number of parallel jobs

handypy.parallel.parallel_tqdm(func, np=8)[source]

Convert a function to parallel version with tqdm progress bar.

Example:

def mul2(x):
  return x*2

parallel_mul2 = parallel_tqdm(mul2)
parallel_mul2([(i,) for i in range(10)])
Parameters
  • func – function

  • np – number of parallel jobs

Returns

a function takes a list of lists.