def to_function(self, default_kind=None):
    'generate a function object from the ref definitions'
    if (self.url and ('://' not in self.url)):
        if (not os.path.isfile(self.url)):
            raise OSError(f'{self.url} not found')
    kind = (self.kind or default_kind)
    if self.url:
        if (self.url.endswith('.yaml') or self.url.startswith('db://') or self.url.startswith('hub://')):
            func = mlrun.import_function(self.url)
            if self.image:
                func.spec.image = self.image
        elif self.url.endswith('.ipynb'):
            func = mlrun.code_to_function(self.name, filename=self.url, image=self.image, kind=kind)
        elif self.url.endswith('.py'):
            if (not self.image):
                raise ValueError('image must be provided with py code files, use function object for more control/settings')
            func = mlrun.code_to_function(self.name, filename=self.url, image=self.image, kind=kind)
        else:
            raise ValueError(f'unsupported function url {self.url} or no spec')
        if self.spec:
            func = enrich_function_from_dict(func, self.spec)
    elif (self.code is not None):
        code = self.code
        if (kind == mlrun.runtimes.RuntimeKinds.serving):
            code = (code + mlrun_footer.format(mlrun.runtimes.serving.serving_subkind))
        func = mlrun.new_function(self.name, kind=kind, image=self.image)
        data = b64encode(code.encode('utf-8')).decode('utf-8')
        func.spec.build.functionSourceCode = data
        if (kind not in mlrun.runtimes.RuntimeKinds.nuclio_runtimes()):
            func.spec.default_handler = 'handler'
        if self.spec:
            func = enrich_function_from_dict(func, self.spec)
    elif self.spec:
        func = mlrun.new_function(self.name, runtime=self.spec)
    else:
        raise ValueError('url or spec or code must be specified')
    if self.requirements:
        func.with_requirements(self.requirements)
    self._function = func
    return func
generate a function object from the ref definitions
def to_function(self, default_kind=None):
    
    if (self.url and ('://' not in self.url)):
        if (not os.path.isfile(self.url)):
            raise OSError(f'{self.url} not found')
    kind = (self.kind or default_kind)
    if self.url:
        if (self.url.endswith('.yaml') or self.url.startswith('db://') or self.url.startswith('hub://')):
            func = mlrun.import_function(self.url)
            if self.image:
                func.spec.image = self.image
        elif self.url.endswith('.ipynb'):
            func = mlrun.code_to_function(self.name, filename=self.url, image=self.image, kind=kind)
        elif self.url.endswith('.py'):
            if (not self.image):
                raise ValueError('image must be provided with py code files, use function object for more control/settings')
            func = mlrun.code_to_function(self.name, filename=self.url, image=self.image, kind=kind)
        else:
            raise ValueError(f'unsupported function url {self.url} or no spec')
        if self.spec:
            func = enrich_function_from_dict(func, self.spec)
    elif (self.code is not None):
        code = self.code
        if (kind == mlrun.runtimes.RuntimeKinds.serving):
            code = (code + mlrun_footer.format(mlrun.runtimes.serving.serving_subkind))
        func = mlrun.new_function(self.name, kind=kind, image=self.image)
        data = b64encode(code.encode('utf-8')).decode('utf-8')
        func.spec.build.functionSourceCode = data
        if (kind not in mlrun.runtimes.RuntimeKinds.nuclio_runtimes()):
            func.spec.default_handler = 'handler'
        if self.spec:
            func = enrich_function_from_dict(func, self.spec)
    elif self.spec:
        func = mlrun.new_function(self.name, runtime=self.spec)
    else:
        raise ValueError('url or spec or code must be specified')
    if self.requirements:
        func.with_requirements(self.requirements)
    self._function = func
    return func