code: def from_url(cls, url: Union[str, GridURL]) -> Self:
      if isinstance(url, GridURL):
          return url
      try:
          # urlparse doesnt handle no protocol properly
          if "://" not in url:
              url = "http://" + url
          parts = urlparse(url)
          host_or_ip_parts = parts.netloc.split(":")
          # netloc is host:port
          port = 80
          if len(host_or_ip_parts) > 1:
              port = int(host_or_ip_parts[1])
          host_or_ip = host_or_ip_parts[0]
          if parts.scheme == "https":
              port = 443
          return cls(
              host_or_ip=host_or_ip,
              path=parts.path,
              port=port,
              protocol=parts.scheme,
              query=getattr(parts, "query", ""),
          )
      except Exception as e:
          print(f"Failed to convert url: {url} to GridURL. {e}")
          raise e
  
imports: from __future__ import annotations
  import copy
  import os
  import re
  from typing import Optional
  from typing import Union
  from urllib.parse import urlparse
  import requests
  from typing_extensions import Self
  from ..serde.serializable import serializable
  from ..util.util import verify_tls
label_desc: Use image node_id 1 for calling the GridURL obj's underlying member method code with example usage: obj.from_url(cls, url) and returns: url, cls