prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  bug(v2): relative file paths in url types
  Passing relative file paths gives a validation error:
  
  ```python
  from docarray import Image
  
  url = 'Test/05978.jpg'
  img = Image(url=url)
  ```
  
  ```text
  Test/05978.jpg
  Traceback (most recent call last):
    File "/home/johannes/.config/JetBrains/PyCharmCE2022.3/scratches/scratch_116.py", line 12, in <module>
      img = Image(url=url)
    File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
  pydantic.error_wrappers.ValidationError: 1 validation error for Image
  url
    unsupported operand type(s) for +: 'NoneType' and 'str' (type=type_error)
  ```
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `docarray/typing/url/any_url.py`
  Content:
  ```
  1 from typing import TYPE_CHECKING, Type, TypeVar
  2 
  3 from pydantic import AnyUrl as BaseAnyUrl
  4 from pydantic import errors, parse_obj_as
  5 
  6 from docarray.typing.abstract_type import AbstractType
  7 
  8 if TYPE_CHECKING:
  9     from pydantic.networks import Parts
  10 
  11     from docarray.proto import NodeProto
  12 
  13 T = TypeVar('T', bound='AnyUrl')
  14 
  15 
  16 class AnyUrl(BaseAnyUrl, AbstractType):
  17     host_required = (
  18         False  # turn off host requirement to allow passing of local paths as URL
  19     )
  20 
  21     def _to_node_protobuf(self) -> 'NodeProto':
  22         """Convert Document into a NodeProto protobuf message. This function should
  23         be called when the Document is nested into another Document that need to
  24         be converted into a protobuf
  25 
  26         :return: the nested item protobuf message
  27         """
  28         from docarray.proto import NodeProto
  29 
  30         return NodeProto(any_url=str(self))
  31 
  32     @classmethod
  33     def validate_parts(cls, parts: 'Parts', validate_port: bool = True) -> 'Parts':
  34         """
  35         A method used to validate parts of a URL.
  36         Our URLs should be able to function both in local and remote settings.
  37         Therefore, we allow missing `scheme`, making it possible to pass a file path.
  38         """
  39         scheme = parts['scheme']
  40         if scheme is None:
  41             pass  # allow missing scheme, unlike pydantic
  42 
  43         elif cls.allowed_schemes and scheme.lower() not in cls.allowed_schemes:
  44             raise errors.UrlSchemePermittedError(set(cls.allowed_schemes))
  45 
  46         if validate_port:
  47             cls._validate_port(parts['port'])
  48 
  49         user = parts['user']
  50         if cls.user_required and user is None:
  51             raise errors.UrlUserInfoError()
  52 
  53         return parts
  54 
  55     @classmethod
  56     def from_protobuf(cls: Type[T], pb_msg: 'str') -> T:
  57         """
  58         read url from a proto msg
  59         :param pb_msg:
  60         :return: url
  61         """
  62         return parse_obj_as(cls, pb_msg)
  63
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/docarray/typing/url/any_url.py b/docarray/typing/url/any_url.py
  --- a/docarray/typing/url/any_url.py
  +++ b/docarray/typing/url/any_url.py
  @@ -1,4 +1,4 @@
  -from typing import TYPE_CHECKING, Type, TypeVar
  +from typing import TYPE_CHECKING, Optional, Type, TypeVar
   
   from pydantic import AnyUrl as BaseAnyUrl
   from pydantic import errors, parse_obj_as
  @@ -34,11 +34,14 @@
           """
           A method used to validate parts of a URL.
           Our URLs should be able to function both in local and remote settings.
  -        Therefore, we allow missing `scheme`, making it possible to pass a file path.
  +        Therefore, we allow missing `scheme`, making it possible to pass a file
  +        path without prefix.
  +        If `scheme` is missing, we assume it is a local file path.
           """
           scheme = parts['scheme']
           if scheme is None:
  -            pass  # allow missing scheme, unlike pydantic
  +            # allow missing scheme, unlike pydantic
  +            pass
   
           elif cls.allowed_schemes and scheme.lower() not in cls.allowed_schemes:
               raise errors.UrlSchemePermittedError(set(cls.allowed_schemes))
  @@ -52,6 +55,44 @@
   
           return parts
   
  +    @classmethod
  +    def build(
  +        cls,
  +        *,
  +        scheme: str,
  +        user: Optional[str] = None,
  +        password: Optional[str] = None,
  +        host: str,
  +        port: Optional[str] = None,
  +        path: Optional[str] = None,
  +        query: Optional[str] = None,
  +        fragment: Optional[str] = None,
  +        **_kwargs: str,
  +    ) -> str:
  +        """
  +        Build a URL from its parts.
  +        The only difference from the pydantic implementation is that we allow
  +        missing `scheme`, making it possible to pass a file path without prefix.
  +        """
  +
  +        # allow missing scheme, unlike pydantic
  +        scheme_ = scheme if scheme is not None else ''
  +        url = super().build(
  +            scheme=scheme_,
  +            user=user,
  +            password=password,
  +            host=host,
  +            port=port,
  +            path=path,
  +            query=query,
  +            fragment=fragment,
  +            **_kwargs,
  +        )
  +        if scheme is None and url.startswith('://'):
  +            # remove the `://` prefix, since scheme is missing
  +            url = url[3:]
  +        return url
  +
       @classmethod
       def from_protobuf(cls: Type[T], pb_msg: 'str') -> T:
           """
  
verification_info: {"golden_diff": "diff --git a/docarray/typing/url/any_url.py b/docarray/typing/url/any_url.py\n--- a/docarray/typing/url/any_url.py\n+++ b/docarray/typing/url/any_url.py\n@@ -1,4 +1,4 @@\n-from typing import TYPE_CHECKING, Type, TypeVar\n+from typing import TYPE_CHECKING, Optional, Type, TypeVar\n \n from pydantic import AnyUrl as BaseAnyUrl\n from pydantic import errors, parse_obj_as\n@@ -34,11 +34,14 @@\n         \"\"\"\n         A method used to validate parts of a URL.\n         Our URLs should be able to function both in local and remote settings.\n-        Therefore, we allow missing `scheme`, making it possible to pass a file path.\n+        Therefore, we allow missing `scheme`, making it possible to pass a file\n+        path without prefix.\n+        If `scheme` is missing, we assume it is a local file path.\n         \"\"\"\n         scheme = parts['scheme']\n         if scheme is None:\n-            pass  # allow missing scheme, unlike pydantic\n+            # allow missing scheme, unlike pydantic\n+            pass\n \n         elif cls.allowed_schemes and scheme.lower() not in cls.allowed_schemes:\n             raise errors.UrlSchemePermittedError(set(cls.allowed_schemes))\n@@ -52,6 +55,44 @@\n \n         return parts\n \n+    @classmethod\n+    def build(\n+        cls,\n+        *,\n+        scheme: str,\n+        user: Optional[str] = None,\n+        password: Optional[str] = None,\n+        host: str,\n+        port: Optional[str] = None,\n+        path: Optional[str] = None,\n+        query: Optional[str] = None,\n+        fragment: Optional[str] = None,\n+        **_kwargs: str,\n+    ) -> str:\n+        \"\"\"\n+        Build a URL from its parts.\n+        The only difference from the pydantic implementation is that we allow\n+        missing `scheme`, making it possible to pass a file path without prefix.\n+        \"\"\"\n+\n+        # allow missing scheme, unlike pydantic\n+        scheme_ = scheme if scheme is not None else ''\n+        url = super().build(\n+            scheme=scheme_,\n+            user=user,\n+            password=password,\n+            host=host,\n+            port=port,\n+            path=path,\n+            query=query,\n+            fragment=fragment,\n+            **_kwargs,\n+        )\n+        if scheme is None and url.startswith('://'):\n+            # remove the `://` prefix, since scheme is missing\n+            url = url[3:]\n+        return url\n+\n     @classmethod\n     def from_protobuf(cls: Type[T], pb_msg: 'str') -> T:\n         \"\"\"\n", "issue": "bug(v2): relative file paths in url types\nPassing relative file paths gives a validation error:\n\n```python\nfrom docarray import Image\n\nurl = 'Test/05978.jpg'\nimg = Image(url=url)\n```\n\n```text\nTest/05978.jpg\nTraceback (most recent call last):\n  File \"/home/johannes/.config/JetBrains/PyCharmCE2022.3/scratches/scratch_116.py\", line 12, in <module>\n    img = Image(url=url)\n  File \"pydantic/main.py\", line 342, in pydantic.main.BaseModel.__init__\npydantic.error_wrappers.ValidationError: 1 validation error for Image\nurl\n  unsupported operand type(s) for +: 'NoneType' and 'str' (type=type_error)\n```\n\n\n", "before_files": [{"content": "from typing import TYPE_CHECKING, Type, TypeVar\n\nfrom pydantic import AnyUrl as BaseAnyUrl\nfrom pydantic import errors, parse_obj_as\n\nfrom docarray.typing.abstract_type import AbstractType\n\nif TYPE_CHECKING:\n    from pydantic.networks import Parts\n\n    from docarray.proto import NodeProto\n\nT = TypeVar('T', bound='AnyUrl')\n\n\nclass AnyUrl(BaseAnyUrl, AbstractType):\n    host_required = (\n        False  # turn off host requirement to allow passing of local paths as URL\n    )\n\n    def _to_node_protobuf(self) -> 'NodeProto':\n        \"\"\"Convert Document into a NodeProto protobuf message. This function should\n        be called when the Document is nested into another Document that need to\n        be converted into a protobuf\n\n        :return: the nested item protobuf message\n        \"\"\"\n        from docarray.proto import NodeProto\n\n        return NodeProto(any_url=str(self))\n\n    @classmethod\n    def validate_parts(cls, parts: 'Parts', validate_port: bool = True) -> 'Parts':\n        \"\"\"\n        A method used to validate parts of a URL.\n        Our URLs should be able to function both in local and remote settings.\n        Therefore, we allow missing `scheme`, making it possible to pass a file path.\n        \"\"\"\n        scheme = parts['scheme']\n        if scheme is None:\n            pass  # allow missing scheme, unlike pydantic\n\n        elif cls.allowed_schemes and scheme.lower() not in cls.allowed_schemes:\n            raise errors.UrlSchemePermittedError(set(cls.allowed_schemes))\n\n        if validate_port:\n            cls._validate_port(parts['port'])\n\n        user = parts['user']\n        if cls.user_required and user is None:\n            raise errors.UrlUserInfoError()\n\n        return parts\n\n    @classmethod\n    def from_protobuf(cls: Type[T], pb_msg: 'str') -> T:\n        \"\"\"\n        read url from a proto msg\n        :param pb_msg:\n        :return: url\n        \"\"\"\n        return parse_obj_as(cls, pb_msg)\n", "path": "docarray/typing/url/any_url.py"}], "after_files": [{"content": "from typing import TYPE_CHECKING, Optional, Type, TypeVar\n\nfrom pydantic import AnyUrl as BaseAnyUrl\nfrom pydantic import errors, parse_obj_as\n\nfrom docarray.typing.abstract_type import AbstractType\n\nif TYPE_CHECKING:\n    from pydantic.networks import Parts\n\n    from docarray.proto import NodeProto\n\nT = TypeVar('T', bound='AnyUrl')\n\n\nclass AnyUrl(BaseAnyUrl, AbstractType):\n    host_required = (\n        False  # turn off host requirement to allow passing of local paths as URL\n    )\n\n    def _to_node_protobuf(self) -> 'NodeProto':\n        \"\"\"Convert Document into a NodeProto protobuf message. This function should\n        be called when the Document is nested into another Document that need to\n        be converted into a protobuf\n\n        :return: the nested item protobuf message\n        \"\"\"\n        from docarray.proto import NodeProto\n\n        return NodeProto(any_url=str(self))\n\n    @classmethod\n    def validate_parts(cls, parts: 'Parts', validate_port: bool = True) -> 'Parts':\n        \"\"\"\n        A method used to validate parts of a URL.\n        Our URLs should be able to function both in local and remote settings.\n        Therefore, we allow missing `scheme`, making it possible to pass a file\n        path without prefix.\n        If `scheme` is missing, we assume it is a local file path.\n        \"\"\"\n        scheme = parts['scheme']\n        if scheme is None:\n            # allow missing scheme, unlike pydantic\n            pass\n\n        elif cls.allowed_schemes and scheme.lower() not in cls.allowed_schemes:\n            raise errors.UrlSchemePermittedError(set(cls.allowed_schemes))\n\n        if validate_port:\n            cls._validate_port(parts['port'])\n\n        user = parts['user']\n        if cls.user_required and user is None:\n            raise errors.UrlUserInfoError()\n\n        return parts\n\n    @classmethod\n    def build(\n        cls,\n        *,\n        scheme: str,\n        user: Optional[str] = None,\n        password: Optional[str] = None,\n        host: str,\n        port: Optional[str] = None,\n        path: Optional[str] = None,\n        query: Optional[str] = None,\n        fragment: Optional[str] = None,\n        **_kwargs: str,\n    ) -> str:\n        \"\"\"\n        Build a URL from its parts.\n        The only difference from the pydantic implementation is that we allow\n        missing `scheme`, making it possible to pass a file path without prefix.\n        \"\"\"\n\n        # allow missing scheme, unlike pydantic\n        scheme_ = scheme if scheme is not None else ''\n        url = super().build(\n            scheme=scheme_,\n            user=user,\n            password=password,\n            host=host,\n            port=port,\n            path=path,\n            query=query,\n            fragment=fragment,\n            **_kwargs,\n        )\n        if scheme is None and url.startswith('://'):\n            # remove the `://` prefix, since scheme is missing\n            url = url[3:]\n        return url\n\n    @classmethod\n    def from_protobuf(cls: Type[T], pb_msg: 'str') -> T:\n        \"\"\"\n        read url from a proto msg\n        :param pb_msg:\n        :return: url\n        \"\"\"\n        return parse_obj_as(cls, pb_msg)\n", "path": "docarray/typing/url/any_url.py"}]}