profit.run

Submodules

Package Contents

Classes

RunnerInterface

Helper class that provides a standard way to create an ABC using

WorkerInterface

The Worker-Interface

Runner

Helper class that provides a standard way to create an ABC using

Worker

Helper class that provides a standard way to create an ABC using

Preprocessor

Helper class that provides a standard way to create an ABC using

Postprocessor

Helper class that provides a standard way to create an ABC using

class profit.run.RunnerInterface(size, input_config, output_config, *, logger_parent: logging.Logger = None)[source]

Bases: profit.util.component.Component

Helper class that provides a standard way to create an ABC using inheritance.

property config
property size
internal_vars = [('DONE',), ('TIME',)]
resize(size)[source]
poll()[source]
clean()[source]
class profit.run.WorkerInterface(run_id: int, *, logger_parent: logging.Logger = None)[source]

Bases: profit.util.component.Component

The Worker-Interface

The Worker-side of the Interface performs two tasks: retrieving input data and transmitting output data.

Only the Worker interacts directly with the Interface, following the scheme: ```

self.interface.retrieve() -> self.interface.input timestamp = time.time() self.interface.output = simulate() self.interface.time = int(time.time() - timestamp) self.interface.transmit()

```

property config
abstract retrieve()[source]

retrieve the input

  1. connect to the Runner-Interface

  2. retrieve the input data and store it in .input

abstract transmit()[source]

transmit the output

  1. transmit the output and time data (.output and .time)

  2. signal the Worker has finished

  3. close the connection to the Runner-Interface

clean()[source]
class profit.run.Runner(*, interface: profit.run.interface.RunnerInterface = 'memmap', worker: Mapping = 'command', work_dir='.', debug=False, parallel=0, sleep=0.1, logfile='runner.log', logger=None)[source]

Bases: profit.util.component.Component

Helper class that provides a standard way to create an ABC using inheritance.

property config
property input_data
property output_data
property flat_output_data
classmethod from_config(run_config, base_config)[source]

Constructor from run config & base config dict

__repr__()[source]

Return repr(self).

change_work_dir()[source]
fill(params_array, offset=0)[source]

fill Interface input with parameters

fill_output(named_output, offset=0)[source]

fill Interface output with values

abstract spawn(params=None, wait=False)[source]

spawn a single run

Parameters:
  • params – a mapping which defines input parameters to be set

  • wait – whether to wait for the run to complete

spawn_array(params_array, wait=False, progress=False)[source]

spawn an array of runs

maximum ‘parallel’ at the same time blocking until all are submitted

abstract poll(run_id)[source]

check the status of the run directly

poll_all()[source]
check_runs()[source]

check the status of runs via the interface

abstract cancel(run_id)[source]
cancel_all()[source]
wait(run_id)[source]
wait_all(progress=False)[source]
clean()[source]
class profit.run.Worker(run_id: int, *, interface: profit.run.interface.WorkerInterface = 'memmap', debug=False, log_path='log', logger=None)[source]

Bases: profit.util.component.Component

Helper class that provides a standard way to create an ABC using inheritance.

abstract work()[source]
clean()[source]
classmethod from_config(config, interface, run_id)[source]
classmethod from_env(env=None)[source]
classmethod wrap(label, outputs=None, inputs=None)[source]

``` @Worker.wrap(‘label’, [‘f’, ‘g’], [‘x’, ‘y’]) def func(x, y):

@Worker.wrap(‘label’, [‘f’, ‘g’]) def func(x, y):

@Worker.wrap(‘label’) def func(x, y) -> [‘f’, ‘g’]:

@Worker.wrap(‘name’, ‘f’, ‘x’) def func(x):

@Worker.wrap(‘name’) def func(x) -> ‘f’:

@Worker.wrap(‘name’) def f(x):

```

class profit.run.Preprocessor(run_dir: str, *, clean=True, logger_parent=None)[source]

Bases: profit.run.worker.Component

Helper class that provides a standard way to create an ABC using inheritance.

abstract prepare(data: Mapping)[source]
post()[source]
classmethod wrap(label, config={})[source]
class profit.run.Postprocessor(*, logger_parent: logging.Logger = None)[source]

Bases: profit.run.worker.Component

Helper class that provides a standard way to create an ABC using inheritance.

abstract retrieve(data: MutableMapping)[source]
classmethod wrap(label, config={})[source]