Skip to content

Commit

Permalink
Adds a check on whether conda is installed when using isolation (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgondu authored Oct 28, 2024
1 parent 45b557b commit a14a954
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/poli/core/util/isolation/instancing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import configparser
import importlib
import logging
import shutil
import subprocess
from pathlib import Path

Expand Down Expand Up @@ -307,6 +308,16 @@ def instance_function_as_isolated_process(
quiet: bool = False,
**kwargs_for_black_box,
) -> ExternalFunction:
# Check if the user has conda installed
if shutil.which("conda") is None:
raise RuntimeError(
"Conda is not installed. For poli's isolation mechanisms to work, "
"we need conda to be installed.\n"
"If you are not interested in using conda, you can install all the "
"relevant dependencies for black boxes using pip and optional arguments.\n"
"Check the documentation of the black box you are interested in for more information."
)

# Register the problem if it hasn't been registered.
register_isolated_function(name=name, quiet=quiet)

Expand Down
13 changes: 13 additions & 0 deletions src/poli/objective_repository/ehrlich/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

from __future__ import annotations

import warnings

import numpy as np

from poli.core.abstract_black_box import AbstractBlackBox
Expand Down Expand Up @@ -106,6 +108,12 @@ def __init__(
num_workers: int = None,
evaluation_budget: int = float("inf"),
):
warnings.warn(
"The EhrlichBlackBox class is deprecated and will be removed in a future version. "
" Please use EhrlichHoloBlackBox after installing with pip install poli[ehrlich].",
DeprecationWarning,
)

super().__init__(batch_size, parallelize, num_workers, evaluation_budget)
self.alphabet = alphabet
self.sequence_length = sequence_length
Expand Down Expand Up @@ -434,6 +442,11 @@ def create(
Closed-Form Test Functions for Biophysical Sequence Optimization Algorithms.
arXiv preprint arXiv:2407.00236. https://arxiv.org/abs/2407.00236
"""
warnings.warn(
"The EhrlichProblemFactory class is deprecated and will be removed in a future version. "
" Please use EhrlichHoloProblemFactory after installing with pip install poli[ehrlich].",
DeprecationWarning,
)
if seed is not None:
seed_python_numpy_and_torch(seed)

Expand Down

0 comments on commit a14a954

Please sign in to comment.