Git Product home page Git Product logo

mopet's People

Contributors

caglorithm avatar lrebscher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mopet's Issues

Receiving ObjectStoreFullError when running Brian2 simulations with Mopet

The error is thrown when ray's ObjectStore is full. This problem is described in FAQ of ray.

Proposed solution is to enable LRU fallback:

ray.init(lru_evict=True)

LRU strategy was used in previous versions of ray, FAQ suggests to enable it again for applications that keep references to all objects ever created (such as iPython/JupyterNotebook).

As this library is focused mainly on scientific computing where many use Jupyter Nootebok, I would suggest to set enable lru_evict=True per default and allow in the Exploration.__init__() to disable it.

Bildschirmfoto 2020-06-05 um 10 18 24

Uncaught NodeError if exploration with name exists and is run again

Description

If I run an exploration with a specific name and then rerun it, it fails as there exists already a node in the HD5 file.

I would have not expected this behavior, instead I expected that it would overwrite the previous run. E.g., I was changing the parameter combinations and just wanted to rerun it (iterative improvement of the experiment design).

However, there are also reasons why this might be a desired behavior, such as protecting against accidental overwrite. If so, I would propose two things: (1) handle exception and provide user friendly warning and (2) add an optional overwrite param to the run method that will delete existing node and save the new results.

Minimal Example

Run the script two times. Second time will fail as HD5 node already exists.

from mopet import mopet
import numpy as np

def run(params):
    return {}


params = {"a": np.arange(0, 1, 0.5)}

ex = mopet.Exploration(run, params, exploration_name="testA")
ex.run()
ex.load_results()
Traceback (most recent call last):
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/synchronization/mopet_test.py", line 11, in <module>
    ex.run()
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 129, in run
    self._pre_storage_routine()
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 328, in _pre_storage_routine
    self._init_hdf()
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 300, in _init_hdf
    self.run_group = self.h5file.create_group("/", self.exploration_name)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/file.py", line 940, in create_group
    title=title, new=True, filters=filters)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/group.py", line 235, in __init__
    super(Group, self).__init__(parentnode, name, _log)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/node.py", line 255, in __init__
    parentnode._g_refnode(self, name, validate)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/group.py", line 526, in _g_refnode
    % (self._v_pathname, childname))
tables.exceptions.NodeError: group ``/`` already has a child node named ``testA``
Closing remaining open files:exploration.h5...done

bool values get transformed to numpy float type

Description

Problem is that 0 dim arrays get always converted to float without checking the type of the given value.

Minimal Example:

import numpy as np
from mopet import mopet

def run(params):
    return {
        "test": True,
        "test2": False
    }

ex = mopet.Exploration(run, {"a": np.arange(0, 1, 0.5)})
ex.run()
ex.load_results()

print(ex.df)

Output:

     a  test  test2
0    0   1.0    0.0
1  0.5   1.0    0.0

Values for test and test2 changed from bool type to numpy float type.

Uncaught NoSuchNodeError if Exploration cannot be found in HDF

Description

Currently, if you try to load results of an exploration that has not been stored in the HDF, a tables.exceptions.NoSuchNodeError gets thrown that is not handled in mopet and terminates the python script.

I would suggest to catch the exception and log an error message that points out that the Exploration with the specified exploration_name has not been stored in the HDF file.
We could return either an empty DataFrame or throw a custom exception such as ExplorationNotFound holding the error message. If we throw an exception we can add it to the method docs so that users can react to it.

Minimal Example

from mopet import mopet
import numpy as np

def run(params):
    return {}

params = {"a": np.arange(0, 1, 0.5)}

ex = mopet.Exploration(run, params, exploration_name="testA")
ex.load_results()
Traceback (most recent call last):
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/synchronization/mopet_test.py", line 12, in <module>
    ex.load_results()
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 184, in load_results
    self._load_all_results(exploration_name, all=all)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 446, in _load_all_results
    hdf_runs_group = self.h5file.get_node("/" + self.exploration_name, "runs")
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/file.py", line 1642, in get_node
    node = self._get_node(nodepath)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/file.py", line 1590, in _get_node
    node = self._node_manager.get_node(nodepath)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/file.py", line 432, in get_node
    node = self.node_factory(key)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/group.py", line 1178, in _g_load_child
    node_type = self._g_check_has_child(childname)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/tables/group.py", line 395, in _g_check_has_child
    % (self._v_pathname, name))
tables.exceptions.NoSuchNodeError: group ``/`` does not have a child named ``/testA/runs``
Closing remaining open files:exploration.h5...done

int value im return dict führt zu AttributeError

Beschreibung

In der _read_group_as_dict Methode wird in der if value.ndim == 0: Condition ein 0-dim array ggfs in numpy.float64 umgewandelt. Jedoch kann value auch von Typ int sein, welcher kein ndim attribut besitzt. Das führt momentan zu einem nicht abgefangenen AttributeError.

Minimales Beispiel:

from mopet import mopet

def run(params):
    print(params)
    return {
        "test": 1
    }

params = { "a": [1, 2]}

ex = mopet.Exploration(run, params)
ex.run()
ex.load_results()

Stacktrace:

Traceback (most recent call last):
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/synchronization/mopet_test.py", line 14, in <module>
    ex.load_results()
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 282, in load_results
    self._hdf_get_data_from_exploration(exploration_name)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 318, in _hdf_get_data_from_exploration
    self._get_run_results(child, run_id)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 328, in _get_run_results
    self.results[run_id] = self._read_group_as_dict(hdf_run)
  File "/Users/lrebscher/git/Synchronization-by-Uncorrelated-Noise/venv/lib/python3.7/site-packages/mopet/mopet.py", line 346, in _read_group_as_dict
    if value.ndim == 0:
AttributeError: 'int' object has no attribute 'ndim'

Lösung

Den Zugriff auf ndim absichern mit:

if hasattr(value, 'ndim') and value.ndim == 0:`

Configure number of CPU cores or GPUs that should be used in Exploration

If we're using mopet on a shared server, it is of high interest to optionally limit the number of CPU cores or GPUs for a given exploration.

Otherwise mopet acts greedy and uses all available cores to full extent and other users are not able to run their own simulations anymore.

Example: we have a server with 64 CPU cores. For my exploration it is sufficient to use 12 cores and accept longer waiting times.

Ray offers this kind of functionality and can be configured in ray.init().
We just have to offer these parameters in the Exploration as well.

It's also nice to have if you run simulations on your local machine as you can reserve some CPU cores for other processes so that you can continue to work on other tasks.

exploration.run() should support kwargs

When calling .run(a = 0), they should be passed on to the exploration function a la

def function(params, kwargs):
    a = kwargs['a']
    b = params['b']
    if a * b > 0:
        return {"good" : True}
    else:
        return {"good" : False}

Support for Python 3.8

Installing mopet in Python 3.8.x environment is currently not possible as the project's python requirement is set to >= 3.6, < 3.8.

pip install mopet
ERROR: Could not find a version that satisfies the requirement mopet (from versions: none)
ERROR: No matching distribution found for mopet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.