From 65697891be538591f57384d3469ab2a7f2a86568 Mon Sep 17 00:00:00 2001 From: Pepper Date: Wed, 4 Dec 2019 04:30:53 +0000 Subject: server_stuff --- ricky/params/__init__.py | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'ricky/params/__init__.py') diff --git a/ricky/params/__init__.py b/ricky/params/__init__.py index 53ac530..82cbc79 100644 --- a/ricky/params/__init__.py +++ b/ricky/params/__init__.py @@ -25,27 +25,14 @@ class Params(object): def __len__(self): return len(self._params) + def _load_probabilities_json(self, probabilities_file=None): - if probabilities_file: - filepath = probabilities_file - else: - filepath = os.path.join( + filepath = probabilities_file or \ + os.path.join( PROBABILITIES_DIR, "%s.json" % (self.__class__.__name__) ) - try: - f = open(filepath, 'r') - data = f.read() - f.close() - return json.loads(data) - except json.scanner.JSONDecodeError as e: - sys.stderr.write("Invalid Json - Problem decoding %s\n" % filepath) - sys.stderr.write("%s\n" % e) - sys.exit(1) - except IOError: - sys.stderr.write( - "Could not find probabilities file %s\n" % filepath) - sys.exit(1) + return json.load(open(filepath)) def randomize( self, @@ -65,7 +52,6 @@ class Params(object): param.randomize(probabilities=probabilities_dict.get(param.name)) - def execute(self): """calls the associated api""" if OFFLINE: @@ -94,12 +80,6 @@ class Params(object): result[param.name] = param.value return result - def as_normalized(self): - return tuple([ - {'name': param.name, 'normalized': param.as_normalized()} - for param in self._params - ]) - def as_serialized(self): """ returns params in serialized form to use in a dataset @@ -120,7 +100,11 @@ class Params(object): param.value = params_dict[param.name] @classmethod - def from_classname(cls, classname): + def new_class_from_classname(cls, classname): + """ + #FIXME make this class a plugin parent class + anything else look weird here? + """ for subclass in cls.__subclasses__(): if subclass.__name__ == classname: return subclass() -- cgit v1.2.3-70-g09d2