How to use the a2ml.api.a2ml.A2ML function in a2ml

To help you get started, we’ve selected a few a2ml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github augerai / a2ml / tests / test_google_a2ml.py View on Github external
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)
github augerai / a2ml / tests / test_facade.py View on Github external
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]
        ops = {
github augerai / a2ml / tests / test_facade.py View on Github external
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('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('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
github augerai / a2ml / a2ml / tasks_queue / tasks_hub_api.py View on Github external
ctx = _create_provider_context(params)
    provider = params.get('provider', 'auger')
    provider_info = params.get('provider_info', {}).get(provider, {})
    ctx.config.set('dataset', provider_info.get('project_file').get('url'), provider)

    cluster = provider_info.get('project', {}).get('cluster', {})
    ctx.config.set('cluster/name', cluster.get('name'), provider)
    ctx.config.set('cluster/min_nodes', cluster.get('min_nodes'), provider)
    ctx.config.set('cluster/max_nodes', cluster.get('max_nodes'), provider)
    ctx.config.set('cluster/type', cluster.get('type'), provider)

    ctx_hub = _read_hub_experiment_session(ctx, params)
    ctx.config.clean_changes()

    res = A2ML(ctx).train()

    _update_hub_objects(ctx, provider, ctx_hub, params)

    return res
github augerai / a2ml / a2ml / tasks_queue / tasks_hub_api.py View on Github external
def deploy_model_task(params):
    ctx = _create_provider_context(params)
    ctx_hub = _read_hub_experiment_session(ctx, params)

    ctx.config.clean_changes()
    res = A2ML(ctx).deploy(model_id = params.get('model_id'), review = params.get('support_review_model'))
    _update_hub_objects(ctx, params.get('provider'), ctx_hub, params)

    return res
github augerai / a2ml / a2ml / api / a2ml.py View on Github external
"""Initializes A2ML PREDIT instance.

        Args:
            ctx (object): An instance of the a2ml Context.
            provider (str): The automl provider(s) you wish to run. For example 'auger,azure,google'. The default is None - use provider set in config.

        Returns:
            A2ML object

        Examples:
            .. code-block:: python

                ctx = Context()
                a2ml = A2ML(ctx, 'auger, azure')
        """
        super(A2ML, self).__init__(ctx, None)
        self.runner = self.build_runner(ctx, provider)
        self.local_runner = lambda: self.build_runner(ctx, provider, force_local=True)
github augerai / a2ml / a2ml / tasks_queue / tasks_api.py View on Github external
        lambda ctx: A2ML(ctx).predict(*params['args'], **params['kwargs'])
    )
github augerai / a2ml / a2ml / tasks_queue / tasks_hub_api.py View on Github external
def _get_leaderboad(params):
    ctx = _create_provider_context(params)
    provider = params['provider']

    res = A2ML(ctx).evaluate()
    _log(res, level=logging.DEBUG)

    if res.get(provider, {}).get('result'):
        data = res[provider]['data']
        leaderboard = data['leaderboard']
        status = data['status']
        trials_count = data.get('trials_count', 0)

        trials = []

        for item in leaderboard:
            trials.append({
                "uid": item['model id'],
                "score": item['all_scores'][item['primary_metric']],
                "scoring": item['primary_metric'],
                "ensemble": 'Ensemble' in item['algorithm'],
github augerai / a2ml / a2ml / tasks_queue / tasks_api.py View on Github external
        lambda ctx: A2ML(ctx).evaluate(*params['args'], **params['kwargs'])
    )
github augerai / a2ml / a2ml / tasks_queue / tasks_api.py View on Github external
        lambda ctx: A2ML(ctx).deploy(*params['args'], **params['kwargs'])
    )