idmtools.entities.iplatform_ops.utils module#

Utils for platform operations.

Here we have mostly utilities to handle batch operations which tend to overlap across different item types.

Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.

idmtools.entities.iplatform_ops.utils.batch_items(items: Iterable | Generator, batch_size=16)[source]#

Batch items.

Parameters:
  • items – Items to batch

  • batch_size – Size of the batch

Returns:

Generator

Raises:

StopIteration

idmtools.entities.iplatform_ops.utils.item_batch_worker_thread(create_func: Callable, items: List, **kwargs) List[source]#

Default batch worker thread function. It just calls create on each item.

Parameters:
  • create_func – Create function for item

  • items – Items to create

Returns:

List of items created

idmtools.entities.iplatform_ops.utils.batch_create_items(items: Iterable | Generator, batch_worker_thread_func: Callable[[List], List] | None = None, create_func: Callable[[...], Any] | None = None, display_progress: bool = True, progress_description: str = 'Commissioning items', unit: str | None = None, **kwargs)[source]#

Batch create items. You must specify either batch_worker_thread_func or create_func.

Parameters:
  • items – Items to create

  • batch_worker_thread_func – Optional Function to execute. Should take a list and return a list

  • create_func – Optional Create function

  • display_progress – Enable progress bar

  • progress_description – Description to show in progress bar

  • unit – Unit for progress bar

  • **kwargs

Returns:

Batches crated results

idmtools.entities.iplatform_ops.utils.show_progress_of_batch(progress_bar: tqdm, futures: List[Future]) List[source]#

Show progress bar for batch.

Parameters:
  • progress_bar – Progress bar

  • futures – List of futures that are still running/queued

Returns:

Returns results