clinamen2.runner package

Submodules

clinamen2.runner.basic_runner module

Implementation of the Runner classes to be used with Dask.

class clinamen2.runner.basic_runner.FunctionRunner(evaluator_function, workers, scheduler_file=None, convert_input=<function FunctionRunner.<lambda>>)[source]

Bases: Runner

Simple Runner for local function evaluation using Dask.

Parameters:
  • evaluator_function (Callable) – Function that calculates the loss. Needs to return a tuple of (float, {}).

  • workers (int) – Number of workers to be started in parallel.

  • scheduler_file (Optional[Path]) – Path to file identifying the dask scheduler.

  • convert_input (Callable) – Function that takes the input array and returns the object that is expected by the Runner. Default is identity.

pop()[source]

Function to fetch results from the Runner

Returns:

  • ID of input array

  • Calculation result

submit(individual)[source]

Function to submit one structure to the Runner

Parameters:

individual (numpy.typing.ArrayLike) – 1D array representing an individual structure.

Returns:

ID of input array

class clinamen2.runner.basic_runner.Runner[source]

Bases: ABC

Abstract class to interface to any queue

Inherit from this class to implement any loss evaluation.

Usage:
  • instantiate

  • submit() or submit_batch(): Send structure(s) to Runner

  • pop(): Retrieve latest result from Runner

Parameters:

recreate_structure – Function that recreates a structure from a given 1D array.

abstract pop()[source]

Function to fetch results from the Runner

Returns:

  • ID of input array

  • Calculation result

abstract submit(individual)[source]

Function to submit one structure to the Runner

Parameters:

individual (numpy.typing.ArrayLike) – 1D array representing an individual structure.

Returns:

ID of input array

submit_batch(individuals)[source]

Function that sequentially calls submit() for all individuals.

Parameters:

individuals (numpy.typing.ArrayLike) – Input to be submitted.

Returns:

List of IDs of input arrays

class clinamen2.runner.basic_runner.ScriptRunner(script_text, script_run_command, script_config=None, convert_input=<function ScriptRunner.<lambda>>, scheduler_info_path=None)[source]

Bases: Runner

Runner for distributed script evaluations using Dask.

Usage:

This class provides the functionality to evaluate individuals in a distributed manner using Dask workers. The provided script is executed on the workers using the script_run_command in a temporary directiory. This directory contains the output of the convert_input function saved with pickle and named “input”. The script is expected to write a pickled WorkerResult object named “result”, or in case of failure save the pickled exception as “result”.

Parameters:
  • script_text (str) – Text of the script to be executed on the workers. Before execution the script will be rendered with jinja using the given script_config as context.

  • script_run_command (str) – Command line command to execute the script on the workers, it has to contain {SCRIPTFILE}, which will be replaced by the file name of the actual script. E.g “python {SCRIPTFILE}”

  • script_config (Optional[dict]) – Dictionary of jinja keyword - value pairs to be used for script rendering. Default is None.

  • convert_input (Callable) – Function that takes the input array and returns the object that is expected by the Runner. Default is identity.

  • scheduler_info_path (Optional[str]) – The path to the Dask scheduler descriptor file. Default is None, which starts the Dask scheduler locally.

peek_script(script_config=None)[source]

Function to check what the jinja script rendering would result in.

Return type:

str

Returns:

Rendered script text.

pop()[source]

Function to fetch results from the Runner

Returns:

  • ID of input array

  • Calculation result

static script_driver(payload)[source]
submit(individual, script_config=None)[source]

Function to submit one structure to the Runner

Parameters:

individual – 1D array representing an individual structure.

Returns:

ID of input array

submit_batch(individuals, script_config=None)[source]

Function that sequentially calls submit() for all individuals.

Parameters:

individuals (numpy.typing.ArrayLike) – Input to be submitted.

Returns:

List of IDs of input arrays

class clinamen2.runner.basic_runner.WorkerResult(loss, information)

Bases: tuple

information

Alias for field number 1

loss

Alias for field number 0

Module contents

Copyright 2023-2025 The Clinamen2 contributors

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.