Skip to content

Commit

Permalink
argparce arguement mirror_netloc
Browse files Browse the repository at this point in the history
  • Loading branch information
jstzwj committed Aug 12, 2024
1 parent 5179f62 commit 2ccc4ba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
10 changes: 7 additions & 3 deletions olah/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ def __init__(self, path: Optional[str] = None) -> None:
self.hf_netloc: str = "huggingface.co"
self.hf_lfs_netloc: str = "cdn-lfs.huggingface.co"

self.mirror_scheme: str = "http"
self.mirror_netloc: str = "localhost:8090"
self.mirror_lfs_netloc: str = "localhost:8090"
self.mirror_scheme: str = "http" if self.ssl_key is None else "https"
self.mirror_netloc: str = (
f"{self.host if self.host != '0.0.0.0' else 'localhost'}:{self.port}"
)
self.mirror_lfs_netloc: str = (
f"{self.host if self.host != '0.0.0.0' else 'localhost'}:{self.port}"
)

self.mirrors_path: List[str] = []

Expand Down
24 changes: 23 additions & 1 deletion olah/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ async def repos(request: Request):
parser.add_argument("--config", "-c", type=str, default="")
parser.add_argument("--host", type=str, default="localhost")
parser.add_argument("--port", type=int, default=8090)
parser.add_argument("--hf-scheme", type=str, default="https", help="The scheme of huggingface site (http or https)")
parser.add_argument("--hf-netloc", type=str, default="huggingface.co")
parser.add_argument("--hf-lfs-netloc", type=str, default="cdn-lfs.huggingface.co")
parser.add_argument("--mirror-scheme", type=str, default="http", help="The scheme of mirror site (http or https)")
parser.add_argument("--mirror-netloc", type=str, default="localhost:8090")
parser.add_argument("--mirror-lfs-netloc", type=str, default="localhost:8090")
parser.add_argument("--has-lfs-site", action="store_true")
parser.add_argument("--ssl-key", type=str, default=None, help="The SSL key file path, if HTTPS is used")
parser.add_argument("--ssl-cert", type=str, default=None, help="The SSL cert file path, if HTTPS is used")
parser.add_argument("--repos-path", type=str, default="./repos", help="The folder to save cached repositories")
Expand All @@ -585,7 +592,22 @@ def is_default_value(args, arg_name):
config = OlahConfig(args.config)
else:
config = OlahConfig()

if not is_default_value(args, "hf_scheme"):
config.hf_scheme = args.hf_scheme
if not is_default_value(args, "hf_netloc"):
config.hf_netloc = args.hf_netloc
if not is_default_value(args, "hf_lfs_netloc"):
config.hf_lfs_netloc = args.hf_lfs_netloc
if not is_default_value(args, "mirror_scheme"):
config.mirror_scheme = args.mirror_scheme
if not is_default_value(args, "mirror_netloc"):
config.mirror_netloc = args.mirror_netloc
if not is_default_value(args, "mirror_lfs_netloc"):
config.mirror_lfs_netloc = args.mirror_lfs_netloc
else:
if not args.has_lfs_site and not is_default_value(args, "mirror_netloc"):
config.mirror_lfs_netloc = args.mirror_netloc

if is_default_value(args, "host"):
args.host = config.host
if is_default_value(args, "port"):
Expand Down

0 comments on commit 2ccc4ba

Please sign in to comment.