Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
S2-group
GitHub Repository: S2-group/android-runner
Path: blob/master/AndroidRunner/ExperimentFactory.py
629 views
1
import logging
2
import os.path as op
3
import shutil
4
5
import paths
6
from . import util
7
from .Experiment import Experiment
8
from .NativeExperiment import NativeExperiment
9
from .Progress import Progress
10
from .WebExperiment import WebExperiment
11
from tests.PluginTests import PluginTests
12
13
logger = logging.getLogger('ExperimentFactory')
14
15
16
class ExperimentFactory(object):
17
def __init__(self):
18
pass
19
20
@staticmethod
21
def from_json(path, progress):
22
"""Returns an Experiment object from a JSON configuration"""
23
logger.info(path)
24
shutil.copy(path, op.join(paths.OUTPUT_DIR, 'config.json'))
25
config = util.load_json(path)
26
experiment_type = config['type']
27
if experiment_type == 'plugintest':
28
return PluginTests(config)
29
if progress is None:
30
progress = Progress(config_file=path, config=config, load_progress=False)
31
restart = False
32
else:
33
restart = True
34
if experiment_type == 'native':
35
return NativeExperiment(config, progress, restart)
36
elif experiment_type == 'web':
37
return WebExperiment(config, progress, restart)
38
else:
39
return Experiment(config, progress, restart)
40
41