예제 #1
0
파일: conftest.py 프로젝트: chrinide/a2ml
def ctx(project):
    ctx = Context(debug=False)
    ctx.config.set('providers', ["auger"])
    ctx.config.set('experiment/name', 'iris-1.csv-experiment')
    ctx.config.set('dataset', 'iris.csv')

    return ctx
예제 #2
0
    def test_minimal_arguments_successfull_creation(self, runner, isolated):
        # successful status
        result = runner.invoke(cmdl, ['new', 'test_project'])
        assert result.exit_code == 0

        # directory created
        target_dir = os.path.join(os.getcwd(), 'test_project')
        assert os.path.exists(target_dir) and os.path.isdir(target_dir)

        # config file exists
        config_file = os.path.join(target_dir, 'auger.yaml')
        assert os.path.exists(config_file)

        # config contains proper data
        config = Context(path=target_dir).config
        assert config.get('name', '') == 'test_project'
예제 #3
0
def create_context(params, new_project=False):
    if params.get('context'):
        ctx = jsonpickle.decode(params['context'])

        ctx.set_runs_on_server(True)
        ctx.config.set('config', 'use_server', False)
        ctx.notificator = notificator
        ctx.request_id = params['_request_id']
        ctx.setup_logger(format='')
    else:
        # For Tasks Test Only!
        project_path = os.path.join(os.environ.get('A2ML_PROJECT_PATH', ''),
                                    params.get('project_name'))

        ctx = Context(path=project_path, debug=params.get("debug_log", False))

        if not new_project:
            if params.get("provider"):
                ctx.config.set('config', 'providers', [params.get("provider")])

            if params.get("source_path"):
                ctx.config.set('config', 'source', params.get("source_path"))

    tmp_dir = os.path.join(os.path.dirname(__file__), 'tmp')

    if not os.path.exists(tmp_dir):
        os.makedirs(tmp_dir)

    # For Azure, since it package current directory
    os.chdir(tmp_dir)

    return ctx
예제 #4
0
파일: tasks_api.py 프로젝트: chrinide/a2ml
def create_context(params, new_project=False):
    if params.get('context'):
        ctx = jsonpickle.decode(params['context'])

        # Server mode supports only one provider in request
        provider = params.get('provider') or to_list(
            ctx.config.get('providers'))[0]
        ctx.name = provider
        ctx.config.name = provider

        ctx.set_runs_on_server(True)
        ctx.config.set('use_server', False, config_name='config')
        ctx.notificator = notificator
        ctx.request_id = params['_request_id']
        ctx.setup_logger(format='')
    else:
        ctx = Context(path=params.get('project_path'),
                      debug=params.get('debug_log', False))

        if not new_project:
            if params.get('provider'):
                ctx.config.set('providers', [params.get('provider')],
                               config_name='config')

            if params.get('source_path'):
                ctx.config.set('source',
                               params.get('source_path'),
                               config_name='config')

    return ctx
예제 #5
0
    def test_import_data(self):

        # load config(s) from test app
        self.ctx = Context()

        a2ml = GoogleA2ML(self.ctx)
        result = a2ml.import_data()
        assert (len(result.dataset_id) > 0)
예제 #6
0
    def test_full_set_of_arguments(self, log, runner, isolated, project):
        os.chdir('..')
        result = runner.invoke(cmdl, [
            'new', 'new_project', '--model-type', 'regression', '--target',
            'target_column', '--source', 'cli-integration-test/iris.csv'
        ])

        assert result.exit_code == 0

        target_dir = os.path.join(os.getcwd(), 'new_project')
        config = Context(path=target_dir).config

        assert config.get('model_type', '') == 'regression'
        assert config.get('target', '') == 'target_column'
        assert config.get('source',
                          '') == os.path.join(os.getcwd(),
                                              'cli-integration-test',
                                              'iris.csv')
예제 #7
0
    def test_import_data(self):
        print("Current directory: {}".format(os.getcwd()))

        # load config(s) from test app
        self.ctx = Context()

        a2ml = GoogleA2ML(self.ctx)
        result = a2ml.import_data()
        assert (len(result.dataset_id) > 0)
