Commit e5b6cf6b authored by Samuel GAIST's avatar Samuel GAIST Committed by Samuel GAIST

[experiment] Properly handle "default" case

There's no prototype available for the experiment as it
needs to be configured with the content of a prefix based
on the toolchain selected for it.
parent 787761be
Pipeline #29955 passed with stage
in 16 minutes and 19 seconds
...@@ -52,7 +52,6 @@ from . import algorithm ...@@ -52,7 +52,6 @@ from . import algorithm
from . import schema from . import schema
from . import database from . import database
from . import toolchain from . import toolchain
from . import prototypes
from . import hash from . import hash
...@@ -233,12 +232,10 @@ class Experiment(object): ...@@ -233,12 +232,10 @@ class Experiment(object):
self.data = None self.data = None
self.errors = [] self.errors = []
if data is None: # loads prototype and validates it if data is None: # Invalid case
# There can't be a prototype for experiments they must be
experiment_data, self.errors = prototypes.load("experiment") # filled based on the toolchain and the content of the prefix
assert not self.errors, "\n * %s" % "\n *".join(self.errors) # nosec raise RuntimeError("Experiments can't have default implementation")
toolchain_data, self.errors = prototypes.load("toolchain")
assert not self.errors, "\n * %s" % "\n *".join(self.errors) # nosec
elif isinstance(data, (tuple, list)): # the user has passed a tuple elif isinstance(data, (tuple, list)): # the user has passed a tuple
......
...@@ -42,6 +42,17 @@ from . import prefix, tmp_prefix ...@@ -42,6 +42,17 @@ from . import prefix, tmp_prefix
from .utils import cleanup from .utils import cleanup
# ----------------------------------------------------------
@nose.tools.raises(RuntimeError)
def test_load_default_experiment_fails():
Experiment(prefix, data=None)
# ----------------------------------------------------------
def test_load_valid_experiment(): def test_load_valid_experiment():
experiment = Experiment(prefix, "user/integers_addition/1/integers_addition") experiment = Experiment(prefix, "user/integers_addition/1/integers_addition")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment