Skip to content

Commit

Permalink
config reader bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jstzwj committed Oct 26, 2023
1 parent 5385363 commit 366d4f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Other languages: [中文](README_zh.md)
## Features
* Models mirror
* Datasets mirror
* Spaces mirror

## Install

Expand Down Expand Up @@ -76,7 +77,6 @@ python -m olah.server --host localhost --port 8090 --repos-path ./hf_mirrors

## Future Work

* Space Mirror
* Authentication
* Administrator and user system
* OOS backend support
Expand Down
31 changes: 15 additions & 16 deletions olah/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ def __init__(self, path: Optional[str] = None) -> None:
self.cache = OlahRuleList.from_list(DEFAULT_CACHE_RULES)

if path is not None:
self.proxy.clear()
self.cache.clear()
self.read_toml(path)

def empty_str(self, s: str) -> Optional[str]:
Expand All @@ -104,18 +102,19 @@ def empty_str(self, s: str) -> Optional[str]:
def read_toml(self, path: str):
config = toml.load(path)

basic = config["basic"]
accessibility = config["accessibility"]
if "basic" in config:
basic = config["basic"]
self.host = basic.get("host", self.host)
self.port = basic.get("port", self.port)
self.ssl_key = self.empty_str(basic.get("ssl-key", self.ssl_key))
self.ssl_cert = self.empty_str(basic.get("ssl-cert", self.ssl_cert))
self.repos_path = basic.get("repos-path", self.repos_path)
self.hf_url = basic.get("hf-url", self.hf_url)
self.hf_lfs_url = basic.get("hf-lfs-url", self.hf_lfs_url)
self.mirror_url = basic.get("mirror-url", self.mirror_url)
self.mirror_lfs_url = basic.get("mirror-lfs-url", self.mirror_lfs_url)

self.host = basic["host"]
self.port = basic["port"]
self.ssl_key = self.empty_str(basic["ssl-key"])
self.ssl_cert = self.empty_str(basic["ssl-cert"])
self.repos_path = basic["repos-path"]
self.hf_url = basic["hf-url"]
self.hf_lfs_url = basic["hf-lfs-url"]
self.mirror_url = basic["mirror-url"]
self.mirror_lfs_url = basic["mirror-lfs-url"]

self.proxy = OlahRuleList.from_list(accessibility["proxy"])
self.cache = OlahRuleList.from_list(accessibility["cache"])
if "accessibility" in config:
accessibility = config["accessibility"]
self.proxy = OlahRuleList.from_list(accessibility.get("proxy", self.proxy))
self.cache = OlahRuleList.from_list(accessibility.get("cache", self.cache))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "olah"
version = "0.0.2"
version = "0.0.3"
description = "Self-hosted lightweight huggingface mirror."
readme = "README.md"
requires-python = ">=3.8"
Expand Down

0 comments on commit 366d4f1

Please sign in to comment.