brandontrabucco/design-bench

AttributeError: module 'numpy' has no attribute 'loads'

Opened this issue · 4 comments

Hi,

After following the instructions in the readme (creating a new environment mbo with the required dependencies) and trying to create a new task, I get the following error:

task = design_bench.make('Superconductor-GP-v0')
/mnt/home/envs/mbo/lib/python3.9/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator GaussianProcessRegressor from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/home/github/design-bench/design_bench/registration.py", line 327, in make
    return registry.make(task_name, dataset_kwargs=dataset_kwargs,
  File "/mnt/home/github/design-bench/design_bench/registration.py", line 155, in make
    return self.spec(task_name).make(
  File "/mnt/home/github/design-bench/design_bench/registration.py", line 109, in make
    return Task(self.dataset, self.oracle,
  File "/mnt/home/github/design-bench/design_bench/task.py", line 263, in __init__
    oracle = import_name(oracle)(dataset, **kwargs)
  File "/mnt/home/github/design-bench/design_bench/oracles/sklearn/gaussian_process_oracle.py", line 91, in __init__
    super(GaussianProcessOracle, self).__init__(
  File "/mnt/home/github/design-bench/design_bench/oracles/approximate_oracle.py", line 300, in __init__
    self.params = self.load_params(self.resource.disk_target)
  File "/mnt/home/github/design-bench/design_bench/oracles/approximate_oracle.py", line 394, in load_params
    rank_correlation = np.loads(file.read())
  File "/mnt/home/envs/mbo/lib/python3.9/site-packages/numpy/__init__.py", line 315, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'loads'

It seems like loads does not exist in this version of Numpy ('1.22.3'). Changing the method call to np.load(...) also does not fix the issue and throws another error.

Thanks.

Hi christopher-beckham,

Thanks for your interest in design-bench!

Can you try this with numpy==1.18.5, which is the version of numpy that we used here: https://github.com/brandontrabucco/design-baselines/blob/master/requirements.txt? Let me know if you have any additional questions.

-Brandon

Hi @brandontrabucco

Thanks for that. Can't believe I missed that requirements.txt file. However, upon correctly downgrading to 1.18.5 (verified it with np.__version__) I get this:

>>> import design_bench
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/beckhamc/.local/lib/python3.7/site-packages/design_bench/__init__.py", line 4, in <module>
    from design_bench.oracles.feature_extractors.\
  File "/home/beckhamc/.local/lib/python3.7/site-packages/design_bench/oracles/feature_extractors/morgan_fingerprint_features.py", line 5, in <module>
    from deepchem.feat.smiles_tokenizer import SmilesTokenizer
  File "/home/beckhamc/.local/lib/python3.7/site-packages/deepchem/__init__.py", line 8, in <module>
    import deepchem.data
  File "/home/beckhamc/.local/lib/python3.7/site-packages/deepchem/data/__init__.py", line 7, in <module>
    from deepchem.data.datasets import pad_features
  File "/home/beckhamc/.local/lib/python3.7/site-packages/deepchem/data/datasets.py", line 18, in <module>
    from numpy.typing import ArrayLike
ModuleNotFoundError: No module named 'numpy.typing'

Installing 1.21.1 seems to fix this however.

I am still having this issue, neither using numpy 1.21.1 nor 1.18.5 seems to be fixing it.

Hi @erfanhamdi

This is a bit of a late response but I had to setup a fresh environment lately for Design Bench and found that 1.22.0 worked.

If you're still interested in using Design Bench I am working on my own fork which fixes some of these issues, it seems like the current code requires some much older dependencies like this version of numpy.