How to use the mlrun.utils.logger.info function in mlrun

To help you get started, we’ve selected a few mlrun 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 mlrun / mlrun / mlrun / api / api / endpoints / runs.py View on Github external
async def update_run(
        request: Request,
        project: str,
        uid: str,
        iter: int = 0,
        db_session: Session = Depends(deps.get_db_session)):
    data = None
    try:
        data = await request.json()
    except ValueError:
        log_and_raise(HTTPStatus.BAD_REQUEST, reason="bad JSON body")

    logger.debug(data)
    await run_in_threadpool(get_db().update_run, db_session, data, uid, project, iter=iter)
    logger.info("update run: {}".format(data))
    return {}
github mlrun / mlrun / mlrun / runtimes / base.py View on Github external
results_tbl.show()

            uid = runspec.metadata.uid
            proj = (
                '--project {}'.format(runspec.metadata.project)
                if runspec.metadata.project
                else ''
            )
            print(
                'to track results use .show() or .logs() or in CLI: \n'
                '!mlrun get run {} {} , !mlrun logs {} {}'.format(uid, proj, uid, proj)
            )

        if result:
            run = RunObject.from_dict(result)
            logger.info('run executed, status={}'.format(run.status.state))
            if run.status.state == 'error':
                if self._is_remote and not self.is_child:
                    print('runtime error: {}'.format(run.status.error))
                raise RunError(run.status.error)
            return run

        return None
github mlrun / mlrun / mlrun / k8s_utils.py View on Github external
body.data = data
        if name.endswith('*'):
            body.metadata = client.V1ObjectMeta(generate_name=name[:-1],
                                                namespace=namespace,
                                                labels=labels)
        else:
            body.metadata = client.V1ObjectMeta(name=name,
                                                namespace=namespace,
                                                labels=labels)
        try:
            resp = self.v1api.create_namespaced_config_map(namespace, body)
        except ApiException as e:
            logger.error('failed to create configmap: {}'.format(e))
            raise e

        logger.info(f'ConfigMap {resp.metadata.name} created')
        return resp.metadata.name
github mlrun / mlrun / mlrun / api / singletons.py View on Github external
def _initialize_db():
    global db
    if config.httpdb.db_type == "filedb":
        logger.info("using FileRunDB")
        db = FileDB(config.httpdb.dirpath)
        db.initialize(None)
    else:
        logger.info("using SQLDB")
        db = SQLDB(config.httpdb.dsn)
        db_session = None
        try:
            db_session = create_session()
            db.initialize(db_session)
        finally:
            db_session.close()
github mlrun / mlrun / mlrun / runtimes / daskjob.py View on Github external
namespace = namespace or config.namespace
    selector = ','.join(['dask.org/component=scheduler'] + selector)
    pods = k8s.list_pods(namespace, selector=selector)
    status = ''
    for pod in pods:
        status = pod.status.phase.lower()
        print(pod)
        if status == 'running':
            cluster = pod.metadata.labels.get('dask.org/cluster-name')
            logger.info(
                'found running dask function {}, cluster={}'.format(
                    pod.metadata.name, cluster
                )
            )
            return status
        logger.info(
            'found dask function {} in non ready state ({})'.format(
                pod.metadata.name, status
            )
        )
    return status
github mlrun / mlrun / mlrun / api / api / endpoints / functions.py View on Github external
async def store_function(
        request: Request,
        project: str,
        name: str,
        tag: str = "",
        versioned: bool = False,
        db_session: Session = Depends(deps.get_db_session)):
    data = None
    try:
        data = await request.json()
    except ValueError:
        log_and_raise(HTTPStatus.BAD_REQUEST, reason="bad JSON body")

    logger.debug(data)
    logger.info(
        "store function: project=%s, name=%s, tag=%s", project, name, tag)
    await run_in_threadpool(get_db().store_function, db_session, data, name, project, tag=tag, versioned=versioned)
    return {}
github mlrun / mlrun / mlrun / api / api / endpoints / functions.py View on Github external
def _get_function_status(data):
    logger.info("function_status:\n{}".format(data))
    selector = data.get("selector")
    kind = data.get("kind")
    if not selector or not kind:
        log_and_raise(HTTPStatus.BAD_REQUEST, reason="runtime error: selector or runtime kind not specified")

    resource = runtime_resources_map.get(kind)
    if "status" not in resource:
        log_and_raise(HTTPStatus.BAD_REQUEST, reason="runtime error: 'status' not supported by this runtime")

    resp = None
    try:
        resp = resource["status"](selector)
        logger.info("status: %s", resp)
    except Exception as err:
        logger.error(traceback.format_exc())
        log_and_raise(HTTPStatus.BAD_REQUEST, reason="runtime error: {}".format(err))
github mlrun / mlrun / mlrun / api / api / utils.py View on Github external
schedule = data.get("schedule")
        if schedule:
            args = (task,)
            job_id = get_scheduler().add(schedule, fn, args)
            get_db().store_schedule(db_session, data)
            response = {"schedule": schedule, "id": job_id}
        else:
            run = fn.run(task, watch=False)
            if run:
                response = run.to_dict()

    except Exception as err:
        logger.error(traceback.format_exc())
        log_and_raise(HTTPStatus.BAD_REQUEST, reason="runtime error: {}".format(err))

    logger.info("response: %s", response)
    return {
        "data": response,
    }
github mlrun / mlrun / mlrun / runtimes / container.py View on Github external
pod = self.status.build_pod
            if not self.status.state == 'ready' and pod:
                k8s = self._get_k8s()
                status = k8s.get_pod_status(pod)
                if logs:
                    if watch:
                        status = k8s.watch(pod)
                    else:
                        resp = k8s.logs(pod)
                        if resp:
                            print(resp.encode())

                if status == 'succeeded':
                    self.status.build_pod = None
                    self.status.state = 'ready'
                    logger.info('build completed successfully')
                    return 'ready'
                if status in ['failed', 'error']:
                    self.status.state = status
                    logger.error(' build {}, watch the build pod logs: {}'.format(status, pod))
                    return status

                logger.info('builder status is: {}, wait for it to complete'.format(status))
            return None