refactor/main #11

Merged
李衍志523370910113 merged 23 commits from refactor/main into dev 2025-02-27 15:51:32 +08:00
2 changed files with 10 additions and 14 deletions
Showing only changes of commit 99ccbbd113 - Show all commits

View File

@ -59,6 +59,7 @@ def convert(
Convert given dir of JOJ3 toml config files to JOJ3 json config files
"""
logger.info(f"Converting files in {root.absolute()}")
root = root.absolute()

@bomingzh can we consder here to make repo_conf.path to store the abosolute value?

@bomingzh can we consder here to make `repo_conf.path` to store the abosolute value?
for repo_toml_path in root.glob("**/repo.toml"):
repo_path = repo_toml_path.parent
repo_obj = rtoml.loads(repo_toml_path.read_text())
@ -72,9 +73,9 @@ def convert(
)
task_obj = rtoml.loads(task_toml_path.read_text())
repo_conf = repo.Config(**repo_obj)
repo_conf.path = repo_toml_path
repo_conf.path = (root / repo_toml_path.relative_to(root)).resolve()

repo_conf.path as absolute

`repo_conf.path` as absolute
task_conf = task.Config(**task_obj)
task_conf.path = task_toml_path
task_conf.path = (root / task_toml_path.relative_to(root)).resolve()

task_conf.path as absolute

`task_conf.path` as absolute
result_model = convert_conf(repo_conf, task_conf)
result_dict = result_model.model_dump(by_alias=True, exclude_none=True)
with result_json_path.open("w") as result_file:

View File

@ -111,7 +111,7 @@ def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail:
return healthcheck_stage
def calc_sha256sum(file_path: str) -> str:
def calc_sha256sum(file_path: Path) -> str:
sha256_hash = hashlib.sha256()
with open(file_path, "rb") as f:
for byte_block in iter(lambda: f.read(65536 * 2), b""):
@ -122,20 +122,15 @@ def calc_sha256sum(file_path: str) -> str:
def get_hash(
immutable_files: list[str], repo_conf: repo.Config
) -> str: # input should be a list
# FIXME: should be finalized when get into the server
current_file_path = Path(__file__).resolve()
project_root = current_file_path.parents[2]
# FIXME: givin the path
file_path = f"{project_root}/tests/immutable_file/"
# file_path = "{Path.home()}/.cache/immutable"
# to be use
# file_path = repo_conf.path
repo_path = repo_conf.path.parent
file_path = Path(f"{repo_path}/immutable_files")
immutable_hash = []
immutable_files_ = []
for i, file in enumerate(immutable_files):
immutable_files[i] = file_path + file.rsplit("/", 1)[-1]
immutable_files_.append(file_path.joinpath(file.rsplit("/", 1)[-1]))
for i, file in enumerate(immutable_files):
immutable_hash.append(calc_sha256sum(file))
for i, file_ in enumerate(immutable_files_):
immutable_hash.append(calc_sha256sum(file_))
hash_check = "-checkFileSumList="