How to use the a2ml.api.utils.dict_dig 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 / a2ml / tasks_queue / tasks_hub_api.py View on Github external
def _create_provider_context(params):
    provider = params.get('provider', 'auger')

    ctx = Context(
        name=provider,
        path=params.get('hub_info', {}).get('projectPath'),
        debug=task_config.debug
    )
    ctx.set_runs_on_server(True)
    ctx.config.set('providers', [provider])

    hub_info = params.get('hub_info', {})
    provider_info = params.get('provider_info', {}).get(provider, {})
    project_name = dict_dig(provider_info, 'project', 'name') or hub_info.get('project_name')
    experiment_name = dict_dig(provider_info, 'experiment', 'name') or hub_info.get('experiment_name')

    if project_name:
        ctx.config.set('name', project_name, provider)
    if experiment_name:
        ctx.config.set('experiment/name', experiment_name, provider)
    if provider_info.get('experiment_session', {}).get('id'):
        ctx.config.set('experiment/run_id', provider_info['experiment_session']['id'], provider)

    return ctx
github augerai / a2ml / a2ml / tasks_queue / tasks_hub_api.py View on Github external
def _create_provider_context(params):
    provider = params.get('provider', 'auger')

    ctx = Context(
        name=provider,
        path=params.get('hub_info', {}).get('projectPath'),
        debug=task_config.debug
    )
    ctx.set_runs_on_server(True)
    ctx.config.set('providers', [provider])

    hub_info = params.get('hub_info', {})
    provider_info = params.get('provider_info', {}).get(provider, {})
    project_name = dict_dig(provider_info, 'project', 'name') or hub_info.get('project_name')
    experiment_name = dict_dig(provider_info, 'experiment', 'name') or hub_info.get('experiment_name')

    if project_name:
        ctx.config.set('name', project_name, provider)
    if experiment_name:
        ctx.config.set('experiment/name', experiment_name, provider)
    if provider_info.get('experiment_session', {}).get('id'):
        ctx.config.set('experiment/run_id', provider_info['experiment_session']['id'], provider)

    return ctx
github augerai / a2ml / a2ml / api / utils / remote_runner.py View on Github external
def download_prediction_result(self, results, local_file):
        for provider in results.keys():
            result = results[provider]
            predicted = dict_dig(result, 'data', 'predicted')
            if predicted and type(predicted)==str and fsclient.is_s3_path(predicted):
                file_path = os.path.splitext(local_file)[0] + '_predicted.csv'
                client = self.create_uploader()
                client.download(predicted, file_path)
                result['data']['predicted'] = file_path
                self.ctx.log(f'{predicted} downloaded to {file_path}')
github augerai / a2ml / a2ml / api / utils / remote_runner.py View on Github external
async def wait_result(self, request_id, local_file):
        data = {}

        while not self.get_response_data_type(data) == 'result':
            data = await self.connect_and_get_result(request_id, local_file)

        if data.get('status') == 'SUCCESS':
            result = data.get('result', {})
            return dict_dig(result, 'response') or result
        else:
            return {
                self.provider: {
                    'result': False,
                    'data': "Server error. Details: %s"%data.get('result')
                }