drugex.parallel package

Submodules

drugex.parallel.collectors module

collectors

Created by: Martin Sicho On: 14.07.22, 10:58

class drugex.parallel.collectors.ListAppend[source]

Bases: ListExtend

class drugex.parallel.collectors.ListExtend[source]

Bases: ListCollector

getList()[source]

drugex.parallel.evaluator module

evaluator

Created by: Martin Sicho On: 29.05.22, 18:12

class drugex.parallel.evaluator.ParallelSupplierEvaluator(supplier_class, n_proc=None, chunk_size=1000, chunks=None, args=None, kwargs=None)[source]

Bases: ParallelProcessor

Class implementing parallel evaluation of MolSupplier instances on input data (see ParallelSupplierEvaluator.apply).

apply(data, collector, error=None, desc_string=None)[source]

Apply the ParallelSupplierEvaluator.run() across a Pool of workers.

Parameters:
  • data – input data to divide into chunks and process in parallel

  • collector – a ResultCollector that receives results of parallel processes

  • error – a callable to handle errors during evaluation of each parallel supplier

  • desc_string – progress bar description string

Returns:

None

error(data)[source]

Catch and log an error occurring in the parallel process.

Raises:

ParallelException

Parameters:

data – error data

initSupplier(supplier_class, chunk)[source]

Initialize a MolSupplier instance on the given chung of data. :param supplier_class: MolSupplier to initialize. :param chunk: Data chunk.

Returns:

initialized MolSupplier

run(chunk, error)[source]

Initialize and start evaluation of the MolSupplier instance on the given chunk of data.

Parameters:

chunk – Current chunk of data.

Returns:

result of the MolSupplier.toList() method for the given chunk.

drugex.parallel.interfaces module

interfaces

Created by: Martin Sicho On: 29.05.22, 18:09

class drugex.parallel.interfaces.ListCollector[source]

Bases: ResultCollector, ABC

abstract getList()[source]
exception drugex.parallel.interfaces.ParallelException[source]

Bases: Exception

class drugex.parallel.interfaces.ParallelProcessor(n_proc=None, chunk_size=1000, chunks=None)[source]

Bases: ABC

Simple interface to define parameters for parallel processing of data.

abstract apply(data, collector)[source]

Apply the processor to the given data.

Parameters:
  • data – input data (format depends on the implementation)

  • collector – a ResultCollector that is used to collect data produced from each process.

Returns:

None.

getChunkSize(data)[source]

Determine the chunk size from data.

Parameters:

data – input data (needs to have len)

Returns:

int representing the size of one chunk sent to the parallel process

class drugex.parallel.interfaces.ResultCollector[source]

Bases: ABC

drugex.parallel.tests module

tests

Created by: Martin Sicho On: 12.04.22, 15:07

class drugex.parallel.tests.TestFileParsers(methodName='runTest')[source]

Bases: TestCase

static getTestFile(name)[source]
test_parallel()[source]
test_parallel_with_suppliers()[source]

Module contents

__init__.py

Created by: Martin Sicho On: 29.05.22, 18:09