예제 #8
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)
예제 #9
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)
예제 #10
0
def create_context(params, new_project=False):
    # TODO:path to config files
    project_path = os.path.join(os.environ.get('A2ML_PROJECT_PATH'),
                                params.get('project_name'))

    os.chdir("tmp")
    print(os.getcwd())
    ctx = Context(path=project_path, debug=params.get("debug_log", False))
    ctx.runs_on_server = True
    ctx.setup_logger(format='')

    if not new_project:
        if params.get("provider"):
            ctx.config.set('config', 'providers', [params.get("provider")])

        if params.get("source_path"):
            ctx.config.set('config', 'source', params.get("source_path"))

    if os.environ.get('AUGER_PROJECT_API_TOKEN'):
        os.environ['AUGER_CREDENTIALS'] = json.dumps({
            'organization':
            os.environ.get('AUGER_ORGANIZATION'),
            'url':
            os.environ.get('HUB_APP_URL'),
            'token':
            os.environ.get('AUGER_PROJECT_API_TOKEN')
        })

    if os.environ.get('AZURE_SUBSCRIPTION_ID'):
        ctx.config.set('azure', 'subscription_id',
                       os.environ.get('AZURE_SUBSCRIPTION_ID'))

    if os.environ.get('AZURE_SERVICE_PRINCIPAL_TENANT_ID'):
        os.environ['AZURE_CREDENTIALS'] = json.dumps({
            'service_principal_tenant_id':
            os.environ.get('AZURE_SERVICE_PRINCIPAL_TENANT_ID'),
            'service_principal_id':
            os.environ.get('AZURE_SERVICE_PRINCIPAL_ID'),
            'service_principal_password':
            os.environ.get('AZURE_SERVICE_PRINCIPAL_PASSWORD')
        })

    return ctx
예제 #11
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()
예제 #12
0
파일: test_tasks.py 프로젝트: chrinide/a2ml
    def test_list_projects_server(self):
        from a2ml.api.a2ml_project import A2MLProject

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

        A2MLProject(ctx, provider).list()
예제 #13
0
class TestAzureA2ML():
    @pytest.mark.skip(reason='make it work first')
    def test_init(self):
        print("Current directory: {}".format(os.getcwd()))
        fulldir = os.getcwd() + "/tests/test_app"
        os.chdir(fulldir)

    @pytest.mark.skip(reason='make it work first')
    def test_import_data(self):
        print("Current directory: {}".format(os.getcwd()))
        self.ctx = Context()
        print("Project name: {}".format(self.ctx.config.get('name')))
        a2ml = AzureA2ML(self.ctx.copy('azure'))
        a2ml.import_data()
예제 #14
0
def ctx():
    # load config(s) from the test app
    return Context()
예제 #15
0
def ctx():
    # load config(s) from the test app
    ctx = Context()
    ctx.rest_api = RestApi('api_url', 'token')
    return ctx
예제 #16
0
 def test_import_data(self):
     print("Current directory: {}".format(os.getcwd()))
     self.ctx = Context()
     print("Project name: {}".format(self.ctx.config['config'].name))
     a2ml = AzureA2ML(self.ctx)
     a2ml.import_data()
예제 #17
0
파일: conftest.py 프로젝트: chrinide/a2ml
def ctx_api():
    # load config(s) from the test app
    ctx = Context(debug=True)
    ctx.config.set('providers', ["auger"])
    ctx.rest_api = RestApi('api_url', 'token')
    return ctx
예제 #18
0
 def setup_method(self, method):
     self.cwd = os.getcwd()
     # run test in context of the test app
     os.chdir('tests/test_app')
     # load config(s) from the test app
     self.ctx = Context()
예제 #19
0
 def test_train(self):
     ctx = Context()
     a2ml = GoogleA2ML(ctx)
     result = a2ml.train()
     print("Train result: {}", format(result))