예제 #1
0
 def test_operation(operation, args):
     auger_operation = MockHelpers.called_with(AugerA2ML, operation,
                                               monkeypatch)
     google_operation = MockHelpers.called_with(GoogleA2ML, operation,
                                                monkeypatch)
     #run operation for a single provider
     ctx.config.set('providers', ['auger'])
     a2ml = A2ML(ctx)
     getattr(a2ml, operation)(*args)
     assert auger_operation.times == 1
     assert google_operation.times == 0
     for arg in range(len(args)):
         assert auger_operation.args[arg + 1] == args[arg]
     #run operation for multiple providers
     if operation != 'deploy' and operation != 'predict':
         ctx.config.set('providers', ['auger', 'google'])
         auger_operation.reset()
         google_operation.reset()
         a2ml = A2ML(ctx)
         getattr(a2ml, operation)(*args)
         assert auger_operation.times == 1
         assert google_operation.times == 1
         for arg in range(len(args)):
             assert auger_operation.args[arg + 1] == args[arg]
             assert google_operation.args[arg + 1] == args[arg]
예제 #2
0
def cmdl(ctx, provider, filename, model_id, threshold, locally, output):
    """Predict with deployed model."""
    ctx.setup_logger(format='')
    A2ML(ctx, provider).predict(filename,
                                model_id,
                                threshold=threshold,
                                locally=locally,
                                output=output)
예제 #3
0
    def test_init(self):
        fulldir = os.getcwd() + "/tests/test_google"
        os.chdir(fulldir)
        # load config(s) from test app
        ctx = Context()

        a2ml = A2ML(ctx)
        assert len(a2ml.runner.providers) == 3
        assert isinstance(a2ml.runner.providers[0], GoogleA2ML)
예제 #4
0
    def test_init(self):
        print("Current directory: {}".format(os.getcwd()))
        fulldir = os.getcwd() + "/tests/test_app"
        os.chdir(fulldir)
        # load config(s) from test app
        ctx = Context()

        a2ml = A2ML(ctx)
        assert len(a2ml.runner.providers) == 3
        assert isinstance(a2ml.runner.providers[0], GoogleA2ML)
예제 #5
0
    def test_import_server(self):
        from a2ml.api.a2ml import A2ML

        ctx = Context(path=os.path.join(
            os.environ.get('A2ML_PROJECT_PATH', ''), 'cli-integration-test'),
                      debug=True)
        provider = "auger"
        ctx.config.set('config', 'providers', [provider])
        ctx.config.set('config', 'use_server', True)

        A2ML(ctx, provider).import_data()
예제 #6
0
 def test_init_a2ml(self, project, ctx, monkeypatch):
     init_auger = MockHelpers.count_calls(
         AugerA2ML, "__init__", monkeypatch)
     init_google = MockHelpers.count_calls(
         GoogleA2ML, "__init__", monkeypatch)
     ctx.config.set('config', 'providers', 'auger')
     a2ml = A2ML(ctx)
     assert len(a2ml.runner.providers) == 1
     assert isinstance(a2ml.runner.providers['auger'], AugerA2ML)
     assert init_auger.times == 1
     assert init_google.times == 0
     # modify config on the fly
     ctx.config.set('config', 'providers', ['auger','google'])
     init_auger.reset()
     init_google.reset()
     a2ml = A2ML(ctx)
     assert len(a2ml.runner.providers) == 2
     assert isinstance(a2ml.runner.providers['auger'], AugerA2ML)
     assert isinstance(a2ml.runner.providers['google'], GoogleA2ML)
     assert init_auger.times == 1
     assert init_google.times == 1
예제 #7
0
 def test_init_a2ml(self, monkeypatch):
     init_auger = MockHelpers.count_calls(AugerA2ML, "__init__",
                                          monkeypatch)
     init_google = MockHelpers.count_calls(GoogleA2ML, "__init__",
                                           monkeypatch)
     self.ctx.config['config'].providers = 'auger'
     a2ml = A2ML(self.ctx)
     assert len(a2ml.runner.providers) == 1
     assert isinstance(a2ml.runner.providers[0], AugerA2ML)
     assert init_auger.times == 1
     assert init_google.times == 0
     # modify config on the fly
     self.ctx.config['config'].providers = ['auger', 'google']
     init_auger.reset()
     init_google.reset()
     a2ml = A2ML(self.ctx)
     assert len(a2ml.runner.providers) == 2
     assert isinstance(a2ml.runner.providers[0], AugerA2ML)
     assert isinstance(a2ml.runner.providers[1], GoogleA2ML)
     assert init_auger.times == 1
     assert init_google.times == 1
