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
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'
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
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
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)
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')
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)
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)
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)
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
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()
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()
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()
def ctx(): # load config(s) from the test app return Context()
def ctx(): # load config(s) from the test app ctx = Context() ctx.rest_api = RestApi('api_url', 'token') return ctx
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()
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
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()
def test_train(self): ctx = Context() a2ml = GoogleA2ML(ctx) result = a2ml.train() print("Train result: {}", format(result))