MachineLearningLifeScience / poli

A library of discrete objectives
MIT License
13 stars 1 forks source link

A unified interface for isolation inside `AbstractBlackBox` #172

Closed miguelgondu closed 4 months ago

miguelgondu commented 6 months ago

Now all the black boxes that have an isolated function inside them have the following block in their __init__:

# e.g. dockstring
if not force_isolation:
    try:
        from poli.objective_repository.dockstring.isolated_function import (
            IsolatedDockstringFunction,
        )

        self.inner_function = IsolatedDockstringFunction(
            target_name=target_name,
            string_representation=string_representation,
        )
    except ImportError:
        self.inner_function = instance_function_as_isolated_process(
            name="dockstring__isolated",
            target_name=target_name,
            string_representation=string_representation,
        )
else:
    self.inner_function = instance_function_as_isolated_process(
        name="dockstring__isolated",
        target_name=target_name,
        string_representation=string_representation,
    )

Do we have a way of abstracting this process?