예제 #8
0
 def test_operation(operation, args):
     auger_operation = MockHelpers.called_with(AugerA2ML, operation,
                                               monkeypatch)
     google_operation = MockHelpers.called_with(GoogleA2ML, operation,
                                                monkeypatch)
     #run operation for a single provider
     self.ctx.config['config'].providers = ['auger']
     a2ml = A2ML(self.ctx)
     getattr(a2ml, operation)(*args)
     assert auger_operation.times == 1
     assert google_operation.times == 0
     for arg in range(len(args)):
         assert auger_operation.args[arg + 1] == args[arg]
     #run operation for multiple providers
     self.ctx.config['config'].providers = ['auger', 'google']
     auger_operation.reset()
     google_operation.reset()
     a2ml = A2ML(self.ctx)
     getattr(a2ml, operation)(*args)
     assert auger_operation.times == 1
     assert google_operation.times == 1
     for arg in range(len(args)):
         assert auger_operation.args[arg + 1] == args[arg]
         assert google_operation.args[arg + 1] == args[arg]
예제 #9
0
def import_data_task(params):
    ctx = create_context(params)

    return A2ML(ctx).import_data()
예제 #10
0
def cmdl(ctx, model_id, locally):
    """Deploy trained model."""
    ctx.setup_logger(format='')
    A2ML(ctx).deploy(model_id, locally)
예제 #11
0
def cmdl(ctx, run_id, provider):
    """Evaluate models after training."""
    ctx.setup_logger(format='')
    A2ML(ctx, provider).evaluate(run_id)
예제 #12
0
def cmdl(ctx, provider, model_id, locally, review):
    """Deploy trained model."""
    ctx.setup_logger(format='')
    A2ML(ctx, provider).deploy(model_id, locally, review)
예제 #13
0
def cmdl(ctx):
    """Import data for training."""
    ctx.setup_logger(format='')
    A2ML(ctx).import_data()
예제 #14
0
파일: cmd_import.py 프로젝트: chrinide/a2ml
def cmdl(ctx, source, provider):
    """Import data for training."""
    ctx.setup_logger(format='')
    A2ML(ctx, provider).import_data(source)
예제 #15
0
def deploy_task(params):
    return with_context(
        params,
        lambda ctx: A2ML(ctx).deploy(*params['args'], **params['kwargs']))
예제 #16
0
def train_task(params):
    return with_context(
        params,
        lambda ctx: A2ML(ctx).train(*params['args'], **params['kwargs']))
예제 #17
0
def cmdl(ctx):
    """Review specified model info."""
    ctx.setup_logger(format='')
    A2ML(ctx).review()
예제 #18
0
def predict_task(params):
    ctx = create_context(params)

    return A2ML(ctx).predict(params.get('filename'), params.get('model_id'),
                             params.get('threshold'))
예제 #19
0
def cmdl(ctx, filename, model_id, threshold, locally):
    """Predict with deployed model."""
    ctx.setup_logger(format='')
    A2ML(ctx).predict(filename, model_id, threshold, locally)
예제 #20
0
def cmdl(ctx):
    """Evaluate models after training."""
    ctx.setup_logger(format='')
    A2ML(ctx).evaluate()
예제 #21
0
def import_data_task(params):
    return with_context(
        params,
        lambda ctx: A2ML(ctx).import_data(*params['args'], **params['kwargs']))
예제 #22
0
def train_task(params):
    ctx = create_context(params)

    return A2ML(ctx).train()
예제 #23
0
def evaluate_task(params):
    return with_context(
        params,
        lambda ctx: A2ML(ctx).evaluate(*params['args'], **params['kwargs']))
예제 #24
0
def evaluate_task(params):
    ctx = create_context(params)

    return A2ML(ctx).evaluate()
예제 #25
0
def predict_task(params):
    return with_context(
        params,
        lambda ctx: A2ML(ctx).predict(*params['args'], **params['kwargs']))
예제 #26
0
def deploy_task(params):
    ctx = create_context(params)

    return A2ML(ctx).deploy(params.get('model_id'))
예제 #27
0
def cmdl(ctx, provider):
    """Train the model."""
    ctx.setup_logger(format='')
    A2ML(ctx, provider).train()
예제 #28
0
파일: tasks_api.py 프로젝트: chrinide/a2ml
def actuals_task(params):
    return with_context(
        params,
        lambda ctx: A2ML(ctx).actuals(*params['args'], **params['kwargs